feat: 订单退款功能对接

This commit is contained in:
duanshuwen
2025-09-29 21:59:07 +08:00
parent 2580e7a266
commit 9cc7b48d36
5 changed files with 212 additions and 299 deletions

View File

@@ -17,10 +17,8 @@
<!-- 退款状态显示 -->
<RefundPopup
v-model="refundVisible"
:refund-type="refundType"
:refund-amount="refundAmount"
@policy-click="viewRefundPolicy"
@confirm-click="handleRefundConfirm"
:orderData="orderData"
@confirm="handleRefundConfirm"
/>
</view>
</template>
@@ -38,15 +36,12 @@ import OrderInfo from "./components/OrderInfo/index.vue";
import RefundPopup from "./components/RefundPopup/index.vue";
const refundVisible = ref(false);
const refundType = ref("free_cancel"); // 默认退款类型
const refundAmount = ref(0); // 退款金额
const orderData = ref({});
onLoad(async ({ orderId }) => {
const res = await userOrderDetail({ orderId });
orderData.value = res.data;
// 设置退款金额为订单支付金额
refundAmount.value = parseFloat(res.data.payAmt || 0);
console.log(res);
});
@@ -62,17 +57,11 @@ const showRefundPopup = () => {
refundVisible.value = true;
};
// 查看退款政策
const viewRefundPolicy = () => {
console.log("查看退款政策");
// 这里可以跳转到退款政策页面或显示详细政策
};
// 确认退款
const handleRefundConfirm = async () => {
const handleRefundConfirm = async ({ orderId }) => {
try {
// 调用退款API
await orderRefund({ orderId: orderData.value.orderId });
await orderRefund({ orderId });
uni.showToast({
title: "退款申请已提交",
@@ -80,10 +69,8 @@ const handleRefundConfirm = async () => {
});
// 刷新订单状态
const res = await userOrderDetail({ orderId: orderData.value.orderId });
const res = await userOrderDetail({ orderId });
orderData.value = res.data;
// 更新退款金额
refundAmount.value = parseFloat(res.data.payAmt || 0);
} catch (error) {
console.error("退款失败:", error);
uni.showToast({