精简页面初始化代码

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

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
import { OSSBaseUrl } from '@/utils/config'; import { OSSBaseUrl } from '@/utils/config';
import { loginStatus, post } from '@/utils/https'; import { loginStatusPage, post } from '@/utils/https';
import { import {
formatFileSize, formatFileSize,
getAuthInfo, getAuthInfo,
@@ -76,16 +76,7 @@ Page({
this.data.order_no = order_no; this.data.order_no = order_no;
this.data.head_id = head_id; this.data.head_id = head_id;
this.data.head_id2 = head_id2; this.data.head_id2 = head_id2;
this.setData({ loading: true }); loginStatusPage(this);
loginStatus()
.then(() => {
this.setData({ isLogin: true, loading: false });
this.init();
})
.catch((err) => {
this.setData({ isLogin: false, loading: false });
console.log('调用登录状态请求失败', err);
});
}, },
/** /**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
import { loginStatus, post } from '@/utils/https'; import { loginStatusPage, post } from '@/utils/https';
import { getAuthInfo, toArray } from '@/utils/util'; import { getAuthInfo, toArray } from '@/utils/util';
Page({ Page({
@@ -65,16 +65,7 @@ Page({
this.data.group_id = `${options.group_id}`; this.data.group_id = `${options.group_id}`;
wx.setNavigationBarTitle({ title: `${decodeURIComponent(`${options.name}`)} 权限` }); wx.setNavigationBarTitle({ title: `${decodeURIComponent(`${options.name}`)} 权限` });
this.setData({ loading: true }); loginStatusPage(this);
loginStatus()
.then(() => {
this.setData({ isLogin: true, loading: false });
this.init();
})
.catch((err) => {
this.setData({ isLogin: false, loading: false });
console.log('调用登录状态请求失败', err);
});
}, },
/** /**

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
import { base } from '@/utils/config'; import { base } from '@/utils/config';
import { checkSesskey, loginStatus, post } from '@/utils/https'; import { checkSesskey, loginStatusPage, post } from '@/utils/https';
import { getStorage, toObject } from '@/utils/util'; import { getStorage, toObject } from '@/utils/util';
Page({ Page({
@@ -45,17 +45,7 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad() { onLoad() {
this.setData({ loading: true }); loginStatusPage(this);
loginStatus()
.then(() => {
console.log('ssss');
this.setData({ isLogin: true, loading: false });
this.init();
})
.catch((err) => {
this.setData({ isLogin: false, loading: false });
console.log('调用登录状态请求失败', err);
});
}, },
loginOut() { loginOut() {
wx.showModal({ wx.showModal({

View File

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

View File

@@ -1,4 +1,4 @@
import { loginStatus, post } from '@/utils/https'; import { loginStatusPage, post } from '@/utils/https';
import { import {
getAuthInfo, getAuthInfo,
priceRetentionDigits, priceRetentionDigits,
@@ -100,18 +100,7 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(_options) { onLoad(_options) {
// console.log(options); loginStatusPage(this);
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);
});
}, },
/** /**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
import { loginStatus, post } from '@/utils/https'; import { loginStatusPage, post } from '@/utils/https';
import { formatTime, getAuthInfo, getDataSet, isArray, toArray, toObject } from '@/utils/util'; import { formatTime, getAuthInfo, getDataSet, isArray, toArray, toObject } from '@/utils/util';
import { voiceRequest } from '@/utils/voiceUtil'; import { voiceRequest } from '@/utils/voiceUtil';
@@ -340,15 +340,7 @@ Page({
loading: true, loading: true,
voice: wx.getStorageSync('processEntryVoice') == 'false' ? false : true, voice: wx.getStorageSync('processEntryVoice') == 'false' ? false : true,
}); });
loginStatus() loginStatusPage(this);
.then(() => {
this.setData({ isLogin: true, loading: false });
this.init();
})
.catch((err) => {
this.setData({ isLogin: false, loading: false });
console.log('调用登录状态请求失败', err);
});
}, },
/** /**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -172,6 +172,23 @@ export const loginStatus = () => {
}); });
}; };
export const loginStatusPage = (that: WechatMiniprogram.Page.Instance<any, any>) => {
that.setData({ loading: true });
return new Promise<void>((resolve, reject) => {
loginStatus()
.then(() => {
that.setData({ isLogin: true, loading: false });
that?.init?.();
resolve();
})
.catch((err) => {
that.setData({ isLogin: false, loading: false });
reject();
console.log('调用登录状态请求失败', err);
});
});
};
/** /**
* *
* @param {*} config { showLoading: true, showError: true } * @param {*} config { showLoading: true, showError: true }