afterSaleDetail.js
4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import {
getAfterSaleDetail,
calcOrderProp,
getOrder,
API_Methods,
APIS,
} from "~/packageMine/pages/order/utils";
import { ORDER_STATUS, OrderStatusEnum } from "~/constants/mine.js";
Page({
/**
* 页面的初始数据
*/
data: {
order: {
express_no: "",
},
orderInfo: {},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.p.router.getRouterParams(options).then((params) => {
if (params) {
this.setData({
...params,
});
this.getOrderAfterSaleDetail(params.subOrderCode);
}
});
},
submitlogistics() {
this.getOrderAfterSaleDetail();
},
getOrderAfterSaleDetail() {
wx.p.wxApi.showLoading("加载中...");
let { goodsSource, tparReturnOrderCode, subOrderCode, goodsSkuCode } =
this.data;
// Methods = goodsSource == 2 ? "afterSaleDetail" : "platformSaleDetail";
API_Methods[goodsSource][APIS.AFTER_SALE_DETAIL]({
subOrderCode,
tparReturnOrderCode,
goodsSkuCode,
})
.then((res) => {
// let status = 0
// if (res.returnOrderStatus == 1000 || res.returnOrderStatus == 1002 || res.returnOrderStatus == 1001 || res.returnOrderStatus == 1004 || (res.returnOrderStatus == 1003 && res.outRefundType == 2)) {
// status = 0
// } else if (res.returnOrderStatus == 1003 && res.outRefundType == 0) {
// status = 1
// } else if (res.returnOrderStatus == 1005 || (res.returnOrderStatus == 1003 && res.outRefundType == 3) || (res.returnOrderStatus == 1003 && res.outRefundType == 1)) {
// status = 2
// }
// const { returnOrderStatus } = res;
const status = getOrder(res); //getAfterSaleDetail({ returnOrderStatus });
const button = status.detail.buttons?.[goodsSource][0] || {}; //status.buttons?.[goodsSource][0];
// button.action = this[button.handler]
let str = "";
if (res.sendbackAddressModel) {
const { sendbackAddressModel } = res;
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,
button,
});
}).catch((err) => {
wx.p.sentry.reportError(`售后详情异常:${err.message}`, {...this.data,err});
})
.finally(() => {
wx.hideLoading();
});
},
confirm() {
// const { status, orderInfo } = this.data;
// if (status == 0) {
// this.cancelSaleApply();
// } else if (status == 2) {
// wx.p.router.go(
// "/packageMine/pages/order/afterSale_step_two/afterSale_step_two",
// orderInfo
// );
// }
// this.cancelSaleApply()
// console.log('this.button', this.data.button)
this[this.data.button.handler]();
// this.toAfterSale();
},
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
);
},
/**撤销申请 */
cancelSaleApply() {
const { orderInfo } = this.data;
let para = {
tparReturnOrderCode: orderInfo.tparReturnOrderCode,
};
wx.showModal({
title: "提示",
content: `请确认是否撤销申请`,
confirmColor: "#F13C3D",
})
.then((res) => {
if (res.confirm) {
wx.p.wxApi.showLoading("提交中");
const URLNAME = "platformEditSale";
wx.p.api.shopmallApi[URLNAME](para).then((res) => {
if (res) {
wx.p.wxApi.showToast("撤销成功");
wx.p.router.go("/packageMine/pages/order/index/index", {
tab: ORDER_STATUS[OrderStatusEnum.COMPLETED],
});
}
}).catch((err) => {
wx.p.sentry.reportError(`撤销售后:${err.message}`, {...this.data.orderInfo,err});
});
}
})
.catch((err) => {
wx.p.sentry.reportError(`撤销售后Modal:${err.message}`, {...this.data.orderInfo,err});
wx.p.wxApi.showToast("已取消");
})
.finally(() => {
setTimeout(() => {
wx.hideLoading();
}, 500);
});
},
previewImage(e) {
let params = e.detail; // 从组件传递的数据
wx.p.wxApi.previewImage(params);
},
onExpressNoInput(e) {
const { value } = e.detail;
this.setData({
"order.express_no": value,
});
},
onSubmitLogistics() {
// 提交物流信息的处理逻辑
console.log("提交物流信息");
},
});