|
楼主 |
发表于 2017-9-30 17:49:53
|
显示全部楼层
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;
}); |
|