feat: 怀化石油汽油券购买前端——门店页购券模块+确认订单/券详情两页,接 hhService/voucher 接口与云闪付控件

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jacobxu666
2026-09-24 10:12:19 +08:00
co-authored by Claude Fable 5
parent 966eac566c
commit 571afb0673
8 changed files with 616 additions and 2 deletions
+62
View File
@@ -0,0 +1,62 @@
// xuchao: 怀化石油汽油减免券——前端常量与工具(全写死,只服务这一个门店,决策 1/10/15)
// 价格真相在后端常量(20000 分),此处 200.00 仅展示用,两处改价必须同步
export const PETROL_SHOP_ID = '851219003520709'
export const VOUCHER_PRICE_TEXT = '200.00'
// xuchao: 非云闪付环境豁免拦截的联调手机号(决策 13)
export const VOUCHER_PAY_WHITELIST_PHONE = '18684839400'
export const VOUCHER_NAME = '怀化石油汽油电子券'
export const VOUCHER_RULE = '加油满 200 元减 8 元'
export const VOUCHER_GUIDE_TEXT = '请在「云闪付 App」里的「湖南社保卡」小程序首页进入「怀化市社保卡场景建设」活动中完成购买'
// 券详情页「使用规则 / 使用流程 / 重要须知」文案,来自石油侧材料(决策 14)
export const VOUCHER_USE_RULES = [
'请加油站收银员以“中石油汽油券”通道扫码核销',
'汽油券单日限用 1 张,多张可叠加使用',
'自购买日起 90 天内有效',
'券一经兑换不可退换'
]
export const VOUCHER_USE_FLOW = [
'加油后至收银台出示二维码核销',
'支付差额可选:油卡 / 现金等'
]
// xuchao: 云闪付容器判定。UA 特征 + window.upsdk 双判,真机实测后定稿(方案文档 §8 挂账项);
// 若实测 UA 关键字不符,只需调整下方正则。
export function isUnionPayApp() {
if (typeof navigator === 'undefined' || !navigator.userAgent) return false
if (!/unionpay|upsdk|云闪付/i.test(navigator.userAgent)) return false
return typeof window !== 'undefined' && !!window.upsdk
}
// xuchao: open-api/hhService/voucher/* 为双层壳:外层 errcode,内层 data.code 才是业务码
// (同 login.vue 的 isBizOk 判定,提到公共层复用)
export function bizOk(res) {
if (!res || res.errcode !== 0) return false
const d = res.data
if (!d || d.code === undefined || d.code === null) {
return !d || (d.status === undefined && d.error === undefined)
}
return d.code === 200
}
export function bizMsg(res) {
return (res && res.data && res.data.msg) || (res && res.errmsg) || ''
}
export function bizData(res) {
return (res && res.data && res.data.data) || {}
}
// statusCode 含义与后端 HhVoucherService.toView 对齐:-1无单 0待支付 1发券中 2已发券 3已退款 4退款处理中 5已关闭
export const VOUCHER_STATUS_TEXT = {
'-1': '',
0: '待支付',
1: '发券中',
2: '有效',
3: '已退款',
4: '退款处理中',
5: '已关闭'
}