wx.request,跟bindscrolltolower一起使用有bug
wx.request,跟scroll-view的bindscrolltolower一起使用有bug。
一下子无数请求,有人说没关系,多请求是好的。但是已经超过10个,而且多次成功 请求,计数次数不准确了!
10 回复
错了错了,你就算没有返回一样触发fail的,还是一样的,wx.request本来就是多请求的,问题是scroll-view的触发也是多次触发。主要是解决scroll-view拖下去触发一次wx.request。结果触发无数次了。估计是scroll-view的问题
var app = getApp() Page({ data: { logs: '56' , myopenid: '' , iscan: true , yue: '' , nian: '' , height: '300' , nei:[], nzc: '' , nsr: '' , yzc: '' , ysr: '' , s:20, e:40, zai: '' , xiu:[], id: '' }, inde: function (e){ console.log(e) app.xiu=e.currentTarget.dataset wx.navigateTo({ url: '../ji/ji' }) }, lower: function (k) { //console.log(k) wx.showToast({ title: '加载中' , icon: 'loading' }) var that= this const page=20 var iscan=that.data.iscan console.log(that.data.s) console.log(that.data.e) if (iscan){ that.setData({iscan: false }) wx.request({ url: 'https://shang.32888.cn/jizhang/get/test1.php' , data: { s: that.data.s , r: app.data.yemian.openid }, header: { 'content-type' : 'application/json' }, success: function (res) { wx.hideToast() console.log( 'nei' ,res) //var id = res.data.nei[0].id; //that.setData({ id: id}); //if(that.data.id==id){return;} if (res.data.nei== null ){ res.data.nei=[{neirong: '没有数据了,这行是最后一行' }] that.setData({ nei: that.data.nei.concat(res.data.nei)}) return false } that.setData({ nei:that.data.nei.concat(res.data.nei) }) // console.log(res.data.length) if (!res.data.nei){that.data.zai= 'kong' } //console.log(that.data.s) that.setData({ s: that.data.e, e: that.data.e + page }) that.setData({ iscan: true }) } }) } }, onLoad: function (e) { var that= this that.setData({ myopenid: app.data.yemian.openid }) var date = new Date(); var mou = date.getMonth() + 1 var nian = date.getFullYear() that.setData({ height: app.data.yemian.height - 70, yue: mou, nian:nian}) // console.log('zhang',e) //var shu='hy' wx.request({ url: 'https://shang.32888.cn/jizhang/get/test1.php' , data: { r: app.data.yemian.openid, s: "" }, success: function (res) { //console.log(res.data) }, complete: function (res) { console.log(res.data) var da=res.data that.setData({ nei: da.nei, nsr: da.nsr.shouru, nzc: da.nzc.zhichu, yzc: da.yzc.zhichu, ysr: da.ysr.shouru}) } }) } }) |