12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import {
- getBannerList
- } from '~/api/global'
- import {
- createStoreBindings
- } from 'mobx-miniprogram-bindings'
- import {
- store
- } from '~/store/index'
- Page({
- data: {
- activityList: false,
- bannerList: []
- },
- onShow() {
- if (typeof this.getTabBar === 'function') {
- this.getTabBar().setData({
- selected: 1
- })
- this.getLocUserInfo()
- if (Object.keys(this.data.userInfo).length > 0) {
- this.getBannerList()
- this.setData({
- activityList: true
- })
- } else {
- getApp().callBack = (res) => {
- this.getLocUserInfo()
- this.getBannerList()
- this.setData({
- activityList: true
- })
- }
- }
- }
- },
- onHide() {
- this.setData({
- activityList: false
- })
- },
- async getBannerList() {
- let bannerList = await getBannerList({
- grade: this.data.userInfo.grade,
- })
- this.setData({
- bannerList,
- })
- },
- resetData() {
- this.selectComponent('#activityList').getActivities()
- this.getBannerList()
- },
- async getLocUserInfo() {
- this.storeBindings = createStoreBindings(this, {
- store,
- fields: {
- userInfo: 'userInfo'
- },
- })
- this.storeBindings.updateStoreBindings()
- },
- onUnload() {
- this.storeBindings.destroyStoreBindings()
- },
- })
|