Compare commits
6 Commits
427b211295
...
368c0d75e7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
368c0d75e7 | ||
|
|
a0b2f69a8e | ||
|
|
b566b0a5ea | ||
|
|
4d9aa59254 | ||
|
|
1edd299f1b | ||
|
|
f9fead83cf |
47
main.js
47
main.js
@@ -1,11 +1,55 @@
|
|||||||
import App from './App'
|
import App from './App'
|
||||||
import uviewPlus from 'uview-plus'
|
import uviewPlus from 'uview-plus'
|
||||||
|
|
||||||
|
const TAB_BAR_STYLE_NOT_FOUND_ERROR = 'setTabBarStyle:fail not TabBar page'
|
||||||
|
|
||||||
|
const shouldIgnoreTabBarStyleError = (error) => {
|
||||||
|
const message = typeof error === 'string'
|
||||||
|
? error
|
||||||
|
: error?.errMsg || error?.message || ''
|
||||||
|
return message.includes(TAB_BAR_STYLE_NOT_FOUND_ERROR)
|
||||||
|
}
|
||||||
|
|
||||||
|
const patchSafeSetTabBarStyle = () => {
|
||||||
|
if (typeof uni === 'undefined' || typeof uni.setTabBarStyle !== 'function') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uni.setTabBarStyle.__upSafePatched) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const originalSetTabBarStyle = uni.setTabBarStyle.bind(uni)
|
||||||
|
const safeSetTabBarStyle = (options = {}) => {
|
||||||
|
try {
|
||||||
|
const result = originalSetTabBarStyle(options)
|
||||||
|
if (result && typeof result.catch === 'function') {
|
||||||
|
return result.catch((error) => {
|
||||||
|
if (shouldIgnoreTabBarStyleError(error)) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
return Promise.reject(error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
} catch (error) {
|
||||||
|
if (shouldIgnoreTabBarStyleError(error)) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
safeSetTabBarStyle.__upSafePatched = true
|
||||||
|
uni.setTabBarStyle = safeSetTabBarStyle
|
||||||
|
}
|
||||||
|
|
||||||
// #ifndef VUE3
|
// #ifndef VUE3
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import './uni.promisify.adaptor'
|
import './uni.promisify.adaptor'
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
App.mpType = 'app'
|
App.mpType = 'app'
|
||||||
|
patchSafeSetTabBarStyle()
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
...App
|
...App
|
||||||
})
|
})
|
||||||
@@ -15,6 +59,7 @@ app.$mount()
|
|||||||
// #ifdef VUE3
|
// #ifdef VUE3
|
||||||
import { createSSRApp } from 'vue'
|
import { createSSRApp } from 'vue'
|
||||||
export function createApp() {
|
export function createApp() {
|
||||||
|
patchSafeSetTabBarStyle()
|
||||||
const app = createSSRApp(App)
|
const app = createSSRApp(App)
|
||||||
// 使用 uview-plus (版本 3.4.0+)
|
// 使用 uview-plus (版本 3.4.0+)
|
||||||
app.use(uviewPlus, () => {
|
app.use(uviewPlus, () => {
|
||||||
@@ -34,4 +79,4 @@ export function createApp() {
|
|||||||
app
|
app
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
|
|||||||
@@ -216,6 +216,12 @@
|
|||||||
return dateStr.split('T')[0] || '-';
|
return dateStr.split('T')[0] || '-';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const resolveCurrentCard = (cards = []) => {
|
||||||
|
if (cards.length === 1) return cards[0];
|
||||||
|
if (cards.length > 1) return cards.find(card => card.is_current) || null;
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
const loadAssetInfo = async () => {
|
const loadAssetInfo = async () => {
|
||||||
const identifier = userStore.state.identifier;
|
const identifier = userStore.state.identifier;
|
||||||
if (!identifier) return;
|
if (!identifier) return;
|
||||||
@@ -236,18 +242,18 @@
|
|||||||
deviceInfo.expireDate = formatDate(data.current_package_expires_at);
|
deviceInfo.expireDate = formatDate(data.current_package_expires_at);
|
||||||
deviceInfo.iccid = data.iccid || '-';
|
deviceInfo.iccid = data.iccid || '-';
|
||||||
deviceInfo.walletBalance = data.wallet_balance ?? 0;
|
deviceInfo.walletBalance = data.wallet_balance ?? 0;
|
||||||
isRealName.value = data.real_name_status === 1;
|
const currentCard = resolveCurrentCard(data.cards || []);
|
||||||
realNameStatus.value = data.real_name_status === 1 ? '已实名' : '未实名';
|
const realNameStatusCode = currentCard?.real_name_status ?? data.real_name_status;
|
||||||
|
isRealName.value = realNameStatusCode === 1;
|
||||||
|
realNameStatus.value = realNameStatusCode === 1 ? '已实名' : '未实名';
|
||||||
boundPhone.value = data.bound_phone || '';
|
boundPhone.value = data.bound_phone || '';
|
||||||
alreadyBindPhone.value = !!data.bound_phone;
|
alreadyBindPhone.value = !!data.bound_phone;
|
||||||
|
|
||||||
// 流量信息已由 TrafficCard 组件独立获取,这里不再处理
|
// 流量信息已由 TrafficCard 组件独立获取,这里不再处理
|
||||||
|
|
||||||
// 当前卡信息
|
// 当前卡信息
|
||||||
let currentCard = null;
|
|
||||||
if (data.cards && data.cards.length > 0) {
|
if (data.cards && data.cards.length > 0) {
|
||||||
currentCard = data.cards.find(card => card.is_current) || '';
|
deviceInfo.currentIccid = currentCard?.iccid || '-';
|
||||||
deviceInfo.currentIccid = currentCard.iccid || '-';
|
|
||||||
|
|
||||||
// 卡列表
|
// 卡列表
|
||||||
deviceInfo.mchList = data.cards.map(card => ({
|
deviceInfo.mchList = data.cards.map(card => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user