Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf3bbaa5de | ||
|
|
45f608c408 |
@@ -83,10 +83,22 @@ export default {
|
|||||||
uni.redirectTo({ url: '/pages/index/login?redirect=' + encodeURIComponent('/pages/venue/detail?id=851219003520709&type=2') })
|
uni.redirectTo({ url: '/pages/index/login?redirect=' + encodeURIComponent('/pages/venue/detail?id=851219003520709&type=2') })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
this.loadUpSdk() // xuchao: 运行时注入云闪付 SDK(构建模板不可靠,见 loadUpSdk 注释)
|
||||||
if (options.orderNo) this.orderNo = options.orderNo
|
if (options.orderNo) this.orderNo = options.orderNo
|
||||||
this.initFromServer()
|
this.initFromServer()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// xuchao: upsdk 运行时注入。不能依赖 index.html 静态标签——HBuilderX 命令行构建的 H5 模板
|
||||||
|
// 不受项目根 index.html 控制(产物会丢标签),与人脸 SDK 同款动态加载兜底。
|
||||||
|
loadUpSdk() {
|
||||||
|
if (typeof window !== 'undefined' && window.upsdk) return
|
||||||
|
if (typeof document === 'undefined') return
|
||||||
|
if (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: 价格展示以服务端 latest 为准(测试期 0.01);已有待支付单自动续用;已发券直接跳券详情
|
// xuchao: 价格展示以服务端 latest 为准(测试期 0.01);已有待支付单自动续用;已发券直接跳券详情
|
||||||
initFromServer() {
|
initFromServer() {
|
||||||
this.$u.api.voucherLatest({ phone: this.phone }).then(res => {
|
this.$u.api.voucherLatest({ phone: this.phone }).then(res => {
|
||||||
@@ -135,26 +147,31 @@ export default {
|
|||||||
},
|
},
|
||||||
// xuchao: 云闪付控件唤起,交互与湘工惠商城一致(xghmall ordersure.vue:195-229 同型)
|
// xuchao: 云闪付控件唤起,交互与湘工惠商城一致(xghmall ordersure.vue:195-229 同型)
|
||||||
launchUnionPay(tn) {
|
launchUnionPay(tn) {
|
||||||
if (typeof window === 'undefined' || !window.upsdk) {
|
this.loadUpSdk()
|
||||||
this.submitting = false
|
const tryPay = (retries) => {
|
||||||
uni.showToast({ title: '支付组件未就绪,请在云闪付内重进页面', icon: 'none' })
|
if (typeof window !== 'undefined' && window.upsdk) {
|
||||||
return
|
window.upsdk.pluginReady(() => {
|
||||||
|
window.upsdk.pay({
|
||||||
|
tn: tn,
|
||||||
|
success: () => {
|
||||||
|
uni.redirectTo({ url: '/pages/petrol/voucherDetail?orderNo=' + this.orderNo })
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
this.submitting = false
|
||||||
|
uni.showToast({ title: '支付未完成,可在门店页继续支付', icon: 'none' })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
// 控件无异步结果时兜底:3 秒后恢复按钮(支付成功路径以回跳/轮询为准)
|
||||||
|
setTimeout(() => { this.submitting = false }, 3000)
|
||||||
|
} else if (retries > 0) {
|
||||||
|
setTimeout(() => tryPay(retries - 1), 500)
|
||||||
|
} else {
|
||||||
|
this.submitting = false
|
||||||
|
uni.showToast({ title: '支付组件加载失败,请在云闪付内重进页面', icon: 'none' })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const orderNo = this.orderNo
|
tryPay(8) // SDK 注入后最多等 4 秒
|
||||||
window.upsdk.pluginReady(() => {
|
|
||||||
window.upsdk.pay({
|
|
||||||
tn: tn,
|
|
||||||
success: () => {
|
|
||||||
uni.redirectTo({ url: '/pages/petrol/voucherDetail?orderNo=' + orderNo })
|
|
||||||
},
|
|
||||||
fail: () => {
|
|
||||||
this.submitting = false
|
|
||||||
uni.showToast({ title: '支付未完成,可在门店页继续支付', icon: 'none' })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
// 控件无异步结果时兜底:3 秒后恢复按钮(支付成功路径以回跳/轮询为准)
|
|
||||||
setTimeout(() => { this.submitting = false }, 3000)
|
|
||||||
},
|
},
|
||||||
goBack() {
|
goBack() {
|
||||||
const pages = getCurrentPages()
|
const pages = getCurrentPages()
|
||||||
|
|||||||
@@ -113,7 +113,8 @@ export default {
|
|||||||
return this.detailType !== '2'
|
return this.detailType !== '2'
|
||||||
},
|
},
|
||||||
isPetrol() {
|
isPetrol() {
|
||||||
return this.loaded && String(this.shopId) === PETROL_SHOP_ID && !this.isVenue
|
// xuchao: 后端券服务探活(latest 返回 price)后才展示购券模块——后端未部署期间整模块自动隐藏,无死入口
|
||||||
|
return this.loaded && String(this.shopId) === PETROL_SHOP_ID && !this.isVenue && !!(this.voucher && this.voucher.price)
|
||||||
},
|
},
|
||||||
voucherBtnText() {
|
voucherBtnText() {
|
||||||
const s = this.voucher ? this.voucher.statusCode : -1
|
const s = this.voucher ? this.voucher.statusCode : -1
|
||||||
@@ -170,10 +171,9 @@ export default {
|
|||||||
if (String(this.shopId) === PETROL_SHOP_ID) this.loadVoucher()
|
if (String(this.shopId) === PETROL_SHOP_ID) this.loadVoucher()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// xuchao: 拉取石油券最新订单状态(未登录不查,按钮保持“¥200 购买”,点击时再引导登录)
|
// xuchao: 拉取石油券最新订单状态(未登录也调用:作为后端服务探活,price 决定模块显隐)
|
||||||
loadVoucher() {
|
loadVoucher() {
|
||||||
const phone = uni.getStorageSync('phone')
|
const phone = uni.getStorageSync('phone') || ''
|
||||||
if (!phone) { this.voucher = null; return }
|
|
||||||
this.$u.api.voucherLatest({ phone }).then(res => {
|
this.$u.api.voucherLatest({ phone }).then(res => {
|
||||||
this.voucher = bizOk(res) ? bizData(res) : null
|
this.voucher = bizOk(res) ? bizData(res) : null
|
||||||
}).catch(() => { this.voucher = null })
|
}).catch(() => { this.voucher = null })
|
||||||
|
|||||||
Reference in New Issue
Block a user