fix: 更新订单相关组件以展示用户昵称和绑定电话,优化用户信息显示

This commit is contained in:
吴昊天 2026-09-29 10:45:45 +08:00
parent 5f0b9f2d78
commit b1884a6f3b
8 changed files with 60 additions and 30 deletions

View File

@ -423,6 +423,10 @@ class OrderCenterServices extends BaseService implements OrderCenterSyncInterfac
}
$detail = $detail->toArray();
$detail['extra_info'] = $this->parseExtraInfo($detail['extra_info']);
// 下单用户昵称/绑定电话(eb_user),供详情"用户信息"区展示
$detailUser = User::where('uid', (int)$detail['uid'])->field('nickname,phone')->find();
$detail['nickname'] = $detailUser['nickname'] ?? '';
$detail['user_phone'] = $detailUser['phone'] ?? '';
// 解析 JSON 字段
if (!empty($detail['custom_form'])) {
$detail['custom_form'] = $this->parseExtraInfo($detail['custom_form']);
@ -2410,6 +2414,18 @@ class OrderCenterServices extends BaseService implements OrderCenterSyncInterfac
unset($item['extra_info']['business_status']);
}
// 批量注入下单用户昵称/电话,供列表页"用户信息"列展示
$uids = array_values(array_unique(array_filter(array_column($list, 'uid'))));
if (!empty($uids)) {
$userMap = User::where('uid', 'in', $uids)->column('nickname,phone', 'uid');
foreach ($list as &$item) {
$user = $userMap[$item['uid']] ?? [];
$item['nickname'] = $user['nickname'] ?? '';
$item['user_phone'] = $user['phone'] ?? '';
}
unset($item);
}
// 批量查询并合并售后状态到列表
$orderNos = array_column($list, 'order_no');
$afterSaleSummary = $this->getAfterSaleSummary($orderNos);

View File

@ -28,11 +28,11 @@
<ul class="list">
<li class="item">
<div>用户名称:</div>
<div class="value">{{ data.real_name || data.contact?.name || '--' }}</div>
<div class="value">{{ data.nickname || '--' }}</div>
</li>
<li class="item">
<div>绑定电话:</div>
<div class="value">{{ data.user_phone || data.contact?.phone || '--' }}</div>
<div class="value">{{ data.user_phone || '--' }}</div>
</li>
</ul>
</div>
@ -60,7 +60,7 @@
</li>
<li class="item">
<div>收货电话:</div>
<div class="value">{{ data.contact?.phone || data.user_phone || '--' }}</div>
<div class="value">{{ data.contact?.phone || '--' }}</div>
</li>
<li class="item">
<div>收货地址:</div>

View File

@ -56,7 +56,7 @@
</template>
<script setup>
import { onMounted, ref } from 'vue';
import { onMounted, ref, watch } from 'vue';
import { useRoute } from 'vue-router';
import { ElMessage } from 'element-plus';
import __asset_order_icon_0 from '@/assets/images/order_icon.png';
@ -69,6 +69,9 @@ import DetailLogistics from './components/DetailLogistics';
defineOptions({ name: 'orderCenterDetail' });
// 传入 id 时作为抽屉内嵌组件使用;不传时为路由整页(取 route.params.id)
const props = defineProps({ id: { type: [String, Number], default: '' } });
const route = useRoute();
const detailData = ref(null);
@ -79,7 +82,7 @@ const logisticsVisible = ref(false);
const logisticsData = ref([]);
function loadDetail() {
const id = route.params.id;
const id = props.id || route.params.id;
if (!id) return;
detailLoading.value = true;
orderCenterDetail(id)
@ -135,6 +138,15 @@ function formatDate(date) {
onMounted(() => {
loadDetail();
});
watch(
() => props.id,
(val) => {
if (val) loadDetail();
}
);
defineExpose({ loadDetail });
</script>
<style lang="scss" scoped>
@ -179,6 +191,8 @@ onMounted(() => {
.list {
display: flex;
flex-wrap: wrap;
row-gap: 12px;
margin-top: 20px;
overflow: hidden;
list-style: none;

View File

@ -198,8 +198,8 @@
</el-table-column>
<el-table-column label="用户信息" min-width="150">
<template #default="scope">
<div>{{ scope.row.contact_name || '--' }}</div>
<div>{{ scope.row.contact_phone || '--' }}</div>
<div>{{ scope.row.nickname || '--' }}</div>
<div>{{ scope.row.user_phone || '--' }}</div>
</template>
</el-table-column>
<el-table-column label="订单金额" min-width="120">
@ -267,12 +267,14 @@
</div></template
>
</el-dialog>
<el-drawer v-model="detailDrawerVisible" title="订单详情" size="720px" @opened="onDetailDrawerOpened">
<OrderCenterDetail :id="detailOrderId" ref="orderDetailRef" />
</el-drawer>
</div>
</template>
<script setup>
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
import { ElMessage, ElMessageBox } from 'element-plus';
import {
orderCenterList,
@ -282,13 +284,10 @@ import {
orderCenterCategories,
orderCenterFilterOptions,
} from '@/api/orderCenter';
import setting from '@/setting';
import OrderCenterDetail from './detail.vue';
defineOptions({ name: 'orderCenter' });
const router = useRouter();
const routePre = setting.routePre;
const searchForm = ref({
order_category: '',
product_type: '',
@ -308,6 +307,9 @@ const loading = ref(false);
const statData = ref({});
const remarkModal = ref(false);
const remarkForm = ref({ id: 0, remark: '' });
const detailDrawerVisible = ref(false);
const detailOrderId = ref(0);
const orderDetailRef = ref(null);
const statusTab = ref('');
const categoryOptions = ref([]);
const productTypeOptions = ref([]);
@ -408,16 +410,14 @@ function handleReset() {
}
function viewDetail(row) {
const routeMap = {
normal: routePre + '/product/normal/order/detail/',
virtual: routePre + '/product/virtual/order/detail/',
cardkey: routePre + '/product/cardkey/order/detail/',
};
const path = routeMap[row.product_type];
if (path) {
router.push({ path: path + row.order_no });
} else {
router.push({ path: routePre + '/order/center/detail/' + row.id });
detailOrderId.value = row.id;
detailDrawerVisible.value = true;
}
function onDetailDrawerOpened() {
// 抽屉打开后触发详情组件重新加载,保证同一订单重复打开时数据最新
if (orderDetailRef.value) {
orderDetailRef.value.loadDetail();
}
}

View File

@ -74,13 +74,13 @@
<el-col :span="8"
><div class="detail-item">
<span class="label">用户名称:</span
><span class="value">{{ detailData.real_name || detailData.contact?.name || '--' }}</span>
><span class="value">{{ detailData.nickname || '--' }}</span>
</div></el-col
>
<el-col :span="8"
><div class="detail-item">
<span class="label">联系电话:</span
><span class="value">{{ detailData.user_phone || detailData.contact?.phone || '--' }}</span>
><span class="value">{{ detailData.user_phone || '--' }}</span>
</div></el-col
>
</el-row>
@ -180,7 +180,7 @@
<el-col :span="8"
><div class="detail-item">
<span class="label">收货电话:</span
><span class="value">{{ detailData.contact?.phone || detailData.user_phone || '--' }}</span>
><span class="value">{{ detailData.contact?.phone || '--' }}</span>
</div></el-col
>
<el-col :span="8"

View File

@ -448,7 +448,7 @@ function onRemarkSuccess() {
function openEditAddress(row) {
addressOrderNo.value = row.order_no;
addressName.value = row.contact_name || row.real_name || '';
addressPhone.value = row.contact_phone || row.user_phone || '';
addressPhone.value = row.contact_phone || '';
addressDetail.value = row.user_address || '';
addressVisible.value = true;
}

View File

@ -73,8 +73,8 @@
</el-table-column>
<el-table-column label="用户信息" min-width="150">
<template #default="scope">
<div>{{ scope.row.contact_name || scope.row.real_name || '--' }}</div>
<div>{{ scope.row.contact_phone || scope.row.user_phone || '--' }}</div>
<div>{{ scope.row.nickname || '--' }}</div>
<div>{{ scope.row.user_phone || '--' }}</div>
</template>
</el-table-column>
<el-table-column label="订单金额" min-width="130">

View File

@ -96,13 +96,13 @@
<el-col :span="8"
><div class="detail-item">
<span class="label">用户名称:</span
><span class="value">{{ orderInfo.real_name || orderInfo.contact?.name || '--' }}</span>
><span class="value">{{ orderInfo.nickname || '--' }}</span>
</div></el-col
>
<el-col :span="8"
><div class="detail-item">
<span class="label">联系电话:</span
><span class="value">{{ orderInfo.user_phone || orderInfo.contact?.phone || '--' }}</span>
><span class="value">{{ orderInfo.user_phone || '--' }}</span>
</div></el-col
>
</el-row>