添加onPageLoadInitAuth函数判断登录
This commit is contained in:
@@ -5,5 +5,6 @@
|
||||
"tab-bar-plugin": "/pages/components/tab-bar-plugin/tab-bar-plugin",
|
||||
"pagination-plugin": "/pages/components/pagination-plugin/pagination-plugin",
|
||||
"search-popup": "/pages/components/search-popup/search-popup"
|
||||
}
|
||||
},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { loginStatusPage, post } from '@/utils/https';
|
||||
import { post, onPageLoadInitAuth } from '@/utils/https';
|
||||
import { menuConfig } from '@/utils/menuConfig';
|
||||
import { getDataSet, toArray, toObject } from '@/utils/util';
|
||||
|
||||
@@ -55,6 +55,7 @@ Page({
|
||||
this.setData({ isLogin: e.detail });
|
||||
if (e.detail) {
|
||||
this.init();
|
||||
this.getIndex();
|
||||
}
|
||||
},
|
||||
init() {
|
||||
@@ -76,7 +77,6 @@ Page({
|
||||
});
|
||||
}
|
||||
});
|
||||
this.getIndex();
|
||||
this.setData({
|
||||
authInfo: this.data.authInfo,
|
||||
menuList: this.data.menuList,
|
||||
@@ -84,12 +84,23 @@ Page({
|
||||
});
|
||||
},
|
||||
getIndex() {
|
||||
post('Index/index', {}).then((res: any) => {
|
||||
const block = toArray(res?.block);
|
||||
if (block.length % 2 != 0) {
|
||||
block.push({ value: '', name: '工作量查看', unit: '' });
|
||||
}
|
||||
this.setData({ block });
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
post('Index/index', {})
|
||||
.then((res: any) => {
|
||||
const block = toArray(res?.block);
|
||||
if (block.length % 2 != 0) {
|
||||
block.push({ value: '', name: '工作量查看', unit: '' });
|
||||
}
|
||||
this.setData({ block, isLogin: true });
|
||||
resolve(res);
|
||||
})
|
||||
.catch((res) => {
|
||||
this.setData({ isLogin: false });
|
||||
reject(res);
|
||||
})
|
||||
.finally(() => {
|
||||
wx.stopPullDownRefresh();
|
||||
});
|
||||
});
|
||||
},
|
||||
onBlockNavTo(e: any) {
|
||||
@@ -118,7 +129,7 @@ Page({
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
loginStatusPage(this);
|
||||
onPageLoadInitAuth(this, () => this.getIndex());
|
||||
wx.hideHomeButton();
|
||||
},
|
||||
|
||||
@@ -135,7 +146,13 @@ Page({
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {},
|
||||
onPullDownRefresh() {
|
||||
if (this.data.isLogin) {
|
||||
this.getIndex();
|
||||
} else {
|
||||
wx.stopPullDownRefresh();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
|
||||
Reference in New Issue
Block a user