From aa642c3628cc6be32e72fb7e2a003ab885dfe8e8 Mon Sep 17 00:00:00 2001 From: qian Date: Sat, 6 Jun 2026 22:19:37 +0800 Subject: [PATCH] =?UTF-8?q?refactor(wallet):=E7=A7=BB=E9=99=A4=E5=A5=97?= =?UTF-8?q?=E9=A4=90=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=AD=A4=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=9C=89=E9=97=AE=E9=A2=98=EF=BC=8C=E6=9A=82=E4=B8=8D=E5=90=AF?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/tenant/src/views/finance/WalletPage.vue | 664 +++++--------------- 1 file changed, 146 insertions(+), 518 deletions(-) diff --git a/web/tenant/src/views/finance/WalletPage.vue b/web/tenant/src/views/finance/WalletPage.vue index c988dc7..4f131aa 100644 --- a/web/tenant/src/views/finance/WalletPage.vue +++ b/web/tenant/src/views/finance/WalletPage.vue @@ -5,7 +5,6 @@ import Icon from '@/components/common/Icon.vue' import request from '@/utils/request' const route = useRoute() -const loading = ref(false) const wallet = ref(null) // Recharge @@ -19,14 +18,6 @@ const paymentInfo = ref(null) // Pay result notification const payResult = ref<'success' | 'fail' | ''>('') -// Plans -const plans = ref([]) -const currentPlan = ref(null) -const showConfirm = ref(false) -const selectedPlan = ref(null) -const selectedMonths = ref(1) -const confirmLoading = ref(false) - // Frozen items const showFrozenModal = ref(false) const frozenItems = ref([]) @@ -43,15 +34,6 @@ const redeemHistoryLoading = ref(false) const redeemTypeLabels: Record = { quota: '额度', plan: '套餐', duration: '时长' } const redeemTypeBadgeClasses: Record = { quota: 'badge-success', plan: 'badge-primary', duration: 'badge-warning' } -const monthsOptions = [ - { label: '1 个月', value: 1 }, - { label: '3 个月', value: 3 }, - { label: '6 个月', value: 6 }, - { label: '12 个月(优惠)', value: 12 }, -] - -const currentPlanId = computed(() => currentPlan.value?.plan_id) - // Computed: preset amounts from payment settings const presetAmounts = computed(() => { if (paymentInfo.value?.amount_options?.length) { @@ -79,12 +61,6 @@ const payMethods = computed(() => { return methods }) -// Current plan details (matched from plans list) -const currentPlanDetail = computed(() => { - if (!currentPlan.value || !plans.value.length) return null - return plans.value.find((p: any) => p.id === currentPlan.value.plan_id) || null -}) - // Balance warning const isLowBalance = computed(() => { if (!wallet.value) return false @@ -109,23 +85,6 @@ async function fetchPaymentInfo() { } } -async function fetchPlans() { - loading.value = true - try { - const [plansRes, currentRes] = await Promise.all([ - request.get('/tenant/plans'), - request.get('/tenant/plan/current').catch(() => ({ data: { data: null } })), - ]) - const raw = plansRes.data?.data - plans.value = Array.isArray(raw) ? raw : (raw?.data || raw?.list || []) - currentPlan.value = currentRes.data?.data || null - } catch { - // interceptor handles error toast - } finally { - loading.value = false - } -} - function selectPresetAmount(amount: number) { rechargeAmount.value = amount customAmount.value = '' @@ -164,42 +123,6 @@ async function handleRecharge() { } } -function calcPrice(plan: any, months: number) { - if (months >= 12) return Number(plan.yearly_price || 0) - return Number(plan.monthly_price || 0) * months -} - -function openConfirm(plan: any) { - selectedPlan.value = plan - selectedMonths.value = 1 - showConfirm.value = true -} - -async function handleSubscribe() { - confirmLoading.value = true - try { - const res = await request.post('/tenant/orders/create', { - order_type: 'new_plan', - plan_id: selectedPlan.value.id, - months: selectedMonths.value, - }) - const order = res.data?.data - if (order?.id) { - await request.post(`/tenant/orders/${order.id}/pay`) - } - showConfirm.value = false - await fetchPlans() - } catch { - // interceptor handles error toast - } finally { - confirmLoading.value = false - } -} - -function isCurrentPlan(plan: any) { - return currentPlan.value && currentPlan.value.plan_id === plan.id -} - // Frozen items async function fetchFrozenItems() { frozenLoading.value = true @@ -284,7 +207,6 @@ function formatRemaining(seconds: number): string { onMounted(() => { fetchWallet() - fetchPlans() fetchPaymentInfo() // Handle pay result from return URL @@ -306,12 +228,12 @@ onBeforeUnmount(() => {