Commit ab7042cc by liimin

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

- 移除了订单列表和售后订单列表中的 pageSize 参数
- 更新了 Popup 组件,增加了 showConfirm 属性
- 重构了订单状态和售后状态的处理逻辑
- 优化了订单详情和售后详情页面的结构
- 统一了物流信息的展示方式
- 调整了订单状态的样式
1 parent c6fa382a
......@@ -5,7 +5,6 @@ module.exports = {
getOrderList(data) {
return api.post({
method: `scrm.api.shopmall.platform.order.page`,
pageSize: 99999,
...data
})
},
......@@ -13,7 +12,6 @@ module.exports = {
getSalesOrderList(data) {
return api.post({
method: `scrm.api.shopmall.platform.after.sales.order.page`,
pageSize: 99999,
...data
})
},
......
......@@ -50,6 +50,10 @@ Component({
type: String,
value: ''
},
showConfirm:{
type: Boolean,
value: true
}
},
/**
......
......@@ -13,7 +13,7 @@
</view>
<view class="popup-footer isFullSucreen" wx:if="{{showFooter}}">
<view class="cancel btn text-center" wx:if="{{only}}" bindtap="hidePopup">取消</view>
<view class="confirm {{only?'btn':'doubtn'}} text-center" bindtap="confirm">确定</view>
<view class="confirm {{only?'btn':'doubtn'}} text-center" wx:if="{{showConfirm}}" bindtap="confirm">确定</view>
</view>
</view>
</view>
\ No newline at end of file
import {
getAfterSaleDetail,
calcOrderProp,
getOrder,
API_Methods,
APIS,
} from "~/packageMine/pages/order/utils";
import { ORDER_STATUS, OrderStatusEnum } from "~/constants/mine.js";
Page({
......@@ -33,9 +36,9 @@ Page({
getOrderAfterSaleDetail() {
wx.p.wxApi.showLoading("加载中...");
let { goodsSource, tparReturnOrderCode, subOrderCode, goodsSkuCode } =
this.data,
Methods = goodsSource == 2 ? "afterSaleDetail" : "platformSaleDetail";
wx.p.api.shopmallApi[Methods]({
this.data;
// Methods = goodsSource == 2 ? "afterSaleDetail" : "platformSaleDetail";
API_Methods[goodsSource][APIS.AFTER_SALE_DETAIL]({
subOrderCode,
tparReturnOrderCode,
goodsSkuCode,
......@@ -49,9 +52,9 @@ Page({
// } else if (res.returnOrderStatus == 1005 || (res.returnOrderStatus == 1003 && res.outRefundType == 3) || (res.returnOrderStatus == 1003 && res.outRefundType == 1)) {
// status = 2
// }
const { returnOrderStatus } = res;
const status = getAfterSaleDetail({ returnOrderStatus });
const button = status.buttons?.[goodsSource][0];
// const { returnOrderStatus } = res;
const status = getOrder(res); //getAfterSaleDetail({ returnOrderStatus });
const button = status.detail.buttons?.[goodsSource][0]; //status.buttons?.[goodsSource][0];
// button.action = this[button.handler]
let str = "";
if (res.sendbackAddressModel) {
......@@ -81,13 +84,13 @@ Page({
// }
// this.cancelSaleApply()
// console.log('this.button', this.data.button)
this[this.data.button.handler]()
this[this.data.button.handler]();
// this.toAfterSale();
},
toAfterSale() {
const { orderInfo } = this.data;
const { orderGoods, imgUrlList,...rest } = orderInfo;
const order = Object.assign({imgList:imgUrlList}, orderGoods, rest);
const { orderGoods, imgUrlList, ...rest } = orderInfo;
const order = Object.assign({ imgList: imgUrlList }, orderGoods, rest);
wx.p.router.go(
"/packageMine/pages/order/afterSale_step_two/afterSale_step_two",
order
......
<block wx:if="{{orderInfo}}">
<view class="layout isFullSucreen">
<!-- 退款状态组件 -->
<refund-status status="{{status}}"></refund-status>
<refund-status status="{{status.detail}}"></refund-status>
<!-- 退货地址和物流信息组件 -->
<block wx:if="{{orderInfo.returnOrderStatus==1001}}">
<return-address-box order-info="{{orderInfo}}"/>
......
......@@ -55,5 +55,7 @@
</view>
</view>
<mp-actionSheet bindactiontap="onSelectExpress" show="{{isShowExpressSelector}}" actions="{{expressList}}" ext-class="express-wrap" title="选择快递公司">
</mp-actionSheet>
\ No newline at end of file
<!-- <mp-actionSheet bindactiontap="onSelectExpress" show-cancel="{{true}}" show="{{isShowExpressSelector}}" actions="{{expressList}}" ext-class="express-wrap" title="选择快递公司">
</mp-actionSheet> -->
<popup show="{{isShowExpressSelector}}" show-close-button="{{true}}" showConfirm="{{false}}" showFooter="{{true}}" headerColor="#F7F7F7" title="选择快递公司">
</popup>
\ No newline at end of file
......@@ -5,11 +5,7 @@ import {
ORDER_STATUS,
OrderStatusEnum,
} from "~/constants/mine.js";
import { calcOrderProp } from "~/packageMine/pages/order/utils";
const Methods = {
[GoodsSource.YZH]: wx.p.api.shopmallApi.afterSalesPlatform,
[GoodsSource.SELF]: wx.p.api.shopmallApi.afterSale,
};
import { calcOrderProp,API_Methods,APIS } from "~/packageMine/pages/order/utils";
Page({
behaviors: [afterSaleMixin],
/**
......@@ -18,7 +14,7 @@ Page({
data: {
RefundReason: Object.freeze(RefundReason),
method: null,
imagesMax: 9,
imagesMax: 5,
},
/**
* 生命周期函数--监听页面加载
......@@ -29,7 +25,7 @@ Page({
const { goodsSource, tparReturnOrderCode, subOrderCode, goodsSkuCode } =
orderObj;
this.setData({
method: Methods[orderObj.goodsSource],
method: API_Methods[orderObj.goodsSource][APIS.AFTER_SALE],
});
if (tparReturnOrderCode) {
this.getOrderAfterSaleDetail(
......@@ -157,8 +153,8 @@ Page({
cb
) {
wx.p.wxApi.showLoading("加载中...");
const Methods = goodsSource == 2 ? "afterSaleDetail" : "platformSaleDetail";
wx.p.api.shopmallApi[Methods]({
// const Methods = goodsSource == 2 ? "afterSaleDetail" : "platformSaleDetail";
API_Methods[goodsSource][APIS.AFTER_SALE_DETAIL]({
subOrderCode,
tparReturnOrderCode,
goodsSkuCode,
......
......@@ -15,7 +15,7 @@ Component({
this.processExpressInfo(val);
},
},
showExpress: {
showAll: {
type: Boolean,
value: false,
},
......@@ -57,9 +57,11 @@ Component({
},
methods: {
processShipmentTrack(shipmentTrack, logisticsStatus) {
if (!this.data.showExpress) {
shipmentTrack = shipmentTrack ? shipmentTrack.slice(0, 2) : [];
if (!shipmentTrack || !shipmentTrack.length) return;
if (!this.data.showAll) {
shipmentTrack = shipmentTrack.slice(0, 2);
}
console.log("🚀 ~ processShipmentTrack ~ shipmentTrack:", shipmentTrack);
return shipmentTrack
.map((track, index) => {
let status = 1000;
......
......@@ -2,6 +2,6 @@
<view class="popup-content">
<Expressage expressInfo="{{expressInfo}}"></Expressage>
<view class="line"></view>
<Express expressInfo="{{expressInfo}}" showExpress="{{showExpress}}" />
<Express expressInfo="{{expressInfo}}" showAll="{{true}}" />
</view>
</popup>
\ No newline at end of file
......@@ -6,8 +6,8 @@
}
.status-box .icon {
width: 80rpx;
height: 80rpx;
width: 64rpx;
height: 64rpx;
}
.status-box .box-info .title {
......@@ -17,7 +17,7 @@
}
.status-box .box-info .tips {
font-size: 28rpx;
font-size: 24rpx;
font-weight: 400;
color: #656566;
}
\ No newline at end of file
import {
orderMixin
} from "~/mixins/index";
import {
OrderStatus
} from "~/constants/mine.js";
import { orderMixin } from "~/mixins/index";
// import { OrderStatus } from "~/constants/mine.js";
import { getOrder } from "~/packageMine/pages/order/utils";
Page({
behaviors: [orderMixin],
/**
* 页面的初始数据
*/
data: {
OrderStatus,
// OrderStatus,
expressInfo: {
"orderCode": "295057717192728657",
"expressCode": "yuantong",
"expressName": "圆通速递",
"shipmentCode": "1231231231dfsdgs",
"logisticsStatus": 1003,
"shipmentItems": [{
"goodsSkuCode": "1125899906842634",
"goodsSkuName": "松下家用微电脑电饭煲SR-MGT108可预约1-4人多功能煮饭电饭锅3L SR-MGT108 银色 ",
"qty": 1
}],
"shipmentTrack": [{
"content": "已签收,签收人凭取货码签收。",
"operateTime": "2019-10-21 17:59:18",
"operator": "Operator"
},
{
"content": "快件已暂存至武汉世界城加州阳光步行街店菜鸟驿站,如有疑问请联系18771141749",
"operateTime": "2019-10-21 13:12:02",
"operator": "Operator"
},
{
"content": "湖北武汉关南公司-朱杰(15172337939,027-59401618)-派件中",
"operateTime": "2019-10-21 11:14:08",
"operator": "Operator"
},
{
"content": "已到达-湖北武汉关南公司",
"operateTime": "2019-10-21 10:29:08",
"operator": "Operator"
},
{
"content": "已到达-湖北武汉关南公司",
"operateTime": "2019-10-21 06:54:16",
"operator": "Operator"
},
{
"content": "湖北武昌转运中心-已发往-湖北武汉关南公司",
"operateTime": "2019-10-20 23:16:43",
"operator": "Operator"
},
{
"content": "已到达-湖北武昌转运中心",
"operateTime": "2019-10-20 23:03:58",
"operator": "Operator"
},
{
"content": "广东深圳福田转运中心-已装袋发往-湖北武昌转运中心",
"operateTime": "2019-10-20 01:29:50",
"operator": "Operator"
},
{
"content": "广东深圳福田转运中心-已进行装车扫描",
"operateTime": "2019-10-20 01:29:50",
"operator": "Operator"
},
{
"content": "广东深圳福田转运中心-已发往-湖北武昌转运中心",
"operateTime": "2019-10-19 23:40:20",
"operator": "Operator"
},
{
"content": "广东深圳福田转运中心-已进行装袋扫描",
"operateTime": "2019-10-19 23:40:20",
"operator": "Operator"
},
{
"content": "已到达-广东深圳福田转运中心",
"operateTime": "2019-10-19 23:22:17",
"operator": "Operator"
},
{
"content": "广东宝安凤凰营业厅-已发往-广东深圳福田转运中心",
"operateTime": "2019-10-19 21:00:33",
"operator": "Operator"
},
{
"content": "广东宝安凤凰营业厅-冯凯(时光漫步)-已收件",
"operateTime": "2019-10-19 20:57:56",
"operator": "Operator"
}
]
}, //物流信息
isShowExpressPop: false,
deliveryStatus: {
......@@ -105,45 +22,34 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.p.router.getRouterParams(options).then(params => {
if (params.item) {
wx.p.router.getRouterParams(options).then((params) => {
const orderObj = params.item;
if (orderObj) {
//物流信息
this.queryLogistics(orderObj.subOrderCode);
this.getOrderDetail(orderObj.subOrderCode);
const order = getOrder(orderObj);
// 订单信息
this.setData({
orderInfo: params.item
})
//物流信息
this.queryLogistics()
//用来获取发货信息
this.getOrderDetail(params.item.subOrderCode);
orderInfo: orderObj,
Status: order.detail,
});
}
// this.setData({
// Status: OrderStatus[this.data.orderInfo.orderStatus],
// });
});
},
queryLogistics() {
let {
subOrderCode
} = this.data.orderInfo
let params = {
subOrderCode,
}
wx.p.api.shopmallApi.queryLogistics(params).then((data) => {
console.log(data, '物流信息')
queryLogistics(subOrderCode) {
wx.p.api.shopmallApi.queryLogistics({ subOrderCode }).then((data) => {
console.log(data, "物流信息");
this.setData({
expressInfo: data
})
})
expressInfo: data,
});
});
},
getOrderDetail(orderCode) {
let {
orderInfo
} = this.data;
getOrderDetail(subOrderCode) {
wx.p.wxApi.showLoading("加载中...");
let params = {
subOrderCode: orderCode
}
wx.p.api.shopmallApi.getOrderDetail(params).then((data) => {
wx.p.api.shopmallApi.getOrderDetail({ subOrderCode }).then((data) => {
console.log("🚀 ~ getOrderDetail ~ this.data.orderInfo:", this.data.orderInfo)
console.log("🚀 ~ getOrderDetail ~ data:", data)
wx.hideLoading();
let {
provinceName,
......@@ -151,21 +57,21 @@ Page({
countyName,
address,
receiveName,
receiveMobile
} = data.receiveAddress
receiveMobile,
} = data.receiveAddress;
this.setData({
orderInfo: {
...data,
...orderInfo,
...this.data.orderInfo,
receiveAddress: provinceName + cityName + countyName + address,
receviveInfo: receiveName + receiveMobile
}
})
receviveInfo: receiveName + receiveMobile,
},
});
});
},
showExpressPop() {
this.setData({
isShowExpressPop: true,
});
}
});
\ No newline at end of file
},
});
<block wx:if="{{orderInfo}}">
<view class="layout">
<!-- <BlockBox>
<Status title="{{Status.title}}" image="{{Status.image}}" tips="{{Status.tips}}"></Status>
</BlockBox> -->
<BlockBox>
<Status title="{{Status.text}}" image="{{Status.image}}" tips="{{Status.tips}}"></Status>
</BlockBox>
<!-- 云中鹤的有物流信息 -->
<BlockBox wx:if="{{orderInfo.goodsSource==1||!orderInfo.goodsSource}}">
<view class="express-box" bindtap="showExpressPop" wx:if="{{expressInfo &&expressInfo.shipmentTrack&&expressInfo.shipmentTrack.length}}">
<BlockBox wx:if="{{(orderInfo.goodsSource==1||!orderInfo.goodsSource) && expressInfo &&expressInfo.shipmentTrack&&expressInfo.shipmentTrack.length}}">
<view class="express-box" bindtap="showExpressPop">
<view class="express-detail">
物流详情
<mp-icon icon="arrow" color="var(--btnColor)" size="{{11}}"></mp-icon>
</view>
<Express expressInfo="{{expressInfo}}" />
<Express expressInfo="{{expressInfo}}" showAll="{{false}}" />
</view>
<WaitDeliver wx:else></WaitDeliver>
</BlockBox>
<!-- 自营商品展示快递信息 -->
<BlockBox wx:if="{{orderInfo.goodsSource==2}}">
<Expressage expressInfo="{{expressInfo}}" wx:if="{{expressInfo && expressInfo.shipmentTrack&&expressInfo.shipmentTrack.length}}"></Expressage>
<WaitDeliver wx:else></WaitDeliver>
<BlockBox wx:if="{{orderInfo.goodsSource==2 && expressInfo}}">
<Expressage expressInfo="{{expressInfo}}"></Expressage>
</BlockBox>
<BlockBox>
<DeliveryInfo orderInfo="{{orderInfo}}" deliveryStatus="{{deliveryStatus}}"></DeliveryInfo>
......
......@@ -152,11 +152,13 @@ Page({
keyword,
} = this.data;
const userInfo = wx.p.storage.get("userInfo") || {};
let { merchantId } = userInfo;
let { merchantId,channelSource } = userInfo;
let obj = {
requestType,
merchantId,
pageSize: 99999,
currentPage: pageNum,
scoreSource:channelSource
};
if (keyword) {
keyword = keyword.replace(/\ /g, "");
......
......@@ -3,6 +3,7 @@ import {
ORDER_STATUS,
AFTER_SALE_STATUS,
AfterSaleStatusEnum,
GoodsSource,
} from "~/constants/mine.js";
export function getOrderStatus({
orderStatus,
......@@ -72,32 +73,32 @@ export function getOrder(orderStatus) {
return ORDER_STATUS[_status_] || {};
}
export function getAfterSaleStatus({ returnOrderStatus } = {}) {
if (returnOrderStatus == 1000) {
// 按钮:售后详情
return AfterSaleStatusEnum.PENDING_REVIEW; //售后---待审核 退款退货的return_order_status:1000:待审批且return_status退换货状态(1000:待审核) 仅退款的return_order_status:1000:待审批且refund_status 退款状态(1000:待审核
} else if (returnOrderStatus == 1001) {
// 按钮:售后详情
return AfterSaleStatusEnum.PENDING_REVIEW_PASSED; //售后---待收货(审核通过) 退款退货的return_order_status:1001:审核通过 且return_status退换货状态(1001:待收货),仅退款的直接到退款完成/退款失败
} else if (returnOrderStatus == 1005) {
// 状态:售后前的状态(云中鹤不同意售后申请)按钮:售后、售后详情
return AfterSaleStatusEnum.PENDING_REVIEW_REJECTED; //售后 -- 审核不通过 退款退货的return_order_status:1005:审核不通过且return_status退换货状态(1008:审核不通过), 仅退款的return_order_status:1005 且refund_status 退款状态(1008:审核不通过
} else if (returnOrderStatus == 1003) {
return AfterSaleStatusEnum.SUCCESS; // 已退款 退款退货的订单return_order_status:1003:已退款且return_status退换货状态(1002:已收货,1003:已退款),仅退款订单 return_order_status:1003:已退款且refund_status 退款状态1002:已退款,
} else if (returnOrderStatus == 1006) {
return AfterSaleStatusEnum.FAILED; // 退款失败 退款退货的return_order_status:1003:已退款 return_status退换货状态(1006:退款异常 ,,仅退款的return_order_status:1003:已退款 且refund_status 退款状态,1004:退款异常
} else {
return AfterSaleStatusEnum.DEFAULT;
}
}
// export function getAfterSaleStatus({ returnOrderStatus } = {}) {
// if (returnOrderStatus == 1000) {
// // 按钮:售后详情
// return AfterSaleStatusEnum.PENDING_REVIEW; //售后---待审核 退款退货的return_order_status:1000:待审批且return_status退换货状态(1000:待审核) 仅退款的return_order_status:1000:待审批且refund_status 退款状态(1000:待审核
// } else if (returnOrderStatus == 1001) {
// // 按钮:售后详情
// return AfterSaleStatusEnum.PENDING_REVIEW_PASSED; //售后---待收货(审核通过) 退款退货的return_order_status:1001:审核通过 且return_status退换货状态(1001:待收货),仅退款的直接到退款完成/退款失败
// } else if (returnOrderStatus == 1005) {
// // 状态:售后前的状态(云中鹤不同意售后申请)按钮:售后、售后详情
// return AfterSaleStatusEnum.PENDING_REVIEW_REJECTED; //售后 -- 审核不通过 退款退货的return_order_status:1005:审核不通过且return_status退换货状态(1008:审核不通过), 仅退款的return_order_status:1005 且refund_status 退款状态(1008:审核不通过
// } else if (returnOrderStatus == 1003) {
// return AfterSaleStatusEnum.SUCCESS; // 已退款 退款退货的订单return_order_status:1003:已退款且return_status退换货状态(1002:已收货,1003:已退款),仅退款订单 return_order_status:1003:已退款且refund_status 退款状态1002:已退款,
// } else if (returnOrderStatus == 1006) {
// return AfterSaleStatusEnum.FAILED; // 退款失败 退款退货的return_order_status:1003:已退款 return_status退换货状态(1006:退款异常 ,,仅退款的return_order_status:1003:已退款 且refund_status 退款状态,1004:退款异常
// } else {
// return AfterSaleStatusEnum.DEFAULT;
// }
// }
export function getAfterSaleDetail(status) {
let _status_ = status;
if (typeof status === "object") {
_status_ = getAfterSaleStatus(status);
}
return AFTER_SALE_STATUS[_status_] || {};
}
// export function getAfterSaleDetail(status) {
// let _status_ = status;
// if (typeof status === "object") {
// _status_ = getAfterSaleStatus(status);
// }
// return AFTER_SALE_STATUS[_status_] || {};
// }
export function calcOrderProp(order){
const { applyQty, sellQty, redeemPoints, freightAmount = 0 } = order;
......@@ -106,3 +107,18 @@ export function calcOrderProp(order){
const ___totalPrice = (redeemPoints || 0) * ___qty + +freightAmount;
return {___qty, ___price, ___totalPrice};
}
export const APIS = {
AFTER_SALE_DETAIL: "AFTER_SALE_DETAIL",
AFTER_SALE: "AFTER_SALE",
};
export const API_Methods = {
[GoodsSource.YZH]: {
[APIS.AFTER_SALE_DETAIL]:wx.p.api.shopmallApi.platformSaleDetail, //售后详情
[APIS.AFTER_SALE]:wx.p.api.shopmallApi.afterSalesPlatform// 售后
},
[GoodsSource.SELF]: {
[APIS.AFTER_SALE_DETAIL]:wx.p.api.shopmallApi.afterSaleDetail,//售后详情
[APIS.AFTER_SALE]:wx.p.api.shopmallApi.afterSale// 售后
}
};
......@@ -37,21 +37,31 @@ Component({
// 直接使用 ORDER_LIST 中的索引作为 tabIndex
const item = e.currentTarget.dataset.item;
wx.p.router.go("/packageMine/pages/order/index/index", {
tab:item,
tab: item,
});
},
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,
],
const userInfo = wx.p.storage.get("userInfo") || {};
let { merchantId, channelSource } = userInfo;
const params = {
merchantId,
pageSize: 1,
currentPage: 1,
scoreSource: channelSource,
};
const orderList = this.data.orderList;
orderList.forEach((item) => {
const p = { ...params, requestType: item.requestType };
wx.p.api.mineApi[item.requestMethod](p).then((data) => {
if(data.total){
item.___count = data.total;
this.setData({
orderList,
});
}
});
});
},
......
......@@ -16,7 +16,7 @@
<glsx-image webp src="/mine/{{item.image}}.png"></glsx-image>
</view>
<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="{{item.___count}}">{{item.___count}}</text>
</view>
</view>
</view>
......
......@@ -89,20 +89,6 @@ Page({
const { url } = e.currentTarget.dataset;
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,
],
});
});
},
// 切换门店
changeMerchant() {
// 获取门店接口 门店数量大于1跳转切换,否则不需切换
......@@ -126,11 +112,8 @@ Page({
}
});
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.getOrderNumberList();
onShow:function() {
// this.getOrderNumberList();
// this.toCheckMember();
},
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!