const app = getApp() import { getBannerList } from '~/api/global' import { getSelfRead } from '~/api/user' import { getFollowWorks } from '~/api/works' import reachBottom from '~/mixins/reachBottom' Page({ behaviors: [reachBottom], data: { navBarHeight: app.globalData.navBarHeight, bannerList: [], // 1关注的人的作品,2是自己的作品 currentType: '1', isFixed: false }, onShow() { if (typeof this.getTabBar === 'function') { this.getTabBar().setData({ selected: 2 }) } let uid = wx.getStorageSync('uid') if (uid) { this.resetData() } else { getApp().callBack = (res) => { this.resetData() } } }, loadMore() { if (this.data.currentType == '1') { this.getData(getFollowWorks, {}) } else if (this.data.currentType == '2') { this.getData(getSelfRead, {}) } }, async getFollowWorks() { let res = await getFollowWorks() console.log(res); }, changeType({ target }) { if (target.dataset.type) { this.setData({ currentType: target.dataset.type }) this.resetData() } }, /** * 监听页面滚动事件 */ onPageScroll(e) { if (e.scrollTop >= 110 && !this.data.isFixed) { this.setData({ isFixed: true }) } else if (e.scrollTop < 110 && this.data.isFixed) { this.setData({ isFixed: false }) } }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { this.loadMore() }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })