Commit 1020813d by liimin

refactor(order): 重构订单相关数据和逻辑

- 重构了订单状态常量,增加了更多订单状态枚举
- 更新了订单按钮逻辑,根据不同状态显示不同按钮
- 修改了订单列表数据结构,增加了更多订单状态字段
- 调整了订单列表组件,支持新的订单状态和按钮逻辑
- 移除了不必要的订单数量获取逻辑
1 parent 95344d0c
...@@ -6,36 +6,189 @@ export const ToolList = Object.freeze([ ...@@ -6,36 +6,189 @@ export const ToolList = Object.freeze([
}, },
]); ]);
export const ORDER_LIST = [ export const OrderStatusEnum = {
{ ALL: "0",
PAY_PENDING: "10000", //待支付
WAIT_DELIVER: "10001", //待发货
WAIT_RECEIVE: "10002", //待收货
COMPLETED: "10003", //已完成
AFTER_SALE: "10004", //售后 (没有这个状态 显示用)
AFTER_SALE_PENDING_REVIEW: "10005", //售后中 -待审核
AFTER_SALE_WAIT_RECEIVE: "10006", //售后中 -待收货(审核通过)
AFTER_SALE_REJECTED: "10007", //售后审核不通过
AFTER_SALE_REFUNDED: "10008", //已退款
AFTER_SALE_REFUNDED_FAILED: "10009", //退款失败
};
export const OrderStatusTypes = {
QUERY_TAB: "QUERY_TAB",// 查询订单列表TAB项
MY_ORDER: "MY_ORDER",// 我的 页面 我的订单 显示的项目
};
export const GoodsSource = {
YZH: 1, //云中鹤订单
SELF: 2, //自营订单
};
export const OrderActionButtons = {
AFTER_SALE: {
text: "售后",
type: "cancelOrder",
class: "btn",
handler: "onAfterSale",
},
CONFIRM_RECEIVE: {
text: "确认收货",
type: "confirmReceive",
class: "btn",
handler: "onConfirmReceive",
},
SHOW_EXPRESS: {
text: "查看物流",
type: "showExpress",
class: "btn",
handler: "onShowExpress",
},
AFTER_SALE_DETAIL: {
text: "售后详情",
type: "after_sale_detail",
class: "btn",
handler: "onAfterSaleDetail",
},
AFTER_SALE_REJECTED: {
text: "审核不通过",
type: "after_sale_rejected",
class: "btn",
handler: "onAfterSaleDetail",
},
};
export const ORDER_STATUS = {
[OrderStatusEnum.ALL]: {
text: "全部", text: "全部",
code: 0, status: OrderStatusEnum.ALL,
index: 0, // 查询订单列表TAB高亮的索引
requestType: 0, // 查询订单列表TAB查询参数
type: OrderStatusTypes.QUERY_TAB, // 查询订单列表显示的TAB项
}, },
{ [OrderStatusEnum.PAY_PENDING]: {
text: "待支付", text: "待支付",
image: "noPay", image: "noPay",
code: 1, status: OrderStatusEnum.PAY_PENDING,
index: 1, // 查询订单列表TAB高亮的索引
requestType: 2,// 查询订单列表TAB查询参数
buttons: null,
type: OrderStatusTypes.MY_ORDER,//我的 页面 我的订单 显示的项目
}, },
{ [OrderStatusEnum.WAIT_DELIVER]: {
text: "待发货", text: "待发货",
image: "noTakeCommodity", image: "noTakeCommodity",
code: 2, status: OrderStatusEnum.WAIT_DELIVER,
index: 2,// 查询订单列表TAB高亮的索引
requestType: 6,// 查询订单列表TAB查询参数
type: OrderStatusTypes.MY_ORDER,//我的 页面 我的订单 显示的项目
buttons: {
[GoodsSource.SELF]: [OrderActionButtons.AFTER_SALE], //自营商品 在商品列表对应的按钮
[GoodsSource.YZH]: [OrderActionButtons.AFTER_SALE],//云中鹤商品 在商品列表对应的按钮
}, },
{ },
[OrderStatusEnum.WAIT_RECEIVE]: {
text: "待收货", text: "待收货",
image: "takeCommodity", image: "takeCommodity",
code: 3, status: 1008,
}, index: 3,// 查询订单列表TAB高亮的索引
{ requestType: 1,// 查询订单列表TAB查询参数
type: OrderStatusTypes.MY_ORDER,//我的 页面 我的订单 显示的项目
buttons: {
[GoodsSource.SELF]: [//自营商品 在商品列表对应的按钮
OrderActionButtons.AFTER_SALE,
OrderActionButtons.CONFIRM_RECEIVE,
OrderActionButtons.SHOW_EXPRESS,
],
[GoodsSource.YZH]: [//云中鹤商品 在商品列表对应的按钮
OrderActionButtons.AFTER_SALE,
OrderActionButtons.CONFIRM_RECEIVE,
OrderActionButtons.SHOW_EXPRESS,
],
},
},
[OrderStatusEnum.COMPLETED]: {
text: "已完成", text: "已完成",
code: 4, status: OrderStatusEnum.COMPLETED,
}, index: 4,// 查询订单列表TAB高亮的索引
{ requestType: 4,// 查询订单列表TAB查询参数
text: "售后", type: OrderStatusTypes.QUERY_TAB,// 查询订单列表显示的TAB项
buttons: {
[GoodsSource.SELF]: [//自营商品 在商品列表对应的按钮
OrderActionButtons.SHOW_EXPRESS,
OrderActionButtons.AFTER_SALE,
],
[GoodsSource.YZH]: [//云中鹤商品 在商品列表对应的按钮
OrderActionButtons.SHOW_EXPRESS,
OrderActionButtons.AFTER_SALE,
],
},
},
[OrderStatusEnum.AFTER_SALE]: {
text: "退货/售后",
my_order_text: "售后",
image: "aftermarket", image: "aftermarket",
code: 5, status: OrderStatusEnum.AFTER_SALE,
}, index: 5,// 查询订单列表TAB高亮的索引
]; requestType: 3,// 查询订单列表TAB查询参数
buttons: null,
type: OrderStatusTypes.MY_ORDER,//我的 页面 我的订单 显示的项目
},
[OrderStatusEnum.AFTER_SALE_PENDING_REVIEW]: {
text: "售后中",
status: OrderStatusEnum.AFTER_SALE_PENDING_REVIEW,
tips: "您可以尝试再次提交退款申请", //售后详情提示语
image: "mine/order/error.png",//售后详情页面显示的状态图标
buttons: {
[GoodsSource.SELF]: [OrderActionButtons.AFTER_SALE_DETAIL],//自营商品 在商品列表对应的按钮
[GoodsSource.YZH]: [OrderActionButtons.AFTER_SALE_DETAIL],//云中鹤商品 在商品列表对应的按钮
},
},
[OrderStatusEnum.AFTER_SALE_WAIT_RECEIVE]: {
text: "售后中",
status: OrderStatusEnum.AFTER_SALE_WAIT_RECEIVE,
tips: "您可以尝试再次提交退款申请", //售后详情提示语
image: "mine/order/error.png",//售后详情页面显示的状态图标
buttons: {
[GoodsSource.SELF]: [OrderActionButtons.AFTER_SALE_DETAIL],//自营商品 在商品列表对应的按钮
[GoodsSource.YZH]: [OrderActionButtons.AFTER_SALE_DETAIL],//云中鹤商品 在商品列表对应的按钮
},
},
[OrderStatusEnum.AFTER_SALE_REJECTED]: {
text: "审核不通过",
status: OrderStatusEnum.AFTER_SALE_REJECTED,
tips: "您可以尝试再次提交退款申请",//售后详情提示语
image: "mine/order/error.png",//售后详情页面显示的状态图标
buttons: {
[GoodsSource.SELF]: [OrderActionButtons.AFTER_SALE_REJECTED],//自营商品 在商品列表对应的按钮
[GoodsSource.YZH]: [OrderActionButtons.AFTER_SALE_REJECTED],//云中鹤商品 在商品列表对应的按钮
},
},
[OrderStatusEnum.AFTER_SALE_REFUNDED]: {
text: "已退款",
status: OrderStatusEnum.AFTER_SALE_REFUNDED,
tips: "您可以尝试再次提交退款申请",//售后详情提示语
image: "mine/order/error.png",//售后详情页面显示的状态图标
buttons: {
[GoodsSource.SELF]: [OrderActionButtons.AFTER_SALE_DETAIL],//自营商品 在商品列表对应的按钮
[GoodsSource.YZH]: [OrderActionButtons.AFTER_SALE_DETAIL],//云中鹤商品 在商品列表对应的按钮
},
},
[OrderStatusEnum.AFTER_SALE_REFUNDED_FAILED]: {
text: "退款失败",
status: OrderStatusEnum.AFTER_SALE_REFUNDED_FAILED,
tips: "您可以尝试再次提交退款申请",//售后详情提示语
image: "mine/order/error.png",//售后详情页面显示的状态图标
buttons: {
[GoodsSource.SELF]: [OrderActionButtons.AFTER_SALE_DETAIL],//自营商品 在商品列表对应的按钮
[GoodsSource.YZH]: [OrderActionButtons.AFTER_SALE_DETAIL],//云中鹤商品 在商品列表对应的按钮
},
},
};
export const RefundReason = [ export const RefundReason = [
{ {
...@@ -214,60 +367,60 @@ export const OrderStatus = [ ...@@ -214,60 +367,60 @@ export const OrderStatus = [
title: "待付款", title: "待付款",
value: "1", value: "1",
image: "mine/order-wait.png", image: "mine/order-wait.png",
tips:'待付款' tips: "待付款",
}, },
{ {
title: "已支付", title: "已支付",
value: "2", value: "2",
image: "mine/order-receiving.png", image: "mine/order-receiving.png",
tips:'已支付' tips: "已支付",
}, },
{ {
title: "已关闭", title: "已关闭",
value: "3", value: "3",
image: "mine/order-close.png", image: "mine/order-close.png",
tips:'已关闭' tips: "已关闭",
}, },
{ {
title: "已发货", title: "已发货",
value: "4", value: "4",
image: "mine/order-receiving.png", image: "mine/order-receiving.png",
tips:'已发货' tips: "已发货",
}, },
{ {
title: "已收货", title: "已收货",
value: "5", value: "5",
image: "mine/order-success.png", image: "mine/order-success.png",
tips:'已收货' tips: "已收货",
}, },
{ {
title: "待发货", title: "待发货",
value: "6", value: "6",
image: "mine/order-wait.png", image: "mine/order-wait.png",
tips:'待发货' tips: "待发货",
}, },
{ {
title: "待安装", title: "待安装",
value: "7", value: "7",
image: "mine/order-wait.png", image: "mine/order-wait.png",
tips:'待安装' tips: "待安装",
}, },
{ {
title: "已安装", title: "已安装",
value: "8", value: "8",
image: "mine/order-success.png", image: "mine/order-success.png",
tips:'已安装' tips: "已安装",
}, },
{ {
title: "售后中", title: "售后中",
value: "9", value: "9",
image: "mine/order-wait.png", image: "mine/order-wait.png",
tips:'售后中' tips: "售后中",
}, },
{ {
title: "售后完成", title: "售后完成",
value: "10", value: "10",
image: "mine/order-close.png", image: "mine/order-close.png",
tips:'售后完成' tips: "售后完成",
}, },
]; ];
...@@ -35,12 +35,16 @@ const GoodsSource ={ ...@@ -35,12 +35,16 @@ const GoodsSource ={
'SELF':2 'SELF':2
}; };
// const ActionMaps = { const ActionMaps = {
// [GoodsSource.SELF]:[ [GoodsSource.SELF]:{
// {text: '核验', type: 'verification', class: 'btn', handler: this.onVerification.bind(this)}
// ]
// };
},
[GoodsSource.YZH]:{
}
};
import { ORDER_STATUS , OrderStatusEnum} from "~/constants/mine.js";
Component({ Component({
/** /**
* 组件的属性列表 * 组件的属性列表
...@@ -49,9 +53,10 @@ Component({ ...@@ -49,9 +53,10 @@ Component({
item: { item: {
type: Object, type: Object,
value: {}, value: {},
observer: function () { observer: function (d) {
console.log(d)
// 当item变化时重新计算按钮 // 当item变化时重新计算按钮
this.updateButtons(); d?.id && this.updateButtons();
}, },
}, },
hasUserInfo: { hasUserInfo: {
...@@ -59,7 +64,7 @@ Component({ ...@@ -59,7 +64,7 @@ Component({
value: false, value: false,
observer: function () { observer: function () {
// 当hasUserInfo变化时重新计算按钮 // 当hasUserInfo变化时重新计算按钮
this.updateButtons(); // this.updateButtons();
}, },
}, },
}, },
...@@ -76,6 +81,33 @@ Component({ ...@@ -76,6 +81,33 @@ Component({
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
orderStatus(){
//订单状态 orderStatus (1001:待支付 1002:待审核,1003:审核不通过,1004:已取消(交易失败) ,1005:订单异常,1006:待处理,1007: 待发货,1008:已发货,1009:已完成(交易成功),1010:售后处理中,1012 订单关闭
//退换货状态 returnStatus (1000:待审核,1001:待收货,1002:已收货,1003:已退款,1004:已生成新订单,1005:已取消,1006:退款异常,1007:商品退回,1008:审核不通过,1010:换货新订单待收货,1011:换货新订单已签收)
//退款状态 refundStatus (1000:待审核,1001:待退款,1002:已退款,1003:已取消,1004:退款异常,1005:审核不通过)
//订单取消状态 cancelStatus(1000:取消成功,1010:取消审核中)
//退款状态 returnOrderStatus(1000:待审核,1001:审核通过,1002:已收货,1003:已退款,1004:已生成新订单,1005:审核不通过)
//goodsSource 1.云中鹤 2.平台商品
console.log(this.data.item)
const {orderStatus,goodsSource,cancelStatus,returnStatus,refundStatus,returnOrderStatus} = this.data.item
if([1002,1006,1007].includes(orderStatus) && (!cancelStatus || cancelStatus==1010)) {
return OrderStatusEnum.WAIT_DELIVER //待发货 order_status属于(1002,1006,1007)且cancel_status不存在或者审核中(1010)
} else if(orderStatus==1008 && (!cancelStatus || cancelStatus==1010)){
return OrderStatusEnum.WAIT_RECEIVE //待收货 order_status属于(1008)且cancel_status不存在或者审核中(1010)
} else if (orderStatus==1009 && (!cancelStatus || cancelStatus==1010)){
return OrderStatusEnum.COMPLETED //已完成 order_status属于(1009)且cancel_status不存在或者审核中(1010)
} else if((returnOrderStatus==1000 && returnStatus==1000) || (returnOrderStatus==1000 && refundStatus==1000)){
return OrderStatusEnum.AFTER_SALE_PENDING_REVIEW //售后---待审核 退款退货的return_order_status:1000:待审批且return_status退换货状态(1000:待审核) 仅退款的return_order_status:1000:待审批且refund_status 退款状态(1000:待审核
} else if(returnOrderStatus==1001 && returnStatus==1001){
return OrderStatusEnum.AFTER_SALE_WAIT_RECEIVE//售后---待收货(审核通过) 退款退货的return_order_status:1001:审核通过 且return_status退换货状态(1001:待收货),仅退款的直接到退款完成/退款失败
} else if((returnOrderStatus==1005 && returnStatus==1008) || (returnOrderStatus==1005 && refundStatus==1008)){
return OrderStatusEnum.AFTER_SALE_REJECTED //售后 -- 审核不通过 退款退货的return_order_status:1005:审核不通过且return_status退换货状态(1008:审核不通过), 仅退款的return_order_status:1005 且refund_status 退款状态(1008:审核不通过
} else if((returnOrderStatus==1003 && [1002,1003].includes(returnStatus))|| (returnOrderStatus==1003 && refundStatus==1002)){
return OrderStatusEnum.AFTER_SALE_REFUNDED // 已退款 退款退货的订单return_order_status:1003:已退款且return_status退换货状态(1002:已收货,1003:已退款),仅退款订单 return_order_status:1003:已退款且refund_status 退款状态1002:已退款,
} else if((returnOrderStatus==1003 && returnStatus==1006) || (returnOrderStatus==1003 && refundStatus==1004)){
return OrderStatusEnum.AFTER_SALE_REFUNDED_FAILED // 退款失败 退款退货的return_order_status:1003:已退款 return_status退换货状态(1006:退款异常 ,,仅退款的return_order_status:1003:已退款 且refund_status 退款状态,1004:退款异常
}
},
// 获取当前订单应该显示的按钮 // 获取当前订单应该显示的按钮
getButtons() { getButtons() {
const { item, hasUserInfo } = this.data; const { item, hasUserInfo } = this.data;
...@@ -173,9 +205,9 @@ Component({ ...@@ -173,9 +205,9 @@ Component({
) { ) {
buttons.push({ buttons.push({
text: "确认收货", text: "确认收货",
type: "confirmReceipt", type: "confirmReceive",
class: "btn confirm", class: "btn confirm",
handler: this.onConfirmReceipt.bind(this), handler: this.onConfirmReceive.bind(this),
}); });
} }
...@@ -260,7 +292,7 @@ Component({ ...@@ -260,7 +292,7 @@ Component({
// 更新按钮 // 更新按钮
updateButtons() { updateButtons() {
const buttons = this.getButtons(); const buttons = ORDER_STATUS[this.orderStatus()].buttons[2]//this.getButtons();
this.setData({ this.setData({
buttons, buttons,
orderItem: this.data.item, orderItem: this.data.item,
...@@ -368,7 +400,7 @@ Component({ ...@@ -368,7 +400,7 @@ Component({
}, },
// 确认收货 // 确认收货
onConfirmReceipt(e) { onConfirmReceive(e) {
let { orderCode } = let { orderCode } =
e.currentTarget.dataset.item || e.currentTarget.dataset; e.currentTarget.dataset.item || e.currentTarget.dataset;
wx.showModal({ wx.showModal({
......
// pages/tab/mine/components/myOrder/myOrder.js // pages/tab/mine/components/myOrder/myOrder.js
import { ORDER_LIST } from '~/constants/mine.js'; import { ORDER_STATUS, OrderStatusTypes } from "~/constants/mine.js";
Component({ Component({
/** /**
...@@ -13,7 +13,20 @@ Component({ ...@@ -13,7 +13,20 @@ Component({
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
orderList: Object.freeze(ORDER_LIST.filter((item) => item.image)), orderList: Object.freeze(
Object.values(ORDER_STATUS).filter(
(item) => item.type == OrderStatusTypes.MY_ORDER
)
),
},
/**
* 组件生命周期
*/
lifetimes: {
attached() {
// 获取订单状态对应的图片
this.getOrderNumberList();
},
}, },
/** /**
...@@ -22,9 +35,24 @@ Component({ ...@@ -22,9 +35,24 @@ Component({
methods: { methods: {
goOrder(e) { goOrder(e) {
// 直接使用 ORDER_LIST 中的索引作为 tabIndex // 直接使用 ORDER_LIST 中的索引作为 tabIndex
const code = e.currentTarget.dataset.code; const index = e.currentTarget.dataset.index;
wx.p.router.go("/packageMine/pages/order/index/index", { wx.p.router.go("/packageMine/pages/order/index/index", {
code, index,
});
},
getOrderNumberList() {
const loginStatus = !wx.p.isLogin;
if (loginStatus) return;
wx.p.api.mineApi.getOrderNumberList().then((res) => {
this.setData({
orderNumberList: [
res.unPayCount,
res.unShippedCount,
res.unReceivedCount,
res.unServiceCount,
],
});
}); });
}, },
}, },
......
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
</view> </view>
<view class="btnBox"> <view class="btnBox">
<view class="independentBox" wx:for="{{orderList}}" wx:key="index"> <view class="independentBox" wx:for="{{orderList}}" wx:key="index">
<view bindtap="goOrder" data-code="{{item.code}}"> <view bindtap="goOrder" data-index="{{item.index}}">
<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.my_order_text||item.text}}</text>
<text class="order-number" wx:if="{{orderNumberList[index] != 0 && orderNumberList}}">{{orderNumberList[index]}}</text> <text class="order-number" wx:if="{{orderNumberList[index] != 0 && orderNumberList}}">{{orderNumberList[index]}}</text>
</view> </view>
</view> </view>
......
...@@ -94,20 +94,7 @@ Page({ ...@@ -94,20 +94,7 @@ Page({
} = e.currentTarget.dataset; } = e.currentTarget.dataset;
wx.p.router.go(url); wx.p.router.go(url);
}, },
async getOrderNumberList() {
const loginStatus = !wx.p.isLogin
if (loginStatus) return;
wx.p.api.mineApi.getOrderNumberList().then((res) => {
this.setData({
orderNumberList: [
res.unPayCount,
res.unShippedCount,
res.unReceivedCount,
res.unServiceCount,
],
});
});
},
// 获取用户会员信息 // 获取用户会员信息
toCheckMember() { toCheckMember() {
// wx.p.router.intercept(false).then((sid) => { // wx.p.router.intercept(false).then((sid) => {
...@@ -147,7 +134,7 @@ Page({ ...@@ -147,7 +134,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
this.getOrderNumberList(); // this.getOrderNumberList();
this.toCheckMember(); // this.toCheckMember();
}, },
}); });
\ 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!