var util = require('../../../utils/util.js'); var api = require('../../../config/api.js'); const app = getApp(); Page({ /** * 页面的初始数据 */ data: { scrollHeight: 0, page: 1, limit: 10, totalPages: 1, addressInfo:{}, servantList:[ ] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var addressInfo=wx.getStorageSync('addressInfo'); if(addressInfo){ this.setData({ addressInfo:addressInfo }) } this.getServantList(); // wx.getSystemInfo({ // success:res=>{ // this.setData({ // scrollHeight: res.windowHeight // }); // } // }); }, viewMore(e){ console.log(e); let workerNo=e.currentTarget.dataset.workerno; wx.navigateTo({ url: '/pages/servant/servantDetail/servantDetail?workerNo='+workerNo, }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { if (this.data.totalPages > this.data.page) { this.setData({ page: this.data.page + 1 }); this.getServantList(); } else { wx.showToast({ title: '没有更多了', icon: 'none', duration: 2000 }); return false; } }, getServantList: function () { // this.setData({ // servantList:this.data.servantList.concat(this.data.servantList),}); util.request(api.getServantList, { page: this.data.page, limit: this.data.limit, shopId:this.data.addressInfo.shopId }) .then(res=>{ console.info(res); if (this.data.page == 1) { this.setData({ servantList: res.data.dataList, totalPages: res.data.pages }); } else{ this.setData({ servantList:this.data.servantList.concat(res.data.dataList), totalPages: res.data.pages }); } }); }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })