!86 【功能修复】修复订单结算页没有优惠券但是提示优惠券不存在的问题#IAK656:issue

Merge pull request !86 from 卢越/master
pull/87/head
芋道源码 2024-08-23 12:04:02 +00:00 committed by Gitee
commit 263eb74695
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 13 additions and 5 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

@ -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;
} }