Commit a2dea110 by liimin

refactor(order): 重构订单模块

- 优化订单状态和请求方法的管理逻辑
- 改进订单列表的获取和更新机制
- 调整订单详情和售后流程的实现方式
- 统一订单相关组件的样式和交互
1 parent 2b5b91f2
Showing 29 changed files with 186 additions and 364 deletions
<block wx:if="{{openScroll}}"> <block wx:if="{{openScroll}}">
<scroll-view class="tab-box {{align}}" scroll-x enable-flex scroll-with-animation scroll-into-view="{{to}}"> <scroll-view class="tab-box {{align}}" scroll-x enable-flex scroll-with-animation scroll-into-view="{{to}}">
<block wx:for="{{tab}}" wx:key="index"> <block wx:for="{{tab}}" wx:key="index">
<view class="tab {{index==count||count==item.code?'active':''}}" bindtap="click" data-count="{{index}}" id="to-{{index}}" > <view class="tab {{index==count||count==item.code?'active':''}}" bindtap="click" data-count="{{index}}" data-item="{{item}}" id="to-{{index}}" >
<view class="text" >{{item.text||item}}</view> <view class="text" >{{item.text||item}}</view>
<!-- <view class="text" style="width:{{38 * item.length + 20}}rpx;">{{item}}</view> --> <!-- <view class="text" style="width:{{38 * item.length + 20}}rpx;">{{item}}</view> -->
<view class="line"></view> <view class="line"></view>
......
...@@ -76,6 +76,7 @@ export const ORDER_STATUS = { ...@@ -76,6 +76,7 @@ export const ORDER_STATUS = {
status: OrderStatusEnum.ALL, status: OrderStatusEnum.ALL,
index: 0, // 查询订单列表TAB高亮的索引 index: 0, // 查询订单列表TAB高亮的索引
requestType: 0, // 查询订单列表TAB查询参数 requestType: 0, // 查询订单列表TAB查询参数
requestMethod:'getOrderList',
type: OrderStatusTypes.QUERY_TAB, // 查询订单列表显示的TAB项 type: OrderStatusTypes.QUERY_TAB, // 查询订单列表显示的TAB项
}, },
[OrderStatusEnum.PAY_PENDING]: { [OrderStatusEnum.PAY_PENDING]: {
...@@ -84,6 +85,7 @@ export const ORDER_STATUS = { ...@@ -84,6 +85,7 @@ export const ORDER_STATUS = {
status: OrderStatusEnum.PAY_PENDING, status: OrderStatusEnum.PAY_PENDING,
index: 1, // 查询订单列表TAB高亮的索引 index: 1, // 查询订单列表TAB高亮的索引
requestType: 2, // 查询订单列表TAB查询参数 requestType: 2, // 查询订单列表TAB查询参数
requestMethod:'getOrderList',
buttons: null, buttons: null,
type: OrderStatusTypes.MY_ORDER, //我的 页面 我的订单 显示的项目 type: OrderStatusTypes.MY_ORDER, //我的 页面 我的订单 显示的项目
}, },
...@@ -93,6 +95,7 @@ export const ORDER_STATUS = { ...@@ -93,6 +95,7 @@ export const ORDER_STATUS = {
status: OrderStatusEnum.WAIT_DELIVER, status: OrderStatusEnum.WAIT_DELIVER,
index: 2, // 查询订单列表TAB高亮的索引 index: 2, // 查询订单列表TAB高亮的索引
requestType: 6, // 查询订单列表TAB查询参数 requestType: 6, // 查询订单列表TAB查询参数
requestMethod:'getOrderList',
type: OrderStatusTypes.MY_ORDER, //我的 页面 我的订单 显示的项目 type: OrderStatusTypes.MY_ORDER, //我的 页面 我的订单 显示的项目
buttons: { buttons: {
[GoodsSource.SELF]: [ [GoodsSource.SELF]: [
...@@ -107,6 +110,7 @@ export const ORDER_STATUS = { ...@@ -107,6 +110,7 @@ export const ORDER_STATUS = {
status: 1008, status: 1008,
index: 3, // 查询订单列表TAB高亮的索引 index: 3, // 查询订单列表TAB高亮的索引
requestType: 1, // 查询订单列表TAB查询参数 requestType: 1, // 查询订单列表TAB查询参数
requestMethod:'getOrderList',
type: OrderStatusTypes.MY_ORDER, //我的 页面 我的订单 显示的项目 type: OrderStatusTypes.MY_ORDER, //我的 页面 我的订单 显示的项目
buttons: { buttons: {
[GoodsSource.SELF]: [ [GoodsSource.SELF]: [
...@@ -126,6 +130,7 @@ export const ORDER_STATUS = { ...@@ -126,6 +130,7 @@ export const ORDER_STATUS = {
status: OrderStatusEnum.COMPLETED, status: OrderStatusEnum.COMPLETED,
index: 4, // 查询订单列表TAB高亮的索引 index: 4, // 查询订单列表TAB高亮的索引
requestType: 4, // 查询订单列表TAB查询参数 requestType: 4, // 查询订单列表TAB查询参数
requestMethod:'getOrderList',
type: OrderStatusTypes.QUERY_TAB, // 查询订单列表显示的TAB项 type: OrderStatusTypes.QUERY_TAB, // 查询订单列表显示的TAB项
buttons: { buttons: {
[GoodsSource.SELF]: [ [GoodsSource.SELF]: [
...@@ -147,6 +152,7 @@ export const ORDER_STATUS = { ...@@ -147,6 +152,7 @@ export const ORDER_STATUS = {
status: OrderStatusEnum.AFTER_SALE, status: OrderStatusEnum.AFTER_SALE,
index: 5, // 查询订单列表TAB高亮的索引 index: 5, // 查询订单列表TAB高亮的索引
requestType: 0, // 查询订单列表TAB查询参数 requestType: 0, // 查询订单列表TAB查询参数
requestMethod:'getSalesOrderList',
buttons: null, buttons: null,
type: OrderStatusTypes.MY_ORDER, //我的 页面 我的订单 显示的项目 type: OrderStatusTypes.MY_ORDER, //我的 页面 我的订单 显示的项目
}, },
......
...@@ -15,6 +15,7 @@ Page({ ...@@ -15,6 +15,7 @@ Page({
*/ */
onLoad: function (options) { onLoad: function (options) {
wx.p.router.getRouterParams(options).then((params) => { wx.p.router.getRouterParams(options).then((params) => {
console.log("🚀 ~ params:", params)
if (params) { if (params) {
this.setData({ this.setData({
...params, ...params,
...@@ -46,7 +47,7 @@ Page({ ...@@ -46,7 +47,7 @@ Page({
const { returnOrderStatus } = res; const { returnOrderStatus } = res;
const status = getAfterSaleDetail({ returnOrderStatus }); const status = getAfterSaleDetail({ returnOrderStatus });
const button = status.buttons?.[goodsSource][0] const button = status.buttons?.[goodsSource][0]
// button.action = this[this.button.handler] // button.action = this[button.handler]
let str = ""; let str = "";
if (res.sendbackAddressModel) { if (res.sendbackAddressModel) {
const { sendbackAddressModel } = res; const { sendbackAddressModel } = res;
...@@ -73,7 +74,8 @@ Page({ ...@@ -73,7 +74,8 @@ Page({
// ); // );
// } // }
// this.cancelSaleApply() // this.cancelSaleApply()
this[this.button.handler]() // console.log('this.button', this.data.button)
this[this.data.button.handler]()
}, },
toAfterSale(){ toAfterSale(){
const { orderInfo } = this.data; const { orderInfo } = this.data;
......
...@@ -4,10 +4,6 @@ Component({ ...@@ -4,10 +4,6 @@ Component({
status: { status: {
type: Object, type: Object,
value: {}, value: {},
observer: function (status) {
console.log("🚀 ~ status:", status)
// this.updateStatus(status);
},
}, },
}, },
data: { data: {
......
...@@ -16,7 +16,6 @@ Page({ ...@@ -16,7 +16,6 @@ Page({
] ]
}, },
choose(e) { choose(e) {
console.log(e)
let { index } = e.currentTarget.dataset let { index } = e.currentTarget.dataset
let { afterSaleList } = this.data, let { afterSaleList } = this.data,
returnType; returnType;
...@@ -28,51 +27,10 @@ Page({ ...@@ -28,51 +27,10 @@ Page({
}) })
this.triggerEvent('returnType',{returnType}) this.triggerEvent('returnType',{returnType})
}, },
click() {
let {
orderObj,
data: { afterSaleList }
} = this
orderObj.refundType = 2
afterSaleList.map(e => {
if (e.active) orderObj.refundType = e.value
})
wx.p.router.go('/packageMine/pages/order/afterSale_step_two/afterSale_step_two', orderObj)
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.orderObj = options this.orderObj = options
}, },
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {}
}) })
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
<afterSale_step_one bindreturnType="changeReturnType"/> <afterSale_step_one bindreturnType="changeReturnType"/>
<!-- </view> --> <!-- </view> -->
<view class="title">申请退货退款</view> <view class="title">申请退货退款</view>
<!-- 退款信息组件 --> <!-- 退款信息组件 -->
<refund-info-box <refund-info-box
orderObj="{{orderObj}}" orderObj="{{orderObj}}"
......
...@@ -40,6 +40,7 @@ Component({ ...@@ -40,6 +40,7 @@ Component({
}, },
onShowRefundCount() { onShowRefundCount() {
return
this.setData({ this.setData({
showRefundCount: true, showRefundCount: true,
}); });
......
...@@ -13,14 +13,14 @@ ...@@ -13,14 +13,14 @@
<view class="box-item-value"> <view class="box-item-value">
<view class="value" bindtap="onShowRefundCount" wx:if="{{!showRefundCount}}"> <view class="value" bindtap="onShowRefundCount" wx:if="{{!showRefundCount}}">
<view class="price">{{refundCount}}件</view> <view class="price">{{refundCount}}件</view>
修改数量 <!-- 修改数量 -->
</view> </view>
<!-- <Stepper wx:else count="{{refundCount}}" min="1" max="10" bindchange="onChangeRefundCount" data-index="{{index}}"></Stepper> --> <!-- <Stepper wx:else count="{{refundCount}}" min="1" max="10" bindchange="onChangeRefundCount" data-index="{{index}}"></Stepper> -->
</view> </view>
</view> </view>
<view class="box-item"> <view class="box-item">
<text class="box-item-title">退款金额</text> <text class="box-item-title">退款金额</text>
<view class="refund">{{refundPrice}}积分</view> <view class="refund">{{refundPrice * refundCount}}积分</view>
</view> </view>
</view> </view>
<popup show="{{showPopup}}" only="{{false}}" title="请选择退款原因" bindconfirm="onConfirmPopup"> <popup show="{{showPopup}}" only="{{false}}" title="请选择退款原因" bindconfirm="onConfirmPopup">
......
...@@ -11,6 +11,7 @@ Component({ ...@@ -11,6 +11,7 @@ Component({
type: Object, type: Object,
value: {}, value: {},
observer: function (val) { observer: function (val) {
console.log("🚀 ~ val:", val)
this.setData({ this.setData({
logisticsData: this.processExpressInfo(val) logisticsData: this.processExpressInfo(val)
}) })
...@@ -20,10 +21,10 @@ Component({ ...@@ -20,10 +21,10 @@ Component({
type: Boolean, type: Boolean,
value: false value: false
}, },
height: { // height: {
type: String, // type: String,
value: '256rpx' // value: '256rpx'
} // }
}, },
data: { data: {
logisticsData: {}, logisticsData: {},
......
.popup-content { .popup-content {
padding: 0 32rpx; padding: 0 32rpx;
max-height: calc(100% + 98rpx);
overflow: hidden;
overflow-y: scroll;
.express-info { .express-info {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
......
<popup show="{{showExpress}}" show-close-button="{{true}}" showFooter="{{false}}" headerColor="#F7F7F7" title="物流详情" bindconfirm="onConfirmPopup"> <popup show="{{showExpress}}" show-close-button="{{true}}" showFooter="{{false}}" headerColor="#F7F7F7" title="物流详情" bindconfirm="onConfirmPopup">
<view class="popup-content"> <view class="popup-content">
<Expressage expressInfo="{{expressInfo}}"></Expressage> <Expressage expressInfo="{{expressInfo}}"></Expressage>
<view class="line"></view> <view class="line"></view>
<Express expressInfo="{{expressInfo}}" showExpress="{{showExpress}} "height="980rpx" /> <Express expressInfo="{{expressInfo}}" showExpress="{{showExpress}}" />
</view> </view>
</popup> </popup>
\ No newline at end of file \ No newline at end of file
const { mockDeliveryInfoData } = require('./mock.js');
Component({ Component({
options: { options: {
...@@ -14,11 +13,4 @@ Component({ ...@@ -14,11 +13,4 @@ Component({
value: {} value: {}
} }
}, },
data: {
// Mock数据用于开发和测试
...mockDeliveryInfoData
},
methods: {
}
}) })
\ No newline at end of file \ No newline at end of file
...@@ -4,5 +4,4 @@ ...@@ -4,5 +4,4 @@
<view class="value">{{orderInfo.receiveAddress || ''}} <view class="value">{{orderInfo.receiveAddress || ''}}
<view class="value">{{orderInfo.receviveInfo || ''}}</view> <view class="value">{{orderInfo.receviveInfo || ''}}</view>
</view> </view>
</view> </view>
\ No newline at end of file \ No newline at end of file
.title { .title {
font-size: 32rpx; font-size: 32rpx;
padding-bottom: 24rpx; padding-bottom: 16rpx;
font-weight: 500; font-weight: 500;
} }
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
} }
.item .label { .item .label {
width: 150rpx; width: 128rpx;
} }
.item .value { .item .value {
width: calc(100% - 150rpx); width: calc(100% - 128rpx);
} }
const { mockOrderInfoData } = require('./mock.js');
Component({ Component({
options: { options: {
addGlobalClass: true, addGlobalClass: true,
...@@ -8,21 +6,6 @@ Component({ ...@@ -8,21 +6,6 @@ Component({
orderInfo: { orderInfo: {
type: Object, type: Object,
value: {} value: {}
},
orderObj: {
type: Array,
value: []
},
statusEnum: {
type: Object,
value: {}
} }
}, },
data: {
// Mock数据用于开发和测试
...mockOrderInfoData
},
methods: {
}
}) })
\ No newline at end of file \ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<content item="{{orderInfo}}" /> <content item="{{orderInfo}}" />
</view> </view>
<view class="order-content"> <view class="order-content">
<block wx:for="{{orderObj}}" wx:key="index"> <!-- <block wx:for="{{orderObj}}" wx:key="index">
<view class="item {{item.alignItems}}"> <view class="item {{item.alignItems}}">
<view class="label">{{item.label}}:</view> <view class="label">{{item.label}}:</view>
<view class="value {{item.styleColor}}"> <view class="value {{item.styleColor}}">
...@@ -14,7 +14,27 @@ ...@@ -14,7 +14,27 @@
<block wx:else>{{orderInfo[item.key] || '-'}}</block> <block wx:else>{{orderInfo[item.key] || '-'}}</block>
</view> </view>
</view> </view>
</block> </block> -->
<view class="item">
<view class="label">实付款:</view>
<view class="value fontColor">{{orderInfo.redeemPoints * orderInfo.sellQty}}积分</view>
</view>
<view class="item">
<view class="label">运费:</view>
<view class="value">¥{{orderInfo.freightAmount||0}}</view>
</view>
<view class="item">
<view class="label">订单编号:</view>
<view class="value">{{orderInfo.orderCode}}</view>
</view>
<view class="item">
<view class="label">下单时间:</view>
<view class="value">{{orderInfo.orderCreatedDate}}</view>
</view>
<view class="item">
<view class="label">支付时间:</view>
<view class="value">{{orderInfo.orderCreatedDate}}</view>
</view>
</view> </view>
<view class="order-bottom"> <view class="order-bottom">
<order-action-buttons order="{{orderInfo}}" /> <order-action-buttons order="{{orderInfo}}" />
......
const mockOrderInfoData = {
orderInfo: {
time: '2023.05.15 14:30:22',
orderCode: '20230515143022001',
shipAddress: '北京市朝阳区某某街道某某小区1号楼101室',
orderStatus: 3
},
orderObj: [
{
label: "下单日期",
key: "time",
},
{
label: "订单编号",
key: "orderCode",
},
{
label: "收货地址",
key: "shipAddress",
alignItems: "flex-start",
},
{
label: "订单状态",
key: "orderStatus",
enum: true,
},
],
statusEnum: {
1: "待付款",
2: "待发货",
3: "已发货",
4: "已完成",
5: "已取消"
}
};
module.exports = {
mockOrderInfoData
};
\ No newline at end of file \ No newline at end of file
import { import {
wxqrcode as QR
} from "~/lib/index";
import {
orderMixin orderMixin
} from "~/mixins/index"; } from "~/mixins/index";
import {
iosTimeFormat
} from "~/utils/format";
import {
mockOrderDetailData
} from "./mock.js";
import {
OrderStatus
} from "~/constants/mine.js";
Page({ Page({
behaviors: [orderMixin], behaviors: [orderMixin],
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
// 使用mock数据用于开发和测试
...mockOrderDetailData,
OrderStatus,
expressInfo: { expressInfo: {
"orderCode": "295057717192728657", "orderCode": "295057717192728657",
"expressCode": "yuantong", "expressCode": "yuantong",
...@@ -106,29 +91,6 @@ Page({ ...@@ -106,29 +91,6 @@ Page({
] ]
}, //物流信息 }, //物流信息
isShowExpressPop: false, isShowExpressPop: false,
orderObj: [{
label: "实付款",
key: 'redeemPoints',
styleColor: 'fontColor'
},
{
label: "运费",
key: 'freightAmount',
sign: true
},
{
label: "订单编号",
key: "orderCode",
},
{
label: "下单时间",
key: "orderCreatedDate",
},
{
label: "支付时间",
key: "orderCreatedDate",
},
],
deliveryStatus: { deliveryStatus: {
1: "待发货", 1: "待发货",
2: "已发货", 2: "已发货",
...@@ -194,50 +156,9 @@ Page({ ...@@ -194,50 +156,9 @@ Page({
receviveInfo: receiveName + receiveMobile receviveInfo: receiveName + receiveMobile
} }
}) })
});
},
toDetail() {
let [temp] = this.data.orderInfo.relatedUserCoupon, {
discountType,
useChannel,
id
} = temp,
detailInfo = {
xx: "xx",
};
if (discountType == 2 || discountType == 4) {
wx.p.router.go("/packageMall/pages/coupon/coupon", {
userCouponId: id,
useMemberType: this.data.useMemberType,
detailInfo,
});
return;
}
/**线上商品代金券 */
if (discountType == 3 && useChannel == 1) {
if (this.data.useMemberType == 1) {
wx.p.wxApi.showToast("代金券已使用");
return;
}
wx.p.router.go("/packageMine/pages/coupon/recommend/recommend", {
couponInfo: temp,
});
return;
}
wx.p.router.go("/packageMine/pages/coupon/detail/detail", {
item: temp,
});
},
setQr(data) {
this.setData({
qr: QR.createQrCodeImg(`t=1&c=${data}`),
}); });
}, },
showExpressPop() { showExpressPop() {
console.log("🚀 ~ showExpressPop ~ showExpressPop:")
this.setData({ this.setData({
isShowExpressPop: true, isShowExpressPop: true,
}); });
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
.express-detail{ .express-detail{
position: absolute; position: absolute;
right: 24rpx; right: 24rpx;
top:10rpx; top:12rpx;
color: var(--btnColor); color: var(--btnColor);
font-weight: 400; font-weight: 400;
font-size: 24rpx; font-size: 24rpx;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<DeliveryInfo orderInfo="{{orderInfo}}" deliveryStatus="{{deliveryStatus}}"></DeliveryInfo> <DeliveryInfo orderInfo="{{orderInfo}}" deliveryStatus="{{deliveryStatus}}"></DeliveryInfo>
</BlockBox> </BlockBox>
<BlockBox> <BlockBox>
<OrderInfo orderInfo="{{orderInfo}}" orderObj="{{orderObj}}" statusEnum="{{statusEnum}}"></OrderInfo> <OrderInfo orderInfo="{{orderInfo}}"></OrderInfo>
</BlockBox> </BlockBox>
<!-- <BlockBox> <!-- <BlockBox>
<content item="{{orderInfo}}" /> <content item="{{orderInfo}}" />
......
...@@ -6,7 +6,10 @@ Component({ ...@@ -6,7 +6,10 @@ Component({
properties: { properties: {
item: { item: {
type: Object, type: Object,
value: {} value: {},
observer: function (v) {
this.compute(v);
}
} }
}, },
...@@ -21,6 +24,14 @@ Component({ ...@@ -21,6 +24,14 @@ Component({
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
compute(item) {
let { applyQty, sellQty, redeemPoints } = item;
const total = sellQty || applyQty || 0;
let sum = redeemPoints * total;
this.setData({
sum,
total
})
}
} }
}) })
\ No newline at end of file \ No newline at end of file
<view class="bottom"> <view class="bottom">
<view class="total"> <view class="total">
共{{item.sellQty||item.applyQty}}件,实付款 共{{total}}件,实付款
<text class="price">{{item.redeemPoints||'--'}}积分</text> <text class="price">{{sum||'--'}}积分</text>
</view> </view>
<order-action-buttons order="{{item}}" has-user-info="{{hasUserInfo}}" /> <order-action-buttons order="{{item}}" has-user-info="{{hasUserInfo}}" />
</view> </view>
\ No newline at end of file \ No newline at end of file
// packageMine/pages/order/index/components/orderActionButtons.js // packageMine/pages/order/index/components/orderActionButtons.js
import { GoodsSource } from "~/constants/mine.js"; import { GoodsSource,ORDER_STATUS,OrderStatusEnum } from "~/constants/mine.js";
import { getOrder } from "~/packageMine/pages/order/utils"; import { getOrder } from "~/packageMine/pages/order/utils";
Component({ Component({
/** /**
...@@ -10,17 +10,12 @@ Component({ ...@@ -10,17 +10,12 @@ Component({
type: Object, type: Object,
value: {}, value: {},
observer: function () { observer: function () {
// 当hasUserInfo变化时重新计算按钮
this.updateButtons(); this.updateButtons();
} }
}, },
hasUserInfo: { hasUserInfo: {
type: Boolean, type: Boolean,
value: false, value: false,
observer: function () {
// 当hasUserInfo变化时重新计算按钮
// this.updateButtons();
},
}, },
}, },
...@@ -57,7 +52,7 @@ Component({ ...@@ -57,7 +52,7 @@ Component({
: []; : [];
// goodsSource ==null 默认云中鹤 // goodsSource ==null 默认云中鹤
this.setData({ this.setData({
buttons: orderButtons, buttons: orderButtons||[],
}); });
}, },
...@@ -70,31 +65,31 @@ Component({ ...@@ -70,31 +65,31 @@ Component({
}, },
// 取消付款 // 取消付款
onCancelPay(e) { // onCancelPay(e) {
let { orderCode } = this.data.order; // let { orderCode } = this.data.order;
wx.showModal({ // wx.showModal({
title: "温馨提示", // title: "温馨提示",
content: "请问您是否要取消付款", // content: "请问您是否要取消付款",
confirmText: "确认", // confirmText: "确认",
cancelText: "取消", // cancelText: "取消",
confirmColor: "#F13C3D", // confirmColor: "#F13C3D",
}).then((res) => { // }).then((res) => {
if (res.confirm) { // if (res.confirm) {
wx.p.api.shopmallApi // wx.p.api.shopmallApi
.cancelPay(orderCode) // .cancelPay(orderCode)
.then(({ code, message }) => { // .then(({ code, message }) => {
if (code == "0") { // if (code == "0") {
wx.p.wxApi.showToast("操作成功"); // wx.p.wxApi.showToast("操作成功");
setTimeout(() => { // setTimeout(() => {
this.clearData(); // this.clearData();
}, 1.5e3); // }, 1.5e3);
} else { // } else {
wx.p.wxApi.showToast(message); // wx.p.wxApi.showToast(message);
} // }
}); // });
} // }
}); // });
}, // },
// 去支付 // 去支付
// onPay(e) { // onPay(e) {
...@@ -172,8 +167,8 @@ Component({ ...@@ -172,8 +167,8 @@ Component({
if (res.confirm) { if (res.confirm) {
wx.p.api.shopmallApi.confirmReceipt(subOrderCode).then((data) => { wx.p.api.shopmallApi.confirmReceipt(subOrderCode).then((data) => {
wx.p.wxApi.showToast("操作成功"); wx.p.wxApi.showToast("操作成功");
setTimeout(() => { setTimeout(() => {//跳转到订单完成列表
this.clearData(); wx.p.router.go('/packageMine/pages/order/index/index',{tab:ORDER_STATUS[OrderStatusEnum.COMPLETED]})
}, 1.5e3); }, 1.5e3);
}); });
} }
...@@ -188,37 +183,10 @@ Component({ ...@@ -188,37 +183,10 @@ Component({
}); });
}, },
// 取消订单
onCancelOrder(e) {
let { orderCode } = this.data.order;
wx.showModal({
title: "温馨提示",
content: "请问您是否要取消售后",
confirmText: "确认",
cancelText: "取消",
confirmColor: "#F13C3D",
}).then((res) => {
if (res.confirm) {
wx.p.api.shopmallApi
.cancelOrder(orderCode)
.then(({ code, message }) => {
if (code == "0") {
wx.p.wxApi.showToast("操作成功");
setTimeout(() => {
this.clearData();
}, 1.5e3);
} else {
wx.p.wxApi.showToast(message);
}
});
}
});
},
// 售后详情 // 售后详情
onAfterSaleDetail(e) { onAfterSaleDetail(e) {
let url = "/packageMine/pages/order/afterSaleDetail/afterSaleDetail"; let url = "/packageMine/pages/order/afterSaleDetail/afterSaleDetail";
let { subOrderCode, goodsSource, tparReturnOrderCode } = this.data.order; let { subOrderCode, goodsSource, tparReturnOrderCode, } = this.data.order;
wx.p.router.go(url, { wx.p.router.go(url, {
subOrderCode, subOrderCode,
goodsSource, goodsSource,
...@@ -226,11 +194,4 @@ Component({ ...@@ -226,11 +194,4 @@ Component({
}); });
}, },
}, },
lifetimes: {
attached() {
// 组件实例进入页面节点树时执行
this.updateButtons();
},
},
}); });
...@@ -11,15 +11,7 @@ Component({ ...@@ -11,15 +11,7 @@ Component({
observer: function (v) { observer: function (v) {
v && this.getStatus(); v && this.getStatus();
}, },
}, }
afterSaleStatus: {
type: Object,
value: {},
},
statusEnum: {
type: Object,
value: {},
},
}, },
/** /**
...@@ -48,7 +40,6 @@ Component({ ...@@ -48,7 +40,6 @@ Component({
refundStatus, refundStatus,
returnOrderStatus, returnOrderStatus,
}); });
console.log(_order);
this.setData({ this.setData({
status: _order.text, status: _order.text,
}); });
......
// packageMine/pages/order/index/index.js // packageMine/pages/order/index/index.js
import { orderMixin } from "~/mixins/index"; import { ORDER_STATUS, OrderStatusTypes,OrderStatusEnum } from "~/constants/mine.js";
import { ORDER_STATUS, OrderStatusTypes } from "~/constants/mine.js";
Page({ Page({
behaviors: [orderMixin],
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
pageNum: 1, pageNum: 1,
requestType: 0,
tab: Object.freeze( tab: Object.freeze(
Object.values(ORDER_STATUS) Object.values(ORDER_STATUS).filter(
.filter( (item) =>
(item) => item.type === OrderStatusTypes.QUERY_TAB ||
item.type === OrderStatusTypes.QUERY_TAB || item.type === OrderStatusTypes.MY_ORDER
item.type === OrderStatusTypes.MY_ORDER )
)
.map((item) => item.text)
), ),
list: [], list: [],
listFlag: true, listFlag: true,
hasUserInfo: true, hasUserInfo: true,
inputDebounceTimer: null,
curTab: { index: 0, requestType: "0", requestMethod: "getOrderList" },
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
// 清理防抖定时器,避免内存泄漏
if (this.data.inputDebounceTimer) {
clearTimeout(this.data.inputDebounceTimer);
}
}, },
navbarReady(e) { navbarReady(e) {
wx.p.wxApi.getViewInfo(".tab", (res) => { wx.p.wxApi.getViewInfo(".tab", (res) => {
this.setData({ this.setData({
...@@ -33,9 +40,8 @@ Page({ ...@@ -33,9 +40,8 @@ Page({
}, },
jump(e) { jump(e) {
let { let {
item: { orderStatus, orderCode, orderSource }, item: { orderCode },
} = e.currentTarget.dataset; } = e.currentTarget.dataset;
if (orderSource == 5 && (orderStatus == 2 || orderStatus == 7)) return;
let url = "/packageMine/pages/order/detail/detail"; let url = "/packageMine/pages/order/detail/detail";
wx.p.router.go(url, { wx.p.router.go(url, {
orderCode, orderCode,
...@@ -56,71 +62,81 @@ Page({ ...@@ -56,71 +62,81 @@ Page({
else wx.p.router.back(); else wx.p.router.back();
}, },
changeTab(e) { changeTab(e) {
let index = e.detail.count, const tab = e.detail.item;
requestType = this.getRequestType(index); this.setIndexAndRequest(tab);
this.setData({
tabIndex: index,
requestType,
});
this.getOrderList();
},
getRequestType(index) {
// index = index ? index : 0
let item = Object.values(ORDER_STATUS).find(
(item) => item.index == (index || 0)
);
return item ? item.requestType : "0";
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
wx.p.router.getRouterParams(options).then((option) => { wx.p.router.getRouterParams(options).then((option) => {
let index = option.index, let tab = option.tab;
requestType = this.getRequestType(index); if(!tab || !tab.index){
this.setData({ tab = ORDER_STATUS[OrderStatusEnum.ALL]
tabIndex: index, }
requestType, this.setIndexAndRequest(tab);
});
this.getOrderList();
// this.clearData(); // 注释掉实际的API调用,使用硬编码数据
}); });
}, },
setIndexAndRequest(tab) {
this.setData(
{
curTab: tab,
},
() => this.clearAndGetList()
);
},
onShow() { onShow() {
if (this.refresh) this.clearData(); if (this.refresh) this.clearAndGetList();
if (this.refresh) this.getOrderList();
}, },
onHide() { onHide() {
this.refresh = true; this.refresh = true;
}, },
async clearData() { async clearData(cb) {
const res = !wx.p.isLogin; const res = !wx.p.isLogin;
if (res) return; if (res) return;
this.setData({ this.setData(
listFlag: false, {
list: [], // 注释掉清空列表,保持硬编码数据 listFlag: false,
nothing: false, list: [],
pageNum: 1, nothing: false,
}); pageNum: 1,
// this.getOrderList(); // 注释掉实际的API调用,使用硬编码数据 },
// this.setData({ cb
// listFlag: true, );
// }); },
clearAndGetList() {
this.clearData(() => this.getOrderList());
}, },
search() { search() {
this.clearData(); this.clearAndGetList();
this.getOrderList();
}, },
clear() { clear() {
this.setData({ this.setData(
keyword: "", {
}); keyword: "",
},
() => this.clearAndGetList()
);
}, },
input(e) { input(e) {
if (this.data.inputDebounceTimer) {
clearTimeout(this.data.inputDebounceTimer);
}
const timer = setTimeout(() => {
this.setData(
{
keyword: e.detail.value,
},
() => this.clearAndGetList()
);
}, 500);
this.setData({ this.setData({
keyword: e.detail.value, inputDebounceTimer: timer,
}); });
}, },
blur() { blur() {
let { keyword } = this.data; let { keyword } = this.data;
this.setData({ this.setData({
...@@ -129,7 +145,11 @@ Page({ ...@@ -129,7 +145,11 @@ Page({
}, },
getOrderList() { getOrderList() {
wx.p.wxApi.showLoading("加载中..."); wx.p.wxApi.showLoading("加载中...");
let { requestType, pageNum, keyword, tabIndex } = this.data; let {
curTab: { requestType, requestMethod },
pageNum,
keyword,
} = this.data;
const userInfo = wx.p.storage.get("userInfo") || {}; const userInfo = wx.p.storage.get("userInfo") || {};
let { merchantId } = userInfo; let { merchantId } = userInfo;
let obj = { let obj = {
...@@ -139,12 +159,10 @@ Page({ ...@@ -139,12 +159,10 @@ Page({
}; };
if (keyword) { if (keyword) {
keyword = keyword.replace(/\ /g, ""); keyword = keyword.replace(/\ /g, "");
if (keyword.length) obj.keyword = keyword; if (keyword.length) obj.goodsInfo = keyword;
} }
let Method = tabIndex == 5 ? "getSalesOrderList" : "getOrderList";
let list = []; let list = [];
wx.p.api.mineApi[Method](obj).then((data) => { wx.p.api.mineApi[requestMethod](obj).then((data) => {
wx.hideLoading(); wx.hideLoading();
data?.list?.map((e) => { data?.list?.map((e) => {
// let { // let {
......
...@@ -11,14 +11,14 @@ ...@@ -11,14 +11,14 @@
<input type="text" placeholder="搜索" value="{{keyword}}" class="input" confirm-type="search" bindconfirm="search" bindinput="input" bindblur="blur" /> <input type="text" placeholder="搜索" value="{{keyword}}" class="input" confirm-type="search" bindconfirm="search" bindinput="input" bindblur="blur" />
<block wx:if="{{keyword}}"> <block wx:if="{{keyword}}">
<view class="clear-box" bindtap="clear"> <view class="clear-box" bindtap="clear">
<view class="sprite-icon icon-clear"></view> <mp-icon type="field" icon="close2" color="#2C2C2C" size="{{14}}"></mp-icon>
</view> </view>
</block> </block>
</view> </view>
</view> </view>
</navigation-bar> </navigation-bar>
<view class="tab" style="top:{{padding_bottom }}px;"> <view class="tab" style="top:{{padding_bottom }}px;">
<tab tab="{{tab}}" bindchange="changeTab" index="{{tabIndex}}"></tab> <tab tab="{{tab}}" bindchange="changeTab" index="{{curTab.index}}"></tab>
</view> </view>
</view> </view>
<block wx:if="{{margin_top}}"> <block wx:if="{{margin_top}}">
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<block wx:if="{{listFlag}}"> <block wx:if="{{listFlag}}">
<block wx:if="{{list.length}}"> <block wx:if="{{list.length}}">
<block wx:for="{{list}}" wx:key="index"> <block wx:for="{{list}}" wx:key="index">
<OrderCard item="{{item}}" after-sale-status="{{afterSaleStatus}}" status-enum="{{statusEnum}}" has-user-info="{{hasUserInfo}}"></OrderCard> <OrderCard item="{{item}}"></OrderCard>
</block> </block>
<block wx:if="{{nothing}}"> <block wx:if="{{nothing}}">
<view class="list-nothing to-bottom"></view> <view class="list-nothing to-bottom"></view>
......
...@@ -23,7 +23,7 @@ export function getOrderStatus({ ...@@ -23,7 +23,7 @@ export function getOrderStatus({
(!cancelStatus || cancelStatus == 1010) (!cancelStatus || cancelStatus == 1010)
) { ) {
// 按钮:售后(去掉) // 按钮:售后(去掉)
return OrderStatusEnum.WAIT_DELIVER //待发货 order_status属于(1002,1006,1007)且cancel_status不存在或者审核中(1010) return OrderStatusEnum.WAIT_DELIVER; //待发货 order_status属于(1002,1006,1007)且cancel_status不存在或者审核中(1010)
} else if ( } else if (
[1008].includes(orderStatus) && [1008].includes(orderStatus) &&
(!cancelStatus || cancelStatus == 1010) (!cancelStatus || cancelStatus == 1010)
...@@ -86,8 +86,8 @@ export function getAfterSaleStatus({ returnOrderStatus } = {}) { ...@@ -86,8 +86,8 @@ export function getAfterSaleStatus({ returnOrderStatus } = {}) {
return AfterSaleStatusEnum.SUCCESS; // 已退款 退款退货的订单return_order_status:1003:已退款且return_status退换货状态(1002:已收货,1003:已退款),仅退款订单 return_order_status:1003:已退款且refund_status 退款状态1002:已退款, return AfterSaleStatusEnum.SUCCESS; // 已退款 退款退货的订单return_order_status:1003:已退款且return_status退换货状态(1002:已收货,1003:已退款),仅退款订单 return_order_status:1003:已退款且refund_status 退款状态1002:已退款,
} else if (returnOrderStatus == 1006) { } else if (returnOrderStatus == 1006) {
return AfterSaleStatusEnum.FAILED; // 退款失败 退款退货的return_order_status:1003:已退款 return_status退换货状态(1006:退款异常 ,,仅退款的return_order_status:1003:已退款 且refund_status 退款状态,1004:退款异常 return AfterSaleStatusEnum.FAILED; // 退款失败 退款退货的return_order_status:1003:已退款 return_status退换货状态(1006:退款异常 ,,仅退款的return_order_status:1003:已退款 且refund_status 退款状态,1004:退款异常
}else{ } else {
return AfterSaleStatusEnum.DEFAULT; return AfterSaleStatusEnum.DEFAULT;
} }
} }
......
...@@ -35,9 +35,9 @@ Component({ ...@@ -35,9 +35,9 @@ Component({
methods: { methods: {
goOrder(e) { goOrder(e) {
// 直接使用 ORDER_LIST 中的索引作为 tabIndex // 直接使用 ORDER_LIST 中的索引作为 tabIndex
const index = e.currentTarget.dataset.index; const item = e.currentTarget.dataset.item;
wx.p.router.go("/packageMine/pages/order/index/index", { wx.p.router.go("/packageMine/pages/order/index/index", {
index, tab:item,
}); });
}, },
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</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-index="{{item.index}}"> <view bindtap="goOrder" data-item="{{item}}">
<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>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!