Commit f3db219d by liimin

refactor(mine): 重构订单相关页面和组件

- 更新 ORDER_LIST 常量,增加"全部"和"已完成"状态
- 调整订单状态码,使其与后端保持一致
- 优化订单列表组件,使用 filter 过滤无效状态
- 重构订单详情页面,提高代码可读性和维护性
- 统一使用 Object.freeze 冻结常量,防止意外修改
1 parent 526d78e1
...@@ -6,25 +6,33 @@ export const ToolList = Object.freeze([ ...@@ -6,25 +6,33 @@ export const ToolList = Object.freeze([
}, },
]); ]);
export const ORDER_LIST = Object.freeze([ export const ORDER_LIST =[
{ {
text: "待付款", text: "全部",
code: 0,
},
{
text: "待支付",
image: "noPay", image: "noPay",
code: 1, code: 1,
}, },
{ {
text: "待发货", text: "待发货",
image: "noTakeCommodity", image: "noTakeCommodity",
code: 3, code: 2,
}, },
{ {
text: "待收货", text: "待收货",
image: "takeCommodity", image: "takeCommodity",
code: 2, code: 3,
},
{
text: "已完成",
code: 4,
}, },
{ {
text: "退款/售后", text: "售后",
image: "aftermarket", image: "aftermarket",
code: 5, code: 5,
}, },
]);
\ No newline at end of file \ No newline at end of file
]
\ No newline at end of file \ No newline at end of file
...@@ -13,7 +13,7 @@ Component({ ...@@ -13,7 +13,7 @@ Component({
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
orderList: ORDER_LIST, orderList: Object.freeze(ORDER_LIST.filter((item) => item.image)),
}, },
/** /**
...@@ -22,10 +22,9 @@ Component({ ...@@ -22,10 +22,9 @@ Component({
methods: { methods: {
goOrder(e) { goOrder(e) {
// 直接使用 ORDER_LIST 中的索引作为 tabIndex // 直接使用 ORDER_LIST 中的索引作为 tabIndex
const tabIndex = e.currentTarget.dataset.index || 0; const code = e.currentTarget.dataset.code;
wx.p.router.go("/packageMine/pages/order/index/index", { wx.p.router.go("/packageMine/pages/order/index/index", {
tabIndex, code,
}); });
}, },
}, },
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<view class="order-box box"> <view class="order-box box">
<view class="title"> <view class="title">
我的订单 我的订单
<view class="edit" bindtap="goOrder" data-index="0"> <view class="edit" bindtap="goOrder">
全部 全部
<view class="arrow"> <view class="arrow">
<glsx-image webp src="mine/right.png"></glsx-image> <glsx-image webp src="mine/right.png"></glsx-image>
...@@ -10,13 +10,13 @@ ...@@ -10,13 +10,13 @@
</view> </view>
</view> </view>
<view class="btnBox"> <view class="btnBox">
<view class="independentBox" wx:for="{{orderList}}" wx:for-index="index" wx:for-item="item" wx:key="index" wx:if="{{index > 0}}"> <view class="independentBox" wx:for="{{orderList}}" wx:key="index">
<view bindtap="goOrder" data-code="{{item.code}}" data-index="{{index}}"> <view bindtap="goOrder" data-code="{{item.code}}">
<view class="order-img"> <view class="order-img">
<glsx-image webp src="mine/{{item.image}}.png"></glsx-image> <glsx-image webp src="mine/{{item.image}}.png"></glsx-image>
</view> </view>
<text class="order-content">{{item.text}}</text> <text class="order-content">{{item.text}}</text>
<text class="order-number" wx:if="{{orderNumberList[index-1] != 0 && orderNumberList}}">{{orderNumberList[index-1]}}</text> <text class="order-number" wx:if="{{orderNumberList[index] != 0 && orderNumberList}}">{{orderNumberList[index]}}</text>
</view> </view>
</view> </view>
</view> </view>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!