|
@@ -28,6 +28,7 @@ const router = useRouter()
|
|
|
const userStore = useUserStore()
|
|
|
const { userInfo } = storeToRefs(userStore)
|
|
|
const show = ref(false)
|
|
|
+const disabled = ref(false)
|
|
|
const { alert } = useMessage()
|
|
|
const data = ref()
|
|
|
const selectedCoupons = ref<Coupon[]>([])
|
|
@@ -71,27 +72,66 @@ const offerPoints = computed(() => {
|
|
|
})
|
|
|
const handlePay = async () => {
|
|
|
console.log(111)
|
|
|
- const couponList =
|
|
|
- selectedCoupons.value?.map((it) => ({
|
|
|
- couponId: it.id,
|
|
|
- projectIds: it.productIds,
|
|
|
- buinessId: it.buinessId,
|
|
|
- })) || []
|
|
|
- const { code } = await requestToast(
|
|
|
- () =>
|
|
|
- orderPay({
|
|
|
- ...data?.value,
|
|
|
- couponList,
|
|
|
- }),
|
|
|
- { success: true, successTitle: '兑换成功' },
|
|
|
- )
|
|
|
- if (code === 0) {
|
|
|
- await router.replace('/pages-sub/home/mall/purchased/success/index')
|
|
|
+ if(disabled.value){
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ disabled.value = true;
|
|
|
+ if(coupons.value.length>0 && selectedCoupons.value?.length===0){
|
|
|
+ uni.showModal({
|
|
|
+ title:"提示",
|
|
|
+ content:"您有" + coupons.value.length + "张优惠券可用,是否要使用?",
|
|
|
+ success: async (res) => {
|
|
|
+ if(res.confirm){
|
|
|
+ handleQ()
|
|
|
+ }
|
|
|
+ if(res.cancel){
|
|
|
+ const couponList =
|
|
|
+ selectedCoupons.value?.map((it) => ({
|
|
|
+ couponId: it.id,
|
|
|
+ projectIds: it.productIds,
|
|
|
+ buinessId: it.buinessId,
|
|
|
+ })) || []
|
|
|
+ const { code } = await requestToast(
|
|
|
+ () =>
|
|
|
+ orderPay({
|
|
|
+ ...data?.value,
|
|
|
+ couponList,
|
|
|
+ }),
|
|
|
+ { success: true, successTitle: '兑换成功' },
|
|
|
+ )
|
|
|
+ disabled.value = false;
|
|
|
+ if (code === 0) {
|
|
|
+ await router.replace('/pages-sub/home/mall/purchased/success/index')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ const couponList =
|
|
|
+ selectedCoupons.value?.map((it) => ({
|
|
|
+ couponId: it.id,
|
|
|
+ projectIds: it.productIds,
|
|
|
+ buinessId: it.buinessId,
|
|
|
+ })) || []
|
|
|
+ const { code } = await requestToast(
|
|
|
+ () =>
|
|
|
+ orderPay({
|
|
|
+ ...data?.value,
|
|
|
+ couponList,
|
|
|
+ }),
|
|
|
+ { success: true, successTitle: '兑换成功' },
|
|
|
+ )
|
|
|
+ if (code === 0) {
|
|
|
+ await router.replace('/pages-sub/home/mall/purchased/success/index')
|
|
|
+ }
|
|
|
+ disabled.value = false;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
const handleQ = async () => {
|
|
|
// await setCoupons()
|
|
|
show.value = true
|
|
|
+ disabled.value = false;
|
|
|
}
|
|
|
const handleSelect = (coupon: Coupon) => {
|
|
|
selectedCoupons.value = [coupon]
|
|
@@ -198,7 +238,7 @@ onLoad(async (query: { data: string }) => {
|
|
|
</div>
|
|
|
<div class="text-black/40 text-base font-normal font-['PingFang_SC']">积分</div>
|
|
|
</div>
|
|
|
- <div class="">
|
|
|
+ <div :class="disabled?'filter':''">
|
|
|
<ButtonEvo @click="handlePay">确认兑换</ButtonEvo>
|
|
|
</div>
|
|
|
</div>
|