commit
263eb74695
|
@ -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>
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue