feat: C 端套餐沉默期展示与自助延期
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 23m46s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 23m46s
- 套餐历史展示沉默期状态、截止日期、累计延期与调整审批中,可延期时显示延期入口 - 新增延期页:资格、档位与自定义天数试算、支付方式、下单(request_id 幂等) - 支付宝走现有支付页;微信为链接时在微信外直接跳转,否则展示二维码与复制链接 - 新增我的延期订单列表与详情、沉默期记录,沉默期错误码转客户提示
This commit is contained in:
132
pages/silence-orders/detail.vue
Normal file
132
pages/silence-orders/detail.vue
Normal file
@@ -0,0 +1,132 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view v-if="loading && !order" class="loading-state">
|
||||
<up-loading-icon text="加载中" size="30"></up-loading-icon>
|
||||
</view>
|
||||
<view v-else-if="!order" class="card empty-card">未找到延期订单</view>
|
||||
<template v-else>
|
||||
<view class="card">
|
||||
<view class="detail-header flex-row-sb">
|
||||
<view class="detail-title">{{ order.package_name || '套餐沉默期延期' }}</view>
|
||||
<view class="detail-status">{{ order.status_name || order.status }}</view>
|
||||
</view>
|
||||
<view v-for="row in rows" :key="row.label" class="detail-row flex-row-sb">
|
||||
<text class="label">{{ row.label }}</text>
|
||||
<text class="value" :class="row.className">{{ row.value }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="canContinuePay" class="btn-apple btn-primary pay-btn" @tap="continuePay">继续支付</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { packageSilenceApi } from '@/api/index.js';
|
||||
import { formatDateTime, formatMoney } from '@/utils/display.js';
|
||||
import { consumePendingPaymentRefresh } from '@/utils/payment.js';
|
||||
import { formatSilenceDate, getSilenceErrorMessage, SILENCE_PAYMENT_LABELS } from '@/utils/silence.js';
|
||||
import { openSilencePayment, SILENCE_REFRESH_TARGET } from '@/utils/silence-payment.js';
|
||||
|
||||
const orderId = ref(0);
|
||||
const order = ref(null);
|
||||
const loading = ref(false);
|
||||
|
||||
const rows = computed(() => {
|
||||
const item = order.value || {};
|
||||
return [
|
||||
{ label: '订单号', value: item.order_no || '-' },
|
||||
{ label: '输入天数', value: item.input_days ? `${item.input_days} 天` : '-' },
|
||||
{ label: '计费 / 延长天数', value: item.extension_days ? `${item.extension_days} 天` : '-' },
|
||||
{ label: '金额', value: `¥${formatMoney(item.amount)}`, className: 'amount' },
|
||||
{ label: '支付方式', value: SILENCE_PAYMENT_LABELS[item.payment_method] || item.payment_method || '-' },
|
||||
{ label: '原截止日期', value: formatSilenceDate(item.before_deadline_at) },
|
||||
{ label: '延期后截止日期', value: formatSilenceDate(item.expected_deadline_at) },
|
||||
{ label: '支付时间', value: formatDateTime(item.paid_at) },
|
||||
{ label: '延期生效时间', value: formatDateTime(item.completed_at) },
|
||||
{ label: '下单时间', value: formatDateTime(item.created_at) }
|
||||
];
|
||||
});
|
||||
|
||||
const canContinuePay = computed(() => order.value?.status === 'pending_payment' && !!order.value?.qr_content);
|
||||
|
||||
const load = async () => {
|
||||
if (!orderId.value) return;
|
||||
loading.value = true;
|
||||
try {
|
||||
order.value = await packageSilenceApi.getOrder(orderId.value);
|
||||
} catch (error) {
|
||||
uni.showToast({ title: getSilenceErrorMessage(error, '加载订单失败'), icon: 'none' });
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const continuePay = async () => {
|
||||
try {
|
||||
await openSilencePayment(order.value, SILENCE_REFRESH_TARGET.ORDER_DETAIL);
|
||||
} catch (error) {
|
||||
uni.showToast({ title: error?.message || '拉起支付失败', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
onLoad((query) => {
|
||||
orderId.value = Number(query?.id) || 0;
|
||||
});
|
||||
|
||||
onShow(async () => {
|
||||
const fromPayment = consumePendingPaymentRefresh(SILENCE_REFRESH_TARGET.ORDER_DETAIL);
|
||||
await load();
|
||||
if (fromPayment && order.value?.status === 'completed') {
|
||||
uni.showToast({ title: '延期成功', icon: 'success' });
|
||||
uni.setStorageSync('silence_extension_completed', Date.now());
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.loading-state {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 200rpx 0;
|
||||
}
|
||||
|
||||
.empty-card {
|
||||
margin-top: 40rpx;
|
||||
text-align: center;
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.detail-header {
|
||||
margin-bottom: var(--space-md);
|
||||
}
|
||||
|
||||
.detail-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.detail-status {
|
||||
font-size: 26rpx;
|
||||
color: var(--primary-dark);
|
||||
}
|
||||
|
||||
.detail-row {
|
||||
padding: 10rpx 0;
|
||||
font-size: 26rpx;
|
||||
|
||||
.label {
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.amount {
|
||||
color: var(--danger);
|
||||
}
|
||||
}
|
||||
|
||||
.pay-btn {
|
||||
margin-top: 32rpx;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user