feat: 新增订单详情退款弹窗

This commit is contained in:
duanshuwen
2025-08-07 20:03:03 +08:00
parent a8a5a90d5e
commit 72c761428b
10 changed files with 1345 additions and 97 deletions

View File

@@ -38,7 +38,7 @@
</template>
<script setup>
import { defineProps, computed, ref } from "vue";
import { defineProps, computed, ref, defineEmits } from "vue";
import {
preOrder,
orderPayNow,
@@ -56,6 +56,9 @@ const PAY_WAY_MAP = {
// 加载状态
const isLoading = ref(false);
// 定义事件发射器
const emit = defineEmits(['show-refund-popup']);
const props = defineProps({
orderData: {
type: Object,
@@ -111,39 +114,35 @@ const handleButtonClick = async () => {
// 支付渠道
const paySource = "1";
if (status === "2") {
// 情况2待使用状态显示退款弹窗
emit('show-refund-popup');
return; // 直接返回,不执行后续代码
}
try {
isLoading.value = true;
if (status === "2") {
// 情况2待使用状态直接申请退款
await orderRefund({ orderId });
// 情况1待支付状态或其他状态先预下单再支付
// 第一步:预下单
const res = await orderPayNow({ orderId, payWay, paySource });
console.log(res);
uni.showToast({
title: "退款申请已提交",
icon: "success",
});
} else {
// 情况1待支付状态或其他状态先预下单再支付
// 第一步:预下单
const res = await orderPayNow({ orderId, payWay, paySource });
console.log(res);
// 仅作为示例,非真实参数信息。
uni.requestPayment({
provider: "wxpay",
timeStamp: String(Date.now()),
nonceStr: "A1B2C3D4E5",
package: "prepay_id=wx20180101abcdefg",
signType: "MD5",
paySign: "",
success: (res) => {
console.log("success:" + JSON.stringify(res));
},
fail: (err) => {
console.log("fail:" + JSON.stringify(err));
},
});
}
// 仅作为示例,非真实参数信息。
uni.requestPayment({
provider: "wxpay",
timeStamp: String(Date.now()),
nonceStr: "A1B2C3D4E5",
package: "prepay_id=wx20180101abcdefg",
signType: "MD5",
paySign: "",
success: (res) => {
console.log("success:" + JSON.stringify(res));
},
fail: (err) => {
console.log("fail:" + JSON.stringify(err));
},
});
} catch (error) {
console.error("操作失败:", error);
uni.showToast({