Commit cc82d4c9 by liimin

refactor(order): 优化售后申请页面逻辑和数据处理

- 重构了 afterSaleDetail 和 afterSale_step_two 页面的代码结构
- 优化了订单信息的获取和处理逻辑
- 统一了图片列表的处理方式
- 添加了退款原因类型的处理
- 调整了组件之间的数据传递方式
1 parent 70c9ca1f
import { getAfterSaleDetail,calcOrderProp } from "~/packageMine/pages/order/utils";
import {
ORDER_STATUS,
OrderStatusEnum,
} from "~/constants/mine.js";
getAfterSaleDetail,
calcOrderProp,
} from "~/packageMine/pages/order/utils";
import { ORDER_STATUS, OrderStatusEnum } from "~/constants/mine.js";
Page({
/**
* 页面的初始数据
......@@ -32,12 +32,13 @@ Page({
},
getOrderAfterSaleDetail() {
wx.p.wxApi.showLoading("加载中...");
let { goodsSource, tparReturnOrderCode, subOrderCode,goodsSkuCode } = this.data,
let { goodsSource, tparReturnOrderCode, subOrderCode, goodsSkuCode } =
this.data,
Methods = goodsSource == 2 ? "afterSaleDetail" : "platformSaleDetail";
wx.p.api.shopmallApi[Methods]({
subOrderCode,
tparReturnOrderCode,
goodsSkuCode
goodsSkuCode,
}).then((res) => {
wx.hideLoading();
// let status = 0
......@@ -50,7 +51,7 @@ Page({
// }
const { returnOrderStatus } = res;
const status = getAfterSaleDetail({ returnOrderStatus });
const button = status.buttons?.[goodsSource][0]
const button = status.buttons?.[goodsSource][0];
// button.action = this[button.handler]
let str = "";
if (res.sendbackAddressModel) {
......@@ -58,12 +59,12 @@ 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})
const { ___qty, ___price, ___totalPrice } = calcOrderProp(res.orderGoods);
Object.assign(res.orderGoods, { ___qty, ___price, ___totalPrice });
this.setData({
orderInfo: res,
status,
button
button,
});
});
},
......@@ -80,17 +81,17 @@ Page({
// }
// this.cancelSaleApply()
// console.log('this.button', this.data.button)
// this[this.data.button.handler]()
this.toAfterSale()
this[this.data.button.handler]()
// this.toAfterSale();
},
toAfterSale(){
const { orderInfo } = this.data;
console.log("🚀 ~ toAfterSale ~ orderInfo:", orderInfo)
return
toAfterSale() {
const { orderInfo } = this.data;
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",
orderInfo
);
"/packageMine/pages/order/afterSale_step_two/afterSale_step_two",
order
);
},
/**撤销申请 */
cancelSaleApply() {
......
......@@ -5,6 +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,
......@@ -17,23 +18,39 @@ Page({
data: {
RefundReason: Object.freeze(RefundReason),
method: null,
imagesMax:9
imagesMax: 9,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.p.router.getRouterParams(options).then((orderObj) => {
console.log("🚀 ~ orderObj:", orderObj)
Object.assign(orderObj, {
returnType:orderObj.returnType||1001,
imgUrls:orderObj.imgUrls || []
})
console.log("🚀 ~ orderObj:", orderObj);
const { goodsSource, tparReturnOrderCode, subOrderCode, goodsSkuCode } =
orderObj;
this.setData({
orderObj,
method: Methods[orderObj.goodsSource],
// maxRefundCount: orderObj.refundCount,
});
if (tparReturnOrderCode) {
this.getOrderAfterSaleDetail(
{ goodsSource, tparReturnOrderCode, subOrderCode, goodsSkuCode },
(order) => {
console.log("🚀 ~ order:", order);
this.setOrderInfo(order);
}
);
} else {
this.setOrderInfo(orderObj);
}
});
},
setOrderInfo(order) {
const _order = Object.assign({}, order, {
returnType: order.returnType || 1001,
imgList: order.imgList || [],
});
this.setData({
orderObj: _order,
});
},
input(e) {
......@@ -65,15 +82,15 @@ Page({
},
del(e) {
let { index } = e.detail;
let { imgUrls } = this.data.orderObj;
imgUrls.splice(index, 1);
let { imgList } = this.data.orderObj;
imgList.splice(index, 1);
this.setData({
"orderObj.imgUrls": imgUrls,
"orderObj.imgList": imgList,
});
},
upLoad() {
let _this = this;
let { imgUrls = [] } = this.data.orderObj;
let { imgList = [] } = this.data.orderObj;
wx.chooseImage({
count: 1,
}).then((res) => {
......@@ -91,10 +108,10 @@ Page({
})
.then((img) => {
wx.p.wxApi.hideLoading();
imgUrls.push(img);
imgList.push(img);
_this.setData({
imgUrls,
"orderObj.imgUrls": imgUrls,
imgList,
"orderObj.imgList": imgList,
});
});
},
......@@ -135,4 +152,23 @@ Page({
}
});
},
getOrderAfterSaleDetail(
{ goodsSource, tparReturnOrderCode, subOrderCode, goodsSkuCode },
cb
) {
wx.p.wxApi.showLoading("加载中...");
const Methods = goodsSource == 2 ? "afterSaleDetail" : "platformSaleDetail";
wx.p.api.shopmallApi[Methods]({
subOrderCode,
tparReturnOrderCode,
goodsSkuCode,
}).then((res) => {
wx.hideLoading();
const { orderGoods, imgUrlList, ...rest } = res;
const order = Object.assign({ imgList: imgUrlList }, orderGoods, rest);
const { ___qty, ___price, ___totalPrice } = calcOrderProp(order);
Object.assign(order, { ___qty, ___price, ___totalPrice });
cb(order);
});
},
});
......@@ -10,6 +10,7 @@
refund-count="{{orderObj.applyQty}}"
max-refund-count="{{maxRefundCount}}"
refund-price="{{orderObj.refundPoints}}"
refund-reason-type="{{orderObj.returnReasonType}}"
show-refund-count="{{showRefundCount}}"
bindconfirmpopup="confirmPopup"
bindchangerefundcount="changeRefundCount"
......@@ -23,10 +24,10 @@
<gl-textarea maxlength="230" placeholder="补充描述,有助于商家更好的处理售后问题" value="{{orderObj.returnContent}}" bindinput="input" showWordLimit customMaxLength></gl-textarea>
</view>
<view class="title">上传图片({{orderObj.imgUrls.length}}/{{imagesMax}})</view>
<view class="title">上传图片({{orderObj.imgList.length}}/{{imagesMax}})</view>
<!-- 图片上传组件 -->
<image-upload-box img-urls="{{orderObj.imgUrls}}" imagesMax="{{imagesMax}}" bindpreviewimage="previewImage" binddel="del" bindupload="upLoad"></image-upload-box>
<image-upload-box img-urls="{{orderObj.imgList}}" imagesMax="{{imagesMax}}" bindpreviewimage="previewImage" binddel="del" bindupload="upLoad"></image-upload-box>
<view class="btn text-center" bindtap="submit">提交</view>
</view>
......
......@@ -17,6 +17,14 @@ Component({
type: Boolean,
value: false,
},
refundReasonType:{
type:Number,
value: 0,
observer: function (val) {
if (!val) return;
this.setRefundReason(val)
},
}
},
data: {
......@@ -55,10 +63,14 @@ Component({
onRadioChange(e) {
const {value} = e.currentTarget.dataset.item;
this.setData({
refundReason: this.data.RefundReasonList.find((item) => item.value == value).text,
});
this.setRefundReason(value)
this.triggerEvent("radiochange", { value });
},
setRefundReason(value){
this.setData({
refundReason: this.data.RefundReasonList.find((item) => item.value == value).text,
});
}
},
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!