Commit 70c9ca1f by liimin

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

- 移除订单状态中的重复代码
- 优化订单详情和售后流程的逻辑
- 统一图片上传组件的样式和功能
- 重构订单列表的渲染逻辑
- 新增 calcOrderProp 函数用于计算订单属性
1 parent f2928b8f
......@@ -100,7 +100,11 @@ export const ORDER_STATUS = {
buttons: {
[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 {
ORDER_STATUS,
OrderStatusEnum,
......@@ -58,7 +58,8 @@ Page({
str = `${sendbackAddressModel.provinceName}${sendbackAddressModel.cityName}${sendbackAddressModel.countyName}${sendbackAddressModel.address}`;
}
res.addressInfo = str;
const {___qty,___price,___totalPrice} =calcOrderProp(res.orderGoods)
Object.assign(res.orderGoods,{___qty,___price,___totalPrice})
this.setData({
orderInfo: res,
status,
......@@ -79,7 +80,17 @@ 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;
console.log("🚀 ~ toAfterSale ~ orderInfo:", orderInfo)
return
wx.p.router.go(
"/packageMine/pages/order/afterSale_step_two/afterSale_step_two",
orderInfo
);
},
/**撤销申请 */
cancelSaleApply() {
......
......@@ -17,6 +17,7 @@ Page({
data: {
RefundReason: Object.freeze(RefundReason),
method: null,
imagesMax:9
},
/**
* 生命周期函数--监听页面加载
......@@ -24,7 +25,10 @@ Page({
onLoad: function (options) {
wx.p.router.getRouterParams(options).then((orderObj) => {
console.log("🚀 ~ orderObj:", orderObj)
orderObj.returnType = 1001;
Object.assign(orderObj, {
returnType:orderObj.returnType||1001,
imgUrls:orderObj.imgUrls || []
})
this.setData({
orderObj,
method: Methods[orderObj.goodsSource],
......
......@@ -7,7 +7,7 @@
<!-- 退款信息组件 -->
<refund-info-box
orderObj="{{orderObj}}"
refund-count="{{orderObj.___qty}}"
refund-count="{{orderObj.applyQty}}"
max-refund-count="{{maxRefundCount}}"
refund-price="{{orderObj.refundPoints}}"
show-refund-count="{{showRefundCount}}"
......@@ -23,10 +23,10 @@
<gl-textarea maxlength="230" placeholder="补充描述,有助于商家更好的处理售后问题" value="{{orderObj.returnContent}}" bindinput="input" showWordLimit customMaxLength></gl-textarea>
</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>
......
......@@ -3,9 +3,12 @@ Component({
imgUrls: {
type: Array,
value: []
},
imagesMax: {
type: Number,
value: 5
}
},
methods: {
previewImage(e) {
let params = e.currentTarget.dataset;
......
......@@ -8,7 +8,7 @@
</block> -->
<!-- <block wx:else> -->
<!-- <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">
<glsx-image webp src="/mine/camera.png"></glsx-image>
</view>
......@@ -19,7 +19,7 @@
<image webp src="{{item}}" mode="aspectFill" class="image"></image>
<view class="del" catchtap="onDel" data-index="{{index}}">
<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>
......
// packageMine/pages/order/index/index.js
import { ORDER_STATUS, OrderStatusTypes,OrderStatusEnum } from "~/constants/mine.js";
import { calcOrderProp } from "~/packageMine/pages/order/utils";
Page({
/**
* 页面的初始数据
......@@ -165,10 +166,7 @@ Page({
wx.p.api.mineApi[requestMethod](obj).then((data) => {
wx.hideLoading();
data?.list?.forEach((e) => {
const { applyQty, sellQty, redeemPoints, freightAmount = 0 } = e;
const ___qty = sellQty || applyQty || 0;
const ___price = (redeemPoints || 0) * ___qty;
const ___totalPrice = (redeemPoints || 0) * ___qty + +freightAmount;
const {___qty,___price,___totalPrice} =calcOrderProp(e)
list.push({
...e,
___price,
......
......@@ -11,7 +11,7 @@
<input type="text" placeholder="搜索" value="{{keyword}}" class="input" confirm-type="search" bindconfirm="search" bindinput="input" bindblur="blur" />
<block wx:if="{{keyword}}">
<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>
</block>
</view>
......
......@@ -98,3 +98,11 @@ export function getAfterSaleDetail(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!