添加onPageLoadInitAuth函数判断登录
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { loginStatusPage, post } from '@/utils/https';
|
||||
import { onPageLoadInitAuth, post } from '@/utils/https';
|
||||
import {
|
||||
cloneLite,
|
||||
getAuthInfo,
|
||||
@@ -28,11 +28,11 @@ Page({
|
||||
this.setData({ isLogin: e.detail });
|
||||
if (e.detail) {
|
||||
this.init();
|
||||
this.getGoodsAttr();
|
||||
}
|
||||
},
|
||||
init() {
|
||||
this.setData({ authInfo: getAuthInfo() });
|
||||
this.getGoodsAttr();
|
||||
},
|
||||
searchChange(e: any) {
|
||||
const key = getDataSet(e).key;
|
||||
@@ -57,19 +57,27 @@ Page({
|
||||
this.getList();
|
||||
},
|
||||
getGoodsAttr() {
|
||||
post('GoodsAttr/list').then((res: any) => {
|
||||
this.data.goodsSubAttr = {};
|
||||
toArray(res?.data?.list).forEach((el) => {
|
||||
toArray(el.sub_attr).forEach((ell) => {
|
||||
this.data.goodsSubAttr[ell.attr_id] = {
|
||||
...ell,
|
||||
p_attr_name: el.attr_name,
|
||||
};
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
post('GoodsAttr/list')
|
||||
.then((res: any) => {
|
||||
this.data.goodsSubAttr = {};
|
||||
toArray(res?.data?.list).forEach((el) => {
|
||||
toArray(el.sub_attr).forEach((ell) => {
|
||||
this.data.goodsSubAttr[ell.attr_id] = {
|
||||
...ell,
|
||||
p_attr_name: el.attr_name,
|
||||
};
|
||||
});
|
||||
});
|
||||
// console.log(this.data.goodsSubAttr);
|
||||
this.setData({ goodsSubAttr: this.data.goodsSubAttr, isLogin: true });
|
||||
this.getList();
|
||||
resolve(res);
|
||||
})
|
||||
.catch((res) => {
|
||||
this.setData({ isLogin: false });
|
||||
reject(res);
|
||||
});
|
||||
});
|
||||
// console.log(this.data.goodsSubAttr);
|
||||
this.setData({ goodsSubAttr: this.data.goodsSubAttr });
|
||||
this.getList();
|
||||
});
|
||||
},
|
||||
getList() {
|
||||
@@ -109,7 +117,7 @@ Page({
|
||||
if (title) {
|
||||
wx.setNavigationBarTitle({ title: decodeURIComponent(title) });
|
||||
}
|
||||
loginStatusPage(this);
|
||||
onPageLoadInitAuth(this, () => this.getGoodsAttr());
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user