【功能修复】修复没有优惠券时点击确定提示优惠券找不到的问题;现在订单结算页面切换地址或者配送方式会重新计算价格

pull/86/head
卢越 2024-08-22 21:59:07 +08:00
parent adc521022f
commit a0f85bf157
2 changed files with 14 additions and 6 deletions

View File

@ -185,7 +185,7 @@
</template> </template>
<script setup> <script setup>
import { reactive, ref } from 'vue'; import { reactive, ref, watch } from 'vue';
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import AddressSelection from '@/pages/order/addressSelection.vue'; import AddressSelection from '@/pages/order/addressSelection.vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
@ -208,7 +208,7 @@
const addressState = ref({ const addressState = ref({
addressInfo: {}, // addressInfo: {}, //
deliveryType: 1, // 1 - 2 - deliveryType: 1, // 1-2-
isPickUp: true, // TODO puhui999: isPickUp: true, // TODO puhui999:
pickUpInfo: {}, // pickUpInfo: {}, //
receiverName: '', // receiverName: '', //
@ -226,7 +226,7 @@
// //
async function onSelectCoupon(couponId) { async function onSelectCoupon(couponId) {
state.orderPayload.couponId = couponId || 0; state.orderPayload.couponId = couponId;
await getOrderInfo(); await getOrderInfo();
state.showCoupon = false; state.showCoupon = false;
} }
@ -336,6 +336,14 @@
await getOrderInfo(); await getOrderInfo();
await getCoupons(); await getCoupons();
}); });
// 使 watch
watch(addressState, async (newAddress, oldAddress) => {
//
if (newAddress.addressInfo.id !== oldAddress.addressInfo.id || newAddress.deliveryType !== oldAddress.deliveryType) {
await getOrderInfo();
}
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -6,7 +6,7 @@
<scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true"> <scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true">
<!--可使用的优惠券区域--> <!--可使用的优惠券区域-->
<view class="subtitle ss-m-l-20">可使用优惠券</view> <view class="subtitle ss-m-l-20">可使用优惠券</view>
<view v-for="(item, index) in state.couponInfo.filter(coupon => coupon.match)" :key="index"> <view v-for="(item, index) in state.couponInfo" :key="index">
<s-coupon-list :data="item" type="user" :disabled="false"> <s-coupon-list :data="item" type="user" :disabled="false">
<template v-slot:reason> <template v-slot:reason>
<view class="ss-flex ss-m-t-24"> <view class="ss-flex ss-m-t-24">
@ -64,13 +64,13 @@
const state = reactive({ const state = reactive({
couponInfo: computed(() => props.modelValue), // couponInfo: computed(() => props.modelValue), //
couponId: 0, // couponId: undefined, //
}); });
// //
function radioChange(couponId) { function radioChange(couponId) {
if (state.couponId === couponId) { if (state.couponId === couponId) {
state.couponId = 0; state.couponId = undefined;
} else { } else {
state.couponId = couponId; state.couponId = couponId;
} }