|
|
@@ -1,46 +1,112 @@
|
|
|
+import { getAfterSaleDetailMethod, cancelAfterSaleMethod, updateAfterSaleMethod } from "../../request";
|
|
|
+
|
|
|
+// progress 数字转页面状态
|
|
|
+const progressToState: Record<string, string> = {
|
|
|
+ '0': 'processing',
|
|
|
+ '1': 'revoked',
|
|
|
+ '2': 'rejected',
|
|
|
+ '3': 'approved',
|
|
|
+ '4': 'completed',
|
|
|
+};
|
|
|
+
|
|
|
Page({
|
|
|
data: {
|
|
|
+ id: '',
|
|
|
+ aftersaleId: '',
|
|
|
pageTitle: '商家处理',
|
|
|
- refundState: 'processing', // 测试数据:processing, approved, revoked, rejected, 或 completed
|
|
|
- days: '06',
|
|
|
- hours: '23',
|
|
|
- minutes: '43',
|
|
|
- seconds: '59',
|
|
|
+ refundState: '',
|
|
|
+ days: '00',
|
|
|
+ hours: '00',
|
|
|
+ minutes: '00',
|
|
|
+ seconds: '00',
|
|
|
goods: {
|
|
|
- name: "肝血贴穴位贴",
|
|
|
- meta1: "10贴",
|
|
|
- price: "240",
|
|
|
- image: ""
|
|
|
+ name: "",
|
|
|
+ meta1: "",
|
|
|
+ price: "",
|
|
|
+ image: "",
|
|
|
},
|
|
|
refundDetail: {
|
|
|
- reason: "少件(含缺少配件)",
|
|
|
- amount: "240.00",
|
|
|
- finishTime: "2025-02-19 20:30:27",
|
|
|
- applyTime: "2025-02-19 14:30:27",
|
|
|
- refundNo: "7364647828273462271"
|
|
|
+ reason: "",
|
|
|
+ amount: "",
|
|
|
+ finishTime: "",
|
|
|
+ applyTime: "",
|
|
|
+ refundNo: "",
|
|
|
},
|
|
|
+ // 协商历史标题和内容
|
|
|
+ negotiateTitle: "",
|
|
|
+ negotiateContent: "",
|
|
|
+ // 拒绝状态处理截止时间
|
|
|
+ handleEndTime: "",
|
|
|
refundDestination: {
|
|
|
type: '退回微信',
|
|
|
- account: '梅*** 158******26'
|
|
|
+ account: '',
|
|
|
},
|
|
|
// 弹窗状态
|
|
|
refundReasonPopupVisible: false,
|
|
|
refundConfirmPopupVisible: false,
|
|
|
refundProofPopupVisible: false,
|
|
|
- refundStatus: 'received',
|
|
|
- refundMaxAmount: '240',
|
|
|
- refundProofImages: [],
|
|
|
+ refundStatus: '',
|
|
|
+ refundMaxAmount: '0',
|
|
|
+ refundProofImages: [] as string[],
|
|
|
},
|
|
|
|
|
|
timer: null as any,
|
|
|
|
|
|
- onLoad() {
|
|
|
- this.updatePageTitle();
|
|
|
- if (this.data.refundState === 'processing' || this.data.refundState === 'rejected') {
|
|
|
- this.startCountdown();
|
|
|
+ onLoad(options: any) {
|
|
|
+ if (options.id) {
|
|
|
+ this.setData({ id: options.id });
|
|
|
+ this.loadDetail(options.id);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ onShow() {
|
|
|
+ if (this.data.id && this.data.refundState) {
|
|
|
+ this.loadDetail(this.data.id);
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ async loadDetail(id: string) {
|
|
|
+ wx.showLoading({ title: '加载中' });
|
|
|
+ try {
|
|
|
+ const res = await getAfterSaleDetailMethod(id);
|
|
|
+ const detail = (res as any)?.data;
|
|
|
+ if (!detail) return;
|
|
|
+
|
|
|
+ const refundState = progressToState[String(detail.progress)] || 'processing';
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ aftersaleId: detail.id || '',
|
|
|
+ refundState,
|
|
|
+ goods: {
|
|
|
+ name: detail.conditioningProgramName || '',
|
|
|
+ meta1: detail.convertDose ? `${detail.convertDose}${detail.convertUnit || '次'}` : '',
|
|
|
+ price: String(detail.applyAmount || 0),
|
|
|
+ image: detail.conditioningProgramPhoto || '',
|
|
|
+ },
|
|
|
+ refundDetail: {
|
|
|
+ reason: detail.reason || '',
|
|
|
+ amount: String(detail.reviewAmount || detail.applyAmount || 0),
|
|
|
+ finishTime: detail.finishTime || '',
|
|
|
+ applyTime: detail.applyTime || '',
|
|
|
+ refundNo: detail.ref || '',
|
|
|
+ },
|
|
|
+ negotiateTitle: detail.title || '',
|
|
|
+ negotiateContent: detail.content || '',
|
|
|
+ handleEndTime: detail.handleEndTime || '',
|
|
|
+ refundMaxAmount: String(detail.applyAmount || 0),
|
|
|
+ refundProofImages: detail.voucherImgs || [],
|
|
|
+ });
|
|
|
+
|
|
|
+ this.updatePageTitle();
|
|
|
+ if (refundState === 'processing' || refundState === 'rejected') {
|
|
|
+ this.startCountdown();
|
|
|
+ }
|
|
|
+ } catch (error: any) {
|
|
|
+ wx.showToast({ title: error.errMsg || '获取详情失败', icon: 'none' });
|
|
|
+ }
|
|
|
+ wx.hideLoading();
|
|
|
+ },
|
|
|
+
|
|
|
updatePageTitle() {
|
|
|
let title = '商家处理';
|
|
|
if (this.data.refundState === 'revoked') {
|
|
|
@@ -58,32 +124,38 @@ Page({
|
|
|
},
|
|
|
|
|
|
startCountdown() {
|
|
|
- // 模拟真实的倒计时,预设当前剩余时间(处理中通常为48小时,拒绝重填通常为7天)
|
|
|
- const targetHours = this.data.refundState === 'rejected' ? 7 * 24 : 48;
|
|
|
- const targetTime = new Date().getTime() + targetHours * 60 * 60 * 1000 - 1000;
|
|
|
-
|
|
|
- this.timer = setInterval(() => {
|
|
|
- const now = new Date().getTime();
|
|
|
- const diff = targetTime - now;
|
|
|
+ if (this.timer) clearInterval(this.timer);
|
|
|
|
|
|
+ const setTime = (diff: number) => {
|
|
|
if (diff <= 0) {
|
|
|
- clearInterval(this.timer);
|
|
|
this.setData({ days: '00', hours: '00', minutes: '00', seconds: '00' });
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
const d = Math.floor(diff / (1000 * 60 * 60 * 24));
|
|
|
const h = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
|
|
const m = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
|
|
|
const s = Math.floor((diff % (1000 * 60)) / 1000);
|
|
|
-
|
|
|
this.setData({
|
|
|
days: d < 10 ? '0' + d : String(d),
|
|
|
hours: h < 10 ? '0' + h : String(h),
|
|
|
minutes: m < 10 ? '0' + m : String(m),
|
|
|
seconds: s < 10 ? '0' + s : String(s),
|
|
|
});
|
|
|
- }, 1000);
|
|
|
+ };
|
|
|
+
|
|
|
+ if (this.data.refundState === 'rejected' && this.data.handleEndTime) {
|
|
|
+ // rejected:倒计时到处理截止时间
|
|
|
+ const target = new Date(this.data.handleEndTime.replace(/-/g, '/')).getTime();
|
|
|
+ const update = () => setTime(target - new Date().getTime());
|
|
|
+ update();
|
|
|
+ this.timer = setInterval(update, 1000);
|
|
|
+ } else {
|
|
|
+ // processing:已过去的时间
|
|
|
+ const applyTime = new Date(this.data.refundDetail.applyTime.replace(/-/g, '/')).getTime();
|
|
|
+ const update = () => setTime(new Date().getTime() - applyTime);
|
|
|
+ update();
|
|
|
+ this.timer = setInterval(update, 1000);
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
// 修改申请:打开确认弹窗
|
|
|
@@ -91,7 +163,6 @@ Page({
|
|
|
this.setData({ refundConfirmPopupVisible: true });
|
|
|
},
|
|
|
|
|
|
- // 确认弹窗处理
|
|
|
onRefundConfirmClose() {
|
|
|
this.setData({ refundConfirmPopupVisible: false });
|
|
|
},
|
|
|
@@ -131,7 +202,6 @@ Page({
|
|
|
}, 1000);
|
|
|
},
|
|
|
|
|
|
- // 原因弹窗处理
|
|
|
onRefundReasonPopupClose() {
|
|
|
this.setData({ refundReasonPopupVisible: false });
|
|
|
},
|
|
|
@@ -144,7 +214,6 @@ Page({
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- // 凭证弹窗处理
|
|
|
onRefundProofPopupClose() {
|
|
|
this.setData({ refundProofPopupVisible: false });
|
|
|
},
|
|
|
@@ -159,7 +228,7 @@ Page({
|
|
|
|
|
|
onViewHistory() {
|
|
|
wx.navigateTo({
|
|
|
- url: '/module/order/pages/negotiation-history/negotiation-history'
|
|
|
+ url: `/module/order/pages/negotiation-history/negotiation-history?id=${this.data.aftersaleId}`
|
|
|
});
|
|
|
},
|
|
|
|
|
|
@@ -174,10 +243,8 @@ Page({
|
|
|
|
|
|
onCallService() {
|
|
|
wx.makePhoneCall({
|
|
|
- phoneNumber: '400-123-4567', // 替换为真实的客服电话
|
|
|
- fail: () => {
|
|
|
- // 用户取消拨打
|
|
|
- }
|
|
|
+ phoneNumber: '400-123-4567',
|
|
|
+ fail: () => { }
|
|
|
});
|
|
|
},
|
|
|
|
|
|
@@ -187,14 +254,19 @@ Page({
|
|
|
content: '撤销退款申请后,可以再次发起退款申请(总共可发起2次)',
|
|
|
confirmText: '确定撤销',
|
|
|
cancelText: '暂不撤销',
|
|
|
- success: (res) => {
|
|
|
+ success: async (res) => {
|
|
|
if (res.confirm) {
|
|
|
- wx.showToast({ title: '已撤销', icon: 'success' });
|
|
|
- setTimeout(() => {
|
|
|
- wx.redirectTo({
|
|
|
- url: '/module/article/pages/success-page/success-page?title=撤销退款申请成功'
|
|
|
- });
|
|
|
- }, 1500);
|
|
|
+ try {
|
|
|
+ await cancelAfterSaleMethod(Number(this.data.aftersaleId));
|
|
|
+ wx.showToast({ title: '已撤销', icon: 'success' });
|
|
|
+ setTimeout(() => {
|
|
|
+ wx.redirectTo({
|
|
|
+ url: '/module/article/pages/success-page/success-page?title=撤销退款申请成功'
|
|
|
+ });
|
|
|
+ }, 1500);
|
|
|
+ } catch (error: any) {
|
|
|
+ wx.showToast({ title: error.errMsg || '撤销失败', icon: 'none' });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|