From 9857f8cdadf9bbda695a689f42e0e8cecfefab3f Mon Sep 17 00:00:00 2001 From: Liuyi <candymxq888@outlook.com> Date: 星期四, 21 十一月 2024 17:08:07 +0800 Subject: [PATCH] 添加积分兑换 --- pages/pointsMall/pointsGoodsDetail/index.vue | 32 +++++++++++++++++++++++--------- 1 files changed, 23 insertions(+), 9 deletions(-) diff --git a/pages/pointsMall/pointsGoodsDetail/index.vue b/pages/pointsMall/pointsGoodsDetail/index.vue index 5199c4a..e2c7fe7 100644 --- a/pages/pointsMall/pointsGoodsDetail/index.vue +++ b/pages/pointsMall/pointsGoodsDetail/index.vue @@ -15,17 +15,27 @@ }) } //积分兑换 + async function confirm(){ + await integralConvertApi({userId:userInfo.value.id,goodsId:detailInfo.value.id}).then(async(res) =>{ + if(res.code == 200){ + uni.showToast({ + title:'兑换成功!', + duration:1000 + }) + setTimeout(() =>{ + uni.navigateTo({ + url:'/pages/pointsMall/pointsExchangeRecord/index' + }) + },1000) + await getGoodsDetail(goodsId) + } + }) + } + //打开确认弹窗 + const alertDialog = ref() async function integralConvert(){ if(detailInfo.value.useIntegral <= Number(userInfo.value.integral)){ - await integralConvertApi({userId:userInfo.value.id,goodsId:detailInfo.value.id}).then(async(res) =>{ - if(res.code == 200){ - uni.showToast({ - title:'兑换成功!', - icon:'none' - }) - await getGoodsDetail(goodsId) - } - }) + alertDialog.value.open() }else{ uni.showToast({ title:'积分余额不足!', @@ -76,6 +86,10 @@ </view> </view> </view> + <!-- 提示窗 --> + <uni-popup ref="alertDialog" type="dialog"> + <uni-popup-dialog type="info" title="提示" :showClose = 'true' content="确认兑换该商品!" @confirm="confirm"></uni-popup-dialog> + </uni-popup> </view> </template> -- Gitblit v1.9.3