feat: 价格计算
This commit is contained in:
@@ -28,8 +28,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, defineProps, defineEmits } from "vue";
|
import { computed, defineProps, defineEmits, ref, onMounted, watch } from "vue";
|
||||||
import { DebounceUtils } from "@/utils";
|
import { DebounceUtils } from "@/utils";
|
||||||
|
import { preOrder } from "@/request/api/OrderApi";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
@@ -54,12 +55,35 @@ const count = computed({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const totalAmt = computed(() => {
|
watch(
|
||||||
const { totalDays } = props.selectedDate;
|
() => count.value,
|
||||||
const { specificationPrice } = props.orderData;
|
(newVal, oldVal) => {
|
||||||
return count.value * Number(specificationPrice) * totalDays;
|
if (newVal !== oldVal) {
|
||||||
|
preOrderPay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
preOrderPay();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const totalAmt = ref(props.orderData.specificationPrice);
|
||||||
|
|
||||||
|
const preOrderPay = async () => {
|
||||||
|
preOrder({
|
||||||
|
"commodityId": props.orderData.commodityId,
|
||||||
|
"purchaseAmount": count.value,
|
||||||
|
"checkInData": props.selectedDate.startDate,
|
||||||
|
"checkOutData": props.selectedDate.endDate,
|
||||||
|
}).then((res) => {
|
||||||
|
console.log("预支付金额计算结果:", res);
|
||||||
|
totalAmt.value = res.data.payAmt;
|
||||||
|
}).catch((err) => {
|
||||||
|
console.error("预支付金额计算失败:", err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const handleBooking = DebounceUtils.createDebounce(() => {
|
const handleBooking = DebounceUtils.createDebounce(() => {
|
||||||
emit("payClick", props.orderData);
|
emit("payClick", props.orderData);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|||||||
@@ -79,6 +79,7 @@
|
|||||||
|
|
||||||
<!-- 底部 -->
|
<!-- 底部 -->
|
||||||
<FooterSection
|
<FooterSection
|
||||||
|
v-if="Object.keys(orderData).length"
|
||||||
v-model="quantity"
|
v-model="quantity"
|
||||||
:selectedDate="selectedDate"
|
:selectedDate="selectedDate"
|
||||||
:orderData="orderData"
|
:orderData="orderData"
|
||||||
|
|||||||
Reference in New Issue
Block a user