Commit 0b229cfd by liimin

refactor(order): 重构订单详情页面

- 移除 RefundStatus 组件中的冗余代码和样式
- 引入 Status 组件以简化退款状态展示
- 删除订单详情页面中的 mock 数据和相关逻辑
- 优化订单详情页面的加载流程
1 parent cb134b98
{ {
"component": true, "component": true,
"usingComponents": { "usingComponents": {
"glsx-image": "/components/image/index" "glsx-image": "/components/image/index",
"Status":"../../../components/Status/Status"
} }
} }
\ No newline at end of file \ No newline at end of file
<view class="status-box">
<!-- 退款状态1:待处理,2待发货,3待确认收到退货,4:退款中,5:已退款,6:退款失败,7:审核不通过 -->
<view class="icon">
<glsx-image webp src="{{refund.image}}"></glsx-image>
</view>
<view class="box-info">
<view class="title">{{refund.title}}</view>
<view class="tips">{{refund.tips}}</view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
<Status image="{{refund.image}}" title="{{refund.title}}" tips="{{refund.tips}}"/>
\ No newline at end of file \ No newline at end of file
.status-box {
display: flex;
justify-content: flex-start;
align-items: center;
gap: 24rpx;
margin-bottom: 32rpx;
}
.status-box .icon {
width: 80rpx;
height: 80rpx;
}
.status-box .box-info .title {
font-size: 40rpx;
font-weight: 500;
color: #282829;
}
.status-box .box-info .tips {
font-size: 28rpx;
font-weight: 400;
color: #656566;
}
\ No newline at end of file \ No newline at end of file
import { RefundStatus } from "~/constants/mine.js";
Component({
properties: {
title: {
type: String,
value: ""
},
tips: {
type: String,
value: ""
},
image: {
type: String,
value: ""
}
}
});
{
"component": true,
"usingComponents": {
"glsx-image": "/components/image/index"
}
}
\ No newline at end of file \ No newline at end of file
<view class="status-box">
<view class="icon">
<glsx-image webp src="{{image}}"></glsx-image>
</view>
<view class="box-info">
<view class="title">{{title}}</view>
<view class="tips">{{tips}}</view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
.status-box {
display: flex;
justify-content: flex-start;
align-items: center;
gap: 24rpx;
margin-bottom: 32rpx;
}
.status-box .icon {
width: 80rpx;
height: 80rpx;
}
.status-box .box-info .title {
font-size: 40rpx;
font-weight: 500;
color: #282829;
}
.status-box .box-info .tips {
font-size: 28rpx;
font-weight: 400;
color: #656566;
}
\ No newline at end of file \ No newline at end of file
...@@ -33,124 +33,16 @@ Page({ ...@@ -33,124 +33,16 @@ Page({
2: "已发货", 2: "已发货",
3: "已收货", 3: "已收货",
}, },
// Mock数据用于调试
mockOrderInfo: {
orderStatus: 5, // 已收货
orderSource: 1,
deliveryCompany: "顺丰快递",
deliveryNumber: "SF1234567890",
deliveryStatus: 3,
merchantName: "海马刀官方旗舰店",
activityBigImg: "https://picsum.photos/200/200",
activityName: "洗车服务券",
orderGoods: [
{
id: "106",
goodsImage: "https://picsum.photos/200/200",
goodsName: "洗车服务券",
specificationData: "1次洗车服务",
retailPrice: "299.00",
activityPrice: null,
goodsNumber: 1,
},
{
id: "107",
goodsImage: "https://picsum.photos/200/200?random=1",
goodsName: "打蜡服务券",
specificationData: "1次打蜡服务",
retailPrice: "199.00",
activityPrice: "159.00",
goodsNumber: 2,
},
],
time: "2023.05.20 12:00:00",
orderCode: "2023052012000001",
shipAddress: "广东省深圳市南山区科技园南区R2-B三楼301室",
outTradeNo: "PAY2023052012000001",
orderPrice: "798.00",
expressFee: "0.00",
payPrice: "699.00",
subOrderCoupon: {
denomination: true,
discountAmount: 10000, // 100元
},
relatedUserCoupon: [
{
discountType: 2,
useChannel: 1,
id: "coupon001",
receiveStartTime: "2023.05.01",
effectiveType: 1,
receiveEndTime: "2023.06.01 23:59:59",
},
],
deliveryType: 1,
orderVerification: {
verificationCode: "VERIFY2023052012000001",
},
},
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
// 使用mock数据进行调试 wx.p.router.getRouterParams(options).then(({ orderCode } = {}) => {
const useMockData = true; // 设置为true使用mock数据,设置为false使用真实接口 if (orderCode) {
this.getOrderDetail(orderCode);
if (useMockData) {
// 使用mock数据
let { orderObj, mockOrderInfo } = this.data;
// 格式化价格数据
mockOrderInfo.orderGoods.map((e) => {
e.retailPrice = Number(e.retailPrice).toFixed(2);
if (e.activityPrice)
e.activityPrice = Number(e.activityPrice).toFixed(2);
});
mockOrderInfo.orderPrice = Number(mockOrderInfo.orderPrice).toFixed(2);
mockOrderInfo.expressFee = Number(mockOrderInfo.expressFee).toFixed(2);
mockOrderInfo.payPrice = Number(mockOrderInfo.payPrice).toFixed(2);
// 根据订单来源调整订单信息
if (mockOrderInfo.orderSource == 4) {
orderObj[2] = {
label: "商户订单号",
key: "outTradeNo",
};
}
this.setData({
orderInfo: mockOrderInfo,
orderObj,
});
// 设置二维码
if (mockOrderInfo.deliveryType == 1 && mockOrderInfo.orderVerification)
this.setQr(mockOrderInfo.orderVerification.verificationCode);
// 处理优惠券数据
if (mockOrderInfo.relatedUserCoupon) {
let list = mockOrderInfo.relatedUserCoupon.map((item) => {
item.receiveStartTime = item.receiveStartTime;
if (item.effectiveType == 1) {
item.receiveEndTime = item.receiveEndTime;
} else {
item.receiveEndTime = item.receiveEndTime.split(' ')[0];
}
return item;
});
this.setData({
couponsList: list,
});
} }
} else { });
// 使用真实接口数据
wx.p.router.getRouterParams(options).then(({ orderCode } = {}) => {
if (orderCode) {
this.getOrderDetail(orderCode);
}
});
}
}, },
getOrderDetail(orderCode) { getOrderDetail(orderCode) {
let { orderObj } = this.data; let { orderObj } = this.data;
...@@ -237,4 +129,4 @@ Page({ ...@@ -237,4 +129,4 @@ Page({
qr: QR.createQrCodeImg(`t=1&c=${data}`), qr: QR.createQrCodeImg(`t=1&c=${data}`),
}); });
}, },
});
\ No newline at end of file \ No newline at end of file
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!