|
@@ -1,7 +1,11 @@
|
|
|
import {
|
|
|
getCategoryWorks,
|
|
|
+ getCategoryLowerList,
|
|
|
searchWorks
|
|
|
} from '~/api/works';
|
|
|
+import {
|
|
|
+ setUserInfo
|
|
|
+} from '~/api/user'
|
|
|
import reachBottom from '~/mixins/reachBottom';
|
|
|
import {
|
|
|
createStoreBindings
|
|
@@ -28,23 +32,25 @@ Page({
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad(options) {
|
|
|
- // 没有二级分类
|
|
|
+ async onLoad(options) {
|
|
|
+ console.log(options, 'options');
|
|
|
if (options.id) {
|
|
|
- this.setData({
|
|
|
- childType: options.id
|
|
|
- });
|
|
|
- this.resetData();
|
|
|
- } else if (options.list) {
|
|
|
- let categoryList = JSON.parse(decodeURIComponent(options.list));
|
|
|
- this.setData({
|
|
|
- categoryList
|
|
|
- });
|
|
|
+ let categoryList = await getCategoryLowerList(options.id)
|
|
|
+ if (categoryList.length == 0) {
|
|
|
+ this.setData({
|
|
|
+ childType: options.id
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ categoryList
|
|
|
+ });
|
|
|
+ }
|
|
|
this.resetData();
|
|
|
}
|
|
|
wx.setNavigationBarTitle({
|
|
|
title: options.title || '搜索'
|
|
|
});
|
|
|
+
|
|
|
this.setData({
|
|
|
type: options.type,
|
|
|
historySearch: wx.getStorageSync('search'),
|
|
@@ -58,6 +64,12 @@ Page({
|
|
|
});
|
|
|
// 立刻更新
|
|
|
this.storeBindings.updateStoreBindings();
|
|
|
+ console.log(this.data.userInfo);
|
|
|
+ if (options.grade && !this.data.userInfo.grade) {
|
|
|
+ setUserInfo({
|
|
|
+ grade: options.grade
|
|
|
+ }, 'put')
|
|
|
+ }
|
|
|
},
|
|
|
// 获取分类的内容
|
|
|
loadMore() {
|