diff --git a/packages/myOrders/groupOrders/index.vue b/packages/myOrders/groupOrders/index.vue index 626aca47..b4128f7a 100644 --- a/packages/myOrders/groupOrders/index.vue +++ b/packages/myOrders/groupOrders/index.vue @@ -168,8 +168,6 @@ export default { }, methods: { selectTab(index, item) { - console.log("🚀 ~ selectTab ~ index:", index) - console.log("🚀 ~ selectTab ~ item:", item) this.selectedTab = index; if (index == 6) { this.evaluateStatus = 2; @@ -235,7 +233,7 @@ export default { goods_ids: this.afterSaleOrderItem.commodity_order_item_list.map(item => item.goods_id), after_sales_type: data.afterSalesType, after_sales_reason: data.refundReason, - refund_amount: this.afterSaleOrderItem.total_amount, + refund_amount: data.refundAmount, application_description: data.refundDescription, // 将图片对象数组转换为字符串数组,多个URL用逗号分隔 application_images: data.imgList && data.imgList.length > 0 ? diff --git a/packages/myOrders/index/index.vue b/packages/myOrders/index/index.vue index e622a71f..63bc122c 100644 --- a/packages/myOrders/index/index.vue +++ b/packages/myOrders/index/index.vue @@ -234,7 +234,7 @@ export default { goods_ids: this.afterSaleOrderItem.commodity_order_item_list.map(item => item.goods_id), after_sales_type: data.afterSalesType, after_sales_reason: data.refundReason, - refund_amount: this.afterSaleOrderItem.total_amount, + refund_amount: data.refundAmount, application_description: data.refundDescription, // 将图片对象数组转换为字符串数组,多个URL用逗号分隔 application_images: data.imgList && data.imgList.length > 0 ? @@ -262,7 +262,7 @@ export default { // 处理退款确认事件 handleRefundConfirmed(data) { - const params = { + const params = { order_id: this.afterSaleItem.id, } request(afterSaleApi.orderRefund, "POST", params).then((res) => { diff --git a/packages/myOrders/index/popup/afterSale/index.vue b/packages/myOrders/index/popup/afterSale/index.vue index 922ad583..320812f8 100644 --- a/packages/myOrders/index/popup/afterSale/index.vue +++ b/packages/myOrders/index/popup/afterSale/index.vue @@ -281,6 +281,9 @@ export default { refundDescription: '', refundMethod: '自行寄回', imgList: [], + refundAmount: 0, // 当前退款金额 + maxRefundAmount: 0, // 最大可退款金额 + postage: 0, // 邮费金额 applyRefundReasons: [ '商品质量问题', '商品与描述不符', @@ -401,12 +404,17 @@ export default { } this.afterSalePopup2 = false; }, - - // 确认退款原因选择 + // 确认退款信息 confirmAfterSaleCancel2() { const afterSaleTypes = ['退货退款', '退款']; const selectedType = afterSaleTypes[this.selectedAfterSaleType2]; console.log('选中的售后类型:', selectedType); + + // 设置默认退款金额和最大退款金额 + this.refundAmount = this.orderItem.total_amount; + this.maxRefundAmount = this.orderItem.total_amount; + // 从订单信息中获取邮费(如果有的话) + this.postage = this.orderItem.postage || 0; let selectedReasonText = ''; if (selectedType == '退货退款') { @@ -486,7 +494,50 @@ export default { // 修改退款金额 modifyRefundAmount() { - console.log('修改退款金额'); + const that = this; + // 打开输入对话框 + uni.showModal({ + title: '修改退款金额', + editable: true, + placeholderText: `请输入不超过¥${this.maxRefundAmount.toFixed(2)}的金额`, + success: function (res) { + if (res.confirm && res.content) { + let inputAmount = parseFloat(res.content); + + // 检查输入是否为有效数字 + if (isNaN(inputAmount) || inputAmount <= 0) { + uni.showToast({ + title: '请输入有效的金额', + icon: 'none' + }); + return; + } + + // 限制为两位小数 + inputAmount = Math.round(inputAmount * 100) / 100; + + // 检查是否超过最大退款金额 + if (inputAmount > that.maxRefundAmount) { + uni.showToast({ + title: `退款金额不能超过¥${that.maxRefundAmount.toFixed(2)}`, + icon: 'none' + }); + return; + } + + // 更新退款金额 + that.refundAmount = inputAmount; + + // 通知父组件退款金额已修改 + that.$emit('refundAmountChanged', that.refundAmount); + + uni.showToast({ + title: '退款金额修改成功', + icon: 'success' + }); + } + } + }); }, // 查看地址详情 @@ -511,9 +562,9 @@ export default { afterSalesType: this.afterSalesType, serviceType: this.selectedServiceType, refundReason: this.selectedRefundReason || this.changeRefundReason, - refundAmount: this.orderItem.total_amount, - maxRefundAmount: this.orderItem.total_amount, - postage: 0, // 假设邮费为0 + refundAmount: this.refundAmount || this.orderItem.total_amount, + maxRefundAmount: this.maxRefundAmount || this.orderItem.total_amount, + postage: this.postage, refundDescription: this.refundDescription, refundMethod: this.refundMethod, merchantAddress: this.orderItem.supplier_address, @@ -548,6 +599,9 @@ export default { this.currentGGIndex = 0; this.refundDescription = ''; this.imgList = []; + this.refundAmount = 0; + this.maxRefundAmount = 0; + this.postage = 0; }, } };