index.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import {
  2. getBannerList
  3. } from '~/api/global'
  4. import {
  5. createStoreBindings
  6. } from 'mobx-miniprogram-bindings'
  7. import {
  8. store
  9. } from '~/store/index'
  10. Page({
  11. data: {
  12. activityList: true,
  13. bannerList: []
  14. },
  15. onShow() {
  16. if (typeof this.getTabBar === 'function') {
  17. this.getTabBar().setData({
  18. selected: 1
  19. })
  20. this.storeBindings = createStoreBindings(this, {
  21. store,
  22. fields: {
  23. userInfo: 'userInfo'
  24. },
  25. })
  26. this.storeBindings.updateStoreBindings()
  27. this.setData({
  28. activityList: true
  29. })
  30. this.getBannerList()
  31. }
  32. },
  33. onHide() {
  34. this.setData({
  35. activityList: false
  36. })
  37. },
  38. async getBannerList() {
  39. let bannerList = await getBannerList({
  40. grade: this.data.userInfo.grade,
  41. })
  42. this.setData({
  43. bannerList,
  44. })
  45. },
  46. resetData() {
  47. this.selectComponent('#activityList').getActivities()
  48. this.getBannerList()
  49. },
  50. onUnload() {
  51. this.storeBindings.destroyStoreBindings()
  52. },
  53. })