|
@@ -11,6 +11,12 @@ import {
|
|
|
getFollowWorks
|
|
|
} from '~/api/works'
|
|
|
import reachBottom from '~/mixins/reachBottom'
|
|
|
+import {
|
|
|
+ createStoreBindings
|
|
|
+} from 'mobx-miniprogram-bindings'
|
|
|
+import {
|
|
|
+ store
|
|
|
+} from '~/store/index'
|
|
|
Page({
|
|
|
behaviors: [reachBottom, share],
|
|
|
data: {
|
|
@@ -26,12 +32,13 @@ Page({
|
|
|
selected: 2
|
|
|
})
|
|
|
}
|
|
|
- let uid = wx.getStorageSync('uid')
|
|
|
- if (uid) {
|
|
|
- this.resetData()
|
|
|
+ this.getLocUserInfo()
|
|
|
+ if (Object.keys(this.data.userInfo).length > 0) {
|
|
|
+ this.requestAgain()
|
|
|
} else {
|
|
|
getApp().callBack = (res) => {
|
|
|
- this.resetData()
|
|
|
+ this.getLocUserInfo()
|
|
|
+ this.requestAgain()
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -44,6 +51,15 @@ Page({
|
|
|
this.getData(getFavoritesList, {})
|
|
|
}
|
|
|
},
|
|
|
+ async getBannerList() {
|
|
|
+ let bannerList = await getBannerList({
|
|
|
+ grade: this.data.userInfo.grade,
|
|
|
+ classify: this.data.currentType
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ bannerList,
|
|
|
+ })
|
|
|
+ },
|
|
|
changeType({
|
|
|
target
|
|
|
}) {
|
|
@@ -55,7 +71,7 @@ Page({
|
|
|
this.setData({
|
|
|
currentType: target.dataset.type
|
|
|
})
|
|
|
- this.resetData()
|
|
|
+ this.requestAgain()
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
@@ -72,10 +88,20 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- /**
|
|
|
- * 页面上拉触底事件的处理函数
|
|
|
- */
|
|
|
- onReachBottom() {
|
|
|
- this.loadMore()
|
|
|
+ requestAgain() {
|
|
|
+ this.resetData()
|
|
|
+ this.getBannerList()
|
|
|
+ },
|
|
|
+ async getLocUserInfo() {
|
|
|
+ this.storeBindings = createStoreBindings(this, {
|
|
|
+ store,
|
|
|
+ fields: {
|
|
|
+ userInfo: 'userInfo'
|
|
|
+ },
|
|
|
+ })
|
|
|
+ this.storeBindings.updateStoreBindings()
|
|
|
+ },
|
|
|
+ onUnload() {
|
|
|
+ this.storeBindings.destroyStoreBindings()
|
|
|
},
|
|
|
})
|