var WxParse = null; //获取应用实例 var app = getApp() var sopenFrame=null var sopenFrame0=null var that=null Page({ data: { indicatorDots: true, vertical: false, autoplay: true, interval: 6000, duration: 1000, loadingHidden: false, // loading images:[], t:0, t0:0, Start:0, Products:[], }, //事件处理函数 swiperchange: function(e) { //console.log(e.detail.current) },onShow: function () { if (typeof this.getTabBar === 'function' && this.getTabBar()) { this.getTabBar().setData({ selected: 1 }) } }, onLoad: function(options) { that=this; WxParse = require('../../wxParse/wxParse.js'); if(options.t){ that.setData({ t:options.t }) if(options.t==2){ wx.setNavigationBarTitle({ title: "健康知识" }) } if(options.t==4){ wx.setNavigationBarTitle({ title: "会客厅" }) }if(options.t==5){ wx.setNavigationBarTitle({ title: "流量专区" }) }if(options.t==7){ wx.setNavigationBarTitle({ title: "品牌展示" }) }if(options.t==10){ wx.setNavigationBarTitle({ title: "企业介绍" }) }if(options.t==11){ wx.setNavigationBarTitle({ title: "操作教程" }) } if(options.t==12){ wx.setNavigationBarTitle({ title: "补贴专区" }) } if(options.t==13){ wx.setNavigationBarTitle({ title: "体验区" }) } } if(options.t0){ that.setData({ t0:options.t0 }) } that.rdata(0); sopenFrame=setInterval(function (){ if(app.globalData.IFRefreshordershop0==1){ app.globalData.IFRefreshordershop0=0; that.setData({ Start: 0 }); that.rdata(0); } }, 1000); },onPullDownRefresh: function () { //在当前页面显示导航条加载动画 wx.showNavigationBarLoading(); //显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框 wx.showLoading({ title: '刷新中...', }) that.clearCache(); that.setData({ loadingHidden:true }); that.rdata(1); },// 页面上拉触底事件(上拉加载更多) onReachBottom: function () { that.setData({ loadingHidden:false }); that.rdata(2);//后台获取新数据并追加渲染 },onnav:function(e) { var index = e.currentTarget.dataset.id if(index==1){ that.setData({ t:15 }) }else{ that.setData({ t:13 }) } that.clearCache(); that.rdata(1); }, // 清缓存 clearCache:function(){ that.setData({ Start: 0, loadingHidden:false }); },rdata:function(t) { try{ var userId = wx.getStorageSync("userId") var LoginId = wx.getStorageSync("LoginId") wx.request({ url: app.globalData.apiurl + "/xapiajax.ashx", data: { action:"getothershopdata0", userId:(!userId?"":userId), LoginId:(!LoginId?"":LoginId), t:that.data.t, t0:that.data.t0, Start:that.data.Start }, method:"GET", dataType:"json", header: { "content-type": "application/json" // 默认值 }, success (res) { if(res.data.status==1){ var tmpArr = null; if(that.data.Start==0){ tmpArr = res.data.productlist; that.setData({ Products:tmpArr, Start: res.data.productlist.length, loadingHidden:true }) }else{ tmpArr = that.data.Products; if(res.data.productlist.length>0){ tmpArr.push.apply(tmpArr,res.data.productlist); } that.setData({ Products:tmpArr, Start: that.data.Start+res.data.productlist.length, loadingHidden:true }) } if(t==1){ //隐藏loading 提示框 wx.hideLoading(); //隐藏导航条加载动画 wx.hideNavigationBarLoading(); //停止下拉刷新 wx.stopPullDownRefresh(); } }else{ if(res.data.msg=="您未登录"||res.data.msg=="参数错误"){ wx.removeStorageSync('userId') wx.removeStorageSync('LoginId') that.rdata(0) } } } }) }catch(err){ wx.showToast({ title: err, icon: "none", duration: 2000 }) } },gotodetail:function(e) { var id = e.currentTarget.dataset.id wx.navigateTo({ url: "../details/index?id="+id }) },qxdetail:function(e) { } })