// packageD/MyFriendApply/myfriends.js var app =getApp(); Page({ /** * 页面的初始数据 */ data: { tabs: [], selected: 0, tabID: 0, bossList: [], detail: {}, uid: 0, inNickName: "", showNoText: false, diyName: "我的朋友", //more isLoadMore: true, page: 1, current_page: 0, last_page:0 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getTab(); }, changeTab(e){ console.log(e); this.setData({ selected: e.currentTarget.dataset.tab, tabID: e.currentTarget.dataset.tab, page:1, bossList:'' }); this.getData(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { if(this.data.current_page >= this.data.last_page){ wx.showToast({ title: '没有更多', icon:'none', duration:1000 }); }else{ var is_page = this.data.page + 1; this.setData({ page:is_page }); console.log(this.data.page); this.getMoreData(); } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, getTab(){ let that = this; let urlStr = app.getNetAddresss("plugin.my-friend.api.my-friend.get-columns"); app._getNetWork({ url: urlStr, success: function (resdata) { var res = resdata.data; if (res.result == 1) { console.log(res); that.setData({ tabs: res.data.columns, tabID: res.data.columns[0].id, diyName: res.data.my_friend_name ? res.data.my_friend_name :'我的朋友', selected:res.data.columns[0].id, }); that.getData(); } else { wx.showToast({ icon: 'none', title: res.msg, duration: 1000 }); } }, fail: function (res) { console.log(res); } }); }, getData(){ let that = this; let urlStr = app.getNetAddresss("plugin.my-friend.api.my-friend.get-list"); app._postNetWork({ url: urlStr, data:{ id: that.data.tabID, page:that.data.page }, success: function (resdata) { var res = resdata.data; if (res.result == 1) { console.log(res); var myData = res.data.list.data; that.setData({ showNoText: app._isTextEmpty(myData), bossList: myData, last_page:res.data.list.last_page, current_page:res.data.list.current_page }); } else { wx.showToast({ icon: 'none', title: res.msg, duration: 1000 }); } }, fail: function (res) { console.log(res); } }); }, getMoreData(){ let that = this; let urlStr = app.getNetAddresss("plugin.my-friend.api.my-friend.get-list"); app._postNetWork({ url: urlStr, data:{ id: that.data.tabID, page:that.data.page }, success: function (resdata) { var res = resdata.data; if (res.result == 1) { console.log(res); var myData = res.data.list.data; that.setData({ showNoText: app._isTextEmpty(myData), bossList: that.data.bossList.concat(myData), last_page:res.data.list.last_page, current_page:res.data.list.current_page }); } else { wx.showToast({ icon: 'none', title: res.msg, duration: 1000 }); } }, fail: function (res) { console.log(res); } }); } });