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