起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

12
返回列表 发新帖
楼主: zazzlec

[处理中3] bind-attr-src 刷新问题

[复制链接]

2

主题

11

帖子

27

积分

新手上路

Rank: 1

积分
27
QQ
 楼主| 发表于 2017-9-30 17:49:27 | 显示全部楼层
jishuang 发表于 2017-9-30 13:57
把.w和js文件发一下看看

<?xml version="1.0" encoding="UTF-8"?>

<div xmlns="http://www.w3.org/1999/xhtml" xid="window" class="window" component="$UI/system/components/justep/window/window" design="device:m;">  
<div component="$UI/system/components/justep/model/model" xid="model" style="top:350px;left:337px;height:auto;"/>

        <div component="$UI/system/components/justep/panel/panel" class="x-panel x-full" xid="panel1">
           <div xid="top1" height="76"    bind-style="{'backgroundImage': 'url('+$model.URL('img/gre/top.jpg')+')'}"   class="x-panel-top topback" >
                           <div component="$UI/system/components/justep/titleBar/titleBar"  xid="titleBar1" title="" style="height:38px;">
                        <!-- 头部左边 -->
                        <div class="top1" xid="div1" >
                          <img src="img/gre/bs.png" bind-attr-src="$model.URL('img/gre/bs.png')" alt="" xid="image1" align="middle" style="width:28px;height:28px;" class="ico"></img>
                        </div>  
                        <!-- 头部中间 -->
                        <div class="top2" xid="div2" style="font-size:18px;font-weight:bold;"  bind-style="{'color':$model.TOPCOLOR()}"  >科学养殖</div>  
                        <!-- 头部右边 -->
                        <div class="top3" xid="div3"    bind-style="{'color':$model.TOPCOLOR()}"  bind-click="div3Click">
                                       safsdf
                        </div>
                      </div>
                      <div class="top6" xid="div5"  bind-style="{'color':$model.TOPCOLOR()}">滚动广告</div>  
           </div>
           <div class="x-panel-content" xid="content2"  >
                   <div component="$UI/system/components/justep/smartContainer/smartContainer" class="x-smartcontainer show  ctt" xid="smartContainer1"  bind-style="{'backgroundImage': 'url('+$model.URL('img/gre/md.jpg')+')'}">
                              <div class="bq" xid="bq1"  bind-style="{'backgroundImage': 'url('+$model.URL('img/gre/bq.png')+')','color':$model.GFJ()}">管</div>
                              
                              <div component="$UI/system/components/justep/row/row" class="x-row" xid="row8">
                                   <div class="x-col" xid="col110"><span xid="span1" style="color:#FFFFFF;"><![CDATA[]]></span></div>
                           </div>
                              <div component="$UI/system/components/justep/row/row" class="x-row" xid="row1">
                                   <div class="x-col" xid="col6">建议投喂系数:1.7</div>
                                   <div class="x-col" xid="col7">当前系数:1.5</div>
                           </div>
                           <div component="$UI/system/components/justep/row/row" class="x-row" xid="row2">
                                   <div class="x-col" xid="col8">损害:<img src="img/gre/s.png" alt="" xid="images" style="width:12px;height:20px;"    ></img></div>
                                   <div class="x-col" xid="col9">水质:<img src="img/gre/x.png" alt="" xid="imagex" style="width:12px;height:20px;"    ></img></div>
                           </div>
                              <div component="$UI/system/components/justep/row/row" class="x-row" xid="row3">
                                   <div class="x-col" xid="col10">饲料剩余:219天</div>
                           </div>
                   </div>
                   <div component="$UI/system/components/justep/smartContainer/smartContainer" class="x-smartcontainer list" xid="smartContainer2">
                                   <div component="$UI/system/components/justep/row/row" class="x-row" xid="row3">
                                   <div class="x-col" xid="col16">
                                            <img src="img/gre/icon/1.png" bind-attr-src="$model.URL('img/gre/icon/1.png')"  alt="" xid="ima1" style="width:60px;height:60px;" class="ico" ></img>
                                            <div class="colzi">每日状态</div>
                                   </div>
                                   <div class="x-col" xid="col17">
                                            <img src="img/gre/icon/2.png" bind-attr-src="$model.URL('img/gre/icon/2.png')"  alt="" xid="ima2" style="width:60px;height:60px;" class="ico" ></img>
                                            <div class="colzi">养殖日记</div>
                                   </div>
                                   <div class="x-col" xid="col18">
                                     <img src="img/gre/icon/3.png" bind-attr-src="$model.URL('img/gre/icon/3.png')"  alt="" xid="ima3" style="width:60px;height:60px;" class="ico" ></img>
                                            <div class="colzi">打样</div>
                                   </div>
                                   <div class="x-col" xid="col19">
                                     <img src="img/gre/icon/4.png" bind-attr-src="$model.URL('img/gre/icon/4.png')"  alt="" xid="ima4" style="width:60px;height:60px;" class="ico" ></img>
                                            <div class="colzi">饲料管理</div>
                                   </div>
                           </div>
                           <div component="$UI/system/components/justep/row/row" class="x-row" xid="row4">
                                   <div class="x-col" xid="col26">
                                            <img src="img/gre/icon/5.png" bind-attr-src="$model.URL('img/gre/icon/5.png')"  alt="" xid="ima5" style="width:60px;height:60px;" class="ico" ></img>
                                            <div class="colzi">评估</div>
                                   </div>
                                   <div class="x-col" xid="col27">
                                     <img src="img/gre/icon/6.png" bind-attr-src="$model.URL('img/gre/icon/6.png')"  alt="" xid="ima6" style="width:60px;height:60px;" class="ico" ></img>
                                            <div class="colzi">药品加入</div>
                                   </div>
                                   <div class="x-col" xid="col28">
                                            <img src="img/gre/icon/7.png" bind-attr-src="$model.URL('img/gre/icon/7.png')"  alt="" xid="ima7" style="width:60px;height:60px;" class="ico" ></img>
                                            <div class="colzi">支出</div>
                                   </div>
                                   <div class="x-col" xid="col33">
                                     <img src="img/gre/icon/8.png" bind-attr-src="$model.URL('img/gre/icon/8.png')"  alt="" xid="ima8" style="width:60px;height:60px;" class="ico" ></img>
                                            <div class="colzi">放养</div>
                                   </div>
                           </div>
                                   <div component="$UI/system/components/justep/row/row" class="row5" xid="row5">
                                     <img src="img/gre/+.png"  bind-attr-src="$model.URL('img/gre/+.png')" alt="" xid="image1" style="width:15px;height:15px;margin:0px auto;"    ></img> 添加更多
                           </div>
                   </div>
           </div>
           
           <div class="x-panel-bottom bt" xid="bottom1"   bind-style="{'backgroundImage': 'url('+$model.URL('img/gre/bt.jpg')+')'}" height="60">
                           <div component="$UI/system/components/justep/titleBar/titleBar"
                        xid="titleBar2" title="" style="height:60px;line-height:60px;">
                        <!-- 左边 -->
                        <div class="bt1" xid="div11" bind-click="div11Click"  bind-style="{'color':$model.TOPCOLOR()}">
                          <img src="img/gre/cheng-zuo.png"  bind-attr-src="$model.URL('img/gre/cheng-zuo.png')" alt="" xid="images1" align="middle" style="width:9px;height:15px;" class="ico"></img> <span xid="pretk" >唐口1</span>
                        </div>  
                        <!-- 中间 -->
                        <div class="bt2" xid="div12"  bind-style="{'color':$model.TOPCOLOR()}">唐口2</div>  
                        <!-- 右边 -->
                        <div class="bt3" xid="div13" bind-style="{'color':$model.TOPCOLOR()}"  bind-click="div13Click">
                                <span xid="nexttk" >唐口3</span> <img src="img/gre/cheng-you.png"  bind-attr-src="$model.URL('img/gre/cheng-you.png')" alt="" xid="images2" align="middle" style="width:9px;height:15px;" class="ico"></img>
                        </div>
                      </div>
           </div>
   </div>
