74 lines
3.2 KiB
JavaScript
74 lines
3.2 KiB
JavaScript
// 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_GUIDE_TEXT = '请在「云闪付 App」里的「湖南社保卡」小程序首页进入「怀化社保卡」活动中完成购买'
|
|
|
|
// 券详情页「使用规则 / 使用流程 / 重要须知」文案,来自石油侧材料(决策 14)
|
|
export const VOUCHER_USE_RULES = [
|
|
'请加油站收银员以“中石油汽油券”通道扫码核销',
|
|
'汽油券单日限用 1 张,多张可叠加使用',
|
|
'自购买日起 90 天内有效',
|
|
'券一经兑换不可退换'
|
|
]
|
|
export const VOUCHER_USE_FLOW = [
|
|
'加油后至收银台出示二维码核销',
|
|
'支付差额可选:油卡 / 现金等'
|
|
]
|
|
|
|
// xuchao: 云闪付 SDK 前置预热注入。HBuilderX 的 H5 构建不吃项目根 index.html(静态标签会被丢),
|
|
// 只能在 main.js 最早期(document-start、App 挂载前)动态注入,逼近 xghmall 的 head 静态加载时机,
|
|
// 让云闪付原生控件桥在首屏就注册,避免到确认订单页才注入导致 upsdk.pay 唤不起。
|
|
// 与 orderConfirm 页的 loadUpSdk 共用同一 script[data-upsdk] 标记,全局只注入一次。
|
|
export function injectUpSdk() {
|
|
if (typeof document === 'undefined' || typeof window === 'undefined') return
|
|
if (window.upsdk || document.querySelector('script[data-upsdk]')) return
|
|
const s = document.createElement('script')
|
|
s.src = 'https://open.95516.com/s/open/js/upsdk.js'
|
|
s.setAttribute('data-upsdk', '1')
|
|
document.head.appendChild(s)
|
|
}
|
|
|
|
// xuchao: 云闪付容器判定只看 UA——不能掺 window.upsdk 是否已加载(SDK 是异步注入的,
|
|
// 首屏点击时可能还没 load 完,会把云闪付内首点误判为站外)。UA 关键字真机实测后定稿。
|
|
export function isUnionPayApp() {
|
|
if (typeof navigator === 'undefined' || !navigator.userAgent) return false
|
|
return /unionpay|upsdk|云闪付/i.test(navigator.userAgent)
|
|
}
|
|
|
|
// 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: '已关闭'
|
|
}
|