/** * Created by Administrator on 2017/11/23. */ (function (win, doc, UXUN, undefined) { "use strict"; var indexPage = UXUN.extend({ constructor: function indexPage() { //执行父类构造器,实现构造器继承 indexPage._Parent(this, arguments); }, init:function(){ var self = this,userInfo = UXUN.getUser(); //未登录 if (!userInfo) { ip.doWhenNoLogin(); }else{ $('#noLogin').hide(); $('#hasLogin').show(); $("#loginName").html(userInfo.loginName); ip.queryPoint(); } self.qurNoticeList(); //公告 //无论从什么地方到首页,都是导航栏首页被选择 _Storage.setItem('pageInitHeadSelectIndex',2); pageHeadObject.selected(); }, qurNoticeList:function(){//查询商城公告数据 this.request({ url: 'qurNoticeList', success: "qurNoticeListRsp", data : { "acttype" : "1014", "onChannel" : "1", "channel" : "005", "contname" : "", "pageSize" : 4, "pageNow" : 1 }, error: "qurNoticeListRsp" }, true); }, /*********************request方法回调函数放置的位置定义(开始)*****************************/ requestCallbacks: { walletIndexRsp:function(data){ var error = UXUN.isError(data); if (error) { if(data.retcode==getApplication('LOGIN_TIME_OUT')){ ip.doWhenNoLogin(); } UXUN.toast(error); return false; } var userInfo = UXUN.getUser(); var isAuth = userInfo && ( userInfo.accountauth == '1' || userInfo.custId ); if(!isAuth){ $("#myPoint").html('实名认证>'); return; } $("#myPoint").html(UXUN.format.money(data.pointcount,0)); }, qurNoticeListRsp : function(data) { var error = UXUN.isError(data); if (error) { UXUN.toast(error); return false; } else { var list = data.acts; for (var i = 0; i < list.length; ++i) { var contname = list[i].contname; var contid = list[i].contid; var html = '· ' + contname + ''; $('.noticel').append(html); } } } }, /*********************request方法回调函数放置的位置定义(结束)*****************************/ /*********************声明式事件定义(开始)*****************************/ events: { 'click .ux-home-menu-left a':'jumpPage', 'click .title div>a':'jumpPage', 'click .login .ubtn':'jumpTo', 'click .login .js_realName':'jumpTo', 'click .announcement .more a':'jumpTo' }, /*********************声明式事件定义(结束)*****************************/ /*********************事件处理器定义(开始)*****************************/ eventHandlers: { jumpPage:function(e,self){ _PluginPage.open(UXUN.getPublicPath()+'view/goods/searchGoods.html',{goodsTypeId:self.attr('data-goodsTypeId')}); }, jumpTo:function(e,self){ e.preventDefault(); _PluginPage.open(UXUN.getPublicPath()+'view/'+$(self).attr("href")); } }, /*********************事件处理器定义(结束)*****************************/ /*********************自定义事件(开始)*****************************/ doWhenNoLogin:function(){ $('#noLogin').show(); $('#hasLogin').hide(); //清除登录状态 UXUN.clearUser(); }, queryPoint:function(){ this.request({ url: 'walletIndex', success: "walletIndexRsp", error: "walletIndexRsp" }, true); } /*********************自定义事件(结束)*****************************/ }); var ip = new indexPage(); ip.init(); }(window, document,UXUN));