1 line
12 KiB
Plaintext
1 line
12 KiB
Plaintext
{"version":3,"sources":["pages/mall/consumer/apply-refund.uvue","pages/user/change-password.uvue","pages/user/terms.uvue","pages/main/index.uvue","uni_modules/ak-req/ak-req.uts"],"sourcesContent":["<template>\r\n <view class=\"apply-refund-page\">\r\n <view class=\"section\">\r\n <view class=\"section-title\">退款类型</view>\r\n <radio-group @change=\"handleTypeChange\" class=\"type-group\">\r\n <label class=\"type-item\">\r\n <radio value=\"1\" :checked=\"refundType === 1\" color=\"#ff5000\" class=\"type-radio\" />\r\n <text>仅退款</text>\r\n </label>\r\n <label class=\"type-item\">\r\n <radio value=\"2\" :checked=\"refundType === 2\" color=\"#ff5000\" class=\"type-radio\" />\r\n <text>退货退款</text>\r\n </label>\r\n </radio-group>\r\n </view>\r\n\r\n <view class=\"section\">\r\n <view class=\"section-title\">退款原因</view>\r\n <picker @change=\"handleReasonChange\" :range=\"reasonList\" class=\"picker\">\r\n <view class=\"picker-content\">\r\n <text v-if=\"refundReason\">{{ refundReason }}</text>\r\n <text v-else class=\"placeholder\">请选择退款原因</text>\r\n <text class=\"arrow\">></text>\r\n </view>\r\n </picker>\r\n </view>\r\n\r\n <view class=\"section\">\r\n <view class=\"section-title\">退款金额</view>\r\n <view class=\"amount-input-wrap\">\r\n <text class=\"currency\">¥</text>\r\n <input \r\n type=\"digit\" \r\n v-model=\"refundAmount\" \r\n class=\"amount-input\" \r\n :placeholder=\"`最多可退 ¥${maxAmount}`\"\r\n />\r\n </view>\r\n <text class=\"amount-tip\">最多可退 ¥{{ maxAmount }},含发货邮费 ¥{{ deliveryFee }}</text>\r\n </view>\r\n\r\n <view class=\"section\">\r\n <view class=\"section-title\">退款说明</view>\r\n <textarea \r\n v-model=\"description\" \r\n class=\"desc-input\" \r\n placeholder=\"选填:补充详细的退款说明,有助于商家快速处理\"\r\n maxlength=\"200\"\r\n />\r\n </view>\r\n\r\n <view class=\"submit-bar\">\r\n <button class=\"submit-btn\" @click=\"submitRefund\" :loading=\"submitting\">提交申请</button>\r\n </view>\r\n </view>\r\n</template>\r\n\r\n<script setup lang=\"uts\">\r\nimport { ref } from 'vue'\r\nimport { onLoad } from '@dcloudio/uni-app'\r\nimport { supabaseService } from '@/utils/supabaseService.uts'\r\n\r\nconst orderId = ref('')\r\nconst orderItemId = ref('') // Optional, if refunding specific item\r\nconst refundType = ref(1) // 1: Only Refund, 2: Return & Refund\r\nconst refundReason = ref('')\r\nconst refundAmount = ref('')\r\nconst description = ref('')\r\nconst maxAmount = ref(0)\r\nconst deliveryFee = ref(0)\r\nconst submitting = ref(false)\r\n\r\nconst reasonList = [\r\n '多拍/错拍/不想要',\r\n '快递一直未送达',\r\n '未按约定时间发货',\r\n '快递无记录',\r\n '空包裹/少货/错发',\r\n '质量问题',\r\n '其他'\r\n]\r\n\r\nconst loadOrderInfo = async () => {\r\n try {\r\n const orderData = await supabaseService.getOrderDetail(orderId.value)\r\n \r\n if (orderData != null) {\r\n // Cast to UTSJSONObject to access properties safely\r\n const order = orderData as UTSJSONObject\r\n const total = order.getNumber('total_amount') ?? 0\r\n const shipping = order.getNumber('shipping_fee') ?? 0\r\n \r\n maxAmount.value = total\r\n deliveryFee.value = shipping\r\n refundAmount.value = maxAmount.value.toString()\r\n }\r\n } catch (err) {\r\n console.error('加载订单信息失败', err)\r\n uni.showToast({\r\n title: '加载订单失败',\r\n icon: 'none'\r\n })\r\n }\r\n}\r\n\r\nonLoad((options) => {\r\n if (options['orderId'] != null) {\r\n orderId.value = options['orderId'] as string\r\n loadOrderInfo()\r\n }\r\n})\r\n\r\nconst handleTypeChange = (e: any) => {\r\n // Use bracket notation to access detail property safely on 'any' type in UTS\r\n // The structure is e -> detail -> value\r\n // We need to cast e to UTSJSONObject first if we want to use bracket notation,\r\n // OR we can use JSON.parse/stringify trick if simple casting fails,\r\n // BUT the most standard way for UTS 'any' which is actually a Map/JSONObject at runtime:\r\n \r\n const target = e as UTSJSONObject\r\n const detail = target['detail'] as UTSJSONObject\r\n const value = detail['value'] as string\r\n refundType.value = parseInt(value)\r\n}\r\n\r\nconst handleReasonChange = (e: any) => {\r\n // Use bracket notation to access detail property safely on 'any' type in UTS\r\n const target = e as UTSJSONObject\r\n const detail = target['detail'] as UTSJSONObject\r\n const value = detail['value'] as number\r\n const index = value\r\n refundReason.value = reasonList[index]\r\n}\r\n\r\nconst submitRefund = async () => {\r\n console.log('=== 提交退款 ===')\r\n console.log('refundReason:', refundReason.value)\r\n console.log('refundAmount:', refundAmount.value)\r\n console.log('maxAmount:', maxAmount.value)\r\n \r\n if (refundReason.value == '') {\r\n uni.showToast({ title: '请选择退款原因', icon: 'none' })\r\n return\r\n }\r\n \r\n const amount = parseFloat(refundAmount.value)\r\n console.log('解析后金额:', amount)\r\n \r\n if (isNaN(amount) || amount <= 0 || amount > maxAmount.value) {\r\n uni.showToast({ title: '请输入有效的退款金额', icon: 'none' })\r\n return\r\n }\r\n \r\n submitting.value = true\r\n uni.showLoading({ title: '提交中...' })\r\n \r\n try {\r\n console.log('调用 createRefund, orderId:', orderId.value)\r\n const result = await supabaseService.createRefund({\r\n order_id: orderId.value,\r\n refund_type: refundType.value,\r\n refund_reason: refundReason.value,\r\n refund_amount: amount,\r\n description: description.value\r\n })\r\n \r\n console.log('createRefund 结果:', JSON.stringify(result))\r\n uni.hideLoading()\r\n \r\n if (result.success) {\r\n uni.showToast({ title: '提交成功', icon: 'success' })\r\n \r\n setTimeout(() => {\r\n uni.navigateBack()\r\n }, 1500)\r\n } else {\r\n uni.showToast({ title: result.message, icon: 'none' })\r\n }\r\n } catch (err) {\r\n console.error('提交退款失败', err)\r\n uni.hideLoading()\r\n uni.showToast({ title: '提交异常', icon: 'none' })\r\n } finally {\r\n submitting.value = false\r\n }\r\n}\r\n</script>\r\n\r\n<style scoped>\r\n.apply-refund-page {\r\n flex: 1;\r\n background-color: #f5f5f5;\r\n padding: 15px;\r\n padding-bottom: 80px;\r\n}\r\n\r\n.section {\r\n background-color: #ffffff;\r\n border-radius: 8px;\r\n padding: 15px;\r\n margin-bottom: 15px;\r\n}\r\n\r\n.section-title {\r\n font-size: 16px;\r\n font-weight: bold;\r\n color: #333;\r\n margin-bottom: 15px;\r\n}\r\n\r\n.type-group {\r\n display: flex;\r\n flex-direction: column;\r\n}\r\n\r\n.type-item {\r\n display: flex;\r\n align-items: center;\r\n margin-bottom: 15px;\r\n font-size: 14px;\r\n}\r\n\r\n.type-radio {\r\n margin-right: 10px;\r\n}\r\n\r\n.picker-content {\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\r\n font-size: 14px;\r\n color: #333;\r\n}\r\n\r\n.placeholder {\r\n color: #999;\r\n}\r\n\r\n.arrow {\r\n color: #ccc;\r\n}\r\n\r\n.amount-input-wrap {\r\n display: flex;\r\n align-items: center;\r\n border-bottom: 1px solid #eee;\r\n padding-bottom: 10px;\r\n margin-bottom: 10px;\r\n}\r\n\r\n.currency {\r\n font-size: 24px;\r\n font-weight: bold;\r\n color: #333;\r\n margin-right: 10px;\r\n}\r\n\r\n.amount-input {\r\n flex: 1;\r\n font-size: 24px;\r\n font-weight: bold;\r\n height: 40px;\r\n}\r\n\r\n.amount-tip {\r\n font-size: 12px;\r\n color: #999;\r\n}\r\n\r\n.desc-input {\r\n width: 100%;\r\n height: 100px;\r\n font-size: 14px;\r\n background-color: #f9f9f9;\r\n border-radius: 4px;\r\n padding: 10px;\r\n box-sizing: border-box;\r\n}\r\n\r\n.submit-bar {\r\n position: fixed;\r\n bottom: 0;\r\n left: 0;\r\n right: 0;\r\n background-color: #ffffff;\r\n padding: 15px;\r\n box-shadow: 0 -2px 10px rgba(0,0,0,0.05);\r\n}\r\n\r\n.submit-btn {\r\n background-color: #ff5000;\r\n color: #ffffff;\r\n border-radius: 22px;\r\n font-size: 16px;\r\n font-weight: bold;\r\n}\r\n</style>\r\n\r\n",null,null,null,null],"names":[],"mappings":";;;;;;;;;;;;;;+BAgFC,eAAA;;AArBD,OAAuB,0BAAmB,CAAzB,UAAA;+BAoBX,eAAA;;;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