This commit is contained in:
2026-03-30 15:09:54 +08:00
parent a98fb14ae7
commit 345b543cfd
8 changed files with 741 additions and 1183 deletions

View File

@ -65,33 +65,13 @@
</view>
</template>
<!-- 待发货 -->
<!-- 待预约 -->
<template v-if="[SHOP_ORDER_UNSLIVER].includes(data.status)">
<view class="order-btns-right">
<!-- <view class="flex-center fs-24 app-fc-main status-btn" @click.stop="$emit('concactService', data)">
联系客服
</view> -->
<!-- <view
class="flex-center fs-24 app-fc-main status-btn"
@click.stop="$emit('afterSale', data)"
>
申请售后
</view> -->
<!-- <view class="flex-center fs-24 app-fc-main status-btn" @click.stop="$emit('refund', data)">
退款
</view> -->
<refund-button
mode="2"
order-status="1"
:order-id="data.order_no"
:refund-total-amount="(data.actual_price || 0) * 100"
:compact="true"
@refund="handleRefund"
@error="handleError"
style="width:140rpx;height:68rpx;"
/>
<view class="flex-center fs-24 app-fc-white status-btn confirm"
<view class="flex-center fs-24 app-fc-main status-btn" @click.stop="$emit('refund', data)">
申请退款
</view>
<view class="flex-center fs-24 app-fc-white status-btn confirm"
@click.stop="jumpToReservation">
立即预约
</view>
@ -155,7 +135,6 @@
<script>
import PopUpModal from "@/components/PopUpModal.vue";
import GoodInfo from "./GoodInfo.vue";
import RefundButton from "@/components/RefundButton.vue";
import {
SHOP_ORDER_STATUS,
SHOP_ORDER_UNPAY,
@ -202,13 +181,45 @@
},
components: {
GoodInfo,
PopUpModal,
RefundButton
PopUpModal
},
options: {
styleIsolation: "shared",
},
computed: {
// 抖音退款组件需要的订单ID
orderId() {
return this.data.order_id || this.data.order_no || "";
},
// 抖音退款组件需要的订单状态1=待核销/待发货2=已核销/已发货)
orderStatusForSDK() {
// 根据你的业务状态映射到抖音SDK需要的状态
// SHOP_ORDER_UNSLIVER = 待发货 -> 映射为 1
if (this.data.status === SHOP_ORDER_UNSLIVER) {
return 1;
}
// SHOP_ORDER_UNRECEIVE = 待收货 -> 映射为 2
if (this.data.status === SHOP_ORDER_UNRECEIVE) {
return 2;
}
return 1;
},
// 订单总金额(单位:分)
orderTotalAmount() {
const price = this.data.actual_price || 0;
// 转换为分
return Math.round(parseFloat(price) * 100);
},
// UniApp 需要传入的退款参数对象
refundParams() {
return {
reasonCode: [410],
note: '用户申请退款',
applySource: 101,
afterSaleType: 3,
needRefundPackFee: true
}
},
orderStatus() {
return SHOP_ORDER_STATUS[this.data.status] || "";
},
@ -258,18 +269,32 @@
this.stopCountDown();
},
methods: {
handleRefund(e) {
console.log('退款结果:', e.detail)
if (e.detail.status === 'success') {
uni.showToast({ title: '退款申请已提交', icon: 'success' })
// 退款回调(组件触发)
handleRefund(event) {
const { status, result, outOrderNo } = event.detail
console.log('退款回调:', { status, result, outOrderNo })
if (status === 'success') {
uni.showToast({
title: '退款申请已提交',
icon: 'success'
})
this.$emit('refund', this.data)
} else {
uni.showToast({ title: '退款失败', icon: 'none' })
uni.showToast({
title: result?.errMsg || '退款失败,请稍后重试',
icon: 'none'
})
}
},
handleError(e) {
console.error('组件错误:', e.detail)
// 错误处理
handleError(event) {
console.error('退款组件报错:', event.detail)
uni.showToast({
title: '组件加载失败,请稍后重试',
icon: 'none'
})
},
startCountDown() {