精简页面初始化代码

This commit is contained in:
zhengw
2026-02-06 15:30:07 +08:00
parent 9ce21008a3
commit f11f4c8000
35 changed files with 85 additions and 376 deletions

View File

@@ -1,4 +1,4 @@
import { loginStatus, post } from '@/utils/https';
import { loginStatusPage, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -124,16 +124,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
this.setData({ loading: true });
loginStatus()
.then(() => {
this.setData({ isLogin: true, loading: false });
this.init();
})
.catch((err) => {
this.setData({ isLogin: false, loading: false });
console.log('调用登录状态请求失败', err);
});
loginStatusPage(this);
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatus, post } from '@/utils/https';
import { loginStatusPage, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -96,16 +96,7 @@ Page({
if (title) {
wx.setNavigationBarTitle({ title });
}
this.setData({ loading: true });
loginStatus()
.then(() => {
this.setData({ isLogin: true, loading: false });
this.init();
})
.catch((err) => {
this.setData({ isLogin: false, loading: false });
console.log('调用登录状态请求失败', err);
});
loginStatusPage(this);
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatus, post } from '@/utils/https';
import { loginStatusPage, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -159,16 +159,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(_options) {
this.setData({ loading: true });
loginStatus()
.then(() => {
this.setData({ isLogin: true, loading: false });
this.init();
})
.catch((err) => {
this.setData({ isLogin: false, loading: false });
console.log('调用登录状态请求失败', err);
});
loginStatusPage(this);
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatus, post } from '@/utils/https';
import { loginStatusPage, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -109,16 +109,7 @@ Page({
if (title) {
wx.setNavigationBarTitle({ title: decodeURIComponent(title) });
}
this.setData({ loading: true });
loginStatus()
.then(() => {
this.setData({ isLogin: true, loading: false });
this.init();
})
.catch((err) => {
this.setData({ isLogin: false, loading: false });
console.log('调用登录状态请求失败', err);
});
loginStatusPage(this);
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatus, post } from '@/utils/https';
import { loginStatusPage, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -135,16 +135,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
this.setData({ loading: true });
loginStatus()
.then(() => {
this.setData({ isLogin: true, loading: false });
this.init();
})
.catch((err) => {
this.setData({ isLogin: false, loading: false });
console.log('调用登录状态请求失败', err);
});
loginStatusPage(this);
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatus, post } from '@/utils/https';
import { loginStatusPage, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -128,16 +128,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
this.setData({ loading: true });
loginStatus()
.then(() => {
this.setData({ isLogin: true, loading: false });
this.init();
})
.catch((err) => {
this.setData({ isLogin: false, loading: false });
console.log('调用登录状态请求失败', err);
});
loginStatusPage(this);
},
/**