import { api_userPaymentOrderRefundPayment } from "../../api/login"; // components/apply-refound/apply-refound.ts Component({ /** * 组件的属性列表 */ properties: { refoundStatus: { type: Boolean, default: false, }, goodsInfo: { type: Object, default: {} } }, /** * 组件的初始数据 */ data: { submitStatus: false, refoundValue: "", // 退款内容 refoundPhone: '' }, /** * 组件的方法列表 */ methods: { textareaInput(e: { detail: any }) { this.setData({ refoundValue: e.detail.value }) }, phoneInput(e: { detail: any }) { this.setData({ refoundPhone: e.detail.value }) }, onRefoundClose() { this.triggerEvent("changeRefoundStatus", false) }, checkPhone(phone: string) { const phoneRule = /^((13[0-9])|(14(0|[5-7]|9))|(15([0-3]|[5-9]))|(16(2|[5-9]))|(17[0-8])|(18[0-9])|(19([0-3]|[5-9])))\d{8}$/; return phoneRule.test(phone); }, async onRefound() { const refoundValue = this.data.refoundValue const refoundPhone = this.data.refoundPhone if (!refoundValue) { wx.showToast({ title: '请输入退款原因', icon: 'none' }) return } if (!this.checkPhone(refoundPhone)) { wx.showToast({ title: '请输入正确的手机号码', icon: 'none' }) return } try { this.setData({ submitStatus: true }) const { goods, orderNo } = this.data.goodsInfo const details: any = [] goods.forEach((item: any) => { details.push({ num: item.goodsNum, onlyRefund: false, userPaymentOrderDetailId: item.id, refundAmount: item.currentPrice }) }) const params = { merOrderNo: orderNo, serviceCharge: false, refundReason: refoundValue, phone: refoundPhone, // 手机号 serviceChargeFee: 0, userRefundOrderDetails: details } const { data } = await api_userPaymentOrderRefundPayment(params) this.setData({ submitStatus: false }) if (data.code == 200) { wx.showToast({ title: '申请成功', icon: 'none' }) this.triggerEvent('onConfirm') } else { wx.showToast({ title: data.message, icon: 'none' }) } } catch { } }, } })