/** * 页面的初始数据 */ data: { orderslist: [], page: 0, totalPage: 0, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { let data={ _ajax:1 } this.getListData(data); }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { let data = { _ajax: 1, wechat_openid: wechat_openid }; this.setData({ orderslist: []//清空数据 }); this.getListData(data);//获取数据 // setTimeout(()=>{ wx.stopPullDownRefresh(); wx.hideLoading(); },2000); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { console.log(3333333); let data = { _ajax: 1, wechat_openid: wechat_openid, page: this.data.page + 1, }; this.getListData(data); }, //获取数据方法开始 getListData(data) { console.log("data.page", data.page); console.log("data.totalPage", this.data.totalPage); if (data.page > this.data.totalPage) { wx.showToast({ title: '无新内容' }); return false; } wx.showLoading({ title: '加载中!' }); let orderslist = this.data.orderslist; for(let i= 0;i<10;i++){ let data = { "order": i + orderslist.length, "state":"未发货", "imgUrl":"http://wx1.sinaimg.cn/mw690/0071poYXly1fn6wez5vjxj303w03wdfn.jpg", "name":"辛辛熊婴儿纸尿裤试用装S码", "price":"9.90",//单价 "sum":"1", "prices":"9.90"//合计 }; orderslist.push(data); } this.setData({ orderslist: orderslist, page: this.data.page+1, totalPage:3 }) wx.hideLoading();