| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- Page({
- data: {
- pageTitle: '商家处理',
- refundState: 'completed', // 测试数据:processing, approved, revoked, rejected, 或 completed
- days: '06',
- hours: '23',
- minutes: '43',
- seconds: '59',
- goods: {
- name: "肝血贴穴位贴",
- meta1: "10贴",
- price: "240",
- image: ""
- },
- refundDetail: {
- reason: "少件(含缺少配件)",
- amount: "240.00",
- finishTime: "2025-02-19 20:30:27",
- applyTime: "2025-02-19 14:30:27",
- refundNo: "7364647828273462271"
- },
- refundDestination: {
- type: '退回微信',
- account: '梅*** 158******26'
- },
- // 弹窗状态
- refundReasonPopupVisible: false,
- refundConfirmPopupVisible: false,
- refundProofPopupVisible: false,
- refundStatus: 'received',
- refundMaxAmount: '240',
- refundProofImages: [],
- },
- timer: null as any,
- onLoad() {
- this.updatePageTitle();
- if (this.data.refundState === 'processing' || this.data.refundState === 'rejected') {
- this.startCountdown();
- }
- },
- updatePageTitle() {
- let title = '商家处理';
- if (this.data.refundState === 'revoked') {
- title = '撤销申请';
- } else if (this.data.refundState === 'completed') {
- title = '退款完成';
- }
- this.setData({ pageTitle: title });
- },
- onUnload() {
- if (this.timer) {
- clearInterval(this.timer);
- }
- },
- 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 (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);
- },
- // 修改申请:打开确认弹窗
- onModify() {
- this.setData({ refundConfirmPopupVisible: true });
- },
- // 确认弹窗处理
- onRefundConfirmClose() {
- this.setData({ refundConfirmPopupVisible: false });
- },
- onChangeRefundStatus(e: any) {
- this.setData({ refundStatus: e.detail.status });
- },
- onOpenRefundReasonAgain() {
- this.setData({
- refundConfirmPopupVisible: false,
- refundReasonPopupVisible: true
- });
- },
- onOpenRefundProofEditor() {
- this.setData({
- refundConfirmPopupVisible: false,
- refundProofPopupVisible: true
- });
- },
- onRefundAmountConfirm(e: any) {
- this.setData({
- ['refundDetail.amount']: e.detail.amount
- });
- },
- onSubmitRefundApply() {
- this.setData({ refundConfirmPopupVisible: false });
- wx.showLoading({ title: '正在提交' });
- setTimeout(() => {
- wx.hideLoading();
- wx.navigateTo({
- url: '/module/order/pages/refund-success/refund-success'
- });
- }, 1000);
- },
- // 原因弹窗处理
- onRefundReasonPopupClose() {
- this.setData({ refundReasonPopupVisible: false });
- },
- onRefundReasonNext(e: any) {
- this.setData({
- ['refundDetail.reason']: e.detail.reason,
- refundReasonPopupVisible: false,
- refundConfirmPopupVisible: true
- });
- },
- // 凭证弹窗处理
- onRefundProofPopupClose() {
- this.setData({ refundProofPopupVisible: false });
- },
- onRefundProofSubmit(e: any) {
- this.setData({
- refundProofImages: e.detail.images,
- refundProofPopupVisible: false,
- refundConfirmPopupVisible: true
- });
- },
- onViewHistory() {
- wx.navigateTo({
- url: '/module/order/pages/negotiation-history/negotiation-history'
- });
- },
- onCopyRefundNo() {
- wx.setClipboardData({
- data: this.data.refundDetail.refundNo,
- success: () => {
- wx.showToast({ title: '已复制', icon: 'none' });
- }
- });
- },
- onCallService() {
- wx.makePhoneCall({
- phoneNumber: '400-123-4567', // 替换为真实的客服电话
- fail: () => {
- // 用户取消拨打
- }
- });
- },
- onRevoke() {
- wx.showModal({
- title: '撤销退款申请',
- content: '撤销退款申请后,可以再次发起退款申请(总共可发起2次)',
- confirmText: '确定撤销',
- cancelText: '暂不撤销',
- success: (res) => {
- if (res.confirm) {
- wx.showToast({ title: '已撤销', icon: 'success' });
- setTimeout(() => {
- wx.redirectTo({
- url: '/module/article/pages/success-page/success-page?title=撤销退款申请成功'
- });
- }, 1500);
- }
- }
- });
- }
- });
|