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:
50
utils/silence-payment.js
Normal file
50
utils/silence-payment.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import { markPendingPaymentRefresh, openAlipayPayment } from '@/utils/payment.js';
|
||||
import { isPaymentLink } from '@/utils/silence.js';
|
||||
|
||||
export const SILENCE_REFRESH_TARGET = {
|
||||
EXTENSION: 'silence-extension',
|
||||
ORDER_DETAIL: 'silence-order-detail'
|
||||
};
|
||||
|
||||
const SILENCE_PAYMENT_DATA_KEY = 'pending_silence_payment_data';
|
||||
|
||||
export const getPendingSilencePayment = () => uni.getStorageSync(SILENCE_PAYMENT_DATA_KEY) || null;
|
||||
|
||||
const isInWechat = () => typeof navigator !== 'undefined' && /micromessenger/i.test(navigator.userAgent);
|
||||
|
||||
/**
|
||||
* 用延期订单返回的 qr_content 拉起支付。
|
||||
* - 支付宝:走现有支付宝支付页(浏览器打开链接 / 截图扫码)。
|
||||
* - 微信:后端给延期订单返回的是微信 H5 支付链接或扫码内容,不是公众号支付参数。
|
||||
* 在微信外且为链接时直接跳转;其余情况进入延期支付页展示二维码与链接。
|
||||
*/
|
||||
export const openSilencePayment = (order, refreshTarget) => {
|
||||
const content = String(order?.qr_content || '').trim();
|
||||
if (!content) return Promise.reject(new Error('支付内容为空'));
|
||||
|
||||
if (order.payment_method === 'alipay') {
|
||||
return openAlipayPayment(content, refreshTarget);
|
||||
}
|
||||
|
||||
markPendingPaymentRefresh(refreshTarget);
|
||||
uni.setStorageSync(SILENCE_PAYMENT_DATA_KEY, {
|
||||
orderId: order.id,
|
||||
orderNo: order.order_no,
|
||||
amount: order.amount,
|
||||
content,
|
||||
timestamp: Date.now()
|
||||
});
|
||||
|
||||
if (isPaymentLink(content) && !isInWechat() && typeof window !== 'undefined') {
|
||||
window.location.href = content;
|
||||
return Promise.resolve({ redirecting: true });
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/silence-payment/silence-payment',
|
||||
success: () => resolve({ redirecting: true }),
|
||||
fail: () => reject(new Error('打开支付页失败'))
|
||||
});
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user