|
|
@@ -2,14 +2,12 @@ import { View, ScrollView, Text, Image } from '@tarojs/components'
|
|
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
|
|
import Taro from '@tarojs/taro'
|
|
|
import { orderClient } from '@/api'
|
|
|
-import { InferResponseType } from 'hono'
|
|
|
import { Navbar } from '@/components/ui/navbar'
|
|
|
-import OrderCard from '@/components/order/OrderCard'
|
|
|
import OrderButtonBar from '@/components/order/OrderButtonBar'
|
|
|
+import CancelReasonDialog from '@/components/common/CancelReasonDialog'
|
|
|
+import { useState } from 'react'
|
|
|
import './index.css'
|
|
|
|
|
|
-type OrderResponse = InferResponseType<typeof orderClient[':id']['$get'], 200>
|
|
|
-
|
|
|
export default function OrderDetailPage() {
|
|
|
// 获取订单ID
|
|
|
const params = Taro.getCurrentInstance().router?.params
|
|
|
@@ -37,7 +35,7 @@ export default function OrderDetailPage() {
|
|
|
// 取消订单mutation
|
|
|
const cancelOrderMutation = useMutation({
|
|
|
mutationFn: async (reason: string) => {
|
|
|
- const response = await orderClient.cancelOrder.$post({
|
|
|
+ const response = await orderClient['cancel-order'].$post({
|
|
|
json: {
|
|
|
orderId,
|
|
|
reason
|
|
|
@@ -48,7 +46,7 @@ export default function OrderDetailPage() {
|
|
|
}
|
|
|
return response.json()
|
|
|
},
|
|
|
- onSuccess: (data) => {
|
|
|
+ onSuccess: () => {
|
|
|
// 取消成功后刷新订单数据
|
|
|
queryClient.invalidateQueries({ queryKey: ['order', orderId] })
|
|
|
|
|
|
@@ -132,13 +130,8 @@ export default function OrderDetailPage() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- // 处理取消订单取消
|
|
|
- const handleCancelDialogClose = () => {
|
|
|
- setShowCancelDialog(false)
|
|
|
- }
|
|
|
-
|
|
|
// 解析商品详情
|
|
|
- const parseGoodsDetail = (goodsDetail: string | null) => {
|
|
|
+ const parseGoodsDetail = (goodsDetail: string | null | undefined) => {
|
|
|
try {
|
|
|
return goodsDetail ? JSON.parse(goodsDetail) : []
|
|
|
} catch {
|
|
|
@@ -331,8 +324,8 @@ export default function OrderDetailPage() {
|
|
|
|
|
|
{/* 取消原因对话框 */}
|
|
|
<CancelReasonDialog
|
|
|
- visible={showCancelDialog}
|
|
|
- onCancel={handleCancelDialogClose}
|
|
|
+ open={showCancelDialog}
|
|
|
+ onOpenChange={setShowCancelDialog}
|
|
|
onConfirm={handleCancelConfirm}
|
|
|
loading={cancelOrderMutation.isPending}
|
|
|
/>
|