Commit cc82d4c9 by liimin

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

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