feat: 订单详情用户信息组件优化
This commit is contained in:
@@ -37,8 +37,8 @@ defineProps({
|
|||||||
createTime: "",
|
createTime: "",
|
||||||
contactName: "",
|
contactName: "",
|
||||||
contactPhone: "",
|
contactPhone: "",
|
||||||
orderStatus: "0", // pending-待处理, completed-已完成, cancelled-已取消
|
orderStatus: "0", // 订单状态 0-待支付 1-待确认 2-待使用 3-已取消 4-退款中 5-已退款 6-已完成
|
||||||
orderType: undefined, // 0-酒店订单, 1-门票订单, 2-其他订单, undefined-工单
|
orderType: undefined, // 0-酒店订单, 1-门票订单, 2-餐饮
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="user-info mb12">
|
<view class="user-info mb12" v-if="hasConsumerData">
|
||||||
<view class="user-info-title">{{ infoTitle }}</view>
|
<view class="user-info-title">{{ infoTitle }}</view>
|
||||||
<view class="user-info-item">
|
<view
|
||||||
<text class="label">{{ contactLabel }}</text>
|
v-for="(item, index) in consumerList"
|
||||||
<text class="value">{{ orderData.visitorName }}</text>
|
:key="getConsumerKey(item, index)"
|
||||||
</view>
|
class="user-info-group"
|
||||||
<view class="user-info-item">
|
>
|
||||||
<text class="label">联系电话:</text>
|
<view class="user-info-item">
|
||||||
<text class="value">{{ orderData.contactPhone }}</text>
|
<text class="label">{{ contactLabel }}</text>
|
||||||
|
<text class="value">{{ item.visitorName || "未填写" }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="user-info-item">
|
||||||
|
<text class="label">联系电话:</text>
|
||||||
|
<text class="value">{{ formatPhone(item.contactPhone) }}</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -40,9 +46,7 @@ const props = defineProps({
|
|||||||
required: true,
|
required: true,
|
||||||
default: () => ({
|
default: () => ({
|
||||||
createTime: "",
|
createTime: "",
|
||||||
contactName: "",
|
consumerInfoList: [],
|
||||||
contactPhone: "",
|
|
||||||
visitorName: "", // 游客姓名
|
|
||||||
orderStatus: "0", // 订单状态 0-待支付 1-待确认 2-待使用 3-已取消 4-退款中 5-已关闭 6-已完成
|
orderStatus: "0", // 订单状态 0-待支付 1-待确认 2-待使用 3-已取消 4-退款中 5-已关闭 6-已完成
|
||||||
orderType: "0", // 0-酒店订单, 1-门票订单, 2-餐饮
|
orderType: "0", // 0-酒店订单, 1-门票订单, 2-餐饮
|
||||||
}),
|
}),
|
||||||
@@ -60,6 +64,31 @@ const contactLabel = computed(() => {
|
|||||||
const config = INFO_CONFIG[props.orderData.orderType] || INFO_CONFIG.default;
|
const config = INFO_CONFIG[props.orderData.orderType] || INFO_CONFIG.default;
|
||||||
return config.contactLabel;
|
return config.contactLabel;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 使用计算属性处理用户信息列表,提供更好的响应性和缓存
|
||||||
|
const consumerList = computed(() => {
|
||||||
|
return props.orderData.consumerInfoList || [];
|
||||||
|
});
|
||||||
|
|
||||||
|
// 检查是否有用户数据
|
||||||
|
const hasConsumerData = computed(() => {
|
||||||
|
return consumerList.value.length > 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 生成更稳定的key值,优先使用唯一标识
|
||||||
|
const getConsumerKey = (item, index) => {
|
||||||
|
return item.id || item.visitorName || `consumer-${index}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 格式化电话号码显示
|
||||||
|
const formatPhone = (phone) => {
|
||||||
|
if (!phone) return "未填写";
|
||||||
|
// 简单的电话号码格式化,中间部分用*号隐藏
|
||||||
|
if (phone.length === 11) {
|
||||||
|
return phone.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
|
||||||
|
}
|
||||||
|
return phone;
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -3,7 +3,12 @@
|
|||||||
<uni-icons type="left" size="20" color="#fff" @click="goBack" />
|
<uni-icons type="left" size="20" color="#fff" @click="goBack" />
|
||||||
|
|
||||||
<OrderStatusInfo :orderData="orderData" />
|
<OrderStatusInfo :orderData="orderData" />
|
||||||
<OrderQrcode size="132" unit="px" :val="orderData.orderId" />
|
<OrderQrcode
|
||||||
|
v-if="orderData.orderStatus === '2'"
|
||||||
|
size="132"
|
||||||
|
unit="px"
|
||||||
|
:val="orderData.orderId"
|
||||||
|
/>
|
||||||
<GoodsInfo :orderData="orderData" />
|
<GoodsInfo :orderData="orderData" />
|
||||||
<UserInfo :orderData="orderData" />
|
<UserInfo :orderData="orderData" />
|
||||||
<NoticeInfo :orderData="orderData" />
|
<NoticeInfo :orderData="orderData" />
|
||||||
|
|||||||
Reference in New Issue
Block a user