This commit is contained in:
@@ -42,6 +42,7 @@
|
|||||||
import { ref, reactive, onMounted } from 'vue';
|
import { ref, reactive, onMounted } from 'vue';
|
||||||
import { authApi, assetApi } from '@/api/index.js';
|
import { authApi, assetApi } from '@/api/index.js';
|
||||||
import { useUserStore } from '@/store/index.js';
|
import { useUserStore } from '@/store/index.js';
|
||||||
|
import { setPhoneBindStatus } from '@/utils/phone-bind.js';
|
||||||
|
|
||||||
const POST_BIND_RELOGIN_NOTICE_KEY = 'postBindReloginNotice';
|
const POST_BIND_RELOGIN_NOTICE_KEY = 'postBindReloginNotice';
|
||||||
|
|
||||||
@@ -139,6 +140,8 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await authApi.bindPhone(bind.phone, bind.code);
|
await authApi.bindPhone(bind.phone, bind.code);
|
||||||
|
const identifier = userStore.state.identifier || uni.getStorageSync('identifier') || '';
|
||||||
|
setPhoneBindStatus(identifier, bind.phone);
|
||||||
|
|
||||||
if (fromLogin.value) {
|
if (fromLogin.value) {
|
||||||
prepareManualRelogin();
|
prepareManualRelogin();
|
||||||
|
|||||||
@@ -148,6 +148,7 @@
|
|||||||
useUserStore
|
useUserStore
|
||||||
} from '@/store/index.js';
|
} from '@/store/index.js';
|
||||||
import { consumePendingPaymentRefresh, PAYMENT_REFRESH_TARGETS } from '@/utils/payment.js';
|
import { consumePendingPaymentRefresh, PAYMENT_REFRESH_TARGETS } from '@/utils/payment.js';
|
||||||
|
import { getPhoneBindStatus, setPhoneBindStatus } from '@/utils/phone-bind.js';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
@@ -258,6 +259,7 @@
|
|||||||
const loadAssetInfo = async () => {
|
const loadAssetInfo = async () => {
|
||||||
const identifier = userStore.state.identifier;
|
const identifier = userStore.state.identifier;
|
||||||
if (!identifier) return;
|
if (!identifier) return;
|
||||||
|
const localBindStatus = getPhoneBindStatus(identifier);
|
||||||
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
@@ -270,7 +272,9 @@
|
|||||||
deviceInfo.status = data.status;
|
deviceInfo.status = data.status;
|
||||||
deviceInfo.imei = data.imei || '-';
|
deviceInfo.imei = data.imei || '-';
|
||||||
deviceInfo.asset_type = data.asset_type || 'device';
|
deviceInfo.asset_type = data.asset_type || 'device';
|
||||||
deviceInfo.bound_phone = data.bound_phone || '';
|
const apiBoundPhone = data.bound_phone || '';
|
||||||
|
const effectiveBoundPhone = apiBoundPhone || localBindStatus?.phone || '';
|
||||||
|
deviceInfo.bound_phone = effectiveBoundPhone;
|
||||||
deviceInfo.packageName = data.current_package || '-';
|
deviceInfo.packageName = data.current_package || '-';
|
||||||
deviceInfo.currentPackageId = Number(data.current_package_id || 0);
|
deviceInfo.currentPackageId = Number(data.current_package_id || 0);
|
||||||
deviceInfo.renewalPrice = data.renewal_price ?? null;
|
deviceInfo.renewalPrice = data.renewal_price ?? null;
|
||||||
@@ -285,8 +289,11 @@
|
|||||||
realNameStatus.value = isRealName.value ? '已实名' : '未实名';
|
realNameStatus.value = isRealName.value ? '已实名' : '未实名';
|
||||||
effectiveRealnamePolicy.value = data.effective_realname_policy || 'none';
|
effectiveRealnamePolicy.value = data.effective_realname_policy || 'none';
|
||||||
userStore.setRealNameStatus(data.real_name_status);
|
userStore.setRealNameStatus(data.real_name_status);
|
||||||
boundPhone.value = data.bound_phone || '';
|
boundPhone.value = effectiveBoundPhone;
|
||||||
alreadyBindPhone.value = !!data.bound_phone;
|
alreadyBindPhone.value = !!(apiBoundPhone || localBindStatus?.bound);
|
||||||
|
if (apiBoundPhone) {
|
||||||
|
setPhoneBindStatus(identifier, apiBoundPhone);
|
||||||
|
}
|
||||||
|
|
||||||
// 流量信息已由 TrafficCard 组件独立获取,这里不再处理
|
// 流量信息已由 TrafficCard 组件独立获取,这里不再处理
|
||||||
|
|
||||||
|
|||||||
25
utils/phone-bind.js
Normal file
25
utils/phone-bind.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
const PHONE_BIND_STATUS_KEY = 'phoneBindStatus';
|
||||||
|
|
||||||
|
const readStatuses = () => {
|
||||||
|
const statuses = uni.getStorageSync(PHONE_BIND_STATUS_KEY);
|
||||||
|
return statuses && typeof statuses === 'object' && !Array.isArray(statuses) ? statuses : {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getPhoneBindStatus = (identifier) => {
|
||||||
|
if (!identifier) return null;
|
||||||
|
|
||||||
|
const status = readStatuses()[identifier];
|
||||||
|
return status && status.bound ? status : null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const setPhoneBindStatus = (identifier, phone) => {
|
||||||
|
if (!identifier) return;
|
||||||
|
|
||||||
|
const statuses = readStatuses();
|
||||||
|
statuses[identifier] = {
|
||||||
|
bound: true,
|
||||||
|
phone: phone || '',
|
||||||
|
updatedAt: Date.now()
|
||||||
|
};
|
||||||
|
uni.setStorageSync(PHONE_BIND_STATUS_KEY, statuses);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user