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:
@@ -1,5 +1,8 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="history-toolbar">
|
||||
<text class="silence-orders-link" role="button" tabindex="0" @tap="openSilenceOrders">我的延期订单</text>
|
||||
</view>
|
||||
<view v-if="!historyLoaded || (loading && packageList.length === 0)" class="loading-state">
|
||||
<up-loading-icon text="加载中" size="30"></up-loading-icon>
|
||||
</view>
|
||||
@@ -27,6 +30,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
import { assetApi } from '@/api/index.js';
|
||||
import PackageHistoryNode from '@/components/PackageHistoryNode.vue';
|
||||
import { useUserStore } from '@/store/index.js';
|
||||
@@ -86,12 +90,39 @@
|
||||
|
||||
const loadMore = () => loadPackageList(true);
|
||||
|
||||
const SILENCE_COMPLETED_KEY = 'silence_extension_completed';
|
||||
const openSilenceOrders = () => {
|
||||
uni.navigateTo({ url: '/pages/silence-orders/silence-orders' });
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
uni.removeStorageSync(SILENCE_COMPLETED_KEY);
|
||||
loadPackageList();
|
||||
});
|
||||
|
||||
// 延期成功后返回本页:重新加载第一页,展示新的沉默期截止日期
|
||||
onShow(() => {
|
||||
if (!uni.getStorageSync(SILENCE_COMPLETED_KEY)) return;
|
||||
uni.removeStorageSync(SILENCE_COMPLETED_KEY);
|
||||
page.value = 1;
|
||||
noMore.value = false;
|
||||
loadPackageList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.history-toolbar {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: var(--space-sm);
|
||||
}
|
||||
|
||||
.silence-orders-link {
|
||||
padding: 8rpx 0;
|
||||
font-size: 26rpx;
|
||||
color: var(--primary-dark);
|
||||
}
|
||||
|
||||
.loading-state {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
485
pages/silence-extension/silence-extension.vue
Normal file
485
pages/silence-extension/silence-extension.vue
Normal file
@@ -0,0 +1,485 @@
|
||||
<template>
|
||||
<view class="container silence-page">
|
||||
<view v-if="loading" class="loading-state">
|
||||
<up-loading-icon text="加载中" size="30"></up-loading-icon>
|
||||
</view>
|
||||
|
||||
<view v-else-if="blockedMessage" class="card blocked-card">
|
||||
<view class="blocked-title">{{ blockedMessage }}</view>
|
||||
<view v-if="pendingOrderNo" class="blocked-desc">未完成订单:{{ pendingOrderNo }}</view>
|
||||
<view class="blocked-actions">
|
||||
<view v-if="pendingOrderNo" class="btn-apple btn-primary" @tap="openOrders">查看我的延期订单</view>
|
||||
<view class="btn-apple btn-secondary" @tap="goBack">返回</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<template v-else-if="eligibility">
|
||||
<view class="card">
|
||||
<view class="section-title">当前沉默期</view>
|
||||
<view class="info-row flex-row-sb">
|
||||
<view class="info-label">当前截止日期</view>
|
||||
<view class="info-value">{{ eligibility.original_deadline || '-' }}</view>
|
||||
</view>
|
||||
<view v-if="eligibility.overdue_days > 0" class="info-row flex-row-sb">
|
||||
<view class="info-label">已过期</view>
|
||||
<view class="info-value danger">{{ eligibility.overdue_days }} 天</view>
|
||||
</view>
|
||||
<view class="info-row flex-row-sb">
|
||||
<view class="info-label">可延期天数</view>
|
||||
<view class="info-value">{{ eligibility.min_days }}~{{ eligibility.max_days }} 天</view>
|
||||
</view>
|
||||
<view v-if="eligibility.extended_days > 0" class="info-row flex-row-sb">
|
||||
<view class="info-label">已累计延期</view>
|
||||
<view class="info-value">{{ eligibility.extended_days }} 天</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="section-title">选择延期天数</view>
|
||||
<view class="option-list">
|
||||
<view
|
||||
v-for="option in options"
|
||||
:key="option.billed_days"
|
||||
class="option-item"
|
||||
:class="{ active: !customMode && selectedDays === option.billed_days }"
|
||||
@tap="selectOption(option)"
|
||||
>
|
||||
<view class="option-days">{{ option.billed_days }} 天</view>
|
||||
<view class="option-amount">¥{{ formatMoney(option.amount) }}</view>
|
||||
<view class="option-deadline">延至 {{ option.new_deadline }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="custom-row" :class="{ active: customMode }">
|
||||
<view class="custom-label" @tap="enableCustom">自定义天数</view>
|
||||
<input
|
||||
class="custom-input"
|
||||
type="number"
|
||||
:value="customDays"
|
||||
:placeholder="`${eligibility.min_days}~${eligibility.max_days}`"
|
||||
@focus="enableCustom"
|
||||
@input="onCustomInput"
|
||||
/>
|
||||
<text class="custom-unit">天</text>
|
||||
</view>
|
||||
<view v-if="customError" class="custom-error">{{ customError }}</view>
|
||||
<view v-else-if="customMode && quoting" class="custom-hint">试算中...</view>
|
||||
</view>
|
||||
|
||||
<view v-if="summary" class="card summary-card">
|
||||
<view class="info-row flex-row-sb">
|
||||
<view class="info-label">计费天数</view>
|
||||
<view class="info-value">{{ summary.billed_days }} 天</view>
|
||||
</view>
|
||||
<view class="info-row flex-row-sb">
|
||||
<view class="info-label">新截止日期</view>
|
||||
<view class="info-value">{{ summary.new_deadline }}</view>
|
||||
</view>
|
||||
<view class="info-row flex-row-sb">
|
||||
<view class="info-label">应付金额</view>
|
||||
<view class="info-value amount">¥{{ formatMoney(summary.amount) }}</view>
|
||||
</view>
|
||||
<view class="summary-tip">按每月 30 天计费,不足 30 天按 30 天计。</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="section-title">支付方式</view>
|
||||
<view v-if="paymentOptions.length === 0" class="empty-desc">当前资产暂不支持在线延期,请联系客服办理</view>
|
||||
<view
|
||||
v-for="method in paymentOptions"
|
||||
:key="method.value"
|
||||
class="payment-item flex-row-sb"
|
||||
:class="{ active: paymentMethod === method.value }"
|
||||
@tap="paymentMethod = method.value"
|
||||
>
|
||||
<text>{{ method.label }}</text>
|
||||
<text class="payment-check">{{ paymentMethod === method.value ? '✓' : '' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="footer-actions">
|
||||
<view class="orders-link" @tap="openOrders">我的延期订单</view>
|
||||
<view
|
||||
class="btn-apple btn-primary submit-btn"
|
||||
:class="{ disabled: !canSubmit }"
|
||||
@tap="submit"
|
||||
>{{ submitting ? '提交中...' : '确认支付' }}</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { assetApi, packageSilenceApi } from '@/api/index.js';
|
||||
import { useUserStore } from '@/store/index.js';
|
||||
import { formatMoney } from '@/utils/display.js';
|
||||
import { consumePendingPaymentRefresh } from '@/utils/payment.js';
|
||||
import {
|
||||
createRequestIdKeeper,
|
||||
getSilenceErrorMessage,
|
||||
getSilencePaymentOptions,
|
||||
getSilenceReasonText,
|
||||
validateExtensionDays
|
||||
} from '@/utils/silence.js';
|
||||
import { openSilencePayment, SILENCE_REFRESH_TARGET } from '@/utils/silence-payment.js';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const packageUsageId = ref(0);
|
||||
const loading = ref(true);
|
||||
const eligibility = ref(null);
|
||||
const blockedMessage = ref('');
|
||||
const pendingOrderNo = ref('');
|
||||
const paymentOptions = ref([]);
|
||||
const paymentMethod = ref('');
|
||||
const selectedDays = ref(0);
|
||||
const customMode = ref(false);
|
||||
const customDays = ref('');
|
||||
const customError = ref('');
|
||||
const quoting = ref(false);
|
||||
const quoteResult = ref(null);
|
||||
const submitting = ref(false);
|
||||
const lastOrderId = ref(0);
|
||||
const requestIds = createRequestIdKeeper();
|
||||
let quoteTimer = null;
|
||||
let quoteSeq = 0;
|
||||
|
||||
const options = computed(() => (Array.isArray(eligibility.value?.options) ? eligibility.value.options : []));
|
||||
const chosenDays = computed(() => (customMode.value ? Number(customDays.value) : selectedDays.value));
|
||||
const summary = computed(() => {
|
||||
if (customMode.value) return customError.value ? null : quoteResult.value;
|
||||
return options.value.find((option) => option.billed_days === selectedDays.value) || null;
|
||||
});
|
||||
const canSubmit = computed(() => (
|
||||
!submitting.value && !!summary.value && !!paymentMethod.value && !(customMode.value && quoting.value)
|
||||
));
|
||||
|
||||
const showToast = (title) => uni.showToast({ title, icon: 'none', duration: 2500 });
|
||||
|
||||
const loadEligibility = async () => {
|
||||
loading.value = true;
|
||||
blockedMessage.value = '';
|
||||
pendingOrderNo.value = '';
|
||||
try {
|
||||
const [data, info] = await Promise.all([
|
||||
packageSilenceApi.getEligibility(packageUsageId.value),
|
||||
assetApi.getInfo(userStore.state.identifier).catch(() => null)
|
||||
]);
|
||||
eligibility.value = data;
|
||||
paymentOptions.value = getSilencePaymentOptions(info?.allowed_payment_methods);
|
||||
if (!paymentOptions.value.some((option) => option.value === paymentMethod.value)) {
|
||||
paymentMethod.value = paymentOptions.value[0]?.value || '';
|
||||
}
|
||||
if (data?.pending_order_no) {
|
||||
pendingOrderNo.value = data.pending_order_no;
|
||||
blockedMessage.value = '已有未完成的延期订单,暂不能新建';
|
||||
} else if (!data?.can_extend) {
|
||||
blockedMessage.value = getSilenceReasonText(data?.reason);
|
||||
} else if (!selectedDays.value) {
|
||||
selectedDays.value = options.value[0]?.billed_days || 0;
|
||||
if (!selectedDays.value) customMode.value = true;
|
||||
}
|
||||
} catch (error) {
|
||||
blockedMessage.value = getSilenceErrorMessage(error, '查询延期资格失败,请稍后重试');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const selectOption = (option) => {
|
||||
customMode.value = false;
|
||||
customError.value = '';
|
||||
selectedDays.value = option.billed_days;
|
||||
};
|
||||
|
||||
const enableCustom = () => {
|
||||
customMode.value = true;
|
||||
};
|
||||
|
||||
const runQuote = async (days) => {
|
||||
const seq = ++quoteSeq;
|
||||
quoting.value = true;
|
||||
try {
|
||||
const data = await packageSilenceApi.quote(packageUsageId.value, days);
|
||||
if (seq !== quoteSeq) return;
|
||||
quoteResult.value = data;
|
||||
} catch (error) {
|
||||
if (seq !== quoteSeq) return;
|
||||
quoteResult.value = null;
|
||||
customError.value = getSilenceErrorMessage(error, '试算失败,请稍后重试');
|
||||
} finally {
|
||||
if (seq === quoteSeq) quoting.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const onCustomInput = (event) => {
|
||||
customMode.value = true;
|
||||
customDays.value = String(event?.detail?.value ?? '').trim();
|
||||
quoteResult.value = null;
|
||||
clearTimeout(quoteTimer);
|
||||
quoteSeq += 1;
|
||||
quoting.value = false;
|
||||
customError.value = customDays.value
|
||||
? validateExtensionDays(customDays.value, eligibility.value?.min_days, eligibility.value?.max_days)
|
||||
: '';
|
||||
if (!customDays.value || customError.value) return;
|
||||
const days = Number(customDays.value);
|
||||
quoteTimer = setTimeout(() => runQuote(days), 500);
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
if (!canSubmit.value) {
|
||||
if (!paymentMethod.value) showToast('请选择支付方式');
|
||||
else if (!summary.value) showToast('请选择延期天数');
|
||||
return;
|
||||
}
|
||||
const days = chosenDays.value;
|
||||
const message = validateExtensionDays(days, eligibility.value?.min_days, eligibility.value?.max_days);
|
||||
if (message) {
|
||||
showToast(message);
|
||||
return;
|
||||
}
|
||||
submitting.value = true;
|
||||
try {
|
||||
const order = await packageSilenceApi.createOrder({
|
||||
package_usage_id: packageUsageId.value,
|
||||
days,
|
||||
payment_method: paymentMethod.value,
|
||||
request_id: requestIds.get(days, paymentMethod.value)
|
||||
});
|
||||
lastOrderId.value = order?.id || 0;
|
||||
if (!order?.qr_content) {
|
||||
showToast('订单已创建,请在"我的延期订单"中继续支付');
|
||||
openOrders();
|
||||
return;
|
||||
}
|
||||
await openSilencePayment(order, SILENCE_REFRESH_TARGET.EXTENSION);
|
||||
} catch (error) {
|
||||
// 网络异常时后端可能已建单:保留 request_id,客户再次点击会拿到同一笔订单。
|
||||
if (!error?.paymentResultUnknown) requestIds.reset();
|
||||
showToast(getSilenceErrorMessage(error, '下单失败,请稍后重试'));
|
||||
if (Number(error?.code) === 1271) await loadEligibility();
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const checkLastOrder = async () => {
|
||||
if (!lastOrderId.value) return;
|
||||
try {
|
||||
const order = await packageSilenceApi.getOrder(lastOrderId.value);
|
||||
if (order?.status === 'completed') {
|
||||
uni.showToast({ title: '延期成功', icon: 'success' });
|
||||
requestIds.reset();
|
||||
uni.setStorageSync('silence_extension_completed', Date.now());
|
||||
setTimeout(() => uni.navigateBack(), 1200);
|
||||
return;
|
||||
}
|
||||
if (order?.status === 'paid') {
|
||||
showToast('支付成功,延期处理中');
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({ url: `/pages/silence-orders/detail?id=${lastOrderId.value}` });
|
||||
} catch (error) {
|
||||
showToast(getSilenceErrorMessage(error, '查询订单失败'));
|
||||
}
|
||||
};
|
||||
|
||||
const openOrders = () => {
|
||||
uni.navigateTo({ url: '/pages/silence-orders/silence-orders' });
|
||||
};
|
||||
|
||||
const goBack = () => uni.navigateBack();
|
||||
|
||||
onLoad((query) => {
|
||||
packageUsageId.value = Number(query?.package_usage_id) || 0;
|
||||
if (!packageUsageId.value) {
|
||||
loading.value = false;
|
||||
blockedMessage.value = '缺少套餐信息,请从套餐历史进入';
|
||||
return;
|
||||
}
|
||||
loadEligibility();
|
||||
});
|
||||
|
||||
onShow(() => {
|
||||
if (consumePendingPaymentRefresh(SILENCE_REFRESH_TARGET.EXTENSION)) checkLastOrder();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.silence-page {
|
||||
padding-bottom: 180rpx;
|
||||
}
|
||||
|
||||
.loading-state {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 200rpx 0;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
margin-bottom: var(--space-md);
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.info-row {
|
||||
padding: 10rpx 0;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.info-value {
|
||||
color: var(--text-primary);
|
||||
|
||||
&.danger {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
&.amount {
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
color: var(--danger);
|
||||
}
|
||||
}
|
||||
|
||||
.option-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.option-item {
|
||||
padding: 24rpx;
|
||||
border: 2rpx solid var(--border-color, #e5e5ea);
|
||||
border-radius: 20rpx;
|
||||
|
||||
&.active {
|
||||
border-color: var(--primary);
|
||||
background: rgba(85, 171, 92, 0.08);
|
||||
}
|
||||
}
|
||||
|
||||
.option-days {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.option-amount {
|
||||
margin-top: 8rpx;
|
||||
font-size: 28rpx;
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.option-deadline {
|
||||
margin-top: 8rpx;
|
||||
font-size: 22rpx;
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.custom-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
margin-top: 24rpx;
|
||||
padding: 20rpx 24rpx;
|
||||
border: 2rpx solid var(--border-color, #e5e5ea);
|
||||
border-radius: 20rpx;
|
||||
|
||||
&.active {
|
||||
border-color: var(--primary);
|
||||
}
|
||||
}
|
||||
|
||||
.custom-label {
|
||||
font-size: 26rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.custom-input {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.custom-error {
|
||||
margin-top: 12rpx;
|
||||
font-size: 24rpx;
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.custom-hint,
|
||||
.summary-tip,
|
||||
.empty-desc {
|
||||
margin-top: 12rpx;
|
||||
font-size: 24rpx;
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.payment-item {
|
||||
padding: 24rpx 0;
|
||||
font-size: 28rpx;
|
||||
border-bottom: 1rpx solid var(--border-color, #e5e5ea);
|
||||
|
||||
&.active {
|
||||
color: var(--primary-dark);
|
||||
}
|
||||
}
|
||||
|
||||
.payment-check {
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
.footer-actions {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 24rpx 32rpx calc(24rpx + env(safe-area-inset-bottom));
|
||||
background: var(--bg-primary);
|
||||
box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.orders-link {
|
||||
font-size: 26rpx;
|
||||
color: var(--primary-dark);
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
min-width: 280rpx;
|
||||
text-align: center;
|
||||
|
||||
&.disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
.blocked-card {
|
||||
margin-top: 40rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.blocked-title {
|
||||
font-size: 30rpx;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.blocked-desc {
|
||||
margin-top: 16rpx;
|
||||
font-size: 24rpx;
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.blocked-actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20rpx;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
</style>
|
||||
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>
|
||||
104
pages/silence-payment/silence-payment.vue
Normal file
104
pages/silence-payment/silence-payment.vue
Normal file
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<view class="container silence-pay-page">
|
||||
<view v-if="!payment" class="card empty-card">未找到待支付的延期订单,请在"我的延期订单"中查看</view>
|
||||
<template v-else>
|
||||
<view class="card">
|
||||
<view class="pay-title">微信支付</view>
|
||||
<view class="pay-amount">¥{{ formatMoney(payment.amount) }}</view>
|
||||
<view class="pay-order">订单号:{{ payment.orderNo || '-' }}</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="method-title">扫码支付</view>
|
||||
<view class="qr-wrap">
|
||||
<u-qrcode :val="payment.content" :size="220" unit="px" :show-loading="false"></u-qrcode>
|
||||
</view>
|
||||
<view class="qr-desc">长按识别二维码,或截图后用微信"扫一扫"支付</view>
|
||||
</view>
|
||||
|
||||
<view v-if="isLink" class="card">
|
||||
<view class="method-title">浏览器支付</view>
|
||||
<view class="qr-desc">复制链接后在手机浏览器中打开完成支付</view>
|
||||
<view class="btn-apple btn-secondary copy-btn" @tap="copyLink">复制支付链接</view>
|
||||
</view>
|
||||
|
||||
<view class="btn-apple btn-primary done-btn" @tap="finish">我已完成支付</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
import { formatMoney } from '@/utils/display.js';
|
||||
import { isPaymentLink } from '@/utils/silence.js';
|
||||
import { getPendingSilencePayment } from '@/utils/silence-payment.js';
|
||||
|
||||
const payment = ref(null);
|
||||
const isLink = computed(() => isPaymentLink(payment.value?.content));
|
||||
|
||||
const copyLink = () => {
|
||||
uni.setClipboardData({
|
||||
data: payment.value.content,
|
||||
success: () => uni.showToast({ title: '已复制', icon: 'success' })
|
||||
});
|
||||
};
|
||||
|
||||
// 返回上一页(延期页或订单详情),由上一页 onShow 查询订单状态
|
||||
const finish = () => uni.navigateBack();
|
||||
|
||||
onShow(() => {
|
||||
payment.value = getPendingSilencePayment();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.silence-pay-page {
|
||||
min-height: 100vh;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.pay-title,
|
||||
.method-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.pay-amount {
|
||||
margin-top: 16rpx;
|
||||
font-size: 48rpx;
|
||||
font-weight: 700;
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.pay-order {
|
||||
margin-top: 8rpx;
|
||||
font-size: 24rpx;
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.qr-wrap {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 32rpx 0;
|
||||
}
|
||||
|
||||
.qr-desc {
|
||||
font-size: 24rpx;
|
||||
color: var(--text-tertiary);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.copy-btn,
|
||||
.done-btn {
|
||||
margin-top: 24rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.empty-card {
|
||||
margin-top: 40rpx;
|
||||
text-align: center;
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
</style>
|
||||
88
pages/silence-records/silence-records.vue
Normal file
88
pages/silence-records/silence-records.vue
Normal file
@@ -0,0 +1,88 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view v-if="loading" class="loading-state">
|
||||
<up-loading-icon text="加载中" size="30"></up-loading-icon>
|
||||
</view>
|
||||
<view v-else-if="records.length === 0" class="empty-state">
|
||||
<view class="empty-title">暂无沉默期记录</view>
|
||||
</view>
|
||||
<view v-else class="timeline">
|
||||
<view v-for="record in records" :key="record.id" class="card record-card">
|
||||
<view class="record-header flex-row-sb">
|
||||
<view class="record-name">{{ record.event_name || record.event_type }}</view>
|
||||
<view class="record-time">{{ formatDateTime(record.created_at) }}</view>
|
||||
</view>
|
||||
<view v-if="record.before_deadline_at || record.after_deadline_at" class="record-row">
|
||||
截止日期:{{ formatSilenceDate(record.before_deadline_at) }} → {{ formatSilenceDate(record.after_deadline_at) }}
|
||||
</view>
|
||||
<view v-if="record.period_days" class="record-row">沉默期天数:{{ record.period_days }} 天</view>
|
||||
<view v-if="record.change_days" class="record-row">变化天数:{{ record.change_days > 0 ? "+" : "" }}{{ record.change_days }} 天</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { packageSilenceApi } from '@/api/index.js';
|
||||
import { formatDateTime } from '@/utils/display.js';
|
||||
import { formatSilenceDate } from '@/utils/silence.js';
|
||||
|
||||
const records = ref([]);
|
||||
const loading = ref(true);
|
||||
|
||||
onLoad(async (query) => {
|
||||
const packageUsageId = Number(query?.package_usage_id) || 0;
|
||||
if (!packageUsageId) {
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const data = await packageSilenceApi.getRecords(packageUsageId);
|
||||
records.value = Array.isArray(data) ? data : [];
|
||||
} catch (error) {
|
||||
console.error('加载沉默期记录失败', error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.loading-state,
|
||||
.empty-state {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 400rpx;
|
||||
}
|
||||
|
||||
.empty-title {
|
||||
font-size: 28rpx;
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.record-card {
|
||||
margin-bottom: var(--space-md);
|
||||
}
|
||||
|
||||
.record-header {
|
||||
margin-bottom: var(--space-sm);
|
||||
}
|
||||
|
||||
.record-name {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.record-time,
|
||||
.record-row {
|
||||
font-size: 24rpx;
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.record-row {
|
||||
padding: 4rpx 0;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user