Fix(购物车&订单):修复地址选择之后事件分发错误问题

This commit is contained in:
lifizer
2024-12-04 12:03:32 +08:00
parent c0a09ad449
commit c5c9c9146b
6 changed files with 223 additions and 274 deletions
+31 -34
View File
@@ -388,49 +388,46 @@ export default {
this.computedPrice('couponId')
}
},
onLoad: function () {
let that = this;
uni.$on('chooseAddress', (res) => {
console.log('监听到选择收货地址:' + JSON.stringify(res));
setTimeout(() => {
uni.showModal({
title:'确定修改地址吗?',
content: '',
showCancel: true,
cancelText: '取消',
confirmText: '确认',
success:(success)=>{
if(success.confirm) {
that.addressInfo = res;
//地址切换也要重新计算一下
that.computedPrice('onLoad chooseAddress');
}
},
complete:(complete)=>{
uni.hideLoading()
},
})
})
},1000)
onLoad() {
const that = this
if (that.$yroute.query.pinkid !== undefined) {
that.pinkId = that.$yroute.query.pinkid;
that.pinkId = that.$yroute.query.pinkid
}
if (that.$yroute.query.id !== undefined) {
that.cartid = that.$yroute.query.id;
that.cartid = that.$yroute.query.id
console.log(that.cartid)
}
if (that.$yroute.query.lotteryRecordId !== undefined) {
that.lotteryRecordId = that.$yroute.query.lotteryRecordId;
that.lotteryRecordId = that.$yroute.query.lotteryRecordId
}
that.getCartInfo();
that.getCartInfo()
},
onUnload: function () {
console.log('关闭监听选择收货地址');
uni.$off('chooseAddress');
},
onShow: function () {
onShow() {
const _this = this
//获取用户信息
this.$store.dispatch("getUser", true);
_this.$store.dispatch("getUser", true)
const chooseAddress = uni.getStorageSync('chooseAddress') || {}
// 监听到选择收货地址
if (chooseAddress.id) {
uni.showModal({
title:'确定修改地址吗?',
content: '',
showCancel: true,
cancelText: '取消',
confirmText: '确认',
success: (res) => {
if(res.confirm) {
_this.addressInfo = chooseAddress
// 地址切换也要重新计算一下
_this.computedPrice('onLoad chooseAddress')
}
},
complete: () => {
uni.hideLoading()
uni.setStorageSync('chooseAddress', {})
}
})
}
},
methods: {
isNullOrEmpty,