feat: 订单详情用户信息组件优化

This commit is contained in:
duanshuwen 2025-08-01 11:52:47 +08:00
parent 824f3c4901
commit a67659d3db
3 changed files with 48 additions and 14 deletions

View File

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

View File

@ -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
v-for="(item, index) in consumerList"
:key="getConsumerKey(item, index)"
class="user-info-group"
>
<view class="user-info-item"> <view class="user-info-item">
<text class="label">{{ contactLabel }}</text> <text class="label">{{ contactLabel }}</text>
<text class="value">{{ orderData.visitorName }}</text> <text class="value">{{ item.visitorName || "未填写" }}</text>
</view> </view>
<view class="user-info-item"> <view class="user-info-item">
<text class="label">联系电话</text> <text class="label">联系电话</text>
<text class="value">{{ orderData.contactPhone }}</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>

View File

@ -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" />