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>
|
||||
170
pages/silence-orders/silence-orders.vue
Normal file
170
pages/silence-orders/silence-orders.vue
Normal file
@@ -0,0 +1,170 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view v-if="!loaded || (loading && orders.length === 0)" class="loading-state">
|
||||
<up-loading-icon text="加载中" size="30"></up-loading-icon>
|
||||
</view>
|
||||
<view v-else-if="orders.length === 0" class="empty-state">
|
||||
<view class="empty-title">暂无延期订单</view>
|
||||
<view class="empty-desc">沉默期过期后可在套餐历史中办理延期</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="order in orders"
|
||||
:key="order.id"
|
||||
class="card order-card"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@tap="openDetail(order)"
|
||||
>
|
||||
<view class="order-header flex-row-sb">
|
||||
<view class="order-name">{{ order.package_name || '套餐沉默期延期' }}</view>
|
||||
<view class="order-status" :class="`status-${order.status}`">{{ order.status_name || order.status }}</view>
|
||||
</view>
|
||||
<view class="order-row flex-row-sb">
|
||||
<text class="label">延期天数</text>
|
||||
<text>{{ order.extension_days || order.input_days }} 天</text>
|
||||
</view>
|
||||
<view class="order-row flex-row-sb">
|
||||
<text class="label">金额</text>
|
||||
<text class="amount">¥{{ formatMoney(order.amount) }}</text>
|
||||
</view>
|
||||
<view class="order-row flex-row-sb">
|
||||
<text class="label">下单时间</text>
|
||||
<text>{{ formatDateTime(order.created_at) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="load-more">
|
||||
<text v-if="loading">加载中...</text>
|
||||
<text v-else-if="noMore">没有更多订单</text>
|
||||
<text v-else role="button" tabindex="0" @tap="loadMore">点击加载更多</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
import { packageSilenceApi } from '@/api/index.js';
|
||||
import { useUserStore } from '@/store/index.js';
|
||||
import { formatDateTime, formatMoney } from '@/utils/display.js';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const orders = ref([]);
|
||||
const loading = ref(false);
|
||||
const loaded = ref(false);
|
||||
const noMore = ref(false);
|
||||
const page = ref(1);
|
||||
const pageSize = 10;
|
||||
|
||||
const load = async (append = false) => {
|
||||
if (loading.value) return;
|
||||
loading.value = true;
|
||||
try {
|
||||
const requestPage = append ? page.value : 1;
|
||||
const data = await packageSilenceApi.getOrders({
|
||||
page: requestPage,
|
||||
page_size: pageSize,
|
||||
asset_identifier: userStore.state.identifier
|
||||
});
|
||||
const items = Array.isArray(data?.items) ? data.items : [];
|
||||
orders.value = append ? [...orders.value, ...items] : items;
|
||||
const total = Number(data?.total) || 0;
|
||||
noMore.value = requestPage * pageSize >= total;
|
||||
page.value = requestPage + 1;
|
||||
} catch (error) {
|
||||
console.error('加载延期订单失败', error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
loaded.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
const loadMore = () => {
|
||||
if (!noMore.value) load(true);
|
||||
};
|
||||
|
||||
const openDetail = (order) => {
|
||||
uni.navigateTo({ url: `/pages/silence-orders/detail?id=${order.id}` });
|
||||
};
|
||||
|
||||
onShow(() => load(false));
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.loading-state,
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 400rpx;
|
||||
}
|
||||
|
||||
.empty-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.empty-desc {
|
||||
margin-top: 12rpx;
|
||||
font-size: 24rpx;
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.order-card {
|
||||
margin-bottom: var(--space-md);
|
||||
}
|
||||
|
||||
.order-header {
|
||||
margin-bottom: var(--space-sm);
|
||||
}
|
||||
|
||||
.order-name {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.order-status {
|
||||
font-size: 24rpx;
|
||||
color: var(--text-secondary);
|
||||
|
||||
&.status-completed {
|
||||
color: var(--primary-dark);
|
||||
}
|
||||
|
||||
&.status-pending_payment {
|
||||
color: #ff9f0a;
|
||||
}
|
||||
|
||||
&.status-closed,
|
||||
&.status-rejected,
|
||||
&.status-refunded {
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
&.status-exception {
|
||||
color: var(--danger);
|
||||
}
|
||||
}
|
||||
|
||||
.order-row {
|
||||
padding: 6rpx 0;
|
||||
font-size: 24rpx;
|
||||
|
||||
.label {
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.amount {
|
||||
color: var(--danger);
|
||||
}
|
||||
}
|
||||
|
||||
.load-more {
|
||||
padding: var(--space-lg);
|
||||
font-size: 24rpx;
|
||||
color: var(--text-tertiary);
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user