</div>





回复 支持 反对

使用道具 举报

2

主题

11

帖子

27

积分

新手上路

Rank: 1

积分
27
QQ
 楼主| 发表于 2017-9-30 17:49:53 | 显示全部楼层
jishuang 发表于 2017-9-30 13:57
把.w和js文件发一下看看

define(function(require){
        var $ = require("jquery");
        var justep = require("$UI/system/lib/justep");
        var CommonUtils = require("$UI/system/components/justep/common/utils");
        var Model = function(){
                this.callParent();
                this.style="yel";
               
        };
       
       
       
        //图片集中替换
        Model.prototype.URL=function(src) {
               
               
                var newstr=src.replace("gre",this.style);  
                return newstr;
        }
       
        //顶部字体颜色
        Model.prototype.TOPCOLOR=function() {
                var src=this.style;
                var color="";
                if(src=="gre"){
                        color="#155a47";
                }else if(src=="org"){
                        color="#ffffff";
                }else if(src=="yel"){
                        color="#272725";
                }
                return color;
        }
        //管服记字体颜色
        Model.prototype.GFJ=function() {
                var src=this.style;
                var color="";
                if(src=="gre"){
                        color="#fff";
                }else if(src=="org"){
                        color="#f8551a";
                }else if(src=="yel"){
                        color="#fd9933";
                }
                return color;
        }
        //页面加载事件
        Model.prototype.modelLoad = function(event) {

               
                var self = this;
               
               

               
               
               
                var wether = justep.Util.getCookie("wether");
                if(wether===null){
                        var host=localStorage.getItem('host');  
                    $.post(host+"html/Mobile/wether",{},function(data){
                            var o=data.msg.HeWeather5[0];
                                var x=o.basic.city+" "+o.now.cond.txt+" "+o.now.tmp+"°C "+o.now.wind.dir +" 气压 "+o.now.pres +" 节气 "+data.jieqi.result.now.name;
                                var sc = $(self.getElementByXid("span1"));
                                sc.text(x);
                                //存cookie
                                justep.Util.addCookie("wether", x,"/",3);
                });
                }else{
                        var sc = $(self.getElementByXid("span1"));
                        sc.text(wether);
                }
            
            
            
            
            
               
            if (justep.Browser.isX5App) {
                        //双击退出程序
                        CommonUtils.attachDoubleClickExitApp(function() {
                                return true;
                        });
                }
          //定制抬头
            var ujson=localStorage.getItem('ujson');  
            var j=eval("("+ujson+")");
            var div13 = $(self.getElementByXid("div2"));
            div13.text(j.title);
          //唐口数据处理
            self.upMenu();
        };
        //下个唐口
        Model.prototype.div13Click = function(event){
                var self = this;
                var div13 = $(self.getElementByXid("div13"));
                var images2 = $(self.getElementByXid("images2"));
                if(images2.is(':hidden')){return;}
                //if(div13.html()===" "){return;}
                var ytlistjson=localStorage.getItem('ytlistjson');  
                var j=eval("("+ytlistjson+")");
                var i=parseInt(localStorage.getItem('index'));  
                if(i<j.length-1){
                       
                        localStorage.setItem("index", ""+(i+1));
                }
                if(window.location.href.indexOf("main", 0)===-1){
                        justep.Shell.showPage("main");
                }else{
                        justep.Shell.showPage("next");
                }
               
        };
        //上个唐口
        Model.prototype.div11Click = function(event){
                var self = this;
                var div11 = $(self.getElementByXid("div11"));
                var images1 = $(self.getElementByXid("images1"));

                if(images1.is(':hidden')){return;}
                //if(div11.html()===" "){return;}
                var ytlistjson=localStorage.getItem('ytlistjson');  
                var j=eval("("+ytlistjson+")");
                var i=parseInt(localStorage.getItem('index'));  
                if(i>0){
                        localStorage.setItem("index", ""+(i-1));
                }
                if(window.location.href.indexOf("main", 0)===-1){
                        justep.Shell.showPage("main");
                }else{
                        justep.Shell.showPage("next");
                }
        };
       

        //第二次进入
        Model.prototype.modelActive = function(event){
                var self = this;
                //唐口数据处理
                self.upMenu();
        };
       
       
        Model.prototype.upMenu = function(event){
                var self = this;
                //唐口数据处理
                var ytlistjson=localStorage.getItem('ytlistjson');  
            var index=localStorage.getItem('index');  
            if(index===null){
                    localStorage.setItem("index", "0");
            }
            var i=parseInt(localStorage.getItem('index'));  
            var j=eval("("+ytlistjson+")");
            var nowobj=j;
            
            
            
            if(nowobj.rent==10){
                    self.style="yel";
            }else if(nowobj.rent==20){
                    self.style="org";
            }else{
                    self.style="gre";
            }
           // self.comp("ima1").refreshData();
            
            
            var sc = $(self.getElementByXid("div3"));
                sc.text(nowobj.home_name);
                var div12 = $(self.getElementByXid("div12"));
                var div11 = $(self.getElementByXid("div11"));
                var div13 = $(self.getElementByXid("div13"));
                var pretk = $(self.getElementByXid("pretk"));
                var nexttk = $(self.getElementByXid("nexttk"));
                var images1 = $(self.getElementByXid("images1"));
                var images2 = $(self.getElementByXid("images2"));
                div12.text(nowobj.home_name);
                if(i===0){
                        //div11.html(" ");
                        images1.hide();
                        pretk.hide();
                        if(j.length===1){
                                //div13.html(" ");
                                images2.hide();
                                nexttk.hide();
                        }else{
                                images2.show();
                                nexttk.show();
                                nexttk.text(j[i+1].home_name);
                        }
                }
                if(i===j.length-1){
                        //div13.html(" ");
                        images2.hide();
                        nexttk.hide();
                        if(j.length===1){
                                //div11.html(" ");
                                images1.hide();
                                pretk.hide();
                        }else{
                                images1.show();
                                pretk.show();
                                pretk.text(j[i-1].home_name);
                        }
                }
            if(i>0&&i<j.length-1){
                    if(j.length===1){
                                //div11.html(" ");
                                //div13.html(" ");
                            images1.hide();
                                pretk.hide();
                                images2.hide();
                                nexttk.hide();
                        }else{
                                images1.show();
                                pretk.show();
                                images2.show();
                                nexttk.show();
                                nexttk.text(j[i+1].home_name);
                                pretk.text(j[i-1].home_name);
                        }
            }
        };
       
       
        return Model;
});
回复 支持 反对

使用道具 举报

91

主题

13万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
35924
发表于 2017-10-11 14:53:44 | 显示全部楼层
如下定义
  1.         var Model = function() {
  2.                 this.callParent();
  3.                 this.style = justep.Bind.observable("yel");

  4.         };
复制代码

然后在model的onActive中给变量赋值,如下
this.style.set("org");

在URL函数中用this.style.get()获取值
远程的联系方法QQ1392416607,添加好友时,需在备注里注明其论坛名字及ID,公司等信息
发远程时同时也发一下帖子地址,方便了解要解决的问题  WeX5教程  WeX5下载



如按照该方法解决,请及时跟帖,便于版主结贴
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-5-8 01:43 , Processed in 0.052608 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表