12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- const app = getApp()
- import {
- getCategoryList,
- getResourceList
- } from "~/api/works"
- import event from '~/mixins/event'
- import share from '~/mixins/share'
- import {
- createStoreBindings
- } from 'mobx-miniprogram-bindings'
- import {
- store
- } from '~/store/index'
- let storeBindings
- Page({
- behaviors: [share, event],
- data: {
- navBarHeight: app.globalData.navBarHeight,
- categoryList: [],
- listOptions: {},
- tmplIds: [],
- },
- onLoad(options) {
- this.getLocUserInfo()
- },
- onShow() {
- if (Object.keys(this.data.userInfo).length > 0) {
- this.requestAgain()
- } else {
- getApp().callBack = (res) => {
- this.getLocUserInfo()
- this.requestAgain()
- }
- }
- if (typeof this.getTabBar === 'function') {
- this.getTabBar().setData({
- selected: 2
- })
- }
- },
- requestAgain() {
- this.getResource()
- this.getCategoryList()
- },
- async getLocUserInfo() {
- this.storeBindings = createStoreBindings(this, {
- store,
- fields: {
- userInfo: 'userInfo',
- },
- })
- this.storeBindings.updateStoreBindings()
- },
- async getCategoryList() {
- let grade = this.data.userInfo.grade
- let categoryList = await getCategoryList({
- grade
- })
- this.setData({
- categoryList
- })
- },
- async getResource() {
- let data = await getResourceList({
- grade: this.data.userInfo.grade
- })
- this.setData({
- listOptions: data,
- })
- },
- jumpChildClassify({
- currentTarget
- }) {
- let firstInfo = currentTarget.dataset.item
- wx.navigateTo({
- url: `/pages/childClassify/index?type=class&title=${firstInfo.title}&id=${firstInfo.id}`,
- })
- },
- showTips() {
- wx.showModal({
- title: '新栏目更新中',
- content: '敬请期待….',
- showCancel: false,
- confirmColor: '#333333',
- success(res) {}
- })
- },
- jumpSearch() {
- wx.navigateTo({
- url: '/pages/childClassify/index?type=search',
- })
- },
- onUnload() {
- this.storeBindings.destroyStoreBindings()
- },
- })
|