添加onPageLoadInitAuth函数判断登录

This commit is contained in:
zhengw
2026-03-10 11:33:42 +08:00
parent 511d29281e
commit 76c28f8d78
40 changed files with 816 additions and 526 deletions

View File

@@ -1,7 +1,7 @@
import { base, defaultAvatarUrl } from '@/utils/config';
import { login } from '@/utils/https';
import { Subscribe } from '@/utils/subscribe';
import { isArray, setStorage } from '@/utils/util';
import { getCurrentPageRoute, isArray } from '@/utils/util';
// import { IStorage } from "@/utils/storage";
// const app = getApp();
@@ -10,26 +10,26 @@ import { isArray, setStorage } from '@/utils/util';
Component({
options: { addGlobalClass: true },
properties: {
isLogin: Boolean,
loading: Boolean,
// isLogin: Boolean,
// loading: Boolean,
isAuth: null,
customStyle: null,
hasTabBar: null,
},
// attached() {
// this.setData({ isLogin: getStorage("isLogin") == 1 });
// console.log("attached");
// Subscribe.on("isLogin", getCurrentPageRoute(), () => {
// this.setData({ isLogin: getStorage("isLogin") == 1 });
// console.log("监听到 isLogin 变化:");
// });
// },
// detached() {
// console.log("detached");
// Subscribe.off("isLogin", getCurrentPageRoute());
// },
attached() {
// this.setData({ isLogin: getStorage('isLogin') == 1 });
// console.log('attached');
Subscribe.on('isLogin', getCurrentPageRoute(), (data: any) => {
// console.log(data);
this.setData({ isLogin: data, loading: false });
// console.log('监听到 isLogin 变化:');
});
},
detached() {
// console.log('detached');
Subscribe.off('isLogin', getCurrentPageRoute());
},
data: {
avatarUrl: defaultAvatarUrl,
@@ -39,14 +39,14 @@ Component({
companyList: [],
encryptedData: '',
iv: '',
isLogin: false,
loading: true,
},
methods: {
handleLogin(e: any) {
this.triggerEvent('handleLogin', e.detail);
},
getPhoneNumberToast() {
setStorage('isLogin', 1);
Subscribe.set('isLogin', 'zzzuz');
wx.showToast({ title: '请先勾选协议', icon: 'none' });
},
changeAgreementCheck(event: any) {