|
|
@@ -15,7 +15,7 @@
|
|
|
<div class="detail-item">
|
|
|
<div class="detail-label">订单名称</div>
|
|
|
<div class="detail-value">
|
|
|
- {{ formData.productName || "--" }}
|
|
|
+ {{ formData.couponName || "--" }}
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 订单编号 -->
|
|
|
@@ -29,56 +29,54 @@
|
|
|
<div class="detail-item">
|
|
|
<div class="detail-label">下单时间</div>
|
|
|
<div class="detail-value">
|
|
|
- {{ formData.orderTime || "--" }}
|
|
|
+ {{ formData.createdTime || "--" }}
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 原价 -->
|
|
|
<div class="detail-item">
|
|
|
<div class="detail-label">原价</div>
|
|
|
<div class="detail-value">
|
|
|
- {{ formData.originalPrice ? `¥${formData.originalPrice}` : "--" }}
|
|
|
+ {{ formatCurrency(formData.originalPrice, 2, "¥") }}
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 优惠价 -->
|
|
|
<div class="detail-item">
|
|
|
<div class="detail-label">优惠价</div>
|
|
|
<div class="detail-value">
|
|
|
- {{ formData.discountedPrice ? `¥${formData.discountedPrice}` : "--" }}
|
|
|
+ {{ formatCurrency(formData.price, 2, "¥") }}
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 数量 -->
|
|
|
<div class="detail-item">
|
|
|
<div class="detail-label">数量</div>
|
|
|
- <div class="detail-value">
|
|
|
- {{ formData.quantity || "--" }}
|
|
|
- </div>
|
|
|
+ <div class="detail-value">x{{ formData.orderCouponMiddleList ? formData.orderCouponMiddleList.length : 0 }}</div>
|
|
|
</div>
|
|
|
<!-- 优惠券减免 -->
|
|
|
<div class="detail-item">
|
|
|
<div class="detail-label">优惠券减免</div>
|
|
|
<div class="detail-value">
|
|
|
- {{ formData.couponDiscount ? `¥${formData.couponDiscount}` : "--" }}
|
|
|
+ {{ formatCurrency(formData.nominalValue, 2, "¥") }}
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 优惠券类型 -->
|
|
|
<div class="detail-item">
|
|
|
<div class="detail-label">优惠券类型</div>
|
|
|
<div class="detail-value">
|
|
|
- {{ formData.couponType || "--" }}
|
|
|
+ {{ getCouponType(formData.type) }}
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 预留手机号 -->
|
|
|
<div class="detail-item">
|
|
|
<div class="detail-label">预留手机号</div>
|
|
|
<div class="detail-value">
|
|
|
- {{ formData.phone || "--" }}
|
|
|
+ {{ formData.userPhone || "--" }}
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 预计收入 -->
|
|
|
<div class="detail-item">
|
|
|
<div class="detail-label">预计收入</div>
|
|
|
<div class="detail-value">
|
|
|
- {{ formData.estimatedIncome ? `¥${formData.estimatedIncome}` : "--" }}
|
|
|
+ {{ formatCurrency(formData.expectIncome, 2, "¥") }}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -97,29 +95,31 @@
|
|
|
{{ getCouponStatusName(coupon.status) }}
|
|
|
</div>
|
|
|
</div>
|
|
|
- <!-- 券码 -->
|
|
|
- <div class="detail-item">
|
|
|
- <div class="detail-label">券码</div>
|
|
|
- <div class="detail-value">
|
|
|
- {{ coupon.code || "--" }}
|
|
|
+ <template v-for="(item, index) in coupon.list" :key="index">
|
|
|
+ <!-- 券码 -->
|
|
|
+ <div class="detail-item">
|
|
|
+ <div class="detail-label">券码</div>
|
|
|
+ <div class="detail-value">
|
|
|
+ {{ item.couponCode || "--" }}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- <!-- 核销时间 -->
|
|
|
- <div v-if="coupon.status === '2'" class="detail-item">
|
|
|
- <div class="detail-label">核销时间</div>
|
|
|
- <div class="detail-value">
|
|
|
- {{ coupon.verifyTime || "--" }}
|
|
|
+ <!-- 核销时间 -->
|
|
|
+ <div v-if="item.usedTime && coupon.status == 2" class="detail-item">
|
|
|
+ <div class="detail-label">核销时间</div>
|
|
|
+ <div class="detail-value">
|
|
|
+ {{ item.usedTime || "--" }}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- <!-- 退款时间 -->
|
|
|
- <div v-if="coupon.status === '3'" class="detail-item">
|
|
|
- <div class="detail-label">退款时间</div>
|
|
|
- <div class="detail-value">
|
|
|
- {{ coupon.refundTime || "--" }}
|
|
|
+ <!-- 退款时间 -->
|
|
|
+ <div v-if="item.refundTime && coupon.status == 5" class="detail-item">
|
|
|
+ <div class="detail-label">退款时间</div>
|
|
|
+ <div class="detail-value">
|
|
|
+ {{ item.refundTime || "--" }}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- <!-- 分隔线 -->
|
|
|
- <el-divider v-if="index < couponList.length - 1" style="margin: 20px 0" />
|
|
|
+ <!-- 分隔线 -->
|
|
|
+ <el-divider v-if="index < couponList.length - 1" style="margin: 20px 0" />
|
|
|
+ </template>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div v-else class="empty-text">--</div>
|
|
|
@@ -134,10 +134,12 @@
|
|
|
* 订单管理 - 详情页面
|
|
|
* 功能:显示订单的详细信息
|
|
|
*/
|
|
|
-import { ref, onMounted } from "vue";
|
|
|
+import { ref, onMounted, computed } from "vue";
|
|
|
import { useRoute, useRouter } from "vue-router";
|
|
|
import { ElMessage } from "element-plus";
|
|
|
import { getStaffConfigDeatail } from "@/api/modules/staffConfig";
|
|
|
+import { queryUserOrderDetail } from "@/api/modules/orderManagement";
|
|
|
+import { formatCurrency } from "@/utils/formatCurrency";
|
|
|
|
|
|
// ==================== 响应式数据定义 ====================
|
|
|
|
|
|
@@ -157,15 +159,40 @@ const couponList = ref<any[]>([]);
|
|
|
/**
|
|
|
* 获取券码状态名称
|
|
|
*/
|
|
|
-const getCouponStatusName = (status: string) => {
|
|
|
- const statusMap: Record<string, string> = {
|
|
|
- "1": "未核销",
|
|
|
- "2": "已核销",
|
|
|
- "3": "已退款"
|
|
|
+const getCouponStatusName = computed(() => {
|
|
|
+ return status => {
|
|
|
+ switch (status) {
|
|
|
+ case 0:
|
|
|
+ return "待支付";
|
|
|
+ case 1:
|
|
|
+ return "未核销";
|
|
|
+ case 2:
|
|
|
+ return "已核销";
|
|
|
+ case 3:
|
|
|
+ return "已过期";
|
|
|
+ case 4:
|
|
|
+ return "已取消";
|
|
|
+ case 5:
|
|
|
+ return "已退款";
|
|
|
+ default:
|
|
|
+ return "--";
|
|
|
+ }
|
|
|
};
|
|
|
- return statusMap[status] || "--";
|
|
|
-};
|
|
|
-
|
|
|
+});
|
|
|
+const getCouponType = computed(() => {
|
|
|
+ return status => {
|
|
|
+ switch (status) {
|
|
|
+ case 1:
|
|
|
+ return "优惠券";
|
|
|
+ case 2:
|
|
|
+ return "红包";
|
|
|
+ case 3:
|
|
|
+ return "平台优惠券";
|
|
|
+ default:
|
|
|
+ return "--";
|
|
|
+ }
|
|
|
+ };
|
|
|
+});
|
|
|
// ==================== 生命周期钩子 ====================
|
|
|
|
|
|
/**
|
|
|
@@ -193,48 +220,39 @@ const goBack = () => {
|
|
|
const initData = async () => {
|
|
|
if (id.value) {
|
|
|
try {
|
|
|
- // TODO: 根据实际API获取订单详情
|
|
|
- // const response = await getOrderDetail({ id: id.value });
|
|
|
- // if (response.code === 200) {
|
|
|
- // formData.value = response.data;
|
|
|
- // couponList.value = response.data.couponList || [];
|
|
|
- // }
|
|
|
-
|
|
|
- // 临时模拟数据
|
|
|
- formData.value = {
|
|
|
- productName: "4拼冰淇淋蛋糕套餐",
|
|
|
- orderNo: "17554469202966300062",
|
|
|
- orderTime: "2025/01/01 12:00:00",
|
|
|
- originalPrice: 400,
|
|
|
- discountedPrice: 380,
|
|
|
- quantity: 3,
|
|
|
- couponDiscount: 20,
|
|
|
- couponType: "商家优惠券/平台优惠券",
|
|
|
- phone: "18900000000",
|
|
|
- estimatedIncome: 380
|
|
|
- };
|
|
|
-
|
|
|
- couponList.value = [
|
|
|
- {
|
|
|
- status: "1",
|
|
|
- code: "B844556562220"
|
|
|
- },
|
|
|
- {
|
|
|
- status: "2",
|
|
|
- code: "B844556562220",
|
|
|
- verifyTime: "2025/01/01 12:00:00"
|
|
|
- },
|
|
|
- {
|
|
|
- status: "3",
|
|
|
- code: "B844556562220",
|
|
|
- refundTime: "2025/01/01 12:00:00"
|
|
|
- }
|
|
|
- ];
|
|
|
+ const res: any = await queryUserOrderDetail({ orderId: id.value });
|
|
|
+ if (res.code === 200) {
|
|
|
+ formData.value = res.data;
|
|
|
+ couponList.value = groupByA(formData.value.orderCouponMiddleList) || [];
|
|
|
+ }
|
|
|
} catch (error) {
|
|
|
ElMessage.error("获取详情失败");
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+const groupByA = arr => {
|
|
|
+ // 创建一个映射表存储每个status值对应的条目
|
|
|
+ const map = {};
|
|
|
+
|
|
|
+ // 遍历原始数组
|
|
|
+ arr.forEach(item => {
|
|
|
+ // 从当前项中提取status字段
|
|
|
+ const { status, ...rest } = item;
|
|
|
+ // 如果当前status值在映射表中不存在,则创建一个新条目
|
|
|
+ if (!map[status]) {
|
|
|
+ map[status] = {
|
|
|
+ status: status,
|
|
|
+ list: []
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ // 将剩余的所有字段添加到对应status的list中
|
|
|
+ map[status].list.push(rest);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 将映射表的值转换为数组并返回
|
|
|
+ return Object.values(map);
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|