|
@@ -2,6 +2,7 @@ import {
|
|
|
createStoreBindings
|
|
|
} from 'mobx-miniprogram-bindings'
|
|
|
import {
|
|
|
+ getCategoryList,
|
|
|
getAuthorityList,
|
|
|
} from "~/api/works"
|
|
|
import share from '~/mixins/share'
|
|
@@ -11,8 +12,10 @@ import {
|
|
|
} from '~/store/index'
|
|
|
Page({
|
|
|
behaviors: [reachBottom, share],
|
|
|
- data: {},
|
|
|
-
|
|
|
+ data: {
|
|
|
+ categoryList: [],
|
|
|
+ isFixed: false
|
|
|
+ },
|
|
|
onShow() {
|
|
|
if (typeof this.getTabBar === 'function') {
|
|
|
this.getTabBar().setData({
|
|
@@ -21,14 +24,18 @@ Page({
|
|
|
}
|
|
|
this.getLocUserInfo()
|
|
|
if (Object.keys(this.data.userInfo).length > 0) {
|
|
|
- this.resetData()
|
|
|
+ this.requestAgain()
|
|
|
} else {
|
|
|
getApp().callBack = (res) => {
|
|
|
this.getLocUserInfo()
|
|
|
- this.resetData()
|
|
|
+ this.requestAgain()
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ requestAgain() {
|
|
|
+ this.resetData()
|
|
|
+ this.getCategoryList()
|
|
|
+ },
|
|
|
async loadMore() {
|
|
|
if (!this.data.userInfo.grade) {
|
|
|
return
|
|
@@ -40,8 +47,23 @@ Page({
|
|
|
list
|
|
|
})
|
|
|
},
|
|
|
- onReachBottom() {
|
|
|
- this.loadMore()
|
|
|
+ async getCategoryList() {
|
|
|
+ let grade = this.data.userInfo.grade
|
|
|
+ let categoryList = await getCategoryList({
|
|
|
+ grade
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ categoryList
|
|
|
+ })
|
|
|
+ },
|
|
|
+ jumpChildClassify({
|
|
|
+ currentTarget
|
|
|
+ }) {
|
|
|
+ let firstInfo = currentTarget.dataset.item
|
|
|
+ let params = firstInfo.childList.length > 0 ? `list=${encodeURIComponent(JSON.stringify(firstInfo.childList))}` : `id=${firstInfo.id}`
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `/pages/childClassify/index?type=class&title=${firstInfo.title}&${params}`,
|
|
|
+ })
|
|
|
},
|
|
|
onUnload() {
|
|
|
this.storeBindings.destroyStoreBindings()
|
|
@@ -58,4 +80,18 @@ Page({
|
|
|
onUnload() {
|
|
|
this.storeBindings.destroyStoreBindings()
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 监听页面滚动事件
|
|
|
+ */
|
|
|
+ onPageScroll(e) {
|
|
|
+ if (e.scrollTop >= 6 && !this.data.isFixed) {
|
|
|
+ this.setData({
|
|
|
+ isFixed: true
|
|
|
+ })
|
|
|
+ } else if (e.scrollTop < 6 && this.data.isFixed) {
|
|
|
+ this.setData({
|
|
|
+ isFixed: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
})
|