12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 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
- })
- },
- async getLocUserInfo() {
- this.storeBindings = createStoreBindings(this, {
- store,
- fields: {
- userInfo: 'userInfo'
- },
- })
- this.storeBindings.updateStoreBindings()
- },
- })
|