import { getActivities, } from '~/api/global' import { createStoreBindings } from 'mobx-miniprogram-bindings' import { store } from '~/store/index' Page({ data: { rankList: [], activityList: [] }, onLoad(options) { this.getLocUserInfo() if (Object.keys(this.data.userInfo).length > 0) { this.getRankList() this.getActivityList() } else { getApp().callBack = (res) => { this.getLocUserInfo() this.getRankList() this.getActivityList() } } }, onShow() { if (typeof this.getTabBar === 'function') { this.getTabBar().setData({ selected: 0 }) } }, async getRankList() { let res = await getActivities({ classify: 2, grade: this.data.userInfo.grade }) console.log(res); this.setData({ rankList: res }) }, async getActivityList() { let res = await getActivities({ classify: 3, grade: this.data.userInfo.grade }) console.log(res, 'bbbb'); this.setData({ activityList: res }) }, activityEvent({ currentTarget }) { let { type, } = currentTarget.dataset.info wx.navigateTo({ url: `/pages/ranking/index?type=${type}`, }) }, jumpUserInfo({ currentTarget }) { if (!currentTarget.dataset.uid) { return } wx.navigateTo({ url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`, }) }, async getLocUserInfo() { this.storeBindings = createStoreBindings(this, { store, fields: { userInfo: 'userInfo' }, }) this.storeBindings.updateStoreBindings() }, })