Liuyi
2024-11-21 9857f8cdadf9bbda695a689f42e0e8cecfefab3f
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>