var app = getApp() var that=null var sopenFrame=null Page( { data: { loadingHidden:false, t:0, mybalance:[], Start: 0, savebutton:"", qybutton:"确定", isShowConfirm:false, username:"", pwd:"" }, onLoad: function(options) { that = this if(options.t){ that.setData({ t:options.t }); } var title="开通推广员" if(that.data.t==1){ title="激活商家" } wx.setNavigationBarTitle({ title: title }) that.setData({ savebutton:title }); that.rdata() that.clearCache();//清本页缓存 that.getlist(0); },rdata: function() { var userId = wx.getStorageSync("userId") var LoginId = wx.getStorageSync("LoginId") }, // 下拉刷新 onPullDownRefresh: function () { //在当前页面显示导航条加载动画 wx.showNavigationBarLoading(); //显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框 wx.showLoading({ title: '刷新中...', }) that.clearCache(); that.getlist(1);//第一次加载数据 }, // 页面上拉触底事件(上拉加载更多) onReachBottom: function () { that.setData({ loadingHidden:false }); that.getlist(2);//后台获取新数据并追加渲染 }, // 清缓存 clearCache:function(){ that.setData({ loadingHidden:false, Start: 0, mybalance:[] }); },getlist: function(gp) { var userId = wx.getStorageSync("userId") var LoginId = wx.getStorageSync("LoginId") wx.request({ url: app.globalData.apiurl + "/xapiajax.ashx", data: { action:"getkttgylist", t:that.data.t, Start:that.data.Start, userId:(userId==null?"":userId), LoginId:(LoginId==null?"":LoginId) }, method:"GET", dataType:"json", header: { "content-type": "application/json" // 默认值 }, success (res) { if(res.data.status==1){ var tmpArr = null; tmpArr = that.data.mybalance; if(res.data.data.length>0){ tmpArr.push.apply(tmpArr,res.data.data); } that.setData({ mybalance: tmpArr, Start: that.data.Start+res.data.data.length, loadingHidden:true }) }else{ wx.showToast({ title: res.data.msg, icon: "none", duration: 3000 }) } if(gp==1){ //隐藏loading 提示框 wx.hideLoading(); //隐藏导航条加载动画 wx.hideNavigationBarLoading(); //停止下拉刷新 wx.stopPullDownRefresh(); } } }) } ,onsubmit:function(e) { var username=e.detail.value.username.replace(/\s+/g, ""); var b=true if(b){ if(username==""){ b=false wx.showToast({ title: "会员账号不能为空!", icon: "none", duration: 3000 }) } } if(b){ that.setData({ username:username, isShowConfirm:true }) } },cancelsubmit:function() { that.setData({ isShowConfirm:false }) }, //输入框中的值 setValue: function (e) { this.setData({ pwd: e.detail.value }) }, onsmlog: function (e) { var id=e.currentTarget.dataset.id; wx.navigateTo({ url: "../mybusiness_smlog/index?t0=" + (that.data.t==1?1:2) + "&MemberId=" + id }) },confirmsubmit:function(e) { var username=that.data.username.replace(/\s+/g, ""); var pwd =that.data.pwd.replace(/\s+/g, ""); var userId = wx.getStorageSync("userId") var LoginId = wx.getStorageSync("LoginId") var b=true if(b){ if(pwd==""){ b=false wx.showToast({ title: "安全密码不能为空!", icon: "none", duration: 3000 }) } } if(b){ that.setData({ qybutton:"请稍候..." }) wx.request({ url: app.globalData.apiurl + "/xapiajax.ashx", data: { action:"kttgy", userId:(!userId?"":userId), LoginId:(!LoginId?"":LoginId), t:that.data.t, username:username, pwd:pwd }, method:"POST", dataType:"json", header: { "content-type": "application/x-www-form-urlencoded" // 默认值 }, success (res) { if(res.data.status==1){ wx.setStorageSync('userInfo', JSON.stringify(res.data.userInfo)) app.globalData.IFRefreshmy=1 wx.showToast({ title: res.data.msg, icon: "success", duration: 3000 }) that.clearCache();//清本页缓存 that.getlist(0); that.cancelsubmit(); }else{ wx.showToast({ title: res.data.msg, icon: "none", duration: 3000 }) } that.setData({ qybutton:"确定" }) } }) } } })