Commit dde6c79d by 张立顺

fix bug

1 parent f7dda912
...@@ -1335,6 +1335,67 @@ Page({ ...@@ -1335,6 +1335,67 @@ Page({
// 添加埋点 // 添加埋点
wx.$track.setTrackData(0, 'submit_order', {}, '', 1) wx.$track.setTrackData(0, 'submit_order', {}, '', 1)
}, },
/** 扫码 / scene 礼券:需在路由策略 setData 写入 scene 之后调用(见 onRoute) */
applyCouponFromScene(userInfo, sceneRaw) {
if (!sceneRaw) return
let scene = decodeURIComponent(sceneRaw)
if (userInfo.userType == 2) {
let id = scene.split('=')[1]
api
.getCouponDeatil({
id
})
.then(info => {
let { code, data, message } = info
if (code == 0) {
if (data.usedFlag == 'Y') {
wx.showModal({
content: '该礼券已被使用',
confirmText: '知道了',
confirmColor: '#347BFF',
showCancel: false,
success(res) {
if (res.confirm) wx.$router.back()
}
})
return
}
this.setOrderObj(data)
api
.getOrderByCustomerCouponId({
customerCouponId: id
})
.then(res => {
let { code, data, message } = res
if (code == 0) {
this.setData({
['orderObj.orderCode']: data.orderCode
})
} else {
this.showToast(message)
}
})
} else {
this.showToast(message)
}
})
} else {
wx.showModal({
title: '温馨提示',
content: '您的账号无法完成此操作',
confirmText: '知道了',
confirmColor: '#347BFF',
showCancel: false,
success(res) {
if (res.confirm) {
wx.$util.refreshPageData()
wx.$router.go('index')
}
}
})
}
},
init(userInfo) { init(userInfo) {
let { scene, orderObj } = this.data let { scene, orderObj } = this.data
if (!orderObj.sellerMerchantName) { if (!orderObj.sellerMerchantName) {
...@@ -1346,67 +1407,8 @@ Page({ ...@@ -1346,67 +1407,8 @@ Page({
orderObj orderObj
}) })
} }
// console.log(this.data)
// console.log(scene);
if (scene) { if (scene) {
scene = decodeURIComponent(scene) this.applyCouponFromScene(userInfo, scene)
if (userInfo.userType == 2) {
let id = scene.split('=')[1]
api
.getCouponDeatil({
id
})
.then(info => {
let { code, data, message } = info
if (code == 0) {
if (data.usedFlag == 'Y') {
wx.showModal({
content: '该礼券已被使用',
confirmText: '知道了',
confirmColor: '#347BFF',
showCancel: false,
success(res) {
if (res.confirm) wx.$router.back()
}
})
return
}
this.setOrderObj(data)
api
.getOrderByCustomerCouponId({
customerCouponId: id
})
.then(res => {
let { code, data, message } = res
if (code == 0) {
this.setData({
['orderObj.orderCode']: data.orderCode
})
} else {
this.showToast(message)
}
})
} else {
this.showToast(message)
}
})
} else {
wx.showModal({
title: '温馨提示',
content: '您的账号无法完成此操作',
confirmText: '知道了',
confirmColor: '#347BFF',
showCancel: false,
success(res) {
if (res.confirm) {
wx.$util.refreshPageData()
wx.$router.go('index')
}
}
})
}
} }
}, },
async getSelectOrderGoodsList(merchantId) { async getSelectOrderGoodsList(merchantId) {
...@@ -2295,6 +2297,10 @@ Page({ ...@@ -2295,6 +2297,10 @@ Page({
try { try {
const routeContext = new RouteContext(this) const routeContext = new RouteContext(this)
await routeContext.execute(res) await routeContext.execute(res)
if (res && res.scene) {
const userInfo = this.data.userInfo || wx.$util.getUserInfo()
if (userInfo) this.applyCouponFromScene(userInfo, res.scene)
}
} catch (error) { } catch (error) {
console.error('onRoute execution failed:', error) console.error('onRoute execution failed:', error)
// Fallback: 至少保证页面不白屏 // Fallback: 至少保证页面不白屏
......
...@@ -263,7 +263,7 @@ const pointRecord = clickEventType => { ...@@ -263,7 +263,7 @@ const pointRecord = clickEventType => {
* @returns {Function} - 返回一个经过防抖处理的函数。 * @returns {Function} - 返回一个经过防抖处理的函数。
*/ */
const debounce = (func, delay, immediate) => { const debounce = (func, delay, immediate) => {
console.log(delay); // console.log(delay);
let timeoutId; // 用于保存定时器ID let timeoutId; // 用于保存定时器ID
return function (...args) { return function (...args) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!