fix: 认证策略是先充值后实名, 首页入口
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 1m11s

This commit is contained in:
luo
2026-08-05 12:02:25 +08:00
parent f9d8a107a4
commit d05a47ffe2
6 changed files with 116 additions and 26 deletions

View File

@@ -136,6 +136,7 @@
import {
assetApi,
deviceApi,
hasActiveOrPendingPackage,
notificationApi
} from '@/api/index.js';
import {
@@ -197,6 +198,7 @@
let boundPhone = ref('');
let realNameStatus = ref('');
let effectiveRealnamePolicy = ref('none');
let realnameEntryChecking = ref(false);
let wifi_info = reactive({
ssid: '',
pwd: ''
@@ -715,6 +717,51 @@
});
};
const shouldRedirectRealnameToPackageOrder = async () => {
if (effectiveRealnamePolicy.value !== 'after_order') return false;
const identifier = userStore.state.identifier;
let cards = [{ real_name_status: isRealName.value ? 1 : 0 }];
if (userInfo.isDevice) {
const data = await deviceApi.getCards(identifier);
cards = Array.isArray(data?.cards) ? data.cards : [];
}
if (cards.some(card => Number(card?.real_name_status) === 1)) return false;
return !(await hasActiveOrPendingPackage(identifier));
};
const openRealnameEntry = async () => {
if (realnameEntryChecking.value) return;
realnameEntryChecking.value = true;
uni.showLoading({ title: '校验中...', mask: true });
try {
const shouldRedirect = await shouldRedirectRealnameToPackageOrder();
uni.hideLoading();
if (!shouldRedirect) {
uni.navigateTo({ url: '/pages/auth/auth' });
return;
}
uni.showModal({
title: '提示',
content: '当前设备所有卡均未实名,且暂无生效中或待生效套餐。请先订购套餐,再进行实名认证。',
confirmText: '去订购',
cancelText: '取消',
success: ({ confirm }) => {
if (confirm) uni.navigateTo({ url: '/pages/package-order/package-order' });
}
});
} catch (error) {
uni.hideLoading();
console.error('校验实名入口条件失败', error);
uni.showToast({ title: '实名条件校验失败,请稍后重试', icon: 'none' });
} finally {
realnameEntryChecking.value = false;
}
};
const enterDetail = (name) => {
switch (name) {
case 'notifications':
@@ -774,23 +821,7 @@
});
break;
case 'authentication':
if (effectiveRealnamePolicy.value === 'after_order') {
uni.showModal({
title: '提示',
content: '当前认证策略为先充值后实名,请先订购套餐后再进行实名认证。是否前往套餐订购页面?',
confirmText: '去订购',
cancelText: '取消',
success: ({ confirm }) => {
if (confirm) {
uni.navigateTo({ url: '/pages/package-order/package-order' });
}
}
});
break;
}
uni.navigateTo({
url: '/pages/auth/auth'
});
openRealnameEntry();
break;
case 'recover':
recoverShow.value = true;