合完了

This commit is contained in:
chen-xin-zhi 2025-03-19 21:29:37 +08:00
parent a1615640c4
commit df093ceb70
5 changed files with 26 additions and 20 deletions

View File

@ -94,9 +94,9 @@
const flushCouponListHandler = () => { // const flushCouponListHandler = () => {
getMyCouponList() // getMyCouponList()
} // }
const getTotalPriceHandler = (val) => { const getTotalPriceHandler = (val) => {
totalAmount = val totalAmount = val
@ -107,13 +107,13 @@
onMounted(() => { onMounted(() => {
emitter.on('getTotalPrice', getTotalPriceHandler) emitter.on('getTotalPrice', getTotalPriceHandler)
emitter.on('flushCouponList', flushCouponListHandler) // emitter.on('flushCouponList', flushCouponListHandler)
}) })
onUnmounted(() => { onUnmounted(() => {
uni.removeStorageSync('couponMap') uni.removeStorageSync('couponMap')
emitter.off('getTotalPrice', getTotalPriceHandler) emitter.off('getTotalPrice', getTotalPriceHandler)
emitter.off('flushCouponList', flushCouponListHandler) // emitter.off('flushCouponList', flushCouponListHandler)
}) })
@ -163,29 +163,31 @@
const getMyCouponList = async () => { const getMyCouponList = async () => {
couponMap = uni.getStorageSync('couponMap') // couponMap = uni.getStorageSync('couponMap')
console.log('读缓存======================>', couponMap) // console.log('======================>', couponMap)
if (couponMap) { // if (couponMap) {
if (isShow.value) myCouponList.value = couponMap['可用'] // if (isShow.value) myCouponList.value = couponMap['']
else myCouponList.value = couponMap['不可用'] // else myCouponList.value = couponMap['']
checkedArr.value = new Array(myCouponList.value.length).fill(false) // checkedArr.value = new Array(myCouponList.value.length).fill(false)
return // return
} // }
const res = await uni.request({ const res = await uni.request({
url: baseUrl + '/coupon/list/all/own', url: baseUrl + '/coupon/list/use',
method: 'POST', method: 'POST',
header: { header: {
cookie cookie
}, },
data: { data: {
currentAmount: totalAmount currentAmount: totalAmount,
isAvailable: isShow.value
} }
}) })
console.log('发请求=====================>', res.data.data) // console.log('=====================>', res.data.data)
couponMap = res.data.data // couponMap = res.data.data
uni.setStorageSync('couponMap', couponMap) // uni.setStorageSync('couponMap', couponMap)
if (isShow.value) myCouponList.value = couponMap['可用'] // if (isShow.value) myCouponList.value = couponMap['']
else myCouponList.value = couponMap['不可用'] // else myCouponList.value = couponMap['']
myCouponList.value = res.data.data
checkedArr.value = new Array(myCouponList.value.length).fill(false) checkedArr.value = new Array(myCouponList.value.length).fill(false)
} }

View File

@ -413,6 +413,7 @@ const wxPay = async( oid )=> { //传入订单id
showLoading() showLoading()
debounceTimer = setTimeout(async () => { debounceTimer = setTimeout(async () => {
await getMyCouponList() await getMyCouponList()
emitter.emit('flushCouponListHandler')
hideLoading() hideLoading()
}, 1000) }, 1000)
} }

View File

@ -455,6 +455,7 @@
showLoading() showLoading()
debounceTimer = setTimeout(async () => { debounceTimer = setTimeout(async () => {
await getMyCouponList() await getMyCouponList()
emitter.emit('flushCouponList')
hideLoading() hideLoading()
}, 1000) }, 1000)
} }

View File

@ -310,6 +310,7 @@ const updateAddressHandler = (val) => {
showLoading() showLoading()
debounceTimer = setTimeout(async () => { debounceTimer = setTimeout(async () => {
await getMyCouponList() await getMyCouponList()
emitter.emit('flushCouponList')
hideLoading() hideLoading()
}, 1000) }, 1000)
} }

View File

@ -452,6 +452,7 @@
showLoading() showLoading()
debounceTimer = setTimeout(async () => { debounceTimer = setTimeout(async () => {
await getMyCouponList() await getMyCouponList()
// emitter.emit('flushCouponList')
hideLoading() hideLoading()
}, 1000) }, 1000)
} }