import { getSelfRead } from '~/api/user' import { getModelTexts, getReadRanking, getSelfReadRanking } from '~/api/global' import { store } from '~/store/index' import { createStoreBindings } from 'mobx-miniprogram-bindings' Page({ /** * 页面的初始数据 */ data: { list: [], // true是人气榜,false是参赛作品 currentType: true, activityUserList: [], bannerList: [], myActivityUser: {}, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { // 手工绑定 this.storeBindings = createStoreBindings(this, { store, fields: { userInfo: 'userInfo' }, actions: { setUser: 'setUser' } }) // 立刻更新 this.storeBindings.updateStoreBindings() this.getModelTexts() this.getReadRanking() }, // 获取范文 async getModelTexts() { let bannerList = await getModelTexts({ grade: 'PRIMARY_FIRST_GRADE' || this.data.userInfo.grade }) this.setData({ bannerList }) }, async getReadRanking() { let { activityUserList, myActivityUser } = await getReadRanking() this.setData({ activityUserList, myActivityUser }) }, async getSelfReadRanking() { let res = await getSelfReadRanking() console.log(res); }, bannelEvent() {}, jumpUserInfo({ currentTarget }) { wx.navigateTo({ url: `/pages/personal/index?uid=${currentTarget.dataset.uid}`, }) }, selectType({ target }) { if (target.dataset.type) { let currentType = JSON.parse(target.dataset.type) if (!currentType) { this.getSelfReadRanking() } this.setData({ currentType }) } }, onShareAppMessage() { } })