|
|
@@ -1,4 +1,4 @@
|
|
|
-import { getAfterSaleDetailMethod, cancelAfterSaleMethod, updateAfterSaleMethod } from "../../request";
|
|
|
+import { getAfterSaleDetailMethod, cancelAfterSaleMethod, applyAfterSaleMethod, updateAfterSaleMethod } from "../../request";
|
|
|
|
|
|
// progress 数字转页面状态
|
|
|
const progressToState: Record<string, string> = {
|
|
|
@@ -12,6 +12,7 @@ const progressToState: Record<string, string> = {
|
|
|
Page({
|
|
|
data: {
|
|
|
id: '',
|
|
|
+ recordId: '',
|
|
|
aftersaleId: '',
|
|
|
pageTitle: '商家处理',
|
|
|
refundState: '',
|
|
|
@@ -31,6 +32,7 @@ Page({
|
|
|
finishTime: "",
|
|
|
applyTime: "",
|
|
|
refundNo: "",
|
|
|
+ updateTime:""
|
|
|
},
|
|
|
// 协商历史标题和内容
|
|
|
negotiateTitle: "",
|
|
|
@@ -46,15 +48,19 @@ Page({
|
|
|
refundConfirmPopupVisible: false,
|
|
|
refundProofPopupVisible: false,
|
|
|
refundStatus: '',
|
|
|
+ refundAction: '', // 'modify' 修改申请 | 'reApply' 再次申请
|
|
|
refundMaxAmount: '0',
|
|
|
refundProofImages: [] as string[],
|
|
|
+ refundDesc: '',
|
|
|
+ // 接口提交所需原始字段
|
|
|
+ rawDetail: {} as any,
|
|
|
},
|
|
|
|
|
|
timer: null as any,
|
|
|
|
|
|
onLoad(options: any) {
|
|
|
if (options.id) {
|
|
|
- this.setData({ id: options.id });
|
|
|
+ this.setData({ id: options.id, recordId: options.recordId || '' });
|
|
|
this.loadDetail(options.id);
|
|
|
}
|
|
|
},
|
|
|
@@ -75,6 +81,7 @@ Page({
|
|
|
const refundState = progressToState[String(detail.progress)] || 'processing';
|
|
|
|
|
|
this.setData({
|
|
|
+ rawDetail: detail,
|
|
|
aftersaleId: detail.id || '',
|
|
|
refundState,
|
|
|
goods: {
|
|
|
@@ -85,16 +92,22 @@ Page({
|
|
|
},
|
|
|
refundDetail: {
|
|
|
reason: detail.reason || '',
|
|
|
- amount: String(detail.reviewAmount || detail.applyAmount || 0),
|
|
|
+ amount: String(detail.applyAmount || 0),
|
|
|
finishTime: detail.finishTime || '',
|
|
|
applyTime: detail.applyTime || '',
|
|
|
refundNo: detail.ref || '',
|
|
|
+ updateTime:detail.updateTime || ''
|
|
|
},
|
|
|
negotiateTitle: detail.title || '',
|
|
|
- negotiateContent: detail.content || '',
|
|
|
+ negotiateContent: (() => {
|
|
|
+ const c = detail.content || '';
|
|
|
+ try { if (c && JSON.parse(c)) return ''; } catch (e) { /* 不是JSON,保留原文 */ }
|
|
|
+ return c;
|
|
|
+ })(),
|
|
|
handleEndTime: detail.handleEndTime || '',
|
|
|
refundMaxAmount: String(detail.applyAmount || 0),
|
|
|
refundProofImages: detail.voucherImgs || [],
|
|
|
+ refundDesc: detail.remark || '',
|
|
|
});
|
|
|
|
|
|
this.updatePageTitle();
|
|
|
@@ -129,6 +142,14 @@ Page({
|
|
|
const setTime = (diff: number) => {
|
|
|
if (diff <= 0) {
|
|
|
this.setData({ days: '00', hours: '00', minutes: '00', seconds: '00' });
|
|
|
+ if (this.timer) {
|
|
|
+ clearInterval(this.timer);
|
|
|
+ this.timer = null;
|
|
|
+ }
|
|
|
+ // 拒绝状态倒计时结束,清除截止时间,触发按钮切换
|
|
|
+ if (this.data.refundState === 'rejected' && this.data.handleEndTime) {
|
|
|
+ this.setData({ handleEndTime: '' });
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
const d = Math.floor(diff / (1000 * 60 * 60 * 24));
|
|
|
@@ -160,7 +181,7 @@ Page({
|
|
|
|
|
|
// 修改申请:打开确认弹窗
|
|
|
onModify() {
|
|
|
- this.setData({ refundConfirmPopupVisible: true });
|
|
|
+ this.setData({ refundAction: 'modify', refundConfirmPopupVisible: true });
|
|
|
},
|
|
|
|
|
|
onRefundConfirmClose() {
|
|
|
@@ -191,15 +212,37 @@ Page({
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- onSubmitRefundApply() {
|
|
|
- this.setData({ refundConfirmPopupVisible: false });
|
|
|
+ async onSubmitRefundApply() {
|
|
|
+ if (!this.data.refundProofImages.length) {
|
|
|
+ wx.showToast({ title: '请上传凭证图片', icon: 'none' });
|
|
|
+ return;
|
|
|
+ }
|
|
|
wx.showLoading({ title: '正在提交' });
|
|
|
- setTimeout(() => {
|
|
|
- wx.hideLoading();
|
|
|
+ const { rawDetail, refundStatus, refundDetail, refundProofImages, refundDesc, recordId, id, aftersaleId, refundAction } = this.data;
|
|
|
+ const params = {
|
|
|
+ patientConditioningRecordId: recordId,
|
|
|
+ patientConditioningProgramId: id,
|
|
|
+ type: rawDetail.type,
|
|
|
+ ...(rawDetail.sellType === '1' ? { receiptStatus: refundStatus || rawDetail.receiptStatus } : {}),
|
|
|
+ reason: refundDetail.reason,
|
|
|
+ applyAmount: Number(refundDetail.amount) || 0,
|
|
|
+ voucherImgs: refundProofImages,
|
|
|
+ remark: refundDesc,
|
|
|
+ };
|
|
|
+ try {
|
|
|
+ if (refundAction === 'modify') {
|
|
|
+ await updateAfterSaleMethod(Number(aftersaleId), params);
|
|
|
+ } else {
|
|
|
+ await applyAfterSaleMethod(params);
|
|
|
+ }
|
|
|
+ this.setData({ refundConfirmPopupVisible: false });
|
|
|
wx.navigateTo({
|
|
|
url: '/module/order/pages/refund-success/refund-success'
|
|
|
});
|
|
|
- }, 1000);
|
|
|
+ } catch (error: any) {
|
|
|
+ wx.showToast({ title: error.errMsg || '提交失败', icon: 'none' });
|
|
|
+ }
|
|
|
+ wx.hideLoading();
|
|
|
},
|
|
|
|
|
|
onRefundReasonPopupClose() {
|
|
|
@@ -215,12 +258,13 @@ Page({
|
|
|
},
|
|
|
|
|
|
onRefundProofPopupClose() {
|
|
|
- this.setData({ refundProofPopupVisible: false });
|
|
|
+ this.setData({ refundProofPopupVisible: false, refundConfirmPopupVisible: true });
|
|
|
},
|
|
|
|
|
|
onRefundProofSubmit(e: any) {
|
|
|
this.setData({
|
|
|
refundProofImages: e.detail.images,
|
|
|
+ refundDesc: e.detail.desc || '',
|
|
|
refundProofPopupVisible: false,
|
|
|
refundConfirmPopupVisible: true
|
|
|
});
|
|
|
@@ -248,6 +292,10 @@ Page({
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ onReApply() {
|
|
|
+ this.setData({ refundAction: 'reApply', refundConfirmPopupVisible: true });
|
|
|
+ },
|
|
|
+
|
|
|
onRevoke() {
|
|
|
wx.showModal({
|
|
|
title: '撤销退款申请',
|