import React, { useState, useEffect } from 'react' import { View, Text, ScrollView } from '@tarojs/components' import Taro from '@tarojs/taro' import { getAfterSaleDetail, cancelAfterSale, formatAfterSaleStatus } from '@/api/shop/shopAfterSale' import type { AfterSaleDetail } from '@/api/shop/shopAfterSale' definePageConfig({ navigationBarTitleText: '售后进度', }) const AfterSaleProgressPage: React.FC = () => { const { id } = Taro.getCurrentInstance().router?.params || {} const [saleInfo, setSaleInfo] = useState(null) const [loading, setLoading] = useState(true) useEffect(() => { if (id) { fetchDetail(id) } }, [id]) const fetchDetail = async (saleId: string) => { try { const data = await getAfterSaleDetail(saleId) setSaleInfo(data) } catch (err: any) { Taro.showToast({ title: err.message || '加载失败', icon: 'none' }) } finally { setLoading(false) } } // 取消售后 const handleCancel = () => { if (!saleInfo) return Taro.showModal({ title: '提示', content: '确定取消售后申请吗?', confirmColor: '#0e932e', success: async (res) => { if (res.confirm) { try { await cancelAfterSale(saleInfo.id) Taro.showToast({ title: '已取消', icon: 'success' }) fetchDetail(saleInfo.id) } catch (err: any) { Taro.showToast({ title: err.message || '取消失败', icon: 'none' }) } } } }) } if (loading) { return ( 加载中... ) } if (!saleInfo) { return ( 暂无数据 ) } const statusInfo = formatAfterSaleStatus(saleInfo.status) // 售后类型名称 const getTypeLabel = (type: string) => { const map: Record = { refund: '仅退款', return: '退货退款', exchange: '换货', repair: '维修' } return map[type] || type } return ( {/* 状态卡片 */} {statusInfo.text} 售后编号:{saleInfo.id} 申请时间:{saleInfo.applyTime} {/* 售后信息 */} 售后信息 售后类型 {getTypeLabel(saleInfo.type)} 售后原因 {saleInfo.reason} {saleInfo.type === 'refund' && ( 退款金额 ¥{saleInfo.amount} )} {saleInfo.rejectReason && ( 拒绝原因 {saleInfo.rejectReason} )} 关联订单 Taro.navigateTo({ url: `/pages/order/detail?id=${saleInfo.orderId}` })}> {saleInfo.orderNo || saleInfo.orderId} {/* 进度步骤 */} {saleInfo.progressRecords && saleInfo.progressRecords.length > 0 && ( 处理进度 {saleInfo.progressRecords.map((record, index) => ( {index < saleInfo.progressRecords.length - 1 && ( )} {record.status} {record.description} {record.remark && {record.remark}} {record.time} ))} )} {/* 商品信息 */} {saleInfo.goodsName && ( 商品信息 🛍️ {saleInfo.goodsName} )} {/* 操作按钮 */} {saleInfo.status === 'pending' && ( 取消申请 )} ) } export default AfterSaleProgressPage