登录逻辑调整
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
// 小程序更新检测
|
||||
|
||||
import { isLogin } from '@/utils';
|
||||
|
||||
export function mpUpdate() {
|
||||
const updateManager = uni.getUpdateManager();
|
||||
updateManager.onCheckForUpdate((res) => {
|
||||
@@ -50,7 +52,20 @@ export function showToast(title: string, { icon, duration, complete }: ToastOpti
|
||||
});
|
||||
}
|
||||
|
||||
export function goPath(path: string) {
|
||||
export function goPath(path: string, needAuth: boolean = false) {
|
||||
if(needAuth && !isLogin()) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '您还未登录,请先登录',
|
||||
showCancel: true,
|
||||
success: (res) => {
|
||||
if(res.confirm) {
|
||||
goLogin();
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(path.includes('home/index') || path.includes('mall/index') || path.includes('qrcode/index') || path.includes('mine/index')) {
|
||||
uni.switchTab({
|
||||
url: path
|
||||
|
@@ -86,7 +86,14 @@ function responseInterceptors() {
|
||||
|
||||
// 如果没有显式定义custom的toast参数为false的话,默认对报错进行toast弹出提示
|
||||
if(custom?.toast !== false) {
|
||||
uni.$u.toast(data.message || data.retinfo);
|
||||
if(data?.retinfo?.includes('未登录')
|
||||
|| data?.retinfo?.includes('未登陆')
|
||||
|| data.message?.includes('未登录')
|
||||
|| data.message?.includes('未登陆')) {
|
||||
getApp()?.globalData?.logger.error('未登录');
|
||||
} else {
|
||||
uni.$u.toast(data.message || data.retinfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果需要catch返回,则进行reject
|
||||
|
Reference in New Issue
Block a user