登录逻辑调整

This commit is contained in:
2024-06-06 17:36:31 +08:00
parent 351e675c6d
commit 8f06cf703d
6 changed files with 48 additions and 24 deletions

View File

@@ -14,15 +14,15 @@
</view>
</view>
<view class='user-info-card' @click.stop='goPath("/pages/mine/index")'>
<view class='user-info-card' @click.stop='goPath("/pages/mine/index",true)'>
<image class='user-avatar' :src='userInfo?.image||defaultAvatar' mode='aspectFill' />
<text class='user-name primary-text-color'>{{ userInfo?.nickName || '点击注册会员' }}</text>
<view class='integral-view primary-text-color' @click.stop='goPath("/pages/mine/subs/integral/index")'>
<view class='integral-view primary-text-color' @click.stop='goPath("/pages/mine/subs/integral/index",true)'>
<text>{{ userInfo?.integration || 0 }}</text>
<text>积分</text>
</view>
<view class='divider' style='height: 83rpx' />
<view class='balance-view' @click.stop='goPath("/pages/mine/subs/recharge/index")'>
<view class='balance-view' @click.stop='goPath("/pages/mine/subs/recharge/index",true)'>
<text class='accent-text-color'>{{ userInfo?.balance || 0 }}</text>
<text>余额()</text>
</view>
@@ -33,12 +33,12 @@
</view>
<view class='menu-view'>
<view @click.stop='goPath("/pages/mine/subs/recharge/index")'>
<view @click.stop='goPath("/pages/mine/subs/recharge/index",true)'>
<image :src='assetsUrl("ic_member_card2.png")' style='width: 108rpx;height: 72rpx;padding: 11rpx 0' />
<text>会员充值</text>
</view>
<view class='divider' style='margin: 0;height: 153rpx' />
<view @click.stop='goPath("/pages/mine/subs/coupon/index")'>
<view @click.stop='goPath("/pages/mine/subs/coupon/index",true)'>
<image :src='assetsUrl("ic_coupon2.png")' style='width: 108rpx;height: 95rpx' />
<text>优惠券</text>
</view>

View File

@@ -136,15 +136,17 @@ onLoad(() => {
});
onShow(async () => {
const { list } = await getOrderList({
pageNum: 1,
pageSize: 9999,
obj: { payStatus: 1 }
});
unPaidOrderCount.value = list.filter((item: any) => isPending(item))?.length || 0;
const { cardurl } = await getCardLink();
cardLink.value = cardurl;
await userStore.getProfile();
if(isLogin()) {
const { list } = await getOrderList({
pageNum: 1,
pageSize: 9999,
obj: { payStatus: 1 }
});
unPaidOrderCount.value = list.filter((item: any) => isPending(item))?.length || 0;
const { cardurl } = await getCardLink();
cardLink.value = cardurl;
await userStore.getProfile();
}
});
const openCard = () => {
@@ -173,7 +175,7 @@ const gotoPath = (path: string) => {
phoneNumber: companyInfo.value.telphone
});
} else {
goPath(path);
goPath(path, true);
}
};

View File

@@ -11,7 +11,7 @@
<view class='qrcode-card'>
<view class='balance-view'>
<text class='balance-text'>账户余额{{ userInfo?.balance || 0 }}</text>
<view class='btn-recharge' @click.stop='goPath("/pages/mine/subs/recharge/index")'>
<view class='btn-recharge' @click.stop='goPath("/pages/mine/subs/recharge/index",true)'>
<text>去充值</text>
<image :src='assetsUrl("ic_arrow_right.png")' />
</view>
@@ -36,7 +36,6 @@
<text>店铺名称{{ userInfo?.creatorName }}</text>
<text>{{ userInfo?.storeId }}</text>
</view>
</view>
</view>
</template>

View File

@@ -25,11 +25,12 @@ list.forEach((item) => {
return true;
}
else {
if (checkWhite(to.url))
return true;
uni.reLaunch({ url: loginPage });
return false;
// if (checkWhite(to.url))
// return true;
//
// uni.reLaunch({ url: loginPage });
// return false;
return true;
}
},
fail(err) {

View File

@@ -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

View File

@@ -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