const app = getApp() import { getHotrecommendList } from "~/api/works" import reachBottom from '~/mixins/reachBottom' import { createStoreBindings } from 'mobx-miniprogram-bindings' import { store } from '~/store/index' Page({ behaviors: [reachBottom], /** * 页面的初始数据 */ data: { background: ['demo-text-1', 'demo-text-2', 'demo-text-3'], currentType: '1' }, /** * 生命周期函数--监听页面加载 */ onShow() { if (typeof this.getTabBar === 'function') { this.getTabBar().setData({ selected: 1 }) } getApp().callBack = (res) => { this.storeBindings = createStoreBindings(this, { store, fields: { userInfo: 'userInfo' }, }) this.storeBindings.updateStoreBindings() this.loadMore() } }, onUnload() { this.storeBindings.destroyStoreBindings() }, loadMore() { console.log(this.data.currentType, 'zzz'); if (this.data.currentType == '1') { this.getData(getHotrecommendList, { grade: this.data.userInfo.grade }) } else if (this.data.currentType == '2') { this.getData(getHotrecommendList, { grade: 'PRESCHOOL' }) } }, onReachBottom() { console.log('触底'); this.loadMore() }, selectType({ target }) { if (target.dataset.type) { this.setData({ currentType: target.dataset.type }) this.resetData() } }, })