feat: 订单详情也接口字段对接

This commit is contained in:
duanshuwen 2025-07-31 13:38:12 +08:00
parent b527e6d206
commit 283530c0e2
3 changed files with 69 additions and 21 deletions

View File

@ -10,11 +10,11 @@
</view> </view>
<view class="order-item"> <view class="order-item">
<text class="label">支付方式</text> <text class="label">支付方式</text>
<text class="value">{{ orderData.payWay }}</text> <text class="value">{{ payWayText }}</text>
</view> </view>
<view class="order-item amount"> <view class="order-item amount">
<text class="label">实际支付金额</text> <text class="label">实际支付金额</text>
<text class="value">¥{{ orderData.payAmt }}</text> <text class="value">{{ formattedAmount }}</text>
</view> </view>
<button class="reserve-button">再次预定</button> <button class="reserve-button">再次预定</button>
<text class="feedback">投诉反馈</text> <text class="feedback">投诉反馈</text>
@ -22,24 +22,42 @@
</template> </template>
<script setup> <script setup>
import { defineProps } from "vue"; import { defineProps, computed } from "vue";
defineProps({ //
const PAY_WAY_MAP = {
0: "微信",
1: "支付宝",
2: "云闪付",
};
const props = defineProps({
orderData: { orderData: {
type: Object, type: Object,
required: true, required: true,
default: () => ({ default: () => ({
id: "", orderId: "",
createTime: "", paySerialNumber: "",
contactName: "", payWay: "", // 0- 1- 2-
contactPhone: "", payAmt: "",
orderStatus: "0", // pending-, completed-, cancelled- orderStatus: "0", // 0- 1- 2-使 3- 4-退 5- 6-
orderType: undefined, // 0-, 1-, 2-, undefined- orderType: "0", // 0-, 1-, 2-
}), }),
}, },
}); });
// 使
const payWayText = computed(() => {
return PAY_WAY_MAP[props.orderData.payWay] || "未知支付方式";
});
//
const formattedAmount = computed(() => {
const amount = props.orderData.payAmt;
return amount ? `¥${parseFloat(amount).toFixed(2)}` : "¥0.00";
});
</script> </script>
<style scoped> <style scoped>
@import "./styles/index.scss"; @import "./styles/index.scss";
</style> </style>

View File

@ -1,8 +1,8 @@
<template> <template>
<view class="user-info mb12"> <view class="user-info mb12">
<view class="user-info-title">游客信息</view> <view class="user-info-title">{{ infoTitle }}</view>
<view class="user-info-item"> <view class="user-info-item">
<text class="label">联系游客</text> <text class="label">{{ contactLabel }}</text>
<text class="value">{{ orderData.visitorName }}</text> <text class="value">{{ orderData.visitorName }}</text>
</view> </view>
<view class="user-info-item"> <view class="user-info-item">
@ -13,24 +13,55 @@
</template> </template>
<script setup> <script setup>
import { defineProps } from "vue"; import { defineProps, computed } from "vue";
defineProps({ //
const ORDER_TYPES = {
HOTEL: "0", //
TICKET: "1", //
DINING: "2", //
};
//
const INFO_CONFIG = {
[ORDER_TYPES.HOTEL]: {
title: "订房信息",
contactLabel: "联系房客:",
},
default: {
title: "游客信息",
contactLabel: "联系游客:",
},
};
const props = defineProps({
orderData: { orderData: {
type: Object, type: Object,
required: true, required: true,
default: () => ({ default: () => ({
id: "",
createTime: "", createTime: "",
contactName: "", contactName: "",
contactPhone: "", contactPhone: "",
orderStatus: "0", // pending-, completed-, cancelled- visitorName: "", //
orderType: undefined, // 0-, 1-, 2-, undefined- orderStatus: "0", // 0- 1- 2-使 3- 4-退 5- 6-
orderType: "0", // 0-, 1-, 2-
}), }),
}, },
}); });
// 使
const infoTitle = computed(() => {
const config = INFO_CONFIG[props.orderData.orderType] || INFO_CONFIG.default;
return config.title;
});
// 使
const contactLabel = computed(() => {
const config = INFO_CONFIG[props.orderData.orderType] || INFO_CONFIG.default;
return config.contactLabel;
});
</script> </script>
<style scoped> <style scoped>
@import "./styles/index.scss"; @import "./styles/index.scss";
</style> </style>

View File

@ -24,7 +24,6 @@ import OrderInfo from "./components/OrderInfo/index.vue";
const orderData = ref({}); const orderData = ref({});
onLoad(async ({ orderId }) => { onLoad(async ({ orderId }) => {
console.log("onShow", orderId);
const res = await userOrderDetail({ orderId }); const res = await userOrderDetail({ orderId });
orderData.value = res.data; orderData.value = res.data;
@ -34,4 +33,4 @@ onLoad(async ({ orderId }) => {
<style lang="scss" scoped> <style lang="scss" scoped>
@import "./styles/detail.scss"; @import "./styles/detail.scss";
</style> </style>