123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- 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()
- },
- })
|