Fix:5397 【商城小程序】商品链接,连续快速点击“送给朋友”,重复弹出多个送礼页面

(cherry picked from commit 6d963a5bc0)
This commit is contained in:
linxi
2026-07-24 11:34:48 +08:00
committed by lifizer
parent cb6abf4a5a
commit ca79a820fb
3 changed files with 56 additions and 13 deletions
+15
View File
@@ -51,6 +51,7 @@ export const chatMixinsV2 = {
audioPlayId: '', audioPlayId: '',
showGiftBtn: false, showGiftBtn: false,
buyLoading: false, buyLoading: false,
buyActionLock: false,
exceptionConfig: { exceptionConfig: {
model_exception: '您提的问题未能理解,云灵思想跑偏啦,重新整理一下问题或者重新提问,让云灵再试试!', model_exception: '您提的问题未能理解,云灵思想跑偏啦,重新整理一下问题或者重新提问,让云灵再试试!',
voice_exception: '' voice_exception: ''
@@ -533,6 +534,10 @@ export const chatMixinsV2 = {
this.productItemBuyNowOrGiftBuy(item, 2) this.productItemBuyNowOrGiftBuy(item, 2)
}, },
productItemBuyNowOrGiftBuy(item, BuyNowOrGiftBuyType) { productItemBuyNowOrGiftBuy(item, BuyNowOrGiftBuyType) {
if (this.buyActionLock) {
return
}
this.buyActionLock = true
this.audioStopHandle() this.audioStopHandle()
this.cart_num = 1 this.cart_num = 1
this.m_id = item.id this.m_id = item.id
@@ -540,6 +545,7 @@ export const chatMixinsV2 = {
const { data } = res const { data } = res
this.storeInfo = {...data.storeInfo} this.storeInfo = {...data.storeInfo}
if(data.storeInfo.stock === 0) { if(data.storeInfo.stock === 0) {
this.buyActionLock = false
uni.showToast({ uni.showToast({
title: "产品库存不足,请选择其他商品", title: "产品库存不足,请选择其他商品",
icon: "none", icon: "none",
@@ -577,6 +583,14 @@ export const chatMixinsV2 = {
return return
} }
this.attr.cartAttr = !this.isOpen ? true : false this.attr.cartAttr = !this.isOpen ? true : false
this.buyActionLock = false
}).catch(error => {
this.buyActionLock = false
uni.showToast({
title: error.msg || '操作失败,请稍后重试',
icon: "none",
duration: 3000
})
}) })
}, },
buyNowOrGiftBuyReq(type) { buyNowOrGiftBuyReq(type) {
@@ -617,6 +631,7 @@ export const chatMixinsV2 = {
}) })
}).finally(() => { }).finally(() => {
_this.buyLoading = false _this.buyLoading = false
_this.buyActionLock = false
}) })
}, },
closeAttrWindow() { closeAttrWindow() {
+26 -12
View File
@@ -398,7 +398,8 @@ export default {
pageKeyId: Object.freeze('orderConfirm'), pageKeyId: Object.freeze('orderConfirm'),
total: 0, total: 0,
couponTitle: '', couponTitle: '',
hasCoupon: false hasCoupon: false,
pageQuery: {}
} }
}, },
computed: mapGetters(["userInfo", "storeItems"]), computed: mapGetters(["userInfo", "storeItems"]),
@@ -417,17 +418,18 @@ export default {
}, },
onLoad(opts) { onLoad(opts) {
const that = this const that = this
if (that.$yroute.query.pinkid !== undefined) { that.pageQuery = Object.assign({}, that.resolvePageQuery(), opts || {})
that.pinkId = that.$yroute.query.pinkid if (that.pageQuery.pinkid !== undefined) {
that.pinkId = that.pageQuery.pinkid
} }
if (that.$yroute.query.id !== undefined) { if (that.pageQuery.id !== undefined) {
that.cartid = that.$yroute.query.id that.cartid = that.pageQuery.id
console.log(that.cartid) console.log(that.cartid)
} }
if (that.$yroute.query.lotteryRecordId !== undefined) { if (that.pageQuery.lotteryRecordId !== undefined) {
that.lotteryRecordId = that.$yroute.query.lotteryRecordId that.lotteryRecordId = that.pageQuery.lotteryRecordId
} }
that.hasCoupon = opts.couponId !== '' that.hasCoupon = !!(opts && opts.couponId !== '')
that.getCartInfo() that.getCartInfo()
}, },
onShow() { onShow() {
@@ -452,14 +454,26 @@ export default {
}, },
methods: { methods: {
isNullOrEmpty, isNullOrEmpty,
resolvePageQuery() {
if (this.$yroute && this.$yroute.query) {
return this.$yroute.query
}
if (this.$route && this.$route.query) {
return this.$route.query
}
if (this._route && this._route.query) {
return this._route.query
}
return {}
},
isLotteryOrder() { isLotteryOrder() {
const cartInfo = Array.isArray(this.orderGroupInfo && this.orderGroupInfo.cartInfo) const cartInfo = Array.isArray(this.orderGroupInfo && this.orderGroupInfo.cartInfo)
? this.orderGroupInfo.cartInfo ? this.orderGroupInfo.cartInfo
: [] : []
return Boolean( return Boolean(
this.lotteryRecordId || this.lotteryRecordId ||
this.$yroute.query.from === 'countyLottery' || this.pageQuery.from === 'countyLottery' ||
Number(this.$yroute.query.drawActivityId || 0) > 0 || Number(this.pageQuery.drawActivityId || 0) > 0 ||
cartInfo.some(item => Number( cartInfo.some(item => Number(
item.drawActivityId || item.drawActivityId ||
(item.productInfo && item.productInfo.drawActivityId) || (item.productInfo && item.productInfo.drawActivityId) ||
@@ -567,8 +581,8 @@ export default {
} }
_this.systemStore = data.systemStore || {} _this.systemStore = data.systemStore || {}
_this.storeSelfMention = data.storeSelfMention _this.storeSelfMention = data.storeSelfMention
if(_this.$yroute.query.address !== undefined ) { if(_this.pageQuery.address !== undefined ) {
_this.addressInfo = JSON.parse(_this.$yroute.query.address) || {} _this.addressInfo = JSON.parse(_this.pageQuery.address) || {}
_this.computedPrice() _this.computedPrice()
} else { } else {
// _this.addressInfo = uni.getStorageSync('sourceAddress') || data.addressInfo || {} // _this.addressInfo = uni.getStorageSync('sourceAddress') || data.addressInfo || {}
+15 -1
View File
@@ -655,7 +655,8 @@ export default {
pageKeyId: '', pageKeyId: '',
couponListLimit2ToShow: [], couponListLimit2ToShow: [],
qualifications: [], qualifications: [],
couponId: null couponId: null,
submitActionLock: false
} }
}, },
computed: mapGetters(['isLogin', 'location', 'userInfo']), computed: mapGetters(['isLogin', 'location', 'userInfo']),
@@ -821,6 +822,7 @@ export default {
} }
}, },
onShow() { onShow() {
this.submitActionLock = false
this.getMapData() this.getMapData()
getGiftCardSendBackground().then(res => { getGiftCardSendBackground().then(res => {
if (res.status === 200) { if (res.status === 200) {
@@ -1500,6 +1502,10 @@ export default {
q.drawActivityId = Number(this.activityId || 0) q.drawActivityId = Number(this.activityId || 0)
break break
} }
if (that.submitActionLock) {
return
}
that.submitActionLock = true
postCartAdd(q).then(function (res) { postCartAdd(q).then(function (res) {
that.isOpen = false that.isOpen = false
that.attr.cartAttr = false that.attr.cartAttr = false
@@ -1511,6 +1517,9 @@ export default {
discount: that.storeInfo.discount, discount: that.storeInfo.discount,
} }
}) })
setTimeout(() => {
that.submitActionLock = false
}, 1500)
return return
} }
if(news === 2) { if(news === 2) {
@@ -1527,8 +1536,12 @@ export default {
// + '&couponId=' + coupId // + '&couponId=' + coupId
url: giftUrl url: giftUrl
}) })
setTimeout(() => {
that.submitActionLock = false
}, 1500)
} }
if(news === 0) { if(news === 0) {
that.submitActionLock = false
uni.showToast({ uni.showToast({
title: "添加购物车成功", title: "添加购物车成功",
icon: "success", icon: "success",
@@ -1541,6 +1554,7 @@ export default {
} }
}).catch(error => { }).catch(error => {
that.isOpen = false; that.isOpen = false;
that.submitActionLock = false
uni.showToast({ uni.showToast({
title: error.msg, title: error.msg,
icon: "none", icon: "none",