feat(messages): 新增 PC 消息中心与订单群聊入口
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { Button, ErrorBlock, List, Skeleton, Tag } from 'antd-mobile'
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import { Button, ErrorBlock, List, Skeleton, Tag, Toast } from 'antd-mobile'
|
||||
import { LeftOutline } from 'antd-mobile-icons'
|
||||
import { Link, useNavigate, useParams } from 'react-router-dom'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
|
||||
import { BrandLogo } from '@/components/BrandLogo'
|
||||
import { useHandoffRecords, useMyOrder } from '@/features/orders/api'
|
||||
import { fetchOrderConversation } from '@/features/messages/api'
|
||||
import { MobileOrderActionPanel } from '@/features/mobile/MobileOrderActionPanel'
|
||||
import {
|
||||
checkoutStatusMeta,
|
||||
@@ -42,6 +43,23 @@ export function MobileOrderDetailPage() {
|
||||
const handoffQuery = useHandoffRecords(id, Boolean(token))
|
||||
const order = query.data
|
||||
const handoffRecords = handoffQuery.data ?? []
|
||||
const [openingChat, setOpeningChat] = useState(false)
|
||||
|
||||
const openOrderChat = async () => {
|
||||
if (!order || openingChat) return
|
||||
setOpeningChat(true)
|
||||
try {
|
||||
const conversation = await fetchOrderConversation(order.id)
|
||||
navigate(`/m/messages/${conversation.id}`)
|
||||
} catch (error) {
|
||||
Toast.show({
|
||||
icon: 'fail',
|
||||
content: error instanceof Error ? error.message : '订单群聊暂时无法打开',
|
||||
})
|
||||
} finally {
|
||||
setOpeningChat(false)
|
||||
}
|
||||
}
|
||||
|
||||
if (!hydrated) {
|
||||
return (
|
||||
@@ -229,6 +247,15 @@ export function MobileOrderDetailPage() {
|
||||
) : null}
|
||||
|
||||
<div className="mobile-order-detail__actions">
|
||||
<Button
|
||||
block
|
||||
fill="outline"
|
||||
color="primary"
|
||||
loading={openingChat}
|
||||
onClick={() => void openOrderChat()}
|
||||
>
|
||||
进入订单群聊
|
||||
</Button>
|
||||
<MobileOrderActionPanel
|
||||
order={order}
|
||||
onChanged={async () => {
|
||||
|
||||
Reference in New Issue
Block a user