Commit 70c9ca1f by liimin

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

- 移除订单状态中的重复代码
- 优化订单详情和售后流程的逻辑
- 统一图片上传组件的样式和功能
- 重构订单列表的渲染逻辑
- 新增 calcOrderProp 函数用于计算订单属性
1 parent f2928b8f
...@@ -100,7 +100,11 @@ export const ORDER_STATUS = { ...@@ -100,7 +100,11 @@ export const ORDER_STATUS = {
buttons: { buttons: {
[GoodsSource.SELF]: [ [GoodsSource.SELF]: [
//自营商品 在商品列表对应的按钮 //自营商品 在商品列表对应的按钮
OrderActionButtons.CONFIRM_RECEIVE, // OrderActionButtons.CONFIRM_RECEIVE,
],
[GoodsSource.YZH]: [
//自营商品 在商品列表对应的按钮
// OrderActionButtons.CONFIRM_RECEIVE,
], ],
}, },
}, },
......
import { getAfterSaleDetail } from "~/packageMine/pages/order/utils"; import { getAfterSaleDetail,calcOrderProp } from "~/packageMine/pages/order/utils";
import { import {
ORDER_STATUS, ORDER_STATUS,
OrderStatusEnum, OrderStatusEnum,
...@@ -58,7 +58,8 @@ Page({ ...@@ -58,7 +58,8 @@ Page({
str = `${sendbackAddressModel.provinceName}${sendbackAddressModel.cityName}${sendbackAddressModel.countyName}${sendbackAddressModel.address}`; str = `${sendbackAddressModel.provinceName}${sendbackAddressModel.cityName}${sendbackAddressModel.countyName}${sendbackAddressModel.address}`;
} }
res.addressInfo = str; res.addressInfo = str;
const {___qty,___price,___totalPrice} =calcOrderProp(res.orderGoods)
Object.assign(res.orderGoods,{___qty,___price,___totalPrice})
this.setData({ this.setData({
orderInfo: res, orderInfo: res,
status, status,
...@@ -79,7 +80,17 @@ Page({ ...@@ -79,7 +80,17 @@ Page({
// } // }
// this.cancelSaleApply() // this.cancelSaleApply()
// console.log('this.button', this.data.button) // console.log('this.button', this.data.button)
this[this.data.button.handler]() // this[this.data.button.handler]()
this.toAfterSale()
},
toAfterSale(){
const { orderInfo } = this.data;
console.log("🚀 ~ toAfterSale ~ orderInfo:", orderInfo)
return
wx.p.router.go(
"/packageMine/pages/order/afterSale_step_two/afterSale_step_two",
orderInfo
);
}, },
/**撤销申请 */ /**撤销申请 */
cancelSaleApply() { cancelSaleApply() {
......
...@@ -17,6 +17,7 @@ Page({ ...@@ -17,6 +17,7 @@ Page({
data: { data: {
RefundReason: Object.freeze(RefundReason), RefundReason: Object.freeze(RefundReason),
method: null, method: null,
imagesMax:9
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
...@@ -24,7 +25,10 @@ Page({ ...@@ -24,7 +25,10 @@ Page({
onLoad: function (options) { onLoad: function (options) {
wx.p.router.getRouterParams(options).then((orderObj) => { wx.p.router.getRouterParams(options).then((orderObj) => {
console.log("🚀 ~ orderObj:", orderObj) console.log("🚀 ~ orderObj:", orderObj)
orderObj.returnType = 1001; Object.assign(orderObj, {
returnType:orderObj.returnType||1001,
imgUrls:orderObj.imgUrls || []
})
this.setData({ this.setData({
orderObj, orderObj,
method: Methods[orderObj.goodsSource], method: Methods[orderObj.goodsSource],
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<!-- 退款信息组件 --> <!-- 退款信息组件 -->
<refund-info-box <refund-info-box
orderObj="{{orderObj}}" orderObj="{{orderObj}}"
refund-count="{{orderObj.___qty}}" refund-count="{{orderObj.applyQty}}"
max-refund-count="{{maxRefundCount}}" max-refund-count="{{maxRefundCount}}"
refund-price="{{orderObj.refundPoints}}" refund-price="{{orderObj.refundPoints}}"
show-refund-count="{{showRefundCount}}" show-refund-count="{{showRefundCount}}"
...@@ -23,10 +23,10 @@ ...@@ -23,10 +23,10 @@
<gl-textarea maxlength="230" placeholder="补充描述,有助于商家更好的处理售后问题" value="{{orderObj.returnContent}}" bindinput="input" showWordLimit customMaxLength></gl-textarea> <gl-textarea maxlength="230" placeholder="补充描述,有助于商家更好的处理售后问题" value="{{orderObj.returnContent}}" bindinput="input" showWordLimit customMaxLength></gl-textarea>
</view> </view>
<view class="title">上传图片</view> <view class="title">上传图片({{orderObj.imgUrls.length}}/{{imagesMax}})</view>
<!-- 图片上传组件 --> <!-- 图片上传组件 -->
<image-upload-box img-urls="{{orderObj.imgUrls}}" bindpreviewimage="previewImage" binddel="del" bindupload="upLoad"></image-upload-box> <image-upload-box img-urls="{{orderObj.imgUrls}}" imagesMax="{{imagesMax}}" bindpreviewimage="previewImage" binddel="del" bindupload="upLoad"></image-upload-box>
<view class="btn text-center" bindtap="submit">提交</view> <view class="btn text-center" bindtap="submit">提交</view>
</view> </view>
......
...@@ -3,9 +3,12 @@ Component({ ...@@ -3,9 +3,12 @@ Component({
imgUrls: { imgUrls: {
type: Array, type: Array,
value: [] value: []
},
imagesMax: {
type: Number,
value: 5
} }
}, },
methods: { methods: {
previewImage(e) { previewImage(e) {
let params = e.currentTarget.dataset; let params = e.currentTarget.dataset;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
</block> --> </block> -->
<!-- <block wx:else> --> <!-- <block wx:else> -->
<!-- <block wx:if="{{imgUrls.length < 5}}"> --> <!-- <block wx:if="{{imgUrls.length < 5}}"> -->
<view wx:if="{{imgUrls.length<5}}" class="item camera-box text-center" bindtap="onUpload"> <view wx:if="{{imgUrls.length<imagesMax}}" class="item camera-box text-center" bindtap="onUpload">
<view class="icon"> <view class="icon">
<glsx-image webp src="/mine/camera.png"></glsx-image> <glsx-image webp src="/mine/camera.png"></glsx-image>
</view> </view>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<image webp src="{{item}}" mode="aspectFill" class="image"></image> <image webp src="{{item}}" mode="aspectFill" class="image"></image>
<view class="del" catchtap="onDel" data-index="{{index}}"> <view class="del" catchtap="onDel" data-index="{{index}}">
<view class="icon"> <view class="icon">
<mp-icon icon="close2" color="#D8D8D8" type="field" size="{{16}}"></mp-icon> <mp-icon icon="close2" color="#656566" type="field" size="{{16}}"></mp-icon>
</view> </view>
</view> </view>
</view> </view>
......
// packageMine/pages/order/index/index.js // packageMine/pages/order/index/index.js
import { ORDER_STATUS, OrderStatusTypes,OrderStatusEnum } from "~/constants/mine.js"; import { ORDER_STATUS, OrderStatusTypes,OrderStatusEnum } from "~/constants/mine.js";
import { calcOrderProp } from "~/packageMine/pages/order/utils";
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
...@@ -165,10 +166,7 @@ Page({ ...@@ -165,10 +166,7 @@ Page({
wx.p.api.mineApi[requestMethod](obj).then((data) => { wx.p.api.mineApi[requestMethod](obj).then((data) => {
wx.hideLoading(); wx.hideLoading();
data?.list?.forEach((e) => { data?.list?.forEach((e) => {
const { applyQty, sellQty, redeemPoints, freightAmount = 0 } = e; const {___qty,___price,___totalPrice} =calcOrderProp(e)
const ___qty = sellQty || applyQty || 0;
const ___price = (redeemPoints || 0) * ___qty;
const ___totalPrice = (redeemPoints || 0) * ___qty + +freightAmount;
list.push({ list.push({
...e, ...e,
___price, ___price,
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<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">
<mp-icon type="field" icon="close2" color="#2C2C2C" size="{{14}}"></mp-icon> <mp-icon type="field" icon="close2" color="#656566" size="{{14}}"></mp-icon>
</view> </view>
</block> </block>
</view> </view>
......
...@@ -98,3 +98,11 @@ export function getAfterSaleDetail(status) { ...@@ -98,3 +98,11 @@ export function getAfterSaleDetail(status) {
} }
return AFTER_SALE_STATUS[_status_] || {}; return AFTER_SALE_STATUS[_status_] || {};
} }
export function calcOrderProp(order){
const { applyQty, sellQty, redeemPoints, freightAmount = 0 } = order;
const ___qty = sellQty || applyQty || 0;
const ___price = (redeemPoints || 0) * ___qty;
const ___totalPrice = (redeemPoints || 0) * ___qty + +freightAmount;
return {___qty, ___price, ___totalPrice};
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!