feat:多支付以及货币符号显示
This commit is contained in:
@@ -8,6 +8,7 @@ import { useRouterPush } from '@/hooks/common/router';
|
||||
import type { Ref } from 'vue';
|
||||
import OrderConfirmModal from '@/components/order-confirm/orderConfirmModal.vue';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { getPaymentConfig } from '@/service/api/payment';
|
||||
|
||||
defineOptions({
|
||||
name: 'BalanceRecharge'
|
||||
@@ -16,7 +17,18 @@ defineOptions({
|
||||
const { t } = useI18n();
|
||||
const { routerPushByKey } = useRouterPush();
|
||||
const appStore = useAppStore();
|
||||
const currencySymbol = ref('¥');
|
||||
|
||||
const fetchCurrencySymbol = async () => {
|
||||
try {
|
||||
const response = await getPaymentConfig();
|
||||
if (response && response.data) {
|
||||
currencySymbol.value = response.data.currencySymbol || '¥';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch currency symbol:', error);
|
||||
}
|
||||
};
|
||||
interface RechargeOption {
|
||||
amount: number;
|
||||
displayAmount: string;
|
||||
@@ -27,13 +39,13 @@ const customAmount = ref<string | number | undefined>(undefined);
|
||||
const selectedAmount = ref<number | null>(null);
|
||||
const isCustomMode = ref<boolean>(false);
|
||||
|
||||
const rechargeOptions: Ref<RechargeOption[]> = ref([
|
||||
{ amount: 10, displayAmount: `${t('page.carddata.money')}10`, price: 10.00 },
|
||||
{ amount: 20, displayAmount: `${t('page.carddata.money')}20`, price: 20.00 },
|
||||
{ amount: 30, displayAmount: `${t('page.carddata.money')}30`, price: 30.00 },
|
||||
{ amount: 50, displayAmount: `${t('page.carddata.money')}50`, price: 50.00 },
|
||||
{ amount: 100, displayAmount: `${t('page.carddata.money')}100`, price: 100.00 },
|
||||
{ amount: 200, displayAmount: `${t('page.carddata.money')}200`, price: 200.00 },
|
||||
const rechargeOptions = computed(() => [
|
||||
{ amount: 10, displayAmount: `${currencySymbol.value}10`, price: 10.00 },
|
||||
{ amount: 20, displayAmount: `${currencySymbol.value}20`, price: 20.00 },
|
||||
{ amount: 30, displayAmount: `${currencySymbol.value}30`, price: 30.00 },
|
||||
{ amount: 50, displayAmount: `${currencySymbol.value}50`, price: 50.00 },
|
||||
{ amount: 100, displayAmount: `${currencySymbol.value}100`, price: 100.00 },
|
||||
{ amount: 200, displayAmount: `${currencySymbol.value}200`, price: 200.00 },
|
||||
]);
|
||||
|
||||
const paymentAmount = computed(() => {
|
||||
@@ -76,10 +88,12 @@ const handleBlur = () => {
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
fetchCurrencySymbol();
|
||||
document.addEventListener('click', handleClickOutside);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
fetchCurrencySymbol();
|
||||
document.removeEventListener('click', handleClickOutside);
|
||||
});
|
||||
|
||||
@@ -202,7 +216,7 @@ const handlePaymentConfirm = async (paymentMethod: 'alipay' | 'wxpay') => {
|
||||
:disabled="!paymentAmount || paymentAmount <= 0"
|
||||
@click="handleRecharge"
|
||||
>
|
||||
<span style="color: var(--text-color, var(--ant-text-color))"> ¥{{ paymentAmount.toFixed(2) }} {{ t('page.carddata.pay') }} </span>
|
||||
<span style="color: var(--text-color, var(--ant-text-color))"> {{ currencySymbol }}{{ paymentAmount.toFixed(2) }} {{ t('page.carddata.pay') }} </span>
|
||||
</AButton>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -8,10 +8,23 @@ import { aliPayPcPay,aliPayWapPay, wxPayScanCode, payBalance } from '@/service/a
|
||||
import { useRouterPush } from '@/hooks/common/router';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useAuthStore} from '@/store/modules/auth';
|
||||
import { getPaymentConfig } from '@/service/api/payment';
|
||||
|
||||
defineOptions({
|
||||
name: 'PackageSubscription'
|
||||
});
|
||||
const currencySymbol = ref('¥');
|
||||
|
||||
const fetchCurrencySymbol = async () => {
|
||||
try {
|
||||
const response = await getPaymentConfig();
|
||||
if (response && response.data) {
|
||||
currencySymbol.value = response.data.currencySymbol || '¥';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch currency symbol:', error);
|
||||
}
|
||||
};
|
||||
const { t } = useI18n();
|
||||
const authStore = useAuthStore();
|
||||
interface RateLimit {
|
||||
@@ -343,6 +356,7 @@ const isPackageActive = computed(() => {
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchCurrencySymbol();
|
||||
fetchDashboardData();
|
||||
await fetchPackages();
|
||||
await fetchUserBalance();
|
||||
@@ -354,7 +368,7 @@ onMounted(async () => {
|
||||
<!-- 顶部价格展示 -->
|
||||
<div class="price-header">
|
||||
<div class="price">
|
||||
<span class="currency">¥</span>
|
||||
<span class="currency">{{ currencySymbol }}</span>
|
||||
<span class="amount">{{ selectedPackage.price }}</span>
|
||||
</div>
|
||||
<div class="subtitle">{{ selectedPackage.packageName }}</div>
|
||||
@@ -380,7 +394,7 @@ onMounted(async () => {
|
||||
{{ t('page.setmeal.highlyrecommended') }}
|
||||
</div>
|
||||
<div class="package-name">{{ option.packageName }}</div>
|
||||
<div class="price">¥{{ option.price }}</div>
|
||||
<div class="price">{{ currencySymbol }}{{ option.price }}</div>
|
||||
<div class="traffic">{{ option.trafficEnable ? option.trafficDisplay : t('page.setmeal.unlimit') }}</div>
|
||||
<div class="device-count">
|
||||
{{ option.clientNumEnable ? `${option.clientNum} ${t('page.setmeal.device')}` : t('page.setmeal.unlimit') }}
|
||||
|
||||
Reference in New Issue
Block a user