Merge branch 'dev'
# Conflicts: # backend/internal/modules/payment/payment_start.go # deploy/docker-compose.dev.yml # frontend/src/features/admin/AdminPaymentsPage.tsx # scripts/dev.sh
This commit is contained in:
@@ -4,6 +4,7 @@ import zhCN from 'antd/locale/zh_CN'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { BrowserRouter } from 'react-router-dom'
|
||||
|
||||
import { MobileRouteGate } from '@/app/MobileRouteGate'
|
||||
import { AppRouter } from '@/app/AppRouter'
|
||||
import { ChatEventsBridge } from '@/features/messages/ChatEventsBridge'
|
||||
import { useSessionStore } from '@/stores/session'
|
||||
@@ -41,6 +42,7 @@ export default function App() {
|
||||
<AntApp>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<BrowserRouter>
|
||||
<MobileRouteGate />
|
||||
<SessionBootstrap />
|
||||
<ChatEventsBridge />
|
||||
<AppRouter />
|
||||
|
||||
@@ -229,265 +229,6 @@ const MobileSellerFormPage = lazy(() =>
|
||||
default: module.MobileSellerFormPage,
|
||||
}))
|
||||
)
|
||||
const AdminLoginPage = lazy(() =>
|
||||
import('@/features/admin/AdminLoginPage').then(module => ({ default: module.AdminLoginPage }))
|
||||
)
|
||||
const AdminGuard = lazy(() =>
|
||||
import('@/features/admin/AdminGuard').then(module => ({ default: module.AdminGuard }))
|
||||
)
|
||||
const AdminChangePasswordPage = lazy(() =>
|
||||
import('@/features/admin/AdminChangePasswordPage').then(module => ({
|
||||
default: module.AdminChangePasswordPage,
|
||||
}))
|
||||
)
|
||||
const AdminDashboardPage = lazy(() =>
|
||||
import('@/features/admin/AdminDashboardPage').then(module => ({
|
||||
default: module.AdminDashboardPage,
|
||||
}))
|
||||
)
|
||||
const AdminOrdersPage = lazy(() =>
|
||||
import('@/features/admin/AdminOrdersPage').then(module => ({
|
||||
default: module.AdminOrdersPage,
|
||||
}))
|
||||
)
|
||||
const AdminListingsPage = lazy(() =>
|
||||
import('@/features/admin/AdminListingsPage').then(module => ({
|
||||
default: module.AdminListingsPage,
|
||||
}))
|
||||
)
|
||||
const AdminUsersPage = lazy(() =>
|
||||
import('@/features/admin/AdminUsersPage').then(module => ({
|
||||
default: module.AdminUsersPage,
|
||||
}))
|
||||
)
|
||||
const AdminRefundReviewPage = lazy(() =>
|
||||
import('@/features/admin/AdminRefundReviewPage').then(module => ({
|
||||
default: module.AdminRefundReviewPage,
|
||||
}))
|
||||
)
|
||||
const AdminWithdrawalsPage = lazy(() =>
|
||||
import('@/features/admin/AdminWithdrawalsPage').then(module => ({
|
||||
default: module.AdminWithdrawalsPage,
|
||||
}))
|
||||
)
|
||||
const AdminDisputesPage = lazy(() =>
|
||||
import('@/features/admin/AdminDisputesPage').then(module => ({
|
||||
default: module.AdminDisputesPage,
|
||||
}))
|
||||
)
|
||||
const AdminFinancePage = lazy(() =>
|
||||
import('@/features/admin/AdminFinancePage').then(module => ({
|
||||
default: module.AdminFinancePage,
|
||||
}))
|
||||
)
|
||||
const AdminFinanceDisbursementsPage = lazy(() =>
|
||||
import('@/features/admin/AdminFinanceDisbursementsPage').then(module => ({
|
||||
default: module.AdminFinanceDisbursementsPage,
|
||||
}))
|
||||
)
|
||||
const AdminOperatingExpensesPage = lazy(() =>
|
||||
import('@/features/admin/AdminOperatingExpensesPage').then(module => ({
|
||||
default: module.AdminOperatingExpensesPage,
|
||||
}))
|
||||
)
|
||||
const AdminAnnouncementsPage = lazy(() =>
|
||||
import('@/features/admin/AdminAnnouncementsPage').then(module => ({
|
||||
default: module.AdminAnnouncementsPage,
|
||||
}))
|
||||
)
|
||||
const AdminAuditLogsPage = lazy(() =>
|
||||
import('@/features/admin/AdminAuditLogsPage').then(module => ({
|
||||
default: module.AdminAuditLogsPage,
|
||||
}))
|
||||
)
|
||||
const AdminSystemConfigsPage = lazy(() =>
|
||||
import('@/features/admin/AdminSystemConfigsPage').then(module => ({
|
||||
default: module.AdminSystemConfigsPage,
|
||||
}))
|
||||
)
|
||||
const AdminPaymentConfigsPage = lazy(() =>
|
||||
import('@/features/admin/AdminPaymentConfigsPage').then(module => ({
|
||||
default: module.AdminPaymentConfigsPage,
|
||||
}))
|
||||
)
|
||||
const AdminRolesPage = lazy(() =>
|
||||
import('@/features/admin/AdminRolesPage').then(module => ({
|
||||
default: module.AdminRolesPage,
|
||||
}))
|
||||
)
|
||||
const AdminSupportGroupsPage = lazy(() =>
|
||||
import('@/features/admin/AdminSupportGroupsPage').then(module => ({
|
||||
default: module.AdminSupportGroupsPage,
|
||||
}))
|
||||
)
|
||||
const AdminStaffAccountsPage = lazy(() =>
|
||||
import('@/features/admin/AdminStaffAccountsPage').then(module => ({
|
||||
default: module.AdminStaffAccountsPage,
|
||||
}))
|
||||
)
|
||||
const AdminBackupsPage = lazy(() =>
|
||||
import('@/features/admin/AdminBackupsPage').then(module => ({
|
||||
default: module.AdminBackupsPage,
|
||||
}))
|
||||
)
|
||||
const AdminCrashCategoriesPage = lazy(() =>
|
||||
import('@/features/admin/AdminCrashCategoriesPage').then(module => ({
|
||||
default: module.AdminCrashCategoriesPage,
|
||||
}))
|
||||
)
|
||||
const AdminCrashProductsPage = lazy(() =>
|
||||
import('@/features/admin/AdminCrashProductsPage').then(module => ({
|
||||
default: module.AdminCrashProductsPage,
|
||||
}))
|
||||
)
|
||||
const AdminCrashOrdersPage = lazy(() =>
|
||||
import('@/features/admin/AdminCrashOrdersPage').then(module => ({
|
||||
default: module.AdminCrashOrdersPage,
|
||||
}))
|
||||
)
|
||||
const AdminCrashConfigPage = lazy(() =>
|
||||
import('@/features/admin/AdminCrashConfigPage').then(module => ({
|
||||
default: module.AdminCrashConfigPage,
|
||||
}))
|
||||
)
|
||||
const AdminManualEntriesPage = lazy(() =>
|
||||
import('@/features/admin/AdminManualEntriesPage').then(module => ({
|
||||
default: module.AdminManualEntriesPage,
|
||||
}))
|
||||
)
|
||||
const AdminPaymentsPage = lazy(() =>
|
||||
import('@/features/admin/AdminPaymentsPage').then(module => ({
|
||||
default: module.AdminPaymentsPage,
|
||||
}))
|
||||
)
|
||||
const AdminPickupsPage = lazy(() =>
|
||||
import('@/features/admin/AdminPickupsPage').then(module => ({
|
||||
default: module.AdminPickupsPage,
|
||||
}))
|
||||
)
|
||||
const AdminChatsPage = lazy(() =>
|
||||
import('@/features/admin/AdminChatsPage').then(module => ({
|
||||
default: module.AdminChatsPage,
|
||||
}))
|
||||
)
|
||||
const AdminChatWelcomePage = lazy(() =>
|
||||
import('@/features/admin/AdminChatWelcomePage').then(module => ({
|
||||
default: module.AdminChatWelcomePage,
|
||||
}))
|
||||
)
|
||||
const AdminQrCodePoolPage = lazy(() =>
|
||||
import('@/features/admin/AdminQrCodePoolPage').then(module => ({
|
||||
default: module.AdminQrCodePoolPage,
|
||||
}))
|
||||
)
|
||||
const AdminNotificationsPage = lazy(() =>
|
||||
import('@/features/admin/AdminNotificationsPage').then(module => ({
|
||||
default: module.AdminNotificationsPage,
|
||||
}))
|
||||
)
|
||||
const AdminPushPage = lazy(() =>
|
||||
import('@/features/admin/AdminPushPage').then(module => ({
|
||||
default: module.AdminPushPage,
|
||||
}))
|
||||
)
|
||||
const AdminInvitationsPage = lazy(() =>
|
||||
import('@/features/admin/AdminInvitationsPage').then(module => ({
|
||||
default: module.AdminInvitationsPage,
|
||||
}))
|
||||
)
|
||||
const AdminPickupDetailPage = lazy(() =>
|
||||
import('@/features/admin/AdminPickupDetailPage').then(module => ({
|
||||
default: module.AdminPickupDetailPage,
|
||||
}))
|
||||
)
|
||||
const AdminFinanceDetailsPage = lazy(() =>
|
||||
import('@/features/admin/AdminFinanceDetailsPage').then(module => ({
|
||||
default: module.AdminFinanceDetailsPage,
|
||||
}))
|
||||
)
|
||||
const AdminWalletLedgerPage = lazy(() =>
|
||||
import('@/features/admin/AdminWalletLedgerPage').then(module => ({
|
||||
default: module.AdminWalletLedgerPage,
|
||||
}))
|
||||
)
|
||||
const AdminQuickRepliesPage = lazy(() =>
|
||||
import('@/features/admin/AdminQuickRepliesPage').then(module => ({
|
||||
default: module.AdminQuickRepliesPage,
|
||||
}))
|
||||
)
|
||||
const AdminTrackingLinksPage = lazy(() =>
|
||||
import('@/features/admin/AdminTrackingLinksPage').then(module => ({
|
||||
default: module.AdminTrackingLinksPage,
|
||||
}))
|
||||
)
|
||||
const AdminDistributionSitesPage = lazy(() =>
|
||||
import('@/features/admin/AdminDistributionSitesPage').then(module => ({
|
||||
default: module.AdminDistributionSitesPage,
|
||||
}))
|
||||
)
|
||||
const AdminDistributionWalletPage = lazy(() =>
|
||||
import('@/features/admin/AdminDistributionWalletPage').then(module => ({
|
||||
default: module.AdminDistributionWalletPage,
|
||||
}))
|
||||
)
|
||||
const AdminDistributionDashboardPage = lazy(() =>
|
||||
import('@/features/admin/AdminDistributionDashboardPage').then(module => ({
|
||||
default: module.AdminDistributionDashboardPage,
|
||||
}))
|
||||
)
|
||||
const AdminDistributionSMSPage = lazy(() =>
|
||||
import('@/features/admin/AdminDistributionSMSPage').then(module => ({
|
||||
default: module.AdminDistributionSMSPage,
|
||||
}))
|
||||
)
|
||||
const AdminDistributionInvitationPage = lazy(() =>
|
||||
import('@/features/admin/AdminDistributionInvitationPage').then(module => ({
|
||||
default: module.AdminDistributionInvitationPage,
|
||||
}))
|
||||
)
|
||||
const AdminDistributionQrCodesPage = lazy(() =>
|
||||
import('@/features/admin/AdminDistributionQrCodesPage').then(module => ({
|
||||
default: module.AdminDistributionQrCodesPage,
|
||||
}))
|
||||
)
|
||||
const AdminDistributionRulesPage = lazy(() =>
|
||||
import('@/features/admin/AdminDistributionRulesPage').then(module => ({
|
||||
default: module.AdminDistributionRulesPage,
|
||||
}))
|
||||
)
|
||||
const AdminDistributionOrdersPage = lazy(() =>
|
||||
import('@/features/admin/AdminDistributionOrdersPage').then(module => ({
|
||||
default: module.AdminDistributionOrdersPage,
|
||||
}))
|
||||
)
|
||||
const AdminDistributionSettlementsPage = lazy(() =>
|
||||
import('@/features/admin/AdminDistributionSettlementsPage').then(module => ({
|
||||
default: module.AdminDistributionSettlementsPage,
|
||||
}))
|
||||
)
|
||||
const AdminDistributionUsersPage = lazy(() =>
|
||||
import('@/features/admin/AdminDistributionUsersPage').then(module => ({
|
||||
default: module.AdminDistributionUsersPage,
|
||||
}))
|
||||
)
|
||||
const AdminSiteAnnouncementsPage = lazy(() =>
|
||||
import('@/features/admin/AdminSiteAnnouncementsPage').then(module => ({
|
||||
default: module.AdminSiteAnnouncementsPage,
|
||||
}))
|
||||
)
|
||||
const AdminDistributionListingsPage = lazy(() =>
|
||||
import('@/features/admin/AdminDistributionListingsPage').then(module => ({
|
||||
default: module.AdminDistributionListingsPage,
|
||||
}))
|
||||
)
|
||||
const AdminDistributionPaymentChannelsPage = lazy(() =>
|
||||
import('@/features/admin/AdminDistributionPaymentChannelsPage').then(module => ({
|
||||
default: module.AdminDistributionPaymentChannelsPage,
|
||||
}))
|
||||
)
|
||||
const AdminLayout = lazy(() =>
|
||||
import('@/layouts/AdminLayout').then(module => ({ default: module.AdminLayout }))
|
||||
)
|
||||
const ProfilePage = lazy(() =>
|
||||
import('@/features/profile/ProfilePage').then(module => ({ default: module.ProfilePage }))
|
||||
)
|
||||
@@ -500,13 +241,7 @@ const ProcessPage = lazy(() =>
|
||||
const RulesPage = lazy(() =>
|
||||
import('@/features/help/RulesPage').then(module => ({ default: module.RulesPage }))
|
||||
)
|
||||
const AdminSectionPlaceholder = lazy(() =>
|
||||
import('@/layouts/AdminLayout').then(module => ({ default: module.AdminSectionPlaceholder }))
|
||||
)
|
||||
|
||||
export function AppRouter() {
|
||||
const adminBase = import.meta.env.VITE_ADMIN_BASE_PATH || '/console-jy8k3m'
|
||||
|
||||
return (
|
||||
<Suspense fallback={<PageLoading />}>
|
||||
<Routes>
|
||||
@@ -574,78 +309,6 @@ export function AppRouter() {
|
||||
<Route path="crash/:id" element={<MobileCrashDetailPage />} />
|
||||
</Route>
|
||||
|
||||
<Route path={`${adminBase}/login`} element={<AdminLoginPage />} />
|
||||
<Route path={adminBase} element={<AdminGuard />}>
|
||||
<Route path="change-password" element={<AdminChangePasswordPage />} />
|
||||
<Route element={<AdminLayout />}>
|
||||
<Route index element={<AdminDashboardPage />} />
|
||||
<Route path="orders" element={<AdminOrdersPage />} />
|
||||
<Route path="orders/refund-review" element={<AdminRefundReviewPage />} />
|
||||
<Route path="listings" element={<AdminListingsPage />} />
|
||||
<Route path="listings/review" element={<AdminListingsPage mode="review" />} />
|
||||
<Route path="users" element={<AdminUsersPage />} />
|
||||
<Route path="withdrawals" element={<AdminWithdrawalsPage />} />
|
||||
<Route path="disputes" element={<AdminDisputesPage />} />
|
||||
<Route path="finance" element={<AdminFinancePage />} />
|
||||
<Route path="finance/dashboard" element={<AdminFinancePage />} />
|
||||
<Route path="finance/disbursements" element={<AdminFinanceDisbursementsPage />} />
|
||||
<Route path="finance/operating-expenses" element={<AdminOperatingExpensesPage />} />
|
||||
<Route path="announcements" element={<AdminAnnouncementsPage />} />
|
||||
<Route path="audit-logs" element={<AdminAuditLogsPage />} />
|
||||
<Route path="system-configs" element={<AdminSystemConfigsPage />} />
|
||||
<Route path="payment-configs" element={<AdminPaymentConfigsPage />} />
|
||||
<Route path="roles" element={<AdminRolesPage />} />
|
||||
<Route path="admin-users" element={<AdminStaffAccountsPage />} />
|
||||
<Route path="backups" element={<AdminBackupsPage />} />
|
||||
<Route path="crash/categories" element={<AdminCrashCategoriesPage />} />
|
||||
<Route path="crash/products" element={<AdminCrashProductsPage />} />
|
||||
<Route path="crash/orders" element={<AdminCrashOrdersPage />} />
|
||||
<Route path="crash/config" element={<AdminCrashConfigPage />} />
|
||||
<Route path="manual-entries" element={<AdminManualEntriesPage />} />
|
||||
<Route path="payments" element={<AdminPaymentsPage />} />
|
||||
<Route path="pickup" element={<AdminPickupsPage />} />
|
||||
<Route path="pickup/:id" element={<AdminPickupDetailPage />} />
|
||||
<Route path="chats" element={<AdminChatsPage />} />
|
||||
<Route path="chat-welcome" element={<AdminChatWelcomePage />} />
|
||||
<Route path="qrcode-pool" element={<AdminQrCodePoolPage />} />
|
||||
<Route path="notifications" element={<AdminNotificationsPage />} />
|
||||
<Route path="push" element={<AdminPushPage />} />
|
||||
<Route path="invitations" element={<AdminInvitationsPage />} />
|
||||
<Route path="finance/details" element={<AdminFinanceDetailsPage />} />
|
||||
<Route path="wallet-ledger" element={<AdminWalletLedgerPage />} />
|
||||
<Route path="chat-quick-replies" element={<AdminQuickRepliesPage />} />
|
||||
<Route path="tracking-links" element={<AdminTrackingLinksPage />} />
|
||||
<Route path="chat-support-groups" element={<AdminSupportGroupsPage />} />
|
||||
<Route path="support-groups" element={<AdminSupportGroupsPage />} />
|
||||
<Route path="distribution/sites" element={<AdminDistributionSitesPage />} />
|
||||
<Route path="distribution/dashboard" element={<AdminDistributionDashboardPage />} />
|
||||
<Route path="distribution/orders" element={<AdminDistributionOrdersPage />} />
|
||||
<Route path="distribution/settlements" element={<AdminDistributionSettlementsPage />} />
|
||||
<Route path="distribution/users" element={<AdminDistributionUsersPage />} />
|
||||
<Route path="distribution/announcements" element={<AdminSiteAnnouncementsPage />} />
|
||||
<Route path="distribution/listings" element={<AdminDistributionListingsPage />} />
|
||||
<Route
|
||||
path="distribution/payment-channels"
|
||||
element={<AdminDistributionPaymentChannelsPage />}
|
||||
/>
|
||||
<Route path="distribution/wallet" element={<AdminDistributionWalletPage />} />
|
||||
<Route path="distribution/sms" element={<AdminDistributionSMSPage />} />
|
||||
<Route path="distribution/invitation" element={<AdminDistributionInvitationPage />} />
|
||||
<Route path="distribution/qrcodes" element={<AdminDistributionQrCodesPage />} />
|
||||
<Route path="distribution/qrcode-pool" element={<AdminDistributionQrCodesPage />} />
|
||||
<Route path="distribution/rules" element={<AdminDistributionRulesPage />} />
|
||||
<Route
|
||||
path="*"
|
||||
element={
|
||||
<AdminSectionPlaceholder
|
||||
title="功能建设中"
|
||||
description="这个后台页面还没有进入迁移批次。"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</Route>
|
||||
</Route>
|
||||
|
||||
<Route path="*" element={<NotFoundPage />} />
|
||||
</Routes>
|
||||
</Suspense>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { useLayoutEffect } from 'react'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
|
||||
import {
|
||||
getMobilePath,
|
||||
isMobileDevice,
|
||||
prefersDesktopSite,
|
||||
setDesktopPreference,
|
||||
} from '@/shared/utils/mobileHost'
|
||||
|
||||
export function MobileRouteGate() {
|
||||
const location = useLocation()
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const params = new URLSearchParams(location.search)
|
||||
if (params.get('desktop') === '1') {
|
||||
setDesktopPreference(true)
|
||||
params.delete('desktop')
|
||||
const search = params.toString()
|
||||
window.location.replace(`${location.pathname}${search ? `?${search}` : ''}${location.hash}`)
|
||||
return
|
||||
}
|
||||
|
||||
if (prefersDesktopSite() || !isMobileDevice()) return
|
||||
|
||||
const mobilePath = getMobilePath(location.pathname)
|
||||
if (mobilePath === location.pathname) return
|
||||
|
||||
window.location.replace(`${mobilePath}${location.search}${location.hash}`)
|
||||
}, [location.hash, location.pathname, location.search])
|
||||
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,685 @@
|
||||
import { useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
Alert,
|
||||
App,
|
||||
Button,
|
||||
Card,
|
||||
Descriptions,
|
||||
Form,
|
||||
Image,
|
||||
Input,
|
||||
InputNumber,
|
||||
Modal,
|
||||
Radio,
|
||||
Space,
|
||||
Tag,
|
||||
Typography,
|
||||
} from 'antd'
|
||||
import {
|
||||
ArrowLeftOutlined,
|
||||
CopyOutlined,
|
||||
EditOutlined,
|
||||
ReloadOutlined,
|
||||
StopOutlined,
|
||||
SwapOutlined,
|
||||
WarningOutlined,
|
||||
} from '@ant-design/icons'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import {
|
||||
adjustExternalAdminListing,
|
||||
fetchAdminListing,
|
||||
fetchAdminUsers,
|
||||
markAbnormalAdminListing,
|
||||
offlineAdminListing,
|
||||
transferAdminListingOwner,
|
||||
} from '@/features/admin/api'
|
||||
import { AdminPageHeader } from '@/features/admin/components/AdminPageHeader'
|
||||
import { StatusTag } from '@/features/admin/components/StatusTag'
|
||||
import { handoffModeMap, readStatusMeta, settlementModeMap } from '@/features/admin/labels'
|
||||
import {
|
||||
adminListingAssetRows,
|
||||
adminListingOwnerRows,
|
||||
adminListingResources,
|
||||
adminListingScreenshotGroups,
|
||||
adminListingSkins,
|
||||
} from '@/features/admin/listingDetailModel'
|
||||
import {
|
||||
listingCodeText,
|
||||
listingQuantity,
|
||||
listingRentalDuration,
|
||||
} from '@/features/admin/listingDisplay'
|
||||
import {
|
||||
listingReviewStatusMeta,
|
||||
listingStatusMeta,
|
||||
resourceBadgeText,
|
||||
} from '@/features/listings/labels'
|
||||
import type { AdminUserItem } from '@/features/admin/types'
|
||||
import { useAdminSessionStore } from '@/stores/adminSession'
|
||||
import { getAdminPath } from '@/shared/api/adminClient'
|
||||
import { formatCoinM, formatDateTime, formatText } from '@/shared/utils/format'
|
||||
|
||||
type ReasonAction = 'offline' | 'abnormal'
|
||||
|
||||
function errorText(error: unknown) {
|
||||
const response = (error as { response?: { data?: { message?: string } } })?.response
|
||||
if (response?.data?.message) return response.data.message
|
||||
return error instanceof Error ? error.message : '请求失败,请稍后重试'
|
||||
}
|
||||
|
||||
const reasonCopy: Record<ReasonAction, { title: string; hint: string; okText: string }> = {
|
||||
offline: {
|
||||
title: '强制下架商品',
|
||||
hint: '下架后商品不再对外展示,号主可修改后重新提交。',
|
||||
okText: '确认下架',
|
||||
},
|
||||
abnormal: {
|
||||
title: '标记商品异常',
|
||||
hint: '标记后商品进入异常状态,便于后续人工核查。',
|
||||
okText: '确认标记',
|
||||
},
|
||||
}
|
||||
|
||||
export function AdminListingDetailPage() {
|
||||
const { id } = useParams()
|
||||
const listingId = Number(id)
|
||||
const navigate = useNavigate()
|
||||
const { message } = App.useApp()
|
||||
const queryClient = useQueryClient()
|
||||
const permissions = useAdminSessionStore(state => state.admin?.permissions)
|
||||
const can = (permission: string) =>
|
||||
Boolean(permissions?.includes('*') || permissions?.includes(permission))
|
||||
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [reasonAction, setReasonAction] = useState<ReasonAction | null>(null)
|
||||
const [reasonForm] = Form.useForm<{ reason: string }>()
|
||||
const [externalOpen, setExternalOpen] = useState(false)
|
||||
const [externalForm] = Form.useForm<{
|
||||
haf_coin_m?: number
|
||||
deposit_yuan?: number
|
||||
awm_bullets?: number
|
||||
level6_helmets?: number
|
||||
level6_armor?: number
|
||||
adjust_mode: 'discount_amount' | 'sale_ratio'
|
||||
discount_amount_yuan?: number
|
||||
sale_ratio?: number
|
||||
reason: string
|
||||
}>()
|
||||
const [transferOpen, setTransferOpen] = useState(false)
|
||||
const [transferForm] = Form.useForm<{
|
||||
keyword?: string
|
||||
target_user_id?: number
|
||||
reason: string
|
||||
}>()
|
||||
const [userKeyword, setUserKeyword] = useState('')
|
||||
const [userSearching, setUserSearching] = useState(false)
|
||||
const [userOptions, setUserOptions] = useState<AdminUserItem[]>([])
|
||||
|
||||
const listingQuery = useQuery({
|
||||
queryKey: ['admin-listing', listingId],
|
||||
queryFn: () => fetchAdminListing(listingId),
|
||||
enabled: Number.isFinite(listingId) && listingId > 0,
|
||||
})
|
||||
const listing = listingQuery.data
|
||||
|
||||
const refresh = async () => {
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: ['admin-listing', listingId] }),
|
||||
queryClient.invalidateQueries({ queryKey: ['admin-listings'] }),
|
||||
queryClient.invalidateQueries({ queryKey: ['admin-pending-listings'] }),
|
||||
])
|
||||
}
|
||||
|
||||
const run = async (action: () => Promise<unknown>, success: string) => {
|
||||
setBusy(true)
|
||||
try {
|
||||
await action()
|
||||
message.success(success)
|
||||
await refresh()
|
||||
return true
|
||||
} catch (error) {
|
||||
message.error(errorText(error))
|
||||
return false
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
const canOperate = Boolean(
|
||||
listing && listing.status !== 'rented' && !['offline', 'abnormal'].includes(listing.status)
|
||||
)
|
||||
const canTransfer = Boolean(listing && listing.status !== 'rented')
|
||||
const canAdjustExternal = Boolean(listing?.is_external_upload) && can('listing:edit_external')
|
||||
const externalLocked = Boolean(
|
||||
!listing ||
|
||||
listing.in_transaction ||
|
||||
!['draft', 'published', 'offline', 'abnormal'].includes(listing.status)
|
||||
)
|
||||
|
||||
const copyCode = async () => {
|
||||
if (!listing) return
|
||||
try {
|
||||
await navigator.clipboard.writeText(listingCodeText(listing))
|
||||
message.success('商品编号已复制')
|
||||
} catch {
|
||||
message.warning('当前环境不支持剪贴板,请手动复制')
|
||||
}
|
||||
}
|
||||
|
||||
const openReason = (action: ReasonAction) => {
|
||||
reasonForm.resetFields()
|
||||
setReasonAction(action)
|
||||
}
|
||||
|
||||
const submitReason = async () => {
|
||||
if (!listing || !reasonAction) return
|
||||
const values = await reasonForm.validateFields()
|
||||
const ok = await run(
|
||||
() =>
|
||||
reasonAction === 'offline'
|
||||
? offlineAdminListing(listing.id, values.reason.trim())
|
||||
: markAbnormalAdminListing(listing.id, values.reason.trim()),
|
||||
reasonAction === 'offline' ? '商品已下架' : '商品已标记异常'
|
||||
)
|
||||
if (ok) setReasonAction(null)
|
||||
}
|
||||
|
||||
const openExternal = () => {
|
||||
if (!listing || !canAdjustExternal || externalLocked) return
|
||||
externalForm.setFieldsValue({
|
||||
haf_coin_m: Number((listing.haf_coin_amount / 1_000_000).toFixed(1)),
|
||||
deposit_yuan: Number((listing.deposit_amount_cent / 100).toFixed(2)),
|
||||
awm_bullets: listingQuantity(listing, 'awmAmmo'),
|
||||
level6_helmets: listingQuantity(listing, 'helmet6'),
|
||||
level6_armor: listingQuantity(listing, 'armor6'),
|
||||
adjust_mode: 'discount_amount',
|
||||
discount_amount_yuan: 0,
|
||||
sale_ratio: undefined,
|
||||
reason: '',
|
||||
})
|
||||
setExternalOpen(true)
|
||||
}
|
||||
|
||||
const submitExternal = async () => {
|
||||
if (!listing) return
|
||||
const values = await externalForm.validateFields()
|
||||
const ok = await run(
|
||||
() =>
|
||||
adjustExternalAdminListing(listing.id, {
|
||||
haf_coin_amount: Math.round(Number(values.haf_coin_m || 0) * 1_000_000),
|
||||
awm_bullets: Math.trunc(Number(values.awm_bullets || 0)),
|
||||
level6_helmets: Math.trunc(Number(values.level6_helmets || 0)),
|
||||
level6_armor: Math.trunc(Number(values.level6_armor || 0)),
|
||||
deposit_amount_cent: Math.round(Number(values.deposit_yuan || 0) * 100),
|
||||
adjust_mode: values.adjust_mode,
|
||||
discount_amount_cent:
|
||||
values.adjust_mode === 'discount_amount'
|
||||
? Math.round(Number(values.discount_amount_yuan || 0) * 100)
|
||||
: undefined,
|
||||
sale_ratio:
|
||||
values.adjust_mode === 'sale_ratio' ? Number(values.sale_ratio || 0) : undefined,
|
||||
reason: values.reason.trim(),
|
||||
}),
|
||||
'外部商品已调整'
|
||||
)
|
||||
if (ok) setExternalOpen(false)
|
||||
}
|
||||
|
||||
const searchUsers = async () => {
|
||||
setUserSearching(true)
|
||||
try {
|
||||
const result = await fetchAdminUsers({
|
||||
keyword: userKeyword.trim(),
|
||||
status: 'active',
|
||||
page: 1,
|
||||
page_size: 8,
|
||||
})
|
||||
setUserOptions(result.items.filter(user => user.realname_status === 'verified'))
|
||||
} catch (error) {
|
||||
message.error(errorText(error))
|
||||
} finally {
|
||||
setUserSearching(false)
|
||||
}
|
||||
}
|
||||
|
||||
const openTransfer = () => {
|
||||
if (!listing || !canTransfer) return
|
||||
transferForm.resetFields()
|
||||
setUserKeyword('')
|
||||
setUserOptions([])
|
||||
setTransferOpen(true)
|
||||
}
|
||||
|
||||
const submitTransfer = async () => {
|
||||
if (!listing) return
|
||||
const values = await transferForm.validateFields()
|
||||
if (!values.target_user_id) {
|
||||
message.warning('请先选择目标号主')
|
||||
return
|
||||
}
|
||||
const ok = await run(
|
||||
() =>
|
||||
transferAdminListingOwner(listing.id, Number(values.target_user_id), values.reason.trim()),
|
||||
'所有权已转移'
|
||||
)
|
||||
if (ok) setTransferOpen(false)
|
||||
}
|
||||
|
||||
if (!Number.isFinite(listingId) || listingId <= 0) {
|
||||
return (
|
||||
<div className="admin-page">
|
||||
<AdminPageHeader eyebrow="JIEYOU OPS · 商品" title="商品详情" />
|
||||
<Alert type="error" showIcon message="商品 ID 不正确" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (listingQuery.isError) {
|
||||
return (
|
||||
<div className="admin-page">
|
||||
<AdminPageHeader eyebrow="JIEYOU OPS · 商品" title="商品详情" />
|
||||
<Alert
|
||||
type="error"
|
||||
showIcon
|
||||
message="商品没有加载出来"
|
||||
description={errorText(listingQuery.error)}
|
||||
action={<Button onClick={() => void listingQuery.refetch()}>重试</Button>}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const assetRows = listing ? adminListingAssetRows(listing) : []
|
||||
const ownerRows = listing ? adminListingOwnerRows(listing) : []
|
||||
const resources = listing ? adminListingResources(listing) : []
|
||||
const skins = listing ? adminListingSkins(listing) : []
|
||||
const screenshotGroups = listing ? adminListingScreenshotGroups(listing) : []
|
||||
const duration = listing ? listingRentalDuration(listing) : { days: '—', dailyLoss: '' }
|
||||
|
||||
return (
|
||||
<div className="admin-page">
|
||||
<AdminPageHeader
|
||||
eyebrow={listing ? `商品编号 ${listingCodeText(listing)}` : 'JIEYOU OPS · 商品'}
|
||||
title={listing?.title || '商品详情'}
|
||||
description={
|
||||
listing
|
||||
? `${formatText(listing.server_region)} · ${formatText(
|
||||
listing.rank_level
|
||||
)} · ${formatText(listing.login_platform)} · 账号 ${listing.account_id}`
|
||||
: '加载中'
|
||||
}
|
||||
meta={
|
||||
listing ? (
|
||||
<Space size={6} wrap>
|
||||
<StatusTag meta={listingStatusMeta(listing.status)} />
|
||||
<StatusTag meta={listingReviewStatusMeta(listing.review_status)} />
|
||||
{listing.is_external_upload ? (
|
||||
<Tag color="geekblue">外部 API · {formatText(listing.source_channel)}</Tag>
|
||||
) : null}
|
||||
</Space>
|
||||
) : null
|
||||
}
|
||||
extra={
|
||||
<Space wrap>
|
||||
<Button icon={<CopyOutlined />} onClick={() => void copyCode()}>
|
||||
复制编号
|
||||
</Button>
|
||||
<Button
|
||||
icon={<ArrowLeftOutlined />}
|
||||
onClick={() => navigate(getAdminPath('/listings'))}
|
||||
>
|
||||
返回列表
|
||||
</Button>
|
||||
<Button
|
||||
icon={<ReloadOutlined />}
|
||||
loading={listingQuery.isFetching}
|
||||
onClick={() => void refresh()}
|
||||
>
|
||||
刷新
|
||||
</Button>
|
||||
{canAdjustExternal ? (
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<EditOutlined />}
|
||||
disabled={externalLocked}
|
||||
onClick={openExternal}
|
||||
>
|
||||
调整商品
|
||||
</Button>
|
||||
) : null}
|
||||
<Button
|
||||
type="primary"
|
||||
ghost
|
||||
icon={<SwapOutlined />}
|
||||
disabled={!canTransfer || !can('listing:approve')}
|
||||
onClick={openTransfer}
|
||||
>
|
||||
转移所有权
|
||||
</Button>
|
||||
<Button
|
||||
icon={<StopOutlined />}
|
||||
disabled={!canOperate || !can('listing:offline')}
|
||||
onClick={() => openReason('offline')}
|
||||
>
|
||||
强制下架
|
||||
</Button>
|
||||
<Button
|
||||
danger
|
||||
icon={<WarningOutlined />}
|
||||
disabled={!canOperate || !can('listing:offline')}
|
||||
onClick={() => openReason('abnormal')}
|
||||
>
|
||||
标记异常
|
||||
</Button>
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
|
||||
{listing ? (
|
||||
<div className="admin-listing-summary">
|
||||
<div>
|
||||
<span>商品状态</span>
|
||||
<StatusTag meta={listingStatusMeta(listing.status)} />
|
||||
</div>
|
||||
<div>
|
||||
<span>审核状态</span>
|
||||
<StatusTag meta={listingReviewStatusMeta(listing.review_status)} />
|
||||
</div>
|
||||
<div>
|
||||
<span>哈夫币</span>
|
||||
<strong>{formatCoinM(listing.haf_coin_amount)}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>押金</span>
|
||||
<strong>¥{(listing.deposit_amount_cent / 100).toFixed(2)}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>商品售价</span>
|
||||
<strong>¥{(listing.price_cent / 100).toFixed(2)}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>预计可租</span>
|
||||
<strong>{duration.days}</strong>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="admin-listing-grid">
|
||||
<Card title="账号属性" size="small" className="admin-detail-card admin-detail-card--wide">
|
||||
<Descriptions column={{ xs: 1, sm: 2, md: 3 }} size="small">
|
||||
{assetRows.map(row => (
|
||||
<Descriptions.Item key={row.label} label={row.label}>
|
||||
{row.value}
|
||||
</Descriptions.Item>
|
||||
))}
|
||||
</Descriptions>
|
||||
</Card>
|
||||
|
||||
<Card title="号主与价格" size="small" className="admin-detail-card">
|
||||
<Descriptions column={1} size="small">
|
||||
{ownerRows.map(row => (
|
||||
<Descriptions.Item key={row.label} label={row.label}>
|
||||
{row.value}
|
||||
</Descriptions.Item>
|
||||
))}
|
||||
<Descriptions.Item label="交接方式">
|
||||
<StatusTag meta={readStatusMeta(handoffModeMap, listing?.handoff_mode)} />
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="结算方式">
|
||||
<StatusTag meta={readStatusMeta(settlementModeMap, listing?.settlement_mode)} />
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</Card>
|
||||
|
||||
<Card title="说明与时间" size="small" className="admin-detail-card">
|
||||
<Descriptions column={1} size="small">
|
||||
<Descriptions.Item label="商品说明">
|
||||
{formatText(listing?.description) || '暂无商品说明'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="审核/后台原因">
|
||||
{formatText(listing?.review_reason)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="上架时间">
|
||||
{formatDateTime(listing?.published_at)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="创建时间">
|
||||
{formatDateTime(listing?.created_at)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="更新时间">
|
||||
{formatDateTime(listing?.updated_at)}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</Card>
|
||||
|
||||
<Card
|
||||
title="库存资产"
|
||||
size="small"
|
||||
className="admin-detail-card admin-detail-card--wide"
|
||||
extra={
|
||||
<span>
|
||||
{resources.length} 项资源 · {skins.length} 个皮肤
|
||||
</span>
|
||||
}
|
||||
>
|
||||
{resources.length ? (
|
||||
<div className="admin-resource-grid">
|
||||
{resources.map(resource => (
|
||||
<div className={`admin-resource-chip is-${resource.mode}`} key={resource.label}>
|
||||
<div>
|
||||
<strong>{resource.label}</strong>
|
||||
<span>×{resource.quantity}</span>
|
||||
</div>
|
||||
<em>{resourceBadgeText(resource, 'compact')}</em>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<Typography.Text type="secondary">暂无库存资源</Typography.Text>
|
||||
)}
|
||||
<div className="admin-skin-tags">
|
||||
{skins.map(skin => (
|
||||
<Tag key={skin}>{skin}</Tag>
|
||||
))}
|
||||
{skins.length === 0 ? (
|
||||
<Typography.Text type="secondary">暂无皮肤数据</Typography.Text>
|
||||
) : null}
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card
|
||||
title="资产截图"
|
||||
size="small"
|
||||
className="admin-detail-card admin-detail-card--wide"
|
||||
extra={
|
||||
<span>{screenshotGroups.reduce((sum, group) => sum + group.urls.length, 0)} 张</span>
|
||||
}
|
||||
>
|
||||
{screenshotGroups.length ? (
|
||||
<div className="admin-screenshot-groups">
|
||||
{screenshotGroups.map(group => (
|
||||
<div key={group.key} className="admin-screenshot-group">
|
||||
<div className="admin-screenshot-group__title">
|
||||
{group.label}
|
||||
<span>{group.urls.length} 张</span>
|
||||
</div>
|
||||
<Image.PreviewGroup>
|
||||
<div className="admin-screenshot-grid">
|
||||
{group.urls.map(url => (
|
||||
<Image key={url} src={url} alt={group.label} width={150} height={96} />
|
||||
))}
|
||||
</div>
|
||||
</Image.PreviewGroup>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<Typography.Text type="secondary">暂无截图</Typography.Text>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<Modal
|
||||
open={reasonAction !== null}
|
||||
title={reasonAction ? reasonCopy[reasonAction].title : ''}
|
||||
okText={reasonAction ? reasonCopy[reasonAction].okText : '确认'}
|
||||
okButtonProps={{ danger: reasonAction === 'offline' }}
|
||||
confirmLoading={busy}
|
||||
onOk={() => void submitReason()}
|
||||
onCancel={() => setReasonAction(null)}
|
||||
destroyOnHidden
|
||||
>
|
||||
<p className="admin-modal-hint">{reasonAction ? reasonCopy[reasonAction].hint : ''}</p>
|
||||
<Form form={reasonForm} layout="vertical">
|
||||
<Form.Item
|
||||
name="reason"
|
||||
label="操作原因"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写操作原因' }]}
|
||||
>
|
||||
<Input.TextArea rows={3} maxLength={255} showCount />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
open={externalOpen}
|
||||
title="调整外部商品"
|
||||
okText="保存调整"
|
||||
confirmLoading={busy}
|
||||
onOk={() => void submitExternal()}
|
||||
onCancel={() => setExternalOpen(false)}
|
||||
destroyOnHidden
|
||||
width={720}
|
||||
>
|
||||
<p className="admin-modal-hint">
|
||||
调整后会重新计算号主价格与租客展示价格;请填写用户申请内容或资产修正原因。
|
||||
</p>
|
||||
<Form form={externalForm} layout="vertical">
|
||||
<div className="admin-form-grid">
|
||||
<Form.Item
|
||||
name="haf_coin_m"
|
||||
label="纯币数量(M)"
|
||||
rules={[{ required: true, message: '请填写纯币数量' }]}
|
||||
>
|
||||
<InputNumber min={0.1} step={1} precision={1} style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="deposit_yuan"
|
||||
label="押金(元)"
|
||||
rules={[{ required: true, message: '请填写押金' }]}
|
||||
>
|
||||
<InputNumber min={0} step={10} precision={2} style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="awm_bullets" label="AWM 子弹">
|
||||
<InputNumber min={0} precision={0} style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="level6_helmets" label="六级头">
|
||||
<InputNumber min={0} precision={0} style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="level6_armor" label="六级甲">
|
||||
<InputNumber min={0} precision={0} style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
<Form.Item name="adjust_mode" label="调整方式">
|
||||
<Radio.Group>
|
||||
<Radio.Button value="discount_amount">按降价金额</Radio.Button>
|
||||
<Radio.Button value="sale_ratio">按发布比例</Radio.Button>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
<Form.Item noStyle shouldUpdate>
|
||||
{({ getFieldValue }) =>
|
||||
getFieldValue('adjust_mode') === 'sale_ratio' ? (
|
||||
<Form.Item
|
||||
name="sale_ratio"
|
||||
label="目标发布比例"
|
||||
rules={[{ required: true, message: '请填写目标比例' }]}
|
||||
>
|
||||
<InputNumber min={0} step={0.1} precision={1} style={{ width: 200 }} />
|
||||
</Form.Item>
|
||||
) : (
|
||||
<Form.Item
|
||||
name="discount_amount_yuan"
|
||||
label="参考价降价(元)"
|
||||
rules={[{ required: true, message: '请填写降价金额' }]}
|
||||
>
|
||||
<InputNumber min={0} step={1} precision={2} style={{ width: 200 }} />
|
||||
</Form.Item>
|
||||
)
|
||||
}
|
||||
</Form.Item>
|
||||
{listing ? (
|
||||
<div className="admin-price-preview">
|
||||
<div>
|
||||
<span>当前哈夫币</span>
|
||||
<strong>{formatCoinM(listing.haf_coin_amount)}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>当前商品售价</span>
|
||||
<strong>¥{(listing.price_cent / 100).toFixed(2)}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>当前押金</span>
|
||||
<strong>¥{(listing.deposit_amount_cent / 100).toFixed(2)}</strong>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
<Form.Item
|
||||
name="reason"
|
||||
label="调整原因"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写调整原因' }]}
|
||||
>
|
||||
<Input.TextArea rows={3} maxLength={255} showCount />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
open={transferOpen}
|
||||
title="转移商品所有权"
|
||||
okText="确认转移"
|
||||
confirmLoading={busy}
|
||||
onOk={() => void submitTransfer()}
|
||||
onCancel={() => setTransferOpen(false)}
|
||||
destroyOnHidden
|
||||
width={620}
|
||||
>
|
||||
<p className="admin-modal-hint">
|
||||
仅支持转移给状态正常且已完成实名的用户;转移后商品归属与后续结算都会切换到新号主。
|
||||
</p>
|
||||
<Form form={transferForm} layout="vertical">
|
||||
<Form.Item label="目标号主">
|
||||
<Space.Compact style={{ width: '100%' }}>
|
||||
<Input
|
||||
value={userKeyword}
|
||||
placeholder="手机号 / 昵称 / 用户 ID"
|
||||
onChange={event => setUserKeyword(event.target.value)}
|
||||
onPressEnter={() => void searchUsers()}
|
||||
/>
|
||||
<Button loading={userSearching} onClick={() => void searchUsers()}>
|
||||
搜索用户
|
||||
</Button>
|
||||
</Space.Compact>
|
||||
</Form.Item>
|
||||
<Form.Item name="target_user_id" label="选择用户">
|
||||
<Radio.Group style={{ width: '100%' }}>
|
||||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
{userOptions.map(user => (
|
||||
<Radio key={user.id} value={user.id}>
|
||||
{formatText(user.phone)} · {formatText(user.nickname)} · ID {user.id}
|
||||
</Radio>
|
||||
))}
|
||||
</Space>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="reason"
|
||||
label="转移原因"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写转移原因' }]}
|
||||
>
|
||||
<Input.TextArea rows={3} maxLength={255} showCount />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,605 @@
|
||||
import { useMemo, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
Alert,
|
||||
App,
|
||||
Button,
|
||||
Card,
|
||||
Descriptions,
|
||||
Form,
|
||||
Image,
|
||||
Input,
|
||||
InputNumber,
|
||||
Modal,
|
||||
Radio,
|
||||
Space,
|
||||
Tag,
|
||||
Typography,
|
||||
} from 'antd'
|
||||
import {
|
||||
ArrowLeftOutlined,
|
||||
CheckCircleOutlined,
|
||||
CloseCircleOutlined,
|
||||
CloseOutlined,
|
||||
EditOutlined,
|
||||
ExportOutlined,
|
||||
ReloadOutlined,
|
||||
} from '@ant-design/icons'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import {
|
||||
adjustAdminListingPrice,
|
||||
approveAdminListing,
|
||||
fetchAdminListing,
|
||||
rejectAdminListing,
|
||||
} from '@/features/admin/api'
|
||||
import { AdminPageHeader } from '@/features/admin/components/AdminPageHeader'
|
||||
import { StatusTag } from '@/features/admin/components/StatusTag'
|
||||
import {
|
||||
listingReviewStatusMeta,
|
||||
listingStatusMeta,
|
||||
resourceBadgeText,
|
||||
} from '@/features/listings/labels'
|
||||
import {
|
||||
adminListingAssetRows,
|
||||
adminListingPricePipeline,
|
||||
adminListingResources,
|
||||
adminListingScreenshotGroups,
|
||||
adminListingSkins,
|
||||
} from '@/features/admin/listingDetailModel'
|
||||
import { listingCodeText } from '@/features/admin/listingDisplay'
|
||||
import { useAdminSessionStore } from '@/stores/adminSession'
|
||||
import { getAdminPath } from '@/shared/api/adminClient'
|
||||
import { formatDateTime, formatMoney, formatText } from '@/shared/utils/format'
|
||||
|
||||
const rejectReasonOptions = [
|
||||
'默认截图,需补充真实截图',
|
||||
'账号资产信息不完整',
|
||||
'价格或押金异常',
|
||||
'封禁记录需补充说明',
|
||||
'联系方式异常',
|
||||
'截图与所填信息不符',
|
||||
'缺少安全中心实机截图',
|
||||
]
|
||||
|
||||
function errorText(error: unknown) {
|
||||
const response = (error as { response?: { data?: { message?: string } } })?.response
|
||||
if (response?.data?.message) return response.data.message
|
||||
return error instanceof Error ? error.message : '请求失败,请稍后重试'
|
||||
}
|
||||
|
||||
function ratioText(value: number) {
|
||||
return value > 0 ? `1:${Math.round(value)}` : '—'
|
||||
}
|
||||
|
||||
export function AdminListingReviewDetailPage() {
|
||||
const { id } = useParams()
|
||||
const listingId = Number(id)
|
||||
const navigate = useNavigate()
|
||||
const { message, modal } = App.useApp()
|
||||
const queryClient = useQueryClient()
|
||||
const permissions = useAdminSessionStore(state => state.admin?.permissions)
|
||||
const can = (permission: string) =>
|
||||
Boolean(permissions?.includes('*') || permissions?.includes(permission))
|
||||
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [rejectOpen, setRejectOpen] = useState(false)
|
||||
const [rejectReason, setRejectReason] = useState('')
|
||||
const [priceOpen, setPriceOpen] = useState(false)
|
||||
const [priceForm] = Form.useForm<{
|
||||
mode: 'ratio' | 'price'
|
||||
buyer_ratio?: number
|
||||
buyer_total_price?: number
|
||||
reason: string
|
||||
}>()
|
||||
const priceMode = Form.useWatch('mode', priceForm) ?? 'ratio'
|
||||
const watchedRatio = Form.useWatch('buyer_ratio', priceForm)
|
||||
const watchedPrice = Form.useWatch('buyer_total_price', priceForm)
|
||||
|
||||
const listingQuery = useQuery({
|
||||
queryKey: ['admin-listing', listingId],
|
||||
queryFn: () => fetchAdminListing(listingId),
|
||||
enabled: Number.isFinite(listingId) && listingId > 0,
|
||||
})
|
||||
const listing = listingQuery.data
|
||||
const pipeline = useMemo(
|
||||
() =>
|
||||
listing
|
||||
? adminListingPricePipeline(listing)
|
||||
: {
|
||||
sellerTotalCent: 0,
|
||||
sellerCoinBaseCent: 0,
|
||||
consumableCent: 0,
|
||||
sellerRatio: 0,
|
||||
platformMarkupCent: 0,
|
||||
buyerTotalCent: 0,
|
||||
buyerCoinBaseCent: 0,
|
||||
buyerRatio: 0,
|
||||
depositCent: 0,
|
||||
dailyLoss: '',
|
||||
rentalDays: '—',
|
||||
},
|
||||
[listing]
|
||||
)
|
||||
|
||||
const refresh = async () => {
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: ['admin-listing', listingId] }),
|
||||
queryClient.invalidateQueries({ queryKey: ['admin-listings'] }),
|
||||
queryClient.invalidateQueries({ queryKey: ['admin-pending-listings'] }),
|
||||
])
|
||||
}
|
||||
|
||||
const run = async (action: () => Promise<unknown>, success: string) => {
|
||||
setBusy(true)
|
||||
try {
|
||||
await action()
|
||||
message.success(success)
|
||||
await refresh()
|
||||
return true
|
||||
} catch (error) {
|
||||
message.error(errorText(error))
|
||||
return false
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
const approve = () => {
|
||||
if (!listing) return
|
||||
modal.confirm({
|
||||
title: '通过审核并上架?',
|
||||
content: `商品「${listing.title}」通过后会按当前状态对外展示。`,
|
||||
okText: '通过审核',
|
||||
onOk: async () => {
|
||||
const ok = await run(() => approveAdminListing(listing.id), '审核已通过')
|
||||
if (ok) navigate(getAdminPath('/listings/review'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const toggleRejectReason = (reason: string) => {
|
||||
const parts = rejectReason
|
||||
.split(';')
|
||||
.map(part => part.trim())
|
||||
.filter(Boolean)
|
||||
const index = parts.indexOf(reason)
|
||||
if (index >= 0) parts.splice(index, 1)
|
||||
else parts.push(reason)
|
||||
setRejectReason(parts.join(';'))
|
||||
}
|
||||
|
||||
const openReject = () => {
|
||||
setRejectReason(listing?.review_reason || '')
|
||||
setRejectOpen(true)
|
||||
}
|
||||
|
||||
const submitReject = async () => {
|
||||
if (!listing) return
|
||||
const reason = rejectReason.trim()
|
||||
if (!reason) {
|
||||
message.warning('请填写拒绝原因')
|
||||
return
|
||||
}
|
||||
const ok = await run(() => rejectAdminListing(listing.id, reason), '已拒绝审核')
|
||||
if (ok) {
|
||||
setRejectOpen(false)
|
||||
navigate(getAdminPath('/listings/review'))
|
||||
}
|
||||
}
|
||||
|
||||
const openPrice = () => {
|
||||
if (!listing) return
|
||||
priceForm.setFieldsValue({
|
||||
mode: 'ratio',
|
||||
buyer_ratio: pipeline.buyerRatio ? Number(pipeline.buyerRatio.toFixed(1)) : undefined,
|
||||
buyer_total_price: pipeline.buyerTotalCent
|
||||
? Number((pipeline.buyerTotalCent / 100).toFixed(2))
|
||||
: undefined,
|
||||
reason: '',
|
||||
})
|
||||
setPriceOpen(true)
|
||||
}
|
||||
|
||||
const submitPrice = async () => {
|
||||
if (!listing) return
|
||||
const values = await priceForm.validateFields()
|
||||
const payload =
|
||||
values.mode === 'ratio'
|
||||
? { buyer_ratio: Number(values.buyer_ratio || 0), reason: values.reason.trim() }
|
||||
: {
|
||||
buyer_total_price_cent: Math.round(Number(values.buyer_total_price || 0) * 100),
|
||||
reason: values.reason.trim(),
|
||||
}
|
||||
if ((payload.buyer_ratio ?? 0) <= 0 && (payload.buyer_total_price_cent ?? 0) <= 0) {
|
||||
message.warning('请填写有效的比例或价格')
|
||||
return
|
||||
}
|
||||
const ok = await run(() => adjustAdminListingPrice(listing.id, payload), '审核价格已调整')
|
||||
if (ok) setPriceOpen(false)
|
||||
}
|
||||
|
||||
if (!Number.isFinite(listingId) || listingId <= 0) {
|
||||
return (
|
||||
<div className="admin-page">
|
||||
<AdminPageHeader eyebrow="JIEYOU OPS · 审核" title="商品审核详情" />
|
||||
<Alert type="error" showIcon message="商品 ID 不正确" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (listingQuery.isError) {
|
||||
return (
|
||||
<div className="admin-page">
|
||||
<AdminPageHeader eyebrow="JIEYOU OPS · 审核" title="商品审核详情" />
|
||||
<Alert
|
||||
type="error"
|
||||
showIcon
|
||||
message="商品没有加载出来"
|
||||
description={errorText(listingQuery.error)}
|
||||
action={<Button onClick={() => void listingQuery.refetch()}>重试</Button>}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const assetRows = listing ? adminListingAssetRows(listing) : []
|
||||
const resources = listing ? adminListingResources(listing) : []
|
||||
const skins = listing ? adminListingSkins(listing) : []
|
||||
const screenshotGroups = listing ? adminListingScreenshotGroups(listing) : []
|
||||
const groupCount = new Map(screenshotGroups.map(group => [group.key, group.urls.length]))
|
||||
const checklist = [
|
||||
{ key: 'coin', label: '纯币截图' },
|
||||
{ key: 'gameId', label: '游戏 ID' },
|
||||
{ key: 'skin', label: '皮肤外观' },
|
||||
{ key: 'tencentSecurity', label: '腾讯安全' },
|
||||
{ key: 'totalAsset', label: '总资产' },
|
||||
].map(item => ({ ...item, count: groupCount.get(item.key) ?? 0 }))
|
||||
|
||||
const pricePreview = (() => {
|
||||
if (!listing) return { ratio: 0, coinPrice: 0, totalPrice: 0 }
|
||||
const coinWan = listing.haf_coin_amount / 10000
|
||||
const consumableYuan = pipeline.consumableCent / 100
|
||||
if (priceMode === 'price') {
|
||||
const total = Number(watchedPrice || 0)
|
||||
const coinPrice = Math.max(0, total - consumableYuan)
|
||||
return {
|
||||
ratio: coinPrice > 0 ? coinWan / coinPrice : 0,
|
||||
coinPrice,
|
||||
totalPrice: total,
|
||||
}
|
||||
}
|
||||
const ratio = Number(watchedRatio || 0)
|
||||
const coinPrice = ratio > 0 ? coinWan / ratio : 0
|
||||
return { ratio, coinPrice, totalPrice: coinPrice + consumableYuan }
|
||||
})()
|
||||
|
||||
return (
|
||||
<div className="admin-page">
|
||||
<AdminPageHeader
|
||||
eyebrow={listing ? `商品编号 ${listingCodeText(listing)}` : 'JIEYOU OPS · 审核'}
|
||||
title={listing?.title || '商品审核详情'}
|
||||
description={
|
||||
listing
|
||||
? `${formatText(listing.server_region)} · ${formatText(
|
||||
listing.rank_level
|
||||
)} · ${formatText(listing.login_platform)} · 提交于 ${formatDateTime(
|
||||
listing.updated_at
|
||||
)}`
|
||||
: '加载中'
|
||||
}
|
||||
meta={
|
||||
listing ? (
|
||||
<Space size={6} wrap>
|
||||
<StatusTag meta={listingStatusMeta(listing.status)} />
|
||||
<StatusTag meta={listingReviewStatusMeta(listing.review_status)} />
|
||||
</Space>
|
||||
) : null
|
||||
}
|
||||
extra={
|
||||
<Space wrap>
|
||||
<Button
|
||||
icon={<ArrowLeftOutlined />}
|
||||
onClick={() => navigate(getAdminPath('/listings/review'))}
|
||||
>
|
||||
返回审核列表
|
||||
</Button>
|
||||
<Button
|
||||
icon={<ReloadOutlined />}
|
||||
loading={listingQuery.isFetching}
|
||||
onClick={() => void refresh()}
|
||||
>
|
||||
刷新
|
||||
</Button>
|
||||
<Button
|
||||
icon={<ExportOutlined />}
|
||||
onClick={() => navigate(getAdminPath(`/listings/${listingId}`))}
|
||||
>
|
||||
商品详情页
|
||||
</Button>
|
||||
<Button icon={<EditOutlined />} disabled={!can('listing:approve')} onClick={openPrice}>
|
||||
调整价格
|
||||
</Button>
|
||||
{listing?.review_status === 'pending' ? (
|
||||
<>
|
||||
<Button
|
||||
danger
|
||||
icon={<CloseOutlined />}
|
||||
disabled={!can('listing:reject')}
|
||||
onClick={openReject}
|
||||
>
|
||||
拒绝
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<CheckCircleOutlined />}
|
||||
loading={busy}
|
||||
disabled={!can('listing:approve')}
|
||||
onClick={approve}
|
||||
>
|
||||
通过并上架
|
||||
</Button>
|
||||
</>
|
||||
) : null}
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
|
||||
{listing ? (
|
||||
<>
|
||||
<Card
|
||||
title="价格核算与加价决策流"
|
||||
size="small"
|
||||
className="admin-detail-card admin-detail-card--wide"
|
||||
>
|
||||
<div className="admin-price-pipeline">
|
||||
<div className="admin-price-card is-seller">
|
||||
<span>卖家发布价</span>
|
||||
<strong>{formatMoney(pipeline.sellerTotalCent)}</strong>
|
||||
<small>发布比例 {ratioText(pipeline.sellerRatio)}</small>
|
||||
<div>
|
||||
纯币 {formatMoney(pipeline.sellerCoinBaseCent)} · 物品{' '}
|
||||
{formatMoney(pipeline.consumableCent)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="admin-price-arrow">平台加价 →</div>
|
||||
<div className="admin-price-card is-rule">
|
||||
<span>平台加价</span>
|
||||
<strong>+{formatMoney(pipeline.platformMarkupCent)}</strong>
|
||||
<small>按平台规则计算</small>
|
||||
<div>号主合计 {formatMoney(pipeline.sellerTotalCent)}</div>
|
||||
</div>
|
||||
<div className="admin-price-arrow">最终展示 →</div>
|
||||
<div className="admin-price-card is-buyer">
|
||||
<span>买家端展示售价</span>
|
||||
<strong>{formatMoney(pipeline.buyerTotalCent)}</strong>
|
||||
<small>展示比例 {ratioText(pipeline.buyerRatio)}</small>
|
||||
<div>
|
||||
纯币 {formatMoney(pipeline.buyerCoinBaseCent)} · 押金{' '}
|
||||
{formatMoney(pipeline.depositCent)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<div className="admin-listing-grid">
|
||||
<Card
|
||||
title="账号核心战备属性"
|
||||
size="small"
|
||||
className="admin-detail-card admin-detail-card--wide"
|
||||
>
|
||||
<Descriptions column={{ xs: 1, sm: 2, md: 3 }} size="small">
|
||||
{assetRows.map(row => (
|
||||
<Descriptions.Item key={row.label} label={row.label}>
|
||||
{row.value}
|
||||
</Descriptions.Item>
|
||||
))}
|
||||
</Descriptions>
|
||||
</Card>
|
||||
|
||||
<Card title="来源溯源与号主信息" size="small" className="admin-detail-card">
|
||||
<Descriptions column={1} size="small">
|
||||
<Descriptions.Item label="号主">
|
||||
{formatText(listing.owner_nickname || listing.owner_phone)} · ID{' '}
|
||||
{listing.owner_id}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="联系电话">
|
||||
{formatText(listing.owner_phone)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="来源渠道">
|
||||
{formatText(listing.source_channel)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="外部上传">
|
||||
{listing.is_external_upload ? '是' : '否'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="账号 ID">{listing.account_id}</Descriptions.Item>
|
||||
<Descriptions.Item label="提交时间">
|
||||
{formatDateTime(listing.updated_at)}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</Card>
|
||||
|
||||
<Card
|
||||
title="物资装备与外观资产"
|
||||
size="small"
|
||||
className="admin-detail-card"
|
||||
extra={<span>额外物资 {formatMoney(pipeline.consumableCent)}</span>}
|
||||
>
|
||||
{resources.length ? (
|
||||
<div className="admin-resource-grid">
|
||||
{resources.map(resource => (
|
||||
<div className={`admin-resource-chip is-${resource.mode}`} key={resource.label}>
|
||||
<div>
|
||||
<strong>{resource.label}</strong>
|
||||
<span>×{resource.quantity}</span>
|
||||
</div>
|
||||
<em>{resourceBadgeText(resource, 'compact')}</em>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<Typography.Text type="secondary">暂无库存资源</Typography.Text>
|
||||
)}
|
||||
<div className="admin-skin-tags">
|
||||
{skins.map(skin => (
|
||||
<Tag key={skin}>{skin}</Tag>
|
||||
))}
|
||||
{skins.length === 0 ? (
|
||||
<Typography.Text type="secondary">暂无皮肤数据</Typography.Text>
|
||||
) : null}
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card
|
||||
title="账号截图凭证审核"
|
||||
size="small"
|
||||
className="admin-detail-card admin-detail-card--wide"
|
||||
extra={
|
||||
<span>
|
||||
{screenshotGroups.reduce((sum, group) => sum + group.urls.length, 0)} 张
|
||||
</span>
|
||||
}
|
||||
>
|
||||
<div className="admin-review-checklist">
|
||||
{checklist.map(item => (
|
||||
<div
|
||||
className={`admin-review-check${item.count > 0 ? ' is-provided' : ' is-missing'}`}
|
||||
key={item.key}
|
||||
>
|
||||
{item.count > 0 ? <CheckCircleOutlined /> : <CloseCircleOutlined />}
|
||||
<span>{item.label}</span>
|
||||
<em>{item.count > 0 ? `已提供 (${item.count})` : '未提供'}</em>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{screenshotGroups.length ? (
|
||||
<div className="admin-screenshot-groups">
|
||||
{screenshotGroups.map(group => (
|
||||
<div key={group.key} className="admin-screenshot-group">
|
||||
<div className="admin-screenshot-group__title">
|
||||
{group.label}
|
||||
<span>{group.urls.length} 张</span>
|
||||
</div>
|
||||
<Image.PreviewGroup>
|
||||
<div className="admin-screenshot-grid">
|
||||
{group.urls.map(url => (
|
||||
<Image key={url} src={url} alt={group.label} width={150} height={96} />
|
||||
))}
|
||||
</div>
|
||||
</Image.PreviewGroup>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="该商品未上传任何截图凭证,请谨慎审核或直接拒绝。"
|
||||
/>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
|
||||
<Modal
|
||||
open={rejectOpen}
|
||||
title="拒绝发布商品"
|
||||
okText="确认拒绝"
|
||||
okButtonProps={{ danger: true }}
|
||||
confirmLoading={busy}
|
||||
onOk={() => void submitReject()}
|
||||
onCancel={() => setRejectOpen(false)}
|
||||
destroyOnHidden
|
||||
width={620}
|
||||
>
|
||||
<p className="admin-modal-hint">点击下方原因可追加或取消,最终会合并写入审核意见。</p>
|
||||
<div className="admin-reason-pills">
|
||||
{rejectReasonOptions.map(reason => {
|
||||
const selected = rejectReason.includes(reason)
|
||||
return (
|
||||
<button
|
||||
key={reason}
|
||||
type="button"
|
||||
className={`admin-reason-pill${selected ? ' is-selected' : ''}`}
|
||||
onClick={() => toggleRejectReason(reason)}
|
||||
>
|
||||
{reason}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<Input.TextArea
|
||||
rows={3}
|
||||
value={rejectReason}
|
||||
onChange={event => setRejectReason(event.target.value)}
|
||||
maxLength={500}
|
||||
showCount
|
||||
placeholder="填写拒绝原因"
|
||||
/>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
open={priceOpen}
|
||||
title="调整审核价格"
|
||||
okText="保存调价"
|
||||
confirmLoading={busy}
|
||||
onOk={() => void submitPrice()}
|
||||
onCancel={() => setPriceOpen(false)}
|
||||
destroyOnHidden
|
||||
width={620}
|
||||
>
|
||||
<Form form={priceForm} layout="vertical">
|
||||
<Form.Item name="mode" label="调整方式">
|
||||
<Radio.Group>
|
||||
<Radio.Button value="ratio">按买家比例</Radio.Button>
|
||||
<Radio.Button value="price">按买家总价</Radio.Button>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
<Form.Item noStyle shouldUpdate>
|
||||
{({ getFieldValue }) =>
|
||||
getFieldValue('mode') === 'ratio' ? (
|
||||
<Form.Item
|
||||
name="buyer_ratio"
|
||||
label="买家展示比例"
|
||||
rules={[{ required: true, message: '请填写买家比例' }]}
|
||||
>
|
||||
<InputNumber min={0.1} step={0.1} precision={1} style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
) : (
|
||||
<Form.Item
|
||||
name="buyer_total_price"
|
||||
label="买家总价(元)"
|
||||
rules={[{ required: true, message: '请填写买家总价' }]}
|
||||
>
|
||||
<InputNumber min={0.01} step={1} precision={2} style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
)
|
||||
}
|
||||
</Form.Item>
|
||||
<div className="admin-price-preview">
|
||||
<div>
|
||||
<span>调整后比例</span>
|
||||
<strong>{ratioText(pricePreview.ratio)}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>调整后纯币价</span>
|
||||
<strong>{formatMoney(Math.round(pricePreview.coinPrice * 100))}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>调整后买家价</span>
|
||||
<strong>{formatMoney(Math.round(pricePreview.totalPrice * 100))}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<Form.Item
|
||||
name="reason"
|
||||
label="调价原因"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写调价原因' }]}
|
||||
>
|
||||
<Input.TextArea rows={3} maxLength={255} showCount />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -12,10 +12,9 @@ import {
|
||||
type TableColumnsType,
|
||||
} from 'antd'
|
||||
import { EyeOutlined, ReloadOutlined } from '@ant-design/icons'
|
||||
import { useSearchParams } from 'react-router-dom'
|
||||
import { useSearchParams, useNavigate } from 'react-router-dom'
|
||||
|
||||
import { fetchAdminListings, fetchAdminPendingListings } from '@/features/admin/api'
|
||||
import { AdminListingDetailDrawer } from '@/features/admin/AdminListingDetailDrawer'
|
||||
import { AdminPageHeader } from '@/features/admin/components/AdminPageHeader'
|
||||
import { DataTable } from '@/features/admin/components/DataTable'
|
||||
import { FilterBar, FilterField } from '@/features/admin/components/FilterBar'
|
||||
@@ -46,6 +45,7 @@ import {
|
||||
import type { AdminListing, AdminListingQuery } from '@/features/admin/types'
|
||||
import { emptyListingPublishOptions, fetchListingPublishOptions } from '@/features/seller/options'
|
||||
import { useAdminSessionStore } from '@/stores/adminSession'
|
||||
import { getAdminPath } from '@/shared/api/adminClient'
|
||||
import { formatText } from '@/shared/utils/format'
|
||||
|
||||
type ListingMode = 'all' | 'review'
|
||||
@@ -344,8 +344,7 @@ export function AdminListingsPage({ mode = 'all' }: { mode?: ListingMode }) {
|
||||
}))
|
||||
const [page, setPage] = useState(1)
|
||||
const [pageSize, setPageSize] = useState(10)
|
||||
const [detailId, setDetailId] = useState<number | null>(null)
|
||||
const [detailOpen, setDetailOpen] = useState(false)
|
||||
const navigate = useNavigate()
|
||||
const permissions = useAdminSessionStore(state => state.admin?.permissions)
|
||||
const canView = Boolean(permissions?.includes('*') || permissions?.includes('listing:view'))
|
||||
|
||||
@@ -418,8 +417,7 @@ export function AdminListingsPage({ mode = 'all' }: { mode?: ListingMode }) {
|
||||
|
||||
const openDetail = (id: number) => {
|
||||
if (!canView) return
|
||||
setDetailId(id)
|
||||
setDetailOpen(true)
|
||||
navigate(getAdminPath(isReviewMode ? `/listings/review/${id}` : `/listings/${id}`))
|
||||
}
|
||||
|
||||
const columns = buildColumns(row => openDetail(row.id), canView)
|
||||
@@ -685,17 +683,6 @@ export function AdminListingsPage({ mode = 'all' }: { mode?: ListingMode }) {
|
||||
onRowClick={canView ? row => openDetail(row.id) : undefined}
|
||||
emptyDescription={isReviewMode ? '没有待审核商品' : '没有匹配的商品'}
|
||||
/>
|
||||
|
||||
{canView ? (
|
||||
<AdminListingDetailDrawer
|
||||
listingId={detailId}
|
||||
open={detailOpen}
|
||||
onClose={() => setDetailOpen(false)}
|
||||
onChanged={() => {
|
||||
void refetch()
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,10 +2,9 @@ import { useMemo, useState } from 'react'
|
||||
import { keepPreviousData, useQuery } from '@tanstack/react-query'
|
||||
import { Alert, Button, Input, Select, Space, Tag, Typography, type TableColumnsType } from 'antd'
|
||||
import { EyeOutlined, ReloadOutlined } from '@ant-design/icons'
|
||||
import { useSearchParams } from 'react-router-dom'
|
||||
import { useSearchParams, useNavigate } from 'react-router-dom'
|
||||
|
||||
import { fetchAdminOrders } from '@/features/admin/api'
|
||||
import { AdminOrderDetailDrawer } from '@/features/admin/AdminOrderDetailDrawer'
|
||||
import { AdminPageHeader } from '@/features/admin/components/AdminPageHeader'
|
||||
import { DataTable } from '@/features/admin/components/DataTable'
|
||||
import { FilterBar, FilterField } from '@/features/admin/components/FilterBar'
|
||||
@@ -23,6 +22,7 @@ import {
|
||||
} from '@/features/admin/labels'
|
||||
import type { AdminOrderListItem, AdminOrderQuery } from '@/features/admin/types'
|
||||
import { useAdminSessionStore } from '@/stores/adminSession'
|
||||
import { getAdminPath } from '@/shared/api/adminClient'
|
||||
import { formatDateTime, formatMoney, formatText } from '@/shared/utils/format'
|
||||
|
||||
const emptyFilters: AdminOrderQuery = {
|
||||
@@ -147,6 +147,7 @@ function buildColumns(
|
||||
|
||||
export function AdminOrdersPage() {
|
||||
const [searchParams] = useSearchParams()
|
||||
const navigate = useNavigate()
|
||||
const initialKeyword = searchParams.get('keyword')?.trim() ?? ''
|
||||
const initialUserId = Number(searchParams.get('user_id')) || undefined
|
||||
|
||||
@@ -162,8 +163,6 @@ export function AdminOrdersPage() {
|
||||
}))
|
||||
const [page, setPage] = useState(1)
|
||||
const [pageSize, setPageSize] = useState(20)
|
||||
const [detailId, setDetailId] = useState<number | null>(null)
|
||||
const [detailOpen, setDetailOpen] = useState(false)
|
||||
const permissions = useAdminSessionStore(state => state.admin?.permissions)
|
||||
const canViewDetail = Boolean(permissions?.includes('*') || permissions?.includes('order:view'))
|
||||
|
||||
@@ -176,10 +175,9 @@ export function AdminOrdersPage() {
|
||||
const columns = useMemo(
|
||||
() =>
|
||||
buildColumns(row => {
|
||||
setDetailId(row.id)
|
||||
setDetailOpen(true)
|
||||
navigate(getAdminPath(`/orders/${row.id}`))
|
||||
}, canViewDetail),
|
||||
[canViewDetail]
|
||||
[canViewDetail, navigate]
|
||||
)
|
||||
|
||||
const patchFilter = (patch: Partial<AdminOrderQuery>) => {
|
||||
@@ -317,21 +315,12 @@ export function AdminOrdersPage() {
|
||||
onRowClick={
|
||||
canViewDetail
|
||||
? row => {
|
||||
setDetailId(row.id)
|
||||
setDetailOpen(true)
|
||||
navigate(getAdminPath(`/orders/${row.id}`))
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
emptyDescription="没有匹配的订单,换个筛选条件试试"
|
||||
/>
|
||||
|
||||
{canViewDetail ? (
|
||||
<AdminOrderDetailDrawer
|
||||
orderId={detailId}
|
||||
open={detailOpen}
|
||||
onClose={() => setDetailOpen(false)}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,12 @@ import { fetchAdminPayments } from '@/features/admin/api'
|
||||
import { AdminPageHeader } from '@/features/admin/components/AdminPageHeader'
|
||||
import { DataTable } from '@/features/admin/components/DataTable'
|
||||
import { FilterBar, FilterField } from '@/features/admin/components/FilterBar'
|
||||
import {
|
||||
paymentBizTypeMap,
|
||||
paymentMethodLabel,
|
||||
paymentProviderLabel,
|
||||
paymentProviderMap,
|
||||
} from '@/features/admin/enumLabels'
|
||||
import type { AdminPaymentQuery, AdminPaymentRow } from '@/features/admin/types'
|
||||
import { useAdminSessionStore } from '@/stores/adminSession'
|
||||
import { formatDateTime, formatMoney, formatText } from '@/shared/utils/format'
|
||||
@@ -27,18 +33,12 @@ const statusOptions = [
|
||||
{ value: 'closed', label: '已关闭' },
|
||||
]
|
||||
|
||||
const bizTypeOptions = [
|
||||
{ value: 'order_pay', label: '订单支付' },
|
||||
{ value: 'main_recharge', label: '充值' },
|
||||
]
|
||||
const bizTypeOptions = Object.entries(paymentBizTypeMap).map(([value, label]) => ({ value, label }))
|
||||
|
||||
const providerOptions = [
|
||||
{ value: 'leshua', label: '乐刷' },
|
||||
{ value: 'lakala', label: '拉卡拉' },
|
||||
{ value: 'shuncheng', label: '顺诚' },
|
||||
{ value: 'saobei', label: '扫呗' },
|
||||
{ value: 'mock', label: '模拟支付' },
|
||||
]
|
||||
const providerOptions = Object.entries(paymentProviderMap).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}))
|
||||
|
||||
const statusMeta: Record<string, { label: string; color: string }> = {
|
||||
pending: { label: '待支付', color: 'gold' },
|
||||
@@ -93,8 +93,8 @@ const columns: TableColumnsType<AdminPaymentRow> = [
|
||||
width: 170,
|
||||
render: (_, row) => (
|
||||
<div className="admin-stack">
|
||||
<span>{formatText(row.provider)}</span>
|
||||
<span className="admin-mono">{formatText(row.pay_way)}</span>
|
||||
<span>{paymentProviderLabel(row.provider)}</span>
|
||||
<span className="admin-mono">{paymentMethodLabel(row.pay_way)}</span>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -40,11 +40,16 @@ import type {
|
||||
AdminSiteAnnouncementQuery,
|
||||
AdminListing,
|
||||
AdminListingPage,
|
||||
AdminListingPriceAdjustPayload,
|
||||
AdminListingQuery,
|
||||
AdminExternalListingAdjustPayload,
|
||||
AdminLoginData,
|
||||
AdminOrderDetail,
|
||||
AdminOrderHandoffRecord,
|
||||
AdminOrderPage,
|
||||
AdminOrderProcessEvent,
|
||||
AdminOrderQuery,
|
||||
AdminOrderRefundStatus,
|
||||
AdminPaymentChannel,
|
||||
AdminPaymentConfig,
|
||||
AdminPaymentConfigOption,
|
||||
@@ -216,6 +221,130 @@ export async function fetchAdminOrder(id: number | string) {
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function fetchAdminOrderHandoffRecords(id: number | string) {
|
||||
const { data } = await adminClient.get<ApiResponse<{ items?: AdminOrderHandoffRecord[] }>>(
|
||||
`/admin/orders/${id}/handoff-records`
|
||||
)
|
||||
return data.data.items ?? []
|
||||
}
|
||||
|
||||
export async function fetchAdminOrderProcessEvents(id: number | string) {
|
||||
const { data } = await adminClient.get<ApiResponse<{ items?: AdminOrderProcessEvent[] }>>(
|
||||
`/admin/orders/${id}/process-events`
|
||||
)
|
||||
return data.data.items ?? []
|
||||
}
|
||||
|
||||
export async function fetchAdminOrderRefundStatus(id: number | string) {
|
||||
const { data } = await adminClient.get<ApiResponse<AdminOrderRefundStatus>>(
|
||||
`/admin/orders/${id}/refund-status`
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export interface AdminOrderCounterCheckoutPayload {
|
||||
consumable_amount_cent: number
|
||||
coin_consumed_m: number
|
||||
other_amount_cent?: number
|
||||
deposit_deduct_amount_cent: number
|
||||
reason: string
|
||||
evidence_urls?: string[]
|
||||
}
|
||||
|
||||
export interface AdminOrderDisputePayload {
|
||||
type: string
|
||||
description: string
|
||||
target_role: 'owner' | 'renter'
|
||||
evidence_urls?: string[]
|
||||
}
|
||||
|
||||
export async function closeAdminOrder(
|
||||
id: number | string,
|
||||
reason: string,
|
||||
confirmZeroOwnerIncome = false
|
||||
) {
|
||||
await adminClient.post(`/admin/orders/${id}/close`, {
|
||||
reason,
|
||||
confirm_zero_owner_income: confirmZeroOwnerIncome,
|
||||
})
|
||||
}
|
||||
|
||||
export async function sealAdminOrder(id: number | string, reason: string) {
|
||||
await adminClient.post(`/admin/orders/${id}/seal`, { reason })
|
||||
}
|
||||
|
||||
export async function markAbnormalAdminOrder(id: number | string, reason: string) {
|
||||
await adminClient.post(`/admin/orders/${id}/mark-abnormal`, { reason })
|
||||
}
|
||||
|
||||
export async function resetAdminOrderHandoff(id: number | string, reason: string) {
|
||||
await adminClient.post(`/admin/orders/${id}/reset-handoff`, { reason })
|
||||
}
|
||||
|
||||
export async function platformHandoffAdminOrder(
|
||||
id: number | string,
|
||||
content: string,
|
||||
reason: string
|
||||
) {
|
||||
await adminClient.post(`/admin/orders/${id}/platform-handoff`, { content, reason })
|
||||
}
|
||||
|
||||
export async function forceHandoffAdminOrder(id: number | string, content: string, reason: string) {
|
||||
await adminClient.post(`/admin/orders/${id}/force-handoff`, { content, reason })
|
||||
}
|
||||
|
||||
export async function confirmAdminOrderCheckout(
|
||||
id: number | string,
|
||||
reason: string,
|
||||
confirmZeroOwnerIncome = false
|
||||
) {
|
||||
await adminClient.post(`/admin/orders/${id}/platform-checkout/confirm`, {
|
||||
reason,
|
||||
confirm_zero_owner_income: confirmZeroOwnerIncome,
|
||||
})
|
||||
}
|
||||
|
||||
export async function counterAdminOrderCheckout(
|
||||
id: number | string,
|
||||
payload: AdminOrderCounterCheckoutPayload
|
||||
) {
|
||||
await adminClient.post(`/admin/orders/${id}/platform-checkout/counter`, payload)
|
||||
}
|
||||
|
||||
export async function disputeAdminOrderCheckout(id: number | string, reason: string) {
|
||||
await adminClient.post(`/admin/orders/${id}/platform-checkout/dispute`, { reason })
|
||||
}
|
||||
|
||||
export async function markAdminOrderOfflineSettlement(id: number | string, remark: string) {
|
||||
await adminClient.post(`/admin/orders/${id}/offline-settlement`, { remark })
|
||||
}
|
||||
|
||||
export async function refundAdminOrder(id: number | string) {
|
||||
const { data } = await adminClient.post<ApiResponse<AdminOrderRefundStatus>>(
|
||||
`/admin/orders/${id}/refund`
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function holdAdminOrderDeposit(id: number | string, reason: string) {
|
||||
await adminClient.post(`/admin/orders/${id}/deposit-hold`, { reason })
|
||||
}
|
||||
|
||||
export async function releaseAdminOrderDeposit(id: number | string, reason: string) {
|
||||
await adminClient.post(`/admin/orders/${id}/deposit-release`, { reason })
|
||||
}
|
||||
|
||||
export async function createAdminOrderDispute(
|
||||
id: number | string,
|
||||
payload: AdminOrderDisputePayload
|
||||
) {
|
||||
const { data } = await adminClient.post<ApiResponse<{ id: number }>>(
|
||||
`/admin/orders/${id}/dispute`,
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function fetchAdminListings(query: AdminListingQuery) {
|
||||
const { data } = await adminClient.get<ApiResponse<Partial<AdminListingPage>>>(
|
||||
'/admin/listings',
|
||||
@@ -274,6 +403,40 @@ export async function markAbnormalAdminListing(id: number | string, reason: stri
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function adjustAdminListingPrice(
|
||||
id: number | string,
|
||||
payload: AdminListingPriceAdjustPayload
|
||||
) {
|
||||
const { data } = await adminClient.post<ApiResponse<AdminListing>>(
|
||||
`/admin/listings/${id}/adjust-price`,
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function adjustExternalAdminListing(
|
||||
id: number | string,
|
||||
payload: AdminExternalListingAdjustPayload
|
||||
) {
|
||||
const { data } = await adminClient.put<ApiResponse<AdminListing>>(
|
||||
`/admin/listings/${id}/external-adjustment`,
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function transferAdminListingOwner(
|
||||
id: number | string,
|
||||
targetUserId: number,
|
||||
reason: string
|
||||
) {
|
||||
const { data } = await adminClient.post<ApiResponse<AdminListing>>(
|
||||
`/admin/listings/${id}/transfer-owner`,
|
||||
{ target_user_id: targetUserId, reason }
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function fetchAdminUsers(query: AdminUserQuery) {
|
||||
const params: Record<string, unknown> = { ...compactParams(query) }
|
||||
if (query.has_deposit_free_quota) {
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import {
|
||||
disputeStatusLabel,
|
||||
disputeTypeLabel,
|
||||
handoffRecordTypeLabel,
|
||||
participantTypeLabel,
|
||||
paymentBizTypeLabel,
|
||||
paymentMethodLabel,
|
||||
paymentProviderLabel,
|
||||
processActionLabel,
|
||||
processStageLabel,
|
||||
} from '@/features/admin/enumLabels'
|
||||
|
||||
describe('paymentBizTypeLabel', () => {
|
||||
it('映射订单与退款业务类型', () => {
|
||||
expect(paymentBizTypeLabel('order_pay')).toBe('订单支付')
|
||||
expect(paymentBizTypeLabel('deposit')).toBe('押金支付')
|
||||
expect(paymentBizTypeLabel('admin_refund')).toBe('人工退款')
|
||||
})
|
||||
|
||||
it('未知值保留原值,空值显示占位符', () => {
|
||||
expect(paymentBizTypeLabel('new_biz_type')).toBe('new_biz_type')
|
||||
expect(paymentBizTypeLabel('')).toBe('—')
|
||||
expect(paymentBizTypeLabel(null)).toBe('—')
|
||||
})
|
||||
})
|
||||
|
||||
describe('paymentProviderLabel / paymentMethodLabel', () => {
|
||||
it('映射渠道与支付方式', () => {
|
||||
expect(paymentProviderLabel('leshua')).toBe('拉卡拉')
|
||||
expect(paymentProviderLabel('demo')).toBe('演示渠道')
|
||||
expect(paymentMethodLabel('wechat')).toBe('微信支付')
|
||||
expect(paymentMethodLabel('alipay')).toBe('支付宝')
|
||||
})
|
||||
|
||||
it('未知值保留原值', () => {
|
||||
expect(paymentProviderLabel('new_provider')).toBe('new_provider')
|
||||
expect(paymentMethodLabel('new_method')).toBe('new_method')
|
||||
})
|
||||
})
|
||||
|
||||
describe('processActionLabel / processStageLabel', () => {
|
||||
it('映射真实流程动作与阶段', () => {
|
||||
expect(processActionLabel('owner_handoff_submitted')).toBe('号主提交交接')
|
||||
expect(processActionLabel('platform_checkout_confirmed')).toBe('客服确认结账')
|
||||
expect(processStageLabel('handoff')).toBe('交接')
|
||||
})
|
||||
|
||||
it('兼容 order.xxx 旧动作格式', () => {
|
||||
expect(processActionLabel('order.created')).toBe('创建订单')
|
||||
expect(processActionLabel('order.paid')).toBe('支付完成')
|
||||
expect(processActionLabel('order.handoff_received')).toBe('租客确认收号')
|
||||
})
|
||||
|
||||
it('未知动作保留原值', () => {
|
||||
expect(processActionLabel('order.unknown_action')).toBe('order.unknown_action')
|
||||
expect(processStageLabel('unknown_stage')).toBe('unknown_stage')
|
||||
})
|
||||
})
|
||||
|
||||
describe('交接与申诉映射', () => {
|
||||
it('映射交接记录类型', () => {
|
||||
expect(handoffRecordTypeLabel('owner_handoff')).toBe('号主交接')
|
||||
expect(handoffRecordTypeLabel('platform_checkout_dispute_opened')).toBe('客服发起结账争议')
|
||||
})
|
||||
|
||||
it('映射申诉类型、状态与发起方', () => {
|
||||
expect(disputeTypeLabel('checkout')).toBe('结账争议')
|
||||
expect(disputeStatusLabel('open')).toBe('处理中')
|
||||
expect(participantTypeLabel('user')).toBe('用户')
|
||||
expect(participantTypeLabel('admin')).toBe('客服')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,154 @@
|
||||
/** 后台订单/支付相关枚举的中文展示。未知值保留原始 code,方便排查新枚举。 */
|
||||
|
||||
function labelOf(map: Record<string, string>, value?: string | null) {
|
||||
const code = (value ?? '').trim()
|
||||
if (!code) return '—'
|
||||
return map[code] ?? code
|
||||
}
|
||||
|
||||
export const paymentBizTypeMap: Record<string, string> = {
|
||||
order_pay: '订单支付',
|
||||
deposit: '押金支付',
|
||||
wallet_recharge: '钱包充值',
|
||||
main_recharge: '充值',
|
||||
cancel_refund: '取消退款',
|
||||
admin_close_refund: '客服关闭退款',
|
||||
admin_refund: '人工退款',
|
||||
checkout_refund: '结账退款',
|
||||
deposit_refund: '押金退款',
|
||||
rent_refund: '租金退款',
|
||||
arbitration_refund: '仲裁退款',
|
||||
admin_seal_refund: '封存退款',
|
||||
mohong_pay: '撞车支付',
|
||||
mohong_refund: '撞车退款',
|
||||
quality_owner_pay: '优质号主保证金',
|
||||
}
|
||||
|
||||
export function paymentBizTypeLabel(value?: string | null) {
|
||||
return labelOf(paymentBizTypeMap, value)
|
||||
}
|
||||
|
||||
export const paymentProviderMap: Record<string, string> = {
|
||||
leshua: '拉卡拉',
|
||||
shuncheng: '顺诚',
|
||||
mock: '模拟支付',
|
||||
demo: '演示渠道',
|
||||
}
|
||||
|
||||
export function paymentProviderLabel(value?: string | null) {
|
||||
return labelOf(paymentProviderMap, value)
|
||||
}
|
||||
|
||||
export const paymentMethodMap: Record<string, string> = {
|
||||
wechat: '微信支付',
|
||||
alipay: '支付宝',
|
||||
unionpay: '银联',
|
||||
qq: 'QQ 钱包',
|
||||
mock: '模拟支付',
|
||||
}
|
||||
|
||||
export function paymentMethodLabel(value?: string | null) {
|
||||
return labelOf(paymentMethodMap, value)
|
||||
}
|
||||
|
||||
export const processStageMap: Record<string, string> = {
|
||||
create: '创建',
|
||||
payment: '支付',
|
||||
handoff: '交接',
|
||||
checkout: '结账',
|
||||
settlement: '结算',
|
||||
dispute: '争议',
|
||||
}
|
||||
|
||||
export function processStageLabel(value?: string | null) {
|
||||
return labelOf(processStageMap, value)
|
||||
}
|
||||
|
||||
export const processActionMap: Record<string, string> = {
|
||||
created: '创建订单',
|
||||
paid: '支付完成',
|
||||
owner_handoff_submitted: '号主提交交接',
|
||||
handoff_submitted: '号主提交交接',
|
||||
platform_handoff_submitted: '客服代交接',
|
||||
admin_force_handoff: '客服确认交接',
|
||||
renter_received_confirmed: '租客确认收号',
|
||||
handoff_received: '租客确认收号',
|
||||
checkout_submitted: '租客发起结账',
|
||||
checkout_countered: '修改结账方案',
|
||||
checkout_confirmed: '号主确认结账',
|
||||
checkout_accepted: '租客接受结账方案',
|
||||
checkout_disputed: '发起结账争议',
|
||||
platform_checkout_countered: '客服修改结账方案',
|
||||
platform_checkout_confirmed: '客服确认结账',
|
||||
platform_checkout_dispute_opened: '客服发起结账争议',
|
||||
offline_settlement_confirmed: '确认线下结算',
|
||||
deposit_held: '暂扣押金',
|
||||
deposit_released: '归还暂扣押金',
|
||||
}
|
||||
|
||||
export function processActionLabel(value?: string | null) {
|
||||
const code = (value ?? '').trim()
|
||||
if (!code) return '—'
|
||||
const direct = processActionMap[code]
|
||||
if (direct) return direct
|
||||
// 兼容手工数据/旧数据里的 order.xxx 形式。
|
||||
if (code.startsWith('order.')) {
|
||||
const suffix = code.slice('order.'.length)
|
||||
const mapped = processActionMap[suffix]
|
||||
if (mapped) return mapped
|
||||
}
|
||||
return code
|
||||
}
|
||||
|
||||
export const handoffRecordTypeMap: Record<string, string> = {
|
||||
owner_handoff: '号主交接',
|
||||
owner_return: '号主归还',
|
||||
renter_return: '租客归还',
|
||||
platform_handoff: '客服代交接',
|
||||
admin_force_handoff: '客服确认交接',
|
||||
renter_checkout: '租客发起结账',
|
||||
platform_checkout_counter: '客服修改结账方案',
|
||||
platform_checkout_dispute_opened: '客服发起结账争议',
|
||||
}
|
||||
|
||||
export function handoffRecordTypeLabel(value?: string | null) {
|
||||
return labelOf(handoffRecordTypeMap, value)
|
||||
}
|
||||
|
||||
export const disputeTypeMap: Record<string, string> = {
|
||||
cannot_login: '无法登录',
|
||||
false_description: '描述不符',
|
||||
account_banned: '账号封禁',
|
||||
asset_loss: '资产损失',
|
||||
haf_coin_dispute: '哈夫币争议',
|
||||
handoff_timeout: '交接超时',
|
||||
return_timeout: '归还超时',
|
||||
checkout_amount: '结账金额争议',
|
||||
checkout: '结账争议',
|
||||
checkout_dispute: '结账争议',
|
||||
}
|
||||
|
||||
export function disputeTypeLabel(value?: string | null) {
|
||||
return labelOf(disputeTypeMap, value)
|
||||
}
|
||||
|
||||
export const disputeStatusMap: Record<string, string> = {
|
||||
open: '处理中',
|
||||
processing: '处理中',
|
||||
resolved: '已解决',
|
||||
cancelled: '已取消',
|
||||
}
|
||||
|
||||
export function disputeStatusLabel(value?: string | null) {
|
||||
return labelOf(disputeStatusMap, value)
|
||||
}
|
||||
|
||||
export const participantTypeMap: Record<string, string> = {
|
||||
user: '用户',
|
||||
admin: '客服',
|
||||
system: '系统',
|
||||
}
|
||||
|
||||
export function participantTypeLabel(value?: string | null) {
|
||||
return labelOf(participantTypeMap, value)
|
||||
}
|
||||
@@ -29,6 +29,16 @@ function toOptions(map: Record<string, StatusMeta>): StatusOption[] {
|
||||
return Object.entries(map).map(([value, meta]) => ({ value, label: meta.label }))
|
||||
}
|
||||
|
||||
const accountSourceLabels: Record<string, string> = {
|
||||
internal: '站内上传',
|
||||
external: '外部上传',
|
||||
}
|
||||
|
||||
export function accountSourceLabel(value?: string | null) {
|
||||
if (!value) return '—'
|
||||
return accountSourceLabels[value] ?? value
|
||||
}
|
||||
|
||||
export const orderStatusMap: Record<string, StatusMeta> = {
|
||||
pending_payment: { label: '待支付', tone: 'gold' },
|
||||
pending_handoff: { label: '待交接', tone: 'blue' },
|
||||
@@ -109,6 +119,15 @@ export const refundStatusMap: Record<string, StatusMeta> = {
|
||||
failed: { label: '退款失败', tone: 'red' },
|
||||
}
|
||||
|
||||
export const paymentStatusMap: Record<string, StatusMeta> = {
|
||||
created: { label: '已创建', tone: 'default' },
|
||||
paying: { label: '支付中', tone: 'processing' },
|
||||
paid: { label: '已支付', tone: 'success' },
|
||||
failed: { label: '支付失败', tone: 'red' },
|
||||
closed: { label: '已关闭', tone: 'default' },
|
||||
refunded: { label: '已退款', tone: 'blue' },
|
||||
}
|
||||
|
||||
export function readStatusMeta(map: Record<string, StatusMeta>, value?: string | null): StatusMeta {
|
||||
if (!value) return { label: '—', tone: 'default' }
|
||||
return map[value] ?? { label: value, tone: 'default' }
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
import type { AdminListing } from '@/features/admin/types'
|
||||
import {
|
||||
faceOwnerText,
|
||||
listingResources,
|
||||
listingStatusMeta,
|
||||
type ListingResourceRow,
|
||||
} from '@/features/listings/labels'
|
||||
import { formatCoinM, formatMoney } from '@/shared/utils/format'
|
||||
|
||||
import {
|
||||
listingAssetText,
|
||||
listingBuyerCoinBasePriceCent,
|
||||
listingBuyerRatio,
|
||||
listingBuyerTotalPriceCent,
|
||||
listingConsumablePriceCent,
|
||||
listingPlatformMarkupCent,
|
||||
listingRentalDuration,
|
||||
listingSellerCoinBasePriceCent,
|
||||
listingSellerRatio,
|
||||
listingSellerTotalPriceCent,
|
||||
listingSkinNames,
|
||||
} from '@/features/admin/listingDisplay'
|
||||
|
||||
function recordOf(value: unknown): Record<string, unknown> {
|
||||
return typeof value === 'object' && value !== null ? (value as Record<string, unknown>) : {}
|
||||
}
|
||||
|
||||
export type ListingRow = { label: string; value: string }
|
||||
|
||||
export type ListingScreenshotGroup = { key: string; label: string; urls: string[] }
|
||||
|
||||
const screenshotGroupLabels: Record<string, string> = {
|
||||
coin: '纯币截图',
|
||||
gameId: '游戏 ID',
|
||||
skin: '皮肤外观',
|
||||
tencentSecurity: '腾讯安全',
|
||||
totalAsset: '总资产',
|
||||
}
|
||||
|
||||
export function adminListingAssetRows(listing: AdminListing): ListingRow[] {
|
||||
const duration = listingRentalDuration(listing)
|
||||
return [
|
||||
{ label: '商品编号', value: listing.listing_no || `#${listing.id}` },
|
||||
{ label: '账号 ID', value: String(listing.account_id) },
|
||||
{ label: '游戏', value: listing.game_name || '—' },
|
||||
{ label: '区服', value: listing.server_region || '—' },
|
||||
{ label: '登录平台', value: listing.login_platform || '—' },
|
||||
{ label: '段位', value: listing.rank_level || '—' },
|
||||
{ label: '烽火等级', value: listingAssetText(listing, 'fire_level') },
|
||||
{ label: '保险格数', value: listingAssetText(listing, 'season_insurance') },
|
||||
{
|
||||
label: '体力 / 负重',
|
||||
value: `${listingAssetText(listing, 'stamina_level')} / ${listingAssetText(
|
||||
listing,
|
||||
'load_level'
|
||||
)}`,
|
||||
},
|
||||
{ label: '绝密 KD', value: listingAssetText(listing, 'secret_kd') },
|
||||
{ label: '常用地区', value: listingAssetText(listing, 'common_regions') },
|
||||
{
|
||||
label: '在线时间',
|
||||
value: formatOnlineTime(recordOf(listing.asset_summary?.online_time)),
|
||||
},
|
||||
{ label: '可改游戏名', value: listingAssetText(listing, 'can_change_game_name') },
|
||||
{
|
||||
label: '全英雄',
|
||||
value:
|
||||
listingAssetText(listing, 'all_hero') !== '—'
|
||||
? listingAssetText(listing, 'all_hero')
|
||||
: listingAssetText(listing, 'all_heroes'),
|
||||
},
|
||||
{ label: '解锁德穆兰', value: listingAssetText(listing, 'unlock_demulan') },
|
||||
{ label: '凌晨可响应', value: listingAssetText(listing, 'early_morning_response') },
|
||||
{ label: '封禁记录', value: listingAssetText(listing, 'ban_record') },
|
||||
{ label: '人脸情况', value: faceOwnerText(listing.asset_summary) || '—' },
|
||||
{ label: '预计可租', value: duration.days },
|
||||
]
|
||||
}
|
||||
|
||||
function formatOnlineTime(value: Record<string, unknown>) {
|
||||
const start = String(value.start ?? '').trim()
|
||||
const end = String(value.end ?? '').trim()
|
||||
if (!start && !end) return '—'
|
||||
return `${start || '—'} 至 ${end || '—'}`
|
||||
}
|
||||
|
||||
export function adminListingOwnerRows(listing: AdminListing): ListingRow[] {
|
||||
const duration = listingRentalDuration(listing)
|
||||
return [
|
||||
{
|
||||
label: '号主',
|
||||
value: listing.owner_phone || listing.owner_nickname || `ID ${listing.owner_id}`,
|
||||
},
|
||||
{ label: '号主 ID', value: String(listing.owner_id) },
|
||||
{ label: '租客租金', value: formatMoney(listingBuyerTotalPriceCent(listing)) },
|
||||
{ label: '号主纯币价格', value: formatMoney(listingSellerCoinBasePriceCent(listing)) },
|
||||
{ label: '号主损耗', value: formatMoney(listingConsumablePriceCent(listing)) },
|
||||
{ label: '号主租金合计', value: formatMoney(listingSellerTotalPriceCent(listing)) },
|
||||
{ label: '平台费用', value: formatMoney(listingPlatformMarkupCent(listing)) },
|
||||
{ label: '押金', value: formatMoney(listing.deposit_amount_cent) },
|
||||
{ label: '哈夫币', value: formatCoinM(listing.haf_coin_amount) },
|
||||
{ label: '每日损耗', value: duration.dailyLoss || '—' },
|
||||
{ label: '预计可租', value: duration.days },
|
||||
{ label: '商品状态', value: listingStatusMeta(listing.status).label },
|
||||
]
|
||||
}
|
||||
|
||||
export function adminListingResources(listing: AdminListing): ListingResourceRow[] {
|
||||
return listingResources(listing.asset_summary)
|
||||
}
|
||||
|
||||
export function adminListingSkins(listing: AdminListing): string[] {
|
||||
return listingSkinNames(listing)
|
||||
}
|
||||
|
||||
export function adminListingScreenshotGroups(listing: AdminListing): ListingScreenshotGroup[] {
|
||||
const groups = recordOf(listing.asset_summary?.screenshot_groups)
|
||||
const result = Object.entries(groups)
|
||||
.map(([key, value]) => ({
|
||||
key,
|
||||
label: screenshotGroupLabels[key] ?? key,
|
||||
urls: Array.isArray(value)
|
||||
? value.filter((url): url is string => typeof url === 'string' && Boolean(url))
|
||||
: [],
|
||||
}))
|
||||
.filter(group => group.urls.length > 0)
|
||||
if (result.length > 0) return result
|
||||
if (listing.screenshot_urls?.length) {
|
||||
return [{ key: 'all', label: '资产截图', urls: listing.screenshot_urls }]
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
export function adminListingPricePipeline(listing: AdminListing) {
|
||||
const duration = listingRentalDuration(listing)
|
||||
return {
|
||||
sellerTotalCent: listingSellerTotalPriceCent(listing),
|
||||
sellerCoinBaseCent: listingSellerCoinBasePriceCent(listing),
|
||||
consumableCent: listingConsumablePriceCent(listing),
|
||||
sellerRatio: listingSellerRatio(listing),
|
||||
platformMarkupCent: listingPlatformMarkupCent(listing),
|
||||
buyerTotalCent: listingBuyerTotalPriceCent(listing),
|
||||
buyerCoinBaseCent: listingBuyerCoinBasePriceCent(listing),
|
||||
buyerRatio: listingBuyerRatio(listing),
|
||||
depositCent: listing.deposit_amount_cent,
|
||||
dailyLoss: duration.dailyLoss,
|
||||
rentalDays: duration.days,
|
||||
}
|
||||
}
|
||||
@@ -118,6 +118,12 @@ describe('admin listing display helpers', () => {
|
||||
expect(listingRatioText(item)).toBe('1:43')
|
||||
})
|
||||
|
||||
it('rounds ratio to an integer', () => {
|
||||
expect(listingRatioText(listing({ asset_summary: { publish_ratio: 33.8256 } }))).toBe('1:34')
|
||||
expect(listingRatioText(listing({ asset_summary: { publish_ratio: 33.4 } }))).toBe('1:33')
|
||||
expect(listingRatioText(listing({ asset_summary: {} }))).toBe('—')
|
||||
})
|
||||
|
||||
it('falls back safely when fields are absent', () => {
|
||||
const item = listing({ listing_no: '', description: '', asset_summary: null })
|
||||
expect(listingCodeText(item)).toBe('SP000001')
|
||||
|
||||
@@ -148,7 +148,7 @@ export function listingRentDepositText(row: AdminListing) {
|
||||
export function listingRatioText(row: AdminListing) {
|
||||
const ratio = numberOf(row.asset_summary?.publish_ratio)
|
||||
if (ratio <= 0) return '—'
|
||||
return `1:${compactNumber(ratio)}`
|
||||
return `1:${Math.round(ratio)}`
|
||||
}
|
||||
|
||||
export function listingAccountLevel(row: AdminListing) {
|
||||
@@ -156,3 +156,74 @@ export function listingAccountLevel(row: AdminListing) {
|
||||
if (fireLevel !== '—') return fireLevel
|
||||
return row.rank_level || '—'
|
||||
}
|
||||
|
||||
function breakdownCent(row: AdminListing, key: string) {
|
||||
const breakdown = recordOf(row.asset_summary?.price_breakdown)
|
||||
const cent = numberOf(breakdown[`${key}_cent`])
|
||||
if (cent > 0) return Math.round(cent)
|
||||
const yuan = numberOf(breakdown[key])
|
||||
return yuan > 0 ? Math.round(yuan * 100) : 0
|
||||
}
|
||||
|
||||
export function listingConsumablePriceCent(row: AdminListing) {
|
||||
return breakdownCent(row, 'consumable_price')
|
||||
}
|
||||
|
||||
export function listingSellerCoinBasePriceCent(row: AdminListing) {
|
||||
const stored = breakdownCent(row, 'seller_coin_base_price')
|
||||
if (stored > 0) return stored
|
||||
const fallback = row.price_cent - listingConsumablePriceCent(row)
|
||||
return Math.max(0, Math.round(fallback))
|
||||
}
|
||||
|
||||
export function listingSellerTotalPriceCent(row: AdminListing) {
|
||||
const stored = breakdownCent(row, 'seller_total_price')
|
||||
if (stored > 0) return stored
|
||||
return listingSellerCoinBasePriceCent(row) + listingConsumablePriceCent(row)
|
||||
}
|
||||
|
||||
export function listingBuyerCoinBasePriceCent(row: AdminListing) {
|
||||
return listingPureCoinPrice(row)
|
||||
}
|
||||
|
||||
export function listingBuyerTotalPriceCent(row: AdminListing) {
|
||||
const stored = breakdownCent(row, 'buyer_total_price')
|
||||
if (stored > 0) return stored
|
||||
return listingBuyerCoinBasePriceCent(row) + listingConsumablePriceCent(row)
|
||||
}
|
||||
|
||||
export function listingPlatformMarkupCent(row: AdminListing) {
|
||||
const stored = breakdownCent(row, 'platform_markup_amount')
|
||||
if (stored > 0) return stored
|
||||
return Math.max(0, listingBuyerCoinBasePriceCent(row) - listingSellerCoinBasePriceCent(row))
|
||||
}
|
||||
|
||||
export function listingSellerRatio(row: AdminListing) {
|
||||
const breakdown = recordOf(row.asset_summary?.price_breakdown)
|
||||
const stored = numberOf(breakdown.seller_ratio) || numberOf(breakdown.seller_reference_ratio)
|
||||
if (stored > 0) return stored
|
||||
const baseYuan = listingSellerCoinBasePriceCent(row) / 100
|
||||
const coinWan = numberOf(row.haf_coin_amount) / 10000
|
||||
return baseYuan > 0 ? coinWan / baseYuan : 0
|
||||
}
|
||||
|
||||
export function listingBuyerRatio(row: AdminListing) {
|
||||
const breakdown = recordOf(row.asset_summary?.price_breakdown)
|
||||
const stored = numberOf(breakdown.buyer_ratio)
|
||||
if (stored > 0) return stored
|
||||
const baseYuan = listingBuyerCoinBasePriceCent(row) / 100
|
||||
const coinWan = numberOf(row.haf_coin_amount) / 10000
|
||||
return baseYuan > 0 ? coinWan / baseYuan : 0
|
||||
}
|
||||
|
||||
export function listingSkinNames(row: AdminListing): string[] {
|
||||
const groups = recordOf(row.asset_summary?.skin_groups)
|
||||
const names: string[] = []
|
||||
Object.values(groups).forEach(value => {
|
||||
if (!Array.isArray(value)) return
|
||||
value.forEach(name => {
|
||||
if (typeof name === 'string' && name.trim()) names.push(name.trim())
|
||||
})
|
||||
})
|
||||
return Array.from(new Set(names))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { orderFundRows } from '@/features/admin/orderDetailModel'
|
||||
import type { AdminOrderDetail } from '@/features/admin/types'
|
||||
|
||||
function order(patch: Partial<AdminOrderDetail> = {}): AdminOrderDetail {
|
||||
return {
|
||||
status: 'completed',
|
||||
pure_coin_original_amount_cent: 0,
|
||||
extra_item_original_amount_cent: 0,
|
||||
rent_discount_amount_cent: 0,
|
||||
actual_pure_coin_amount_cent: 0,
|
||||
actual_pure_coin_discount_cent: 0,
|
||||
growth_points_basis_cent: 0,
|
||||
rent_amount_cent: 0,
|
||||
owner_rent_amount_cent: 0,
|
||||
platform_fee_cent: 0,
|
||||
deposit_amount_cent: 0,
|
||||
deposit_original_amount_cent: 0,
|
||||
deposit_waived_amount_cent: 0,
|
||||
...patch,
|
||||
} as AdminOrderDetail
|
||||
}
|
||||
|
||||
describe('orderFundRows', () => {
|
||||
it('优惠为 0 时不产生负零金额', () => {
|
||||
const rows = orderFundRows(order())
|
||||
const discount = rows.find(row => row.label === '最终实际纯币优惠')
|
||||
expect(discount?.amountCent).toBe(0)
|
||||
expect(Object.is(discount?.amountCent, -0)).toBe(false)
|
||||
})
|
||||
|
||||
it('有优惠时展示为负数,便于区分扣减', () => {
|
||||
const rows = orderFundRows(order({ actual_pure_coin_discount_cent: 940 }))
|
||||
expect(rows.find(row => row.label === '最终实际纯币优惠')?.amountCent).toBe(-940)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,152 @@
|
||||
import type { AdminOrderDetail } from '@/features/admin/types'
|
||||
|
||||
export type OrderFundRow = { label: string; amountCent: number }
|
||||
|
||||
export type SnapshotResource = {
|
||||
key: string
|
||||
label: string
|
||||
quantity: number
|
||||
mode: string
|
||||
price: string
|
||||
}
|
||||
|
||||
function recordOf(value: unknown): Record<string, unknown> {
|
||||
if (typeof value === 'string' && value.trim()) {
|
||||
try {
|
||||
const parsed = JSON.parse(value) as unknown
|
||||
return recordOf(parsed)
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
return typeof value === 'object' && value !== null ? (value as Record<string, unknown>) : {}
|
||||
}
|
||||
|
||||
function numberOf(value: unknown) {
|
||||
const parsed = Number(value)
|
||||
return Number.isFinite(parsed) ? parsed : 0
|
||||
}
|
||||
|
||||
export function orderTotalCent(order: AdminOrderDetail) {
|
||||
return numberOf(order.rent_amount_cent) + numberOf(order.deposit_amount_cent)
|
||||
}
|
||||
|
||||
export function orderSnapshot(order: AdminOrderDetail) {
|
||||
return recordOf(order.account_snapshot)
|
||||
}
|
||||
|
||||
function snapshotAssetSummary(order: AdminOrderDetail) {
|
||||
return recordOf(orderSnapshot(order).asset_summary)
|
||||
}
|
||||
|
||||
function snapshotBreakdownCent(order: AdminOrderDetail, key: string) {
|
||||
const breakdown = recordOf(snapshotAssetSummary(order).price_breakdown)
|
||||
const cent = numberOf(breakdown[`${key}_cent`])
|
||||
if (cent > 0) return Math.round(cent)
|
||||
const yuan = numberOf(breakdown[key])
|
||||
return yuan > 0 ? Math.round(yuan * 100) : 0
|
||||
}
|
||||
|
||||
export function orderSnapshotResources(order: AdminOrderDetail): SnapshotResource[] {
|
||||
const raw = snapshotAssetSummary(order).resources
|
||||
if (!Array.isArray(raw)) return []
|
||||
return raw
|
||||
.map(entry => {
|
||||
const row = recordOf(entry)
|
||||
const quantity = Math.trunc(numberOf(row.quantity))
|
||||
return {
|
||||
key: String(row.key ?? ''),
|
||||
label: String(row.label ?? row.key ?? '').trim(),
|
||||
quantity: quantity > 0 ? quantity : 0,
|
||||
mode: String(row.mode ?? '').trim(),
|
||||
price: String(row.price ?? '').trim(),
|
||||
}
|
||||
})
|
||||
.filter(row => row.label && row.quantity > 0)
|
||||
.slice(0, 8)
|
||||
}
|
||||
|
||||
export function orderSnapshotRatio(order: AdminOrderDetail) {
|
||||
const assetSummary = snapshotAssetSummary(order)
|
||||
const breakdown = recordOf(assetSummary.price_breakdown)
|
||||
const sellerRatio = numberOf(breakdown.seller_ratio) || numberOf(assetSummary.publish_ratio)
|
||||
const buyerRatio = numberOf(breakdown.buyer_ratio)
|
||||
return { sellerRatio, buyerRatio }
|
||||
}
|
||||
|
||||
export function orderFundRows(order: AdminOrderDetail): OrderFundRow[] {
|
||||
const rows: OrderFundRow[] = [
|
||||
{
|
||||
label: '预收纯币原价',
|
||||
amountCent: numberOf(order.pure_coin_original_amount_cent),
|
||||
},
|
||||
{
|
||||
label: '预收额外物品',
|
||||
amountCent: numberOf(order.extra_item_original_amount_cent),
|
||||
},
|
||||
]
|
||||
if (numberOf(order.rent_discount_amount_cent) > 0) {
|
||||
rows.push(
|
||||
{ label: '原始租金', amountCent: numberOf(order.rent_original_amount_cent) },
|
||||
{
|
||||
label: `${order.renter_growth_level_name || '成长等级'}优惠`,
|
||||
amountCent:
|
||||
numberOf(order.rent_discount_amount_cent) > 0
|
||||
? -numberOf(order.rent_discount_amount_cent)
|
||||
: 0,
|
||||
}
|
||||
)
|
||||
}
|
||||
if (order.status === 'completed') {
|
||||
rows.push(
|
||||
{
|
||||
label: '最终实际纯币原价',
|
||||
amountCent: numberOf(order.actual_pure_coin_amount_cent),
|
||||
},
|
||||
{
|
||||
label: '最终实际纯币优惠',
|
||||
amountCent:
|
||||
numberOf(order.actual_pure_coin_discount_cent) > 0
|
||||
? -numberOf(order.actual_pure_coin_discount_cent)
|
||||
: 0,
|
||||
},
|
||||
{
|
||||
label: '积分计算纯币基数',
|
||||
amountCent: numberOf(order.growth_points_basis_cent),
|
||||
}
|
||||
)
|
||||
}
|
||||
rows.push({ label: '租客租金', amountCent: numberOf(order.rent_amount_cent) })
|
||||
|
||||
const ownerCoinBaseCent = snapshotBreakdownCent(order, 'seller_coin_base_price')
|
||||
if (ownerCoinBaseCent > 0) {
|
||||
const ownerLossCent = snapshotBreakdownCent(order, 'consumable_price')
|
||||
rows.push(
|
||||
{ label: '号主纯币价格', amountCent: ownerCoinBaseCent },
|
||||
{ label: '号主损耗', amountCent: ownerLossCent },
|
||||
{ label: '号主租金合计', amountCent: numberOf(order.owner_rent_amount_cent) }
|
||||
)
|
||||
} else {
|
||||
rows.push({ label: '号主租金', amountCent: numberOf(order.owner_rent_amount_cent) })
|
||||
}
|
||||
|
||||
rows.push(
|
||||
{ label: '平台费用', amountCent: numberOf(order.platform_fee_cent) },
|
||||
{ label: '实付押金', amountCent: numberOf(order.deposit_amount_cent) },
|
||||
{ label: '原始押金', amountCent: numberOf(order.deposit_original_amount_cent) },
|
||||
{ label: '免押额度', amountCent: numberOf(order.deposit_waived_amount_cent) }
|
||||
)
|
||||
if (numberOf(order.refund_amount_cent) > 0) {
|
||||
rows.push({ label: '退款金额', amountCent: numberOf(order.refund_amount_cent) })
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
/** 预计结束时间:优先用后端字段,缺失时按起租时间 + 租期推算。 */
|
||||
export function orderEstimatedEndAt(order: AdminOrderDetail): string | null {
|
||||
if (order.estimated_end_at) return order.estimated_end_at
|
||||
if (!order.rented_at || !order.estimated_duration_hours) return null
|
||||
const start = new Date(order.rented_at).getTime()
|
||||
if (!Number.isFinite(start)) return null
|
||||
return new Date(start + order.estimated_duration_hours * 3600_000).toISOString()
|
||||
}
|
||||
@@ -159,8 +159,14 @@ export interface AdminCheckoutInfo {
|
||||
initiated_by: number
|
||||
status: string
|
||||
round_count: number
|
||||
turn: string
|
||||
turn?: string
|
||||
proposed_by?: number
|
||||
max_rounds: number
|
||||
price_role?: string
|
||||
display_amount_cent?: number
|
||||
pure_coin_amount_cent?: number
|
||||
pure_coin_discount_cent?: number
|
||||
pure_coin_payable_cent?: number
|
||||
content: string
|
||||
evidence_urls: string[]
|
||||
rent_amount_cent?: number | null
|
||||
@@ -254,10 +260,78 @@ export interface AdminOrderDetail {
|
||||
payment_deadline_at?: string | null
|
||||
distribution_site_id?: number | null
|
||||
source_track_code?: string
|
||||
price_role?: string
|
||||
base_price_cent?: number
|
||||
shelf_markup_cent?: number
|
||||
markup_site_id?: number
|
||||
shelf_ratio?: number
|
||||
shelf_ratio_delta?: number
|
||||
rent_original_amount_cent?: number
|
||||
rent_discount_amount_cent?: number
|
||||
pure_coin_original_amount_cent?: number
|
||||
extra_item_original_amount_cent?: number
|
||||
actual_coin_consumed_m?: number
|
||||
actual_pure_coin_amount_cent?: number
|
||||
actual_pure_coin_discount_cent?: number
|
||||
actual_extra_item_amount_cent?: number
|
||||
renter_growth_level?: string
|
||||
renter_growth_level_name?: string
|
||||
renter_discount_bps?: number
|
||||
growth_points_basis_cent?: number
|
||||
growth_points_per_yuan?: number
|
||||
growth_points_awarded?: number
|
||||
growth_points_awarded_at?: string | null
|
||||
managed_admin_id?: number | null
|
||||
offline_settled_by?: number | null
|
||||
source_channel?: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
/** 后台交接记录:一次交接/归还/结账提交的不可变留痕。 */
|
||||
export interface AdminOrderHandoffRecord {
|
||||
id: number
|
||||
order_id: number
|
||||
from_user_id: number
|
||||
to_user_id: number
|
||||
type: string
|
||||
content: string
|
||||
confirmed_by_renter_at?: string | null
|
||||
confirmed_by_owner_at?: string | null
|
||||
created_at: string
|
||||
}
|
||||
|
||||
/** 后台交易时间线:提交、修改、确认、结算等过程记录。 */
|
||||
export interface AdminOrderProcessEvent {
|
||||
id: number
|
||||
business_type: string
|
||||
business_id: number
|
||||
stage: string
|
||||
action: string
|
||||
actor_type: string
|
||||
actor_id: number
|
||||
actor_name: string
|
||||
target_type: string
|
||||
target_id?: number | null
|
||||
target_name: string
|
||||
content: string
|
||||
reason: string
|
||||
payload?: Record<string, unknown> | null
|
||||
attachment_urls?: string[]
|
||||
state_before?: Record<string, unknown> | null
|
||||
state_after?: Record<string, unknown> | null
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface AdminOrderRefundStatus {
|
||||
order_id: number
|
||||
order_no: string
|
||||
refund_status: string
|
||||
refund_amount_cent: number
|
||||
refunded_at?: string | null
|
||||
total_amount_cent: number
|
||||
}
|
||||
|
||||
export interface AdminListingQuery {
|
||||
page?: number
|
||||
page_size?: number
|
||||
@@ -321,6 +395,31 @@ export interface AdminListingPage {
|
||||
page_size: number
|
||||
}
|
||||
|
||||
export interface AdminListingPriceAdjustPayload {
|
||||
buyer_ratio?: number
|
||||
buyer_total_price_cent?: number
|
||||
reason?: string
|
||||
}
|
||||
|
||||
export type AdminExternalListingAdjustMode = 'discount_amount' | 'sale_ratio'
|
||||
|
||||
export interface AdminExternalListingAdjustPayload {
|
||||
haf_coin_amount: number
|
||||
awm_bullets: number
|
||||
level6_helmets: number
|
||||
level6_armor: number
|
||||
deposit_amount_cent: number
|
||||
adjust_mode: AdminExternalListingAdjustMode
|
||||
discount_amount_cent?: number
|
||||
sale_ratio?: number
|
||||
reason: string
|
||||
}
|
||||
|
||||
export interface AdminListingTransferOwnerPayload {
|
||||
target_user_id: number
|
||||
reason: string
|
||||
}
|
||||
|
||||
export interface AdminUserQuery {
|
||||
page?: number
|
||||
page_size?: number
|
||||
|
||||
@@ -24,6 +24,16 @@ import { Link, useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import { BrandLogo } from '@/components/BrandLogo'
|
||||
import { useListingDetail } from '@/features/listings/api'
|
||||
import {
|
||||
banRecordText,
|
||||
faceOwnerText,
|
||||
gameNameChangeText,
|
||||
listingPriceDetail,
|
||||
listingRatioText,
|
||||
listingRentalDays,
|
||||
listingResources,
|
||||
resourceBadgeText,
|
||||
} from '@/features/listings/labels'
|
||||
import { recordListingView, useListingCollections } from '@/features/listings/collections'
|
||||
import {
|
||||
addRemoteFavorite,
|
||||
@@ -104,48 +114,32 @@ function skinGroupsOf(item: Listing) {
|
||||
.filter(group => group.names.length > 0)
|
||||
}
|
||||
|
||||
function resourcesOf(item: Listing) {
|
||||
const raw = item.asset_summary?.resources
|
||||
if (!Array.isArray(raw)) return []
|
||||
return raw
|
||||
.map(entry => {
|
||||
const row = (entry ?? {}) as Record<string, unknown>
|
||||
return {
|
||||
label: textOf(row.label) || textOf(row.key),
|
||||
quantity: Number(row.quantity ?? 0),
|
||||
mode: textOf(row.mode),
|
||||
}
|
||||
})
|
||||
.filter(row => row.label && row.quantity > 0)
|
||||
}
|
||||
|
||||
function ratioOf(item: Listing) {
|
||||
const published = Number(item.asset_summary?.publish_ratio ?? 0)
|
||||
if (published > 0) return `${published}w`
|
||||
const priceYuan = item.price_cent / 100
|
||||
const coinM = item.haf_coin_amount / 1_000_000
|
||||
if (priceYuan <= 0 || coinM <= 0) return ''
|
||||
return `${((coinM / priceYuan) * 100).toFixed(0)}w`
|
||||
}
|
||||
|
||||
function coreStats(item: Listing) {
|
||||
const summary = item.asset_summary ?? {}
|
||||
const dailyLoss = Number(summary.daily_loss_m ?? 0)
|
||||
const secretKd = Number(summary.secret_kd ?? 0)
|
||||
const rentalDays = listingRentalDays(item)
|
||||
const faceOwner = faceOwnerText(summary)
|
||||
const banRecord = banRecordText(summary)
|
||||
const gameNameChange = gameNameChangeText(summary)
|
||||
const ratio = listingRatioText(item)
|
||||
return [
|
||||
{ label: '哈夫币', value: formatCoinM(item.haf_coin_amount) },
|
||||
{ label: '保险格数', value: textOf(summary.season_insurance) },
|
||||
{ label: '折算比', value: ratioOf(item) ? `1 元 ≈ ${ratioOf(item)}` : '' },
|
||||
{ label: '折算比', value: ratio ? `1 元 ≈ ${ratio}` : '' },
|
||||
{ label: '火力等级', value: textOf(summary.fire_level) },
|
||||
{ label: '体力', value: textOf(summary.stamina_level) },
|
||||
{ label: '负重', value: textOf(summary.load_level) },
|
||||
{ label: '日消耗', value: dailyLoss > 0 ? `${dailyLoss} M / 天` : '' },
|
||||
{ label: '预计租期', value: rentalDays ? `${rentalDays} 天` : '' },
|
||||
{ label: '绝密 KD', value: secretKd > 0 ? String(secretKd) : '' },
|
||||
{ label: '段位', value: item.rank_level },
|
||||
{ label: '登录方式', value: item.login_platform },
|
||||
{ label: '区服', value: item.server_region },
|
||||
{ label: '在线时段', value: onlineTimeText(summary.online_time) },
|
||||
{ label: '可改游戏名', value: textOf(summary.modifiable_name) },
|
||||
{ label: '可改游戏名', value: gameNameChange },
|
||||
{ label: '封禁记录', value: banRecord },
|
||||
{ label: '人脸情况', value: faceOwner },
|
||||
{ label: '全英雄', value: textOf(summary.all_heroes) },
|
||||
{ label: '凌晨响应', value: textOf(summary.early_morning_response) },
|
||||
].filter(stat => stat.value)
|
||||
@@ -276,11 +270,12 @@ export function ListingDetailPage() {
|
||||
const labels = screenshotLabels(data)
|
||||
const activeLabel = labels.get(activeImage) ?? ''
|
||||
const skins = skinGroupsOf(data)
|
||||
const resources = resourcesOf(data)
|
||||
const resources = listingResources(data.asset_summary)
|
||||
const stats = coreStats(data)
|
||||
const isOwner = user?.id === data.owner_id
|
||||
const favorited = token ? Boolean(favoriteIDsQuery.data?.has(data.id)) : isFavorite(data.id)
|
||||
const totalCent = data.price_cent + data.deposit_amount_cent
|
||||
const priceDetail = listingPriceDetail(data)
|
||||
|
||||
const toggleFavoriteState = async () => {
|
||||
if (token) {
|
||||
@@ -383,7 +378,10 @@ export function ListingDetailPage() {
|
||||
|
||||
<div className="ld-price">
|
||||
<span>总租金</span>
|
||||
<strong>{money(data.price_cent)}</strong>
|
||||
<strong>
|
||||
{money(data.price_cent)}
|
||||
{priceDetail ? <small className="ld-price__detail">{priceDetail}</small> : null}
|
||||
</strong>
|
||||
<em>
|
||||
押金 {money(data.deposit_amount_cent)} · 合计 {money(totalCent)}
|
||||
</em>
|
||||
@@ -396,7 +394,7 @@ export function ListingDetailPage() {
|
||||
</div>
|
||||
<div>
|
||||
<span>折算比</span>
|
||||
<strong>{ratioOf(data) || '—'}</strong>
|
||||
<strong>{listingRatioText(data) || '—'}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>段位</span>
|
||||
@@ -497,7 +495,7 @@ export function ListingDetailPage() {
|
||||
<div className="ld-resource" key={row.label}>
|
||||
<span>{row.label}</span>
|
||||
<strong>{row.quantity}</strong>
|
||||
{row.mode === '赠送' ? <em>赠送</em> : null}
|
||||
<em className={`ld-resource__mode is-${row.mode}`}>{resourceBadgeText(row)}</em>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
@@ -576,7 +574,10 @@ export function ListingDetailPage() {
|
||||
<Descriptions.Item label="商品" span={2}>
|
||||
{data.title}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="租金">{money(data.price_cent)}</Descriptions.Item>
|
||||
<Descriptions.Item label="租金">
|
||||
{money(data.price_cent)}
|
||||
{priceDetail ? <small className="ld-modal-detail">{priceDetail}</small> : null}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="押金">{money(data.deposit_amount_cent)}</Descriptions.Item>
|
||||
<Descriptions.Item label="哈夫币">{formatCoinM(data.haf_coin_amount)}</Descriptions.Item>
|
||||
<Descriptions.Item label="号主">
|
||||
|
||||
@@ -27,6 +27,16 @@ import { Link } from 'react-router-dom'
|
||||
import { BrandLogo } from '@/components/BrandLogo'
|
||||
import { HomePortalRow } from '@/features/home/HomePortalRow'
|
||||
import { useListings } from '@/features/listings/api'
|
||||
import {
|
||||
banRecordText,
|
||||
faceOwnerText,
|
||||
gameNameChangeText,
|
||||
listingRatioText,
|
||||
listingRentalDays,
|
||||
listingResources,
|
||||
onlineTimeText,
|
||||
resourceBadgeText,
|
||||
} from '@/features/listings/labels'
|
||||
import {
|
||||
awmRanges,
|
||||
coinRanges,
|
||||
@@ -79,15 +89,6 @@ function assetText(item: Listing, key: string) {
|
||||
return String(value)
|
||||
}
|
||||
|
||||
function ratioText(item: Listing) {
|
||||
const published = Number(item.asset_summary?.publish_ratio ?? 0)
|
||||
if (published > 0) return `${published}w`
|
||||
const priceYuan = item.price_cent / 100
|
||||
const coinM = item.haf_coin_amount / 1_000_000
|
||||
if (priceYuan <= 0 || coinM <= 0) return ''
|
||||
return `${((coinM / priceYuan) * 100).toFixed(0)}w`
|
||||
}
|
||||
|
||||
function skinNames(item: Listing): string[] {
|
||||
const groups = item.asset_summary?.skin_groups
|
||||
if (!groups || typeof groups !== 'object') return []
|
||||
@@ -101,18 +102,6 @@ function skinNames(item: Listing): string[] {
|
||||
return Array.from(new Set(names)).slice(0, 8)
|
||||
}
|
||||
|
||||
function resourceItems(item: Listing): { label: string; quantity: number }[] {
|
||||
const raw = item.asset_summary?.resources
|
||||
if (!Array.isArray(raw)) return []
|
||||
return raw
|
||||
.map(entry => {
|
||||
const row = (entry ?? {}) as Record<string, unknown>
|
||||
return { label: String(row.label ?? row.key ?? ''), quantity: Number(row.quantity ?? 0) }
|
||||
})
|
||||
.filter(row => row.label && row.quantity > 0)
|
||||
.slice(0, 6)
|
||||
}
|
||||
|
||||
function ListingCover({ item }: { item: Listing }) {
|
||||
if (item.cover_url) {
|
||||
return (
|
||||
@@ -130,6 +119,10 @@ function ListingCover({ item }: { item: Listing }) {
|
||||
}
|
||||
|
||||
function ListingRow({ item }: { item: Listing }) {
|
||||
const rentalDays = listingRentalDays(item)
|
||||
const faceOwner = faceOwnerText(item.asset_summary)
|
||||
const banRecord = banRecordText(item.asset_summary)
|
||||
const gameNameChange = gameNameChangeText(item.asset_summary)
|
||||
const specs = [
|
||||
{ label: '哈夫币', value: formatCoinM(item.haf_coin_amount) },
|
||||
{ label: '保险', value: assetText(item, 'season_insurance') },
|
||||
@@ -138,10 +131,18 @@ function ListingRow({ item }: { item: Listing }) {
|
||||
{ label: '段位', value: item.rank_level },
|
||||
{ label: '登录', value: item.login_platform },
|
||||
{ label: '区服', value: item.server_region },
|
||||
{ label: '折算比', value: ratioText(item) ? `1元≈${ratioText(item)}` : '' },
|
||||
{ label: '在线', value: onlineTimeText(item.asset_summary) },
|
||||
{ label: '预计租期', value: rentalDays ? `${rentalDays} 天` : '' },
|
||||
{ label: '人脸', value: faceOwner },
|
||||
{ label: '封禁', value: banRecord },
|
||||
{ label: '改名', value: gameNameChange },
|
||||
{
|
||||
label: '折算比',
|
||||
value: listingRatioText(item) ? `1元≈${listingRatioText(item)}` : '',
|
||||
},
|
||||
].filter(spec => spec.value)
|
||||
const skins = skinNames(item)
|
||||
const resources = resourceItems(item)
|
||||
const resources = listingResources(item.asset_summary).slice(0, 6)
|
||||
|
||||
return (
|
||||
<article className="listing-row">
|
||||
@@ -190,8 +191,9 @@ function ListingRow({ item }: { item: Listing }) {
|
||||
<div className="listing-row__resources">
|
||||
<em>仓库物资</em>
|
||||
{resources.map(row => (
|
||||
<span key={row.label}>
|
||||
<span key={row.label} className={`is-${row.mode}`}>
|
||||
{row.label} {row.quantity}
|
||||
<i>{resourceBadgeText(row, 'compact')}</i>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
@@ -227,6 +229,11 @@ function ListingGridCover({ item }: { item: Listing }) {
|
||||
}
|
||||
|
||||
function ListingGridCard({ item }: { item: Listing }) {
|
||||
const online = onlineTimeText(item.asset_summary)
|
||||
const rentalDays = listingRentalDays(item)
|
||||
const faceOwner = faceOwnerText(item.asset_summary)
|
||||
const banRecord = banRecordText(item.asset_summary)
|
||||
const gameNameChange = gameNameChangeText(item.asset_summary)
|
||||
return (
|
||||
<Link to={`/listings/${item.id}`} className="listing-card-link">
|
||||
<Card className="listing-card" hoverable cover={<ListingGridCover item={item} />}>
|
||||
@@ -243,6 +250,11 @@ function ListingGridCard({ item }: { item: Listing }) {
|
||||
<Tag bordered={false}>{item.server_region || '区服待定'}</Tag>
|
||||
<Tag bordered={false}>{item.login_platform || '登录方式待定'}</Tag>
|
||||
{item.rank_level ? <Tag bordered={false}>{item.rank_level}</Tag> : null}
|
||||
{online ? <Tag bordered={false}>在线 {online}</Tag> : null}
|
||||
{rentalDays ? <Tag bordered={false}>预计租期 {rentalDays} 天</Tag> : null}
|
||||
{faceOwner ? <Tag bordered={false}>人脸 {faceOwner}</Tag> : null}
|
||||
{banRecord ? <Tag bordered={false}>封禁 {banRecord}</Tag> : null}
|
||||
{gameNameChange ? <Tag bordered={false}>改名 {gameNameChange}</Tag> : null}
|
||||
</div>
|
||||
<div className="listing-card__meta">
|
||||
<span>哈夫币 {formatCoinM(item.haf_coin_amount)}</span>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useInfiniteQuery, useQuery } from '@tanstack/react-query'
|
||||
|
||||
import { apiClient, unwrapData } from '@/shared/api/client'
|
||||
import type { ApiResponse, Listing, PublicListingPage } from '@/shared/api/types'
|
||||
@@ -60,6 +60,20 @@ export function useListings(query: ListingQuery) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useInfiniteListings(query: ListingQuery) {
|
||||
return useInfiniteQuery({
|
||||
queryKey: ['listings-infinite', query],
|
||||
initialPageParam: 1,
|
||||
queryFn: ({ pageParam }) =>
|
||||
fetchListings({
|
||||
...query,
|
||||
page: pageParam,
|
||||
}),
|
||||
getNextPageParam: lastPage =>
|
||||
lastPage.page * lastPage.page_size < lastPage.total ? lastPage.page + 1 : undefined,
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchListingDetail(id: number | string) {
|
||||
return unwrapData<Listing>(apiClient.get<ApiResponse<Listing>>(`/listings/${id}`))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import {
|
||||
faceOwnerText,
|
||||
listingPriceDetail,
|
||||
listingRatioText,
|
||||
listingResources,
|
||||
resourceBadgeText,
|
||||
resourceChargeText,
|
||||
} from '@/features/listings/labels'
|
||||
|
||||
type RatioItem = {
|
||||
price_cent: number
|
||||
haf_coin_amount: number
|
||||
asset_summary?: Record<string, unknown>
|
||||
}
|
||||
|
||||
function listing(patch: Partial<RatioItem> = {}): RatioItem {
|
||||
return { price_cent: 0, haf_coin_amount: 0, asset_summary: {}, ...patch }
|
||||
}
|
||||
|
||||
describe('listingRatioText', () => {
|
||||
it('优先使用 publish_ratio,并按四舍五入取整到万', () => {
|
||||
expect(listingRatioText(listing({ asset_summary: { publish_ratio: 33.8256 } }))).toBe('34w')
|
||||
expect(listingRatioText(listing({ asset_summary: { publish_ratio: 33.4 } }))).toBe('33w')
|
||||
})
|
||||
|
||||
it('缺少 publish_ratio 时按「万币 / 元」兜底计算', () => {
|
||||
expect(listingRatioText(listing({ haf_coin_amount: 30_000_000, price_cent: 9_369 }))).toBe(
|
||||
'32w'
|
||||
)
|
||||
})
|
||||
|
||||
it('价格或币量缺失时返回空串,不渲染占位', () => {
|
||||
expect(listingRatioText(listing({ haf_coin_amount: 30_000_000 }))).toBe('')
|
||||
expect(listingRatioText(listing({ price_cent: 10_000 }))).toBe('')
|
||||
expect(listingRatioText(listing({ asset_summary: { publish_ratio: 0 } }))).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
describe('listingPriceDetail', () => {
|
||||
const item = {
|
||||
price_cent: 191350,
|
||||
asset_summary: { pure_coin_price_cent: 176350, extra_item_price_cent: 15000 },
|
||||
}
|
||||
|
||||
it('把额外物资标成收费项', () => {
|
||||
expect(listingPriceDetail(item)).toBe('(纯币租金 ¥1,763.50 + 额外物资收费 ¥150.00)')
|
||||
expect(listingPriceDetail(item, { compact: true })).toBe('纯币 ¥1,763.50 + 物资收费 ¥150.00')
|
||||
})
|
||||
|
||||
it('只有纯币租金时省略收费项,无拆分时不渲染', () => {
|
||||
expect(
|
||||
listingPriceDetail({
|
||||
price_cent: 176350,
|
||||
asset_summary: { pure_coin_price_cent: 176350, extra_item_price_cent: 0 },
|
||||
})
|
||||
).toBe('(纯币租金 ¥1,763.50)')
|
||||
expect(listingPriceDetail({ price_cent: 176350, asset_summary: {} })).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
describe('resourceChargeText', () => {
|
||||
it('区分赠送、收费与未标注', () => {
|
||||
expect(resourceChargeText('赠送')).toBe('赠送')
|
||||
expect(resourceChargeText('收费')).toBe('额外收费')
|
||||
expect(resourceChargeText('收费', true)).toBe('收费')
|
||||
expect(resourceChargeText('付费')).toBe('未标注')
|
||||
expect(resourceChargeText('')).toBe('未标注')
|
||||
expect(resourceChargeText(undefined)).toBe('未标注')
|
||||
})
|
||||
})
|
||||
|
||||
describe('listingResources', () => {
|
||||
it('归一化模式、计算收费项小计并过滤空项', () => {
|
||||
const rows = listingResources({
|
||||
resources: [
|
||||
{ key: 'ammo6', label: '6级弹', quantity: 50, mode: '收费', price_cent: 10 },
|
||||
{ key: 'helmet6', label: '6头', quantity: 5, mode: '收费', price: '3.9元/个' },
|
||||
{ key: 'med', label: '医疗包', quantity: 3, mode: '赠送', price_cent: 100 },
|
||||
{ key: 'legacy', label: '旧数据', quantity: 2, mode: '付费', price: '2.5元/个' },
|
||||
{ key: 'empty', label: '', quantity: 1, mode: '收费' },
|
||||
{ key: 'zero', label: '零数量', quantity: 0, mode: '收费' },
|
||||
],
|
||||
})
|
||||
|
||||
expect(rows).toEqual([
|
||||
{
|
||||
label: '6级弹',
|
||||
quantity: 50,
|
||||
mode: 'paid',
|
||||
modeText: '额外收费',
|
||||
amountCent: 500,
|
||||
amountText: '5.0',
|
||||
},
|
||||
{
|
||||
label: '6头',
|
||||
quantity: 5,
|
||||
mode: 'paid',
|
||||
modeText: '额外收费',
|
||||
amountCent: 1950,
|
||||
amountText: '19.5',
|
||||
},
|
||||
{
|
||||
label: '医疗包',
|
||||
quantity: 3,
|
||||
mode: 'gift',
|
||||
modeText: '赠送',
|
||||
amountCent: 0,
|
||||
amountText: '',
|
||||
},
|
||||
{
|
||||
label: '旧数据',
|
||||
quantity: 2,
|
||||
mode: 'unknown',
|
||||
modeText: '未标注',
|
||||
amountCent: 0,
|
||||
amountText: '',
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
it('缺少 resources 时返回空数组', () => {
|
||||
expect(listingResources(undefined)).toEqual([])
|
||||
expect(listingResources({})).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('resourceBadgeText', () => {
|
||||
const base = { label: '6级弹', quantity: 50, modeText: '额外收费' } as const
|
||||
|
||||
it('收费项带小计金额,赠送与未标注用固定文案', () => {
|
||||
expect(resourceBadgeText({ ...base, mode: 'paid', amountCent: 500, amountText: '5.0' })).toBe(
|
||||
'额外收费 ¥5.0'
|
||||
)
|
||||
expect(
|
||||
resourceBadgeText({ ...base, mode: 'paid', amountCent: 500, amountText: '5.0' }, 'compact')
|
||||
).toBe('收费 ¥5.0')
|
||||
expect(resourceBadgeText({ ...base, mode: 'paid', amountCent: 0, amountText: '' })).toBe(
|
||||
'额外收费'
|
||||
)
|
||||
expect(resourceBadgeText({ ...base, mode: 'gift', amountCent: 0, amountText: '' })).toBe(
|
||||
'随号赠送'
|
||||
)
|
||||
expect(
|
||||
resourceBadgeText({ ...base, mode: 'gift', amountCent: 0, amountText: '' }, 'compact')
|
||||
).toBe('赠送')
|
||||
expect(resourceBadgeText({ ...base, mode: 'unknown', amountCent: 0, amountText: '' })).toBe(
|
||||
'未标注'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('faceOwnerText', () => {
|
||||
it('把是/否映射为本人/非本人', () => {
|
||||
expect(faceOwnerText({ face_owner: '是' })).toBe('本人')
|
||||
expect(faceOwnerText({ face_owner: '否' })).toBe('非本人')
|
||||
})
|
||||
|
||||
it('兼容已映射文案与空值', () => {
|
||||
expect(faceOwnerText({ face_owner: '本人' })).toBe('本人')
|
||||
expect(faceOwnerText({ face_owner: '非本人' })).toBe('非本人')
|
||||
expect(faceOwnerText({ face_owner: ' ' })).toBe('')
|
||||
expect(faceOwnerText(null)).toBe('')
|
||||
})
|
||||
|
||||
it('未知文案原样保留', () => {
|
||||
expect(faceOwnerText({ face_owner: '需配合人脸' })).toBe('需配合人脸')
|
||||
})
|
||||
})
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { StatusMeta } from '@/features/admin/labels'
|
||||
import { parseUnitPriceCent } from '@/shared/utils/pricing'
|
||||
|
||||
export const listingStatusMap: Record<string, StatusMeta> = {
|
||||
draft: { label: '草稿', tone: 'default' },
|
||||
@@ -47,6 +48,10 @@ const assetFieldLabels: Record<string, string> = {
|
||||
skin_names: '皮肤名称',
|
||||
online_time: '在线时间',
|
||||
online_time_text: '在线时间',
|
||||
face_owner: '人脸情况',
|
||||
ban_record: '封禁记录',
|
||||
can_change_game_name: '可改游戏名',
|
||||
modifiable_name: '可改游戏名',
|
||||
rank_level: '段位',
|
||||
haf_coin_amount: '哈夫币',
|
||||
}
|
||||
@@ -64,6 +69,201 @@ function formatOnlineTime(value: unknown) {
|
||||
return `${start || '—'} 至 ${end || '—'}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品在线时段的统一展示文案,格式与原详情页保持一致(start - end)。
|
||||
* 空值返回空字符串,由调用方决定是否隐藏或替换为占位符。
|
||||
*/
|
||||
export function onlineTimeText(summary?: Record<string, unknown> | null): string {
|
||||
if (!summary || typeof summary !== 'object') return ''
|
||||
|
||||
const value = summary.online_time
|
||||
if (typeof value === 'string') return value.trim()
|
||||
if (!value || typeof value !== 'object') return ''
|
||||
|
||||
const item = value as { start?: unknown; end?: unknown }
|
||||
const start = typeof item.start === 'string' ? item.start.trim() : ''
|
||||
const end = typeof item.end === 'string' ? item.end.trim() : ''
|
||||
if (!start && !end) return ''
|
||||
if (start === end) return start
|
||||
return `${start} - ${end}`
|
||||
}
|
||||
|
||||
export function faceOwnerText(summary?: Record<string, unknown> | null): string {
|
||||
const value = summary?.face_owner
|
||||
if (typeof value !== 'string') return ''
|
||||
const text = value.trim()
|
||||
if (!text) return ''
|
||||
if (text === '是' || text === '本人' || text === '有') return '本人'
|
||||
if (text === '否' || text === '非本人' || text === '无') return '非本人'
|
||||
return text
|
||||
}
|
||||
|
||||
export function banRecordText(summary?: Record<string, unknown> | null): string {
|
||||
const value = summary?.ban_record
|
||||
if (typeof value !== 'string') return ''
|
||||
const text = value.trim()
|
||||
if (!text) return ''
|
||||
if (text.includes('无') || text === '否') return '无封禁'
|
||||
if (text.includes('有') || text === '是') return '有封禁'
|
||||
return text
|
||||
}
|
||||
|
||||
export function gameNameChangeText(summary?: Record<string, unknown> | null): string {
|
||||
const primary = summary?.can_change_game_name
|
||||
const fallback = summary?.modifiable_name
|
||||
const raw = typeof primary === 'string' && primary.trim() ? primary : fallback
|
||||
if (typeof raw !== 'string') return ''
|
||||
const text = raw.trim()
|
||||
if (!text) return ''
|
||||
if (text === '是') return '可改'
|
||||
if (text === '否') return '不可改'
|
||||
return text
|
||||
}
|
||||
|
||||
export function listingPriceBreakdown(item: {
|
||||
price_cent: number
|
||||
asset_summary?: Record<string, unknown>
|
||||
}) {
|
||||
const summary = item.asset_summary ?? {}
|
||||
const pureCoinCent = Number(summary.pure_coin_price_cent ?? 0)
|
||||
const extraItemCent = Number(summary.extra_item_price_cent ?? 0)
|
||||
return {
|
||||
pureCoinCent: Number.isFinite(pureCoinCent) ? pureCoinCent : 0,
|
||||
extraItemCent: Number.isFinite(extraItemCent) ? extraItemCent : 0,
|
||||
hasBreakdown: pureCoinCent > 0 || extraItemCent > 0,
|
||||
}
|
||||
}
|
||||
|
||||
export function listingPriceDetail(
|
||||
item: {
|
||||
price_cent: number
|
||||
asset_summary?: Record<string, unknown>
|
||||
},
|
||||
options?: { compact?: boolean }
|
||||
): string {
|
||||
const { pureCoinCent, extraItemCent } = listingPriceBreakdown(item)
|
||||
const pureLabel = options?.compact ? '纯币' : '纯币租金'
|
||||
const extraLabel = options?.compact ? '物资收费' : '额外物资收费'
|
||||
const parts = [
|
||||
pureCoinCent > 0 ? `${pureLabel} ¥${formatCentAmount(pureCoinCent)}` : '',
|
||||
extraItemCent > 0 ? `${extraLabel} ¥${formatCentAmount(extraItemCent)}` : '',
|
||||
].filter(Boolean)
|
||||
if (!parts.length) return ''
|
||||
const text = parts.join(' + ')
|
||||
return options?.compact ? text : `(${text})`
|
||||
}
|
||||
|
||||
function formatCentAmount(cent: number) {
|
||||
return (cent / 100).toLocaleString('zh-CN', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 折算比文案,单位「万哈夫币 / 元」,统一按四舍五入取整展示。
|
||||
* 后端比例筛选也用同一口径(math.Round),保证展示与筛选一致。
|
||||
*/
|
||||
export function listingRatioText(item: {
|
||||
price_cent: number
|
||||
haf_coin_amount: number
|
||||
asset_summary?: Record<string, unknown>
|
||||
}): string {
|
||||
const published = Number(item.asset_summary?.publish_ratio ?? 0)
|
||||
if (Number.isFinite(published) && published > 0) return `${Math.round(published)}w`
|
||||
|
||||
const priceYuan = item.price_cent / 100
|
||||
const coinM = item.haf_coin_amount / 1_000_000
|
||||
if (!Number.isFinite(priceYuan) || !Number.isFinite(coinM)) return ''
|
||||
if (priceYuan <= 0 || coinM <= 0) return ''
|
||||
return `${Math.round((coinM / priceYuan) * 100)}w`
|
||||
}
|
||||
|
||||
export type ResourceChargeMode = 'gift' | 'paid' | 'unknown'
|
||||
|
||||
export type ListingResourceRow = {
|
||||
label: string
|
||||
quantity: number
|
||||
mode: ResourceChargeMode
|
||||
modeText: string
|
||||
/** 收费项的单项小计(分);赠送或缺少单价时为 0。 */
|
||||
amountCent: number
|
||||
/** 小计金额文案,保留一位小数,例如 18.1。 */
|
||||
amountText: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源计费模式。后端计价只把「收费」计入额外物资,
|
||||
* 「付费」等历史取值一律视为未标注,避免展示与计价口径不一致。
|
||||
*/
|
||||
export function resourceChargeMode(mode: unknown): ResourceChargeMode {
|
||||
const text = typeof mode === 'string' ? mode.trim() : ''
|
||||
if (text === '赠送') return 'gift'
|
||||
if (text === '收费') return 'paid'
|
||||
return 'unknown'
|
||||
}
|
||||
|
||||
export function resourceChargeText(mode: unknown, compact = false): string {
|
||||
const kind = resourceChargeMode(mode)
|
||||
if (kind === 'gift') return '赠送'
|
||||
if (kind === 'paid') return compact ? '收费' : '额外收费'
|
||||
return '未标注'
|
||||
}
|
||||
|
||||
export function listingResources(summary?: Record<string, unknown> | null): ListingResourceRow[] {
|
||||
const raw = summary?.resources
|
||||
if (!Array.isArray(raw)) return []
|
||||
return raw
|
||||
.map(entry => {
|
||||
const row = (entry ?? {}) as Record<string, unknown>
|
||||
const label = String(row.label ?? row.key ?? '').trim()
|
||||
const parsedQuantity = Number(row.quantity ?? 0)
|
||||
const quantity =
|
||||
Number.isFinite(parsedQuantity) && parsedQuantity > 0 ? Math.trunc(parsedQuantity) : 0
|
||||
const mode = resourceChargeMode(row.mode)
|
||||
const amountCent = mode === 'paid' ? quantity * resourceUnitPriceCent(row) : 0
|
||||
return {
|
||||
label,
|
||||
quantity,
|
||||
mode,
|
||||
modeText: resourceChargeText(row.mode),
|
||||
amountCent,
|
||||
amountText: amountCent > 0 ? (amountCent / 100).toFixed(1) : '',
|
||||
}
|
||||
})
|
||||
.filter(row => row.label && row.quantity > 0)
|
||||
}
|
||||
|
||||
function resourceUnitPriceCent(row: Record<string, unknown>): number {
|
||||
const priceCent = Number(row.price_cent ?? 0)
|
||||
if (Number.isFinite(priceCent) && priceCent > 0) return Math.trunc(priceCent)
|
||||
return parseUnitPriceCent(String(row.price ?? ''))
|
||||
}
|
||||
|
||||
/** 卡片徽标:收费项带小计金额,赠送项固定文案。 */
|
||||
export function resourceBadgeText(
|
||||
row: ListingResourceRow,
|
||||
variant: 'detail' | 'compact' = 'detail'
|
||||
): string {
|
||||
if (row.mode === 'gift') return variant === 'detail' ? '随号赠送' : '赠送'
|
||||
if (row.mode === 'paid') {
|
||||
const label = variant === 'detail' ? '额外收费' : '收费'
|
||||
return row.amountText ? `${label} ¥${row.amountText}` : label
|
||||
}
|
||||
return '未标注'
|
||||
}
|
||||
|
||||
export function listingRentalDays(item: {
|
||||
haf_coin_amount: number
|
||||
asset_summary?: Record<string, unknown>
|
||||
}): number | null {
|
||||
const coinM = Number(item.haf_coin_amount) / 1_000_000
|
||||
const dailyLoss = Number(item.asset_summary?.daily_loss_m ?? 0)
|
||||
if (!Number.isFinite(coinM) || coinM <= 0) return null
|
||||
if (!Number.isFinite(dailyLoss) || dailyLoss <= 0) return null
|
||||
return Math.max(1, Math.ceil(coinM / dailyLoss))
|
||||
}
|
||||
|
||||
export function formatAssetValue(key: string, value: unknown): string {
|
||||
if (value == null || value === '') return '—'
|
||||
if (key === 'online_time') {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState } from 'react'
|
||||
import { useMemo, useState, type ReactNode } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import {
|
||||
Button,
|
||||
@@ -8,26 +8,75 @@ import {
|
||||
PullToRefresh,
|
||||
SearchBar,
|
||||
Skeleton,
|
||||
Swiper,
|
||||
Tag,
|
||||
} from 'antd-mobile'
|
||||
import { DownOutline, RightOutline, SearchOutline } from 'antd-mobile-icons'
|
||||
import { Link } from 'react-router-dom'
|
||||
import {
|
||||
AddCircleOutline,
|
||||
BillOutline,
|
||||
CheckShieldOutline,
|
||||
DownOutline,
|
||||
FlagOutline,
|
||||
GiftOutline,
|
||||
PhoneFill,
|
||||
RightOutline,
|
||||
SearchOutline,
|
||||
ShopbagOutline,
|
||||
SmileOutline,
|
||||
} from 'antd-mobile-icons'
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
|
||||
import { BrandLogo } from '@/components/BrandLogo'
|
||||
import { useListings } from '@/features/listings/api'
|
||||
import {
|
||||
fallbackBanners,
|
||||
useHomeConfig,
|
||||
type HomeBannerItem,
|
||||
type HomeEntryConfig,
|
||||
} from '@/features/home/api'
|
||||
import { useInfiniteListings } from '@/features/listings/api'
|
||||
import {
|
||||
banRecordText,
|
||||
faceOwnerText,
|
||||
gameNameChangeText,
|
||||
listingRatioText,
|
||||
listingRentalDays,
|
||||
listingResources,
|
||||
onlineTimeText,
|
||||
resourceBadgeText,
|
||||
} from '@/features/listings/labels'
|
||||
import {
|
||||
awmRanges,
|
||||
coinRanges,
|
||||
dailyLossRanges,
|
||||
depositRanges,
|
||||
emptyListingFilters,
|
||||
fireLevelRanges,
|
||||
priceRanges,
|
||||
ratioRanges,
|
||||
secretKdRanges,
|
||||
totalRanges,
|
||||
type ListingFilterState,
|
||||
} from '@/features/listings/ListingFilterPanel'
|
||||
import { fetchListingPublishOptions } from '@/features/seller/options'
|
||||
import { formatCoinM } from '@/shared/utils/format'
|
||||
import type { Listing } from '@/shared/api/types'
|
||||
|
||||
const sortOptions = [
|
||||
{ value: '', label: '综合推荐' },
|
||||
{ value: 'published', label: '最新发布' },
|
||||
{ value: 'ratioDesc', label: '比例最高' },
|
||||
{ value: 'ratioAsc', label: '比例最低' },
|
||||
{ value: 'priceAsc', label: '价格最低' },
|
||||
{ value: 'priceDesc', label: '价格最高' },
|
||||
{ value: 'coinDesc', label: '哈夫币最多' },
|
||||
{ value: 'coinAsc', label: '哈夫币最少' },
|
||||
{ value: 'awmDesc', label: 'AWM最多' },
|
||||
{ value: 'awmAsc', label: 'AWM最少' },
|
||||
]
|
||||
|
||||
const zoneTabs = [
|
||||
{ key: 'all', label: '全部' },
|
||||
{ key: 'premium', label: '极品' },
|
||||
{ key: 'sale', label: '特惠' },
|
||||
{ key: 'gift', label: '赠送' },
|
||||
{ key: 'night', label: '夜间' },
|
||||
@@ -35,18 +84,24 @@ const zoneTabs = [
|
||||
{ key: 'highCoin', label: '高币' },
|
||||
]
|
||||
|
||||
const sortOptions = [
|
||||
{ value: '', label: '综合推荐' },
|
||||
{ value: 'published', label: '最新发布' },
|
||||
{ value: 'ratio', label: '比例优先' },
|
||||
{ value: 'coinDesc', label: '哈夫币从高到低' },
|
||||
{ value: 'priceAsc', label: '价格从低到高' },
|
||||
]
|
||||
|
||||
const insuranceOptions = ['2*1', '2*2', '2*3', '3*3']
|
||||
const levelOptions = ['4级', '5级', '6级', '7级']
|
||||
const loginOptions = ['扫码', '账号密码']
|
||||
|
||||
type MultiFilterKey =
|
||||
'insurance' | 'stamina' | 'load' | 'loginMethod' | 'ranks' | 'regions' | 'skinNames'
|
||||
|
||||
type RangeFilterKey =
|
||||
| 'coinKey'
|
||||
| 'priceKey'
|
||||
| 'ratioKey'
|
||||
| 'awmKey'
|
||||
| 'depositKey'
|
||||
| 'totalKey'
|
||||
| 'fireLevelKey'
|
||||
| 'dailyLossKey'
|
||||
| 'secretKdKey'
|
||||
|
||||
function money(cents: number) {
|
||||
return `¥${(cents / 100).toFixed(2)}`
|
||||
}
|
||||
@@ -68,6 +123,7 @@ function MobileChipGroup({
|
||||
selected: string[]
|
||||
onToggle: (option: string) => void
|
||||
}) {
|
||||
if (options.length === 0) return null
|
||||
return (
|
||||
<div className="mobile-filter-group">
|
||||
<span className="mobile-filter-group__label">{label}</span>
|
||||
@@ -87,22 +143,88 @@ function MobileChipGroup({
|
||||
)
|
||||
}
|
||||
|
||||
function MobileRangeGroup({
|
||||
label,
|
||||
options,
|
||||
activeKey,
|
||||
onSelect,
|
||||
}: {
|
||||
label: string
|
||||
options: { key: string; label: string }[]
|
||||
activeKey?: string
|
||||
onSelect: (key: string) => void
|
||||
}) {
|
||||
return (
|
||||
<div className="mobile-filter-group">
|
||||
<span className="mobile-filter-group__label">{label}</span>
|
||||
<div className="mobile-filter-chips">
|
||||
{options.map(option => (
|
||||
<button
|
||||
key={option.key}
|
||||
type="button"
|
||||
className={`mobile-filter-chip${activeKey === option.key ? ' is-active' : ''}`}
|
||||
onClick={() => onSelect(option.key)}
|
||||
>
|
||||
{option.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function MobileListingCard({ item }: { item: Listing }) {
|
||||
const [coverFailed, setCoverFailed] = useState(false)
|
||||
const online = onlineTimeText(item.asset_summary)
|
||||
const rentalDays = listingRentalDays(item)
|
||||
const faceOwner = faceOwnerText(item.asset_summary)
|
||||
const banRecord = banRecordText(item.asset_summary)
|
||||
const gameNameChange = gameNameChangeText(item.asset_summary)
|
||||
const ratio = listingRatioText(item)
|
||||
const resources = listingResources(item.asset_summary).slice(0, 2)
|
||||
const specs = [
|
||||
assetText(item, 'season_insurance') ? `保险 ${assetText(item, 'season_insurance')}` : '',
|
||||
assetText(item, 'stamina_level') ? `体力 ${assetText(item, 'stamina_level')}` : '',
|
||||
assetText(item, 'load_level') ? `负重 ${assetText(item, 'load_level')}` : '',
|
||||
].filter(Boolean)
|
||||
{ label: '保险', value: assetText(item, 'season_insurance') },
|
||||
{ label: '体力', value: assetText(item, 'stamina_level') },
|
||||
{ label: '负重', value: assetText(item, 'load_level') },
|
||||
{ label: '区服', value: item.server_region },
|
||||
{ label: '租期', value: rentalDays ? `${rentalDays}天` : '' },
|
||||
{ label: '在线', value: online },
|
||||
{ label: '人脸', value: faceOwner },
|
||||
{ label: '封禁', value: banRecord },
|
||||
{ label: '改名', value: gameNameChange },
|
||||
]
|
||||
.filter(spec => spec.value)
|
||||
.slice(0, 5)
|
||||
|
||||
return (
|
||||
<Link to={`/m/listings/${item.id}`} className="mobile-listing-card">
|
||||
<div className="mobile-listing-card__cover">
|
||||
{item.cover_url ? (
|
||||
<img src={item.cover_url} alt={item.title} loading="lazy" />
|
||||
{item.cover_url && !coverFailed ? (
|
||||
<img
|
||||
src={item.cover_url}
|
||||
alt={item.title}
|
||||
loading="lazy"
|
||||
onError={() => setCoverFailed(true)}
|
||||
/>
|
||||
) : (
|
||||
<BrandLogo height={38} variant="seal" />
|
||||
<div className="mobile-listing-card__fallback">
|
||||
<BrandLogo height={36} variant="seal" />
|
||||
<span>实拍图整理中</span>
|
||||
</div>
|
||||
)}
|
||||
{item.is_premium ||
|
||||
item.owner_is_quality_owner ||
|
||||
item.compensation_plan === 'insurance' ? (
|
||||
<div className="mobile-listing-card__badges">
|
||||
{item.owner_is_quality_owner ? <span>优质号主</span> : null}
|
||||
{item.is_premium ? <span className="is-premium">极品</span> : null}
|
||||
{item.compensation_plan === 'insurance' ? (
|
||||
<span className="is-insurance">保险</span>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div className="mobile-listing-card__body">
|
||||
<div className="mobile-listing-card__top">
|
||||
<span className="mobile-listing-card__no">{item.listing_no}</span>
|
||||
@@ -110,22 +232,35 @@ function MobileListingCard({ item }: { item: Listing }) {
|
||||
{item.in_transaction ? '租赁中' : '可租'}
|
||||
</Tag>
|
||||
</div>
|
||||
|
||||
<h3>{item.title}</h3>
|
||||
<div className="mobile-listing-card__core">
|
||||
<strong>{formatCoinM(item.haf_coin_amount)}</strong>
|
||||
{ratio ? <span>1:{ratio}</span> : null}
|
||||
</div>
|
||||
<div className="mobile-listing-card__tags">
|
||||
<span>{item.server_region || '区服待定'}</span>
|
||||
<span>{item.rank_level || '段位待定'}</span>
|
||||
<span>哈夫币 {formatCoinM(item.haf_coin_amount)}</span>
|
||||
{specs.map(spec => (
|
||||
<span key={spec}>{spec}</span>
|
||||
<span key={`${spec.label}-${spec.value}`}>
|
||||
<em>{spec.label}</em>
|
||||
{spec.value}
|
||||
</span>
|
||||
))}
|
||||
{resources.map(resource => (
|
||||
<span key={resource.label}>
|
||||
<em>{resource.label}</em>
|
||||
{resource.quantity}
|
||||
<i>{resourceBadgeText(resource, 'compact')}</i>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mobile-listing-card__bottom">
|
||||
<div>
|
||||
<strong>{money(item.price_cent)}</strong>
|
||||
<small>押金 {money(item.deposit_amount_cent)}</small>
|
||||
</div>
|
||||
<span className="mobile-listing-card__more">
|
||||
查看 <RightOutline />
|
||||
<span className="mobile-listing-card__cta">
|
||||
立即租 <RightOutline />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -133,7 +268,44 @@ function MobileListingCard({ item }: { item: Listing }) {
|
||||
)
|
||||
}
|
||||
|
||||
function QuickService({
|
||||
to,
|
||||
icon,
|
||||
label,
|
||||
hint,
|
||||
onClick,
|
||||
}: {
|
||||
to?: string
|
||||
icon: ReactNode
|
||||
label: string
|
||||
hint: string
|
||||
onClick?: () => void
|
||||
}) {
|
||||
const content = (
|
||||
<>
|
||||
<span className="mobile-quick-service__icon">{icon}</span>
|
||||
<strong>{label}</strong>
|
||||
<small>{hint}</small>
|
||||
</>
|
||||
)
|
||||
|
||||
if (to) {
|
||||
return (
|
||||
<Link to={to} className="mobile-quick-service">
|
||||
{content}
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<button type="button" className="mobile-quick-service" onClick={onClick}>
|
||||
{content}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
export function MobileHomePage() {
|
||||
const navigate = useNavigate()
|
||||
const [keyword, setKeyword] = useState('')
|
||||
const [searchValue, setSearchValue] = useState('')
|
||||
const [zone, setZone] = useState('all')
|
||||
@@ -142,50 +314,99 @@ export function MobileHomePage() {
|
||||
const [draft, setDraft] = useState<ListingFilterState>(emptyListingFilters)
|
||||
const [filterOpen, setFilterOpen] = useState(false)
|
||||
const [sortOpen, setSortOpen] = useState(false)
|
||||
const [entryPreview, setEntryPreview] = useState<HomeEntryConfig | null>(null)
|
||||
|
||||
const homeConfig = useHomeConfig()
|
||||
const publishOptions = useQuery({
|
||||
queryKey: ['listing-publish-options'],
|
||||
queryFn: fetchListingPublishOptions,
|
||||
staleTime: 300_000,
|
||||
})
|
||||
const quickSkinGroups = (publishOptions.data?.skin_groups ?? []).filter(group =>
|
||||
['melee', 'operatorRed'].includes(group.key)
|
||||
)
|
||||
|
||||
const coin = coinRanges.find(range => range.key === filters.coinKey)
|
||||
const price = priceRanges.find(range => range.key === filters.priceKey)
|
||||
const ratio = ratioRanges.find(range => range.key === filters.ratioKey)
|
||||
const awm = awmRanges.find(range => range.key === filters.awmKey)
|
||||
const deposit = depositRanges.find(range => range.key === filters.depositKey)
|
||||
const total = totalRanges.find(range => range.key === filters.totalKey)
|
||||
const fireLevel = fireLevelRanges.find(range => range.key === filters.fireLevelKey)
|
||||
const dailyLoss = dailyLossRanges.find(range => range.key === filters.dailyLossKey)
|
||||
const secretKd = secretKdRanges.find(range => range.key === filters.secretKdKey)
|
||||
|
||||
const { data, isPending, isError, refetch } = useListings({
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
keyword,
|
||||
zone: zone === 'all' ? '' : zone,
|
||||
sort,
|
||||
min_coin: coin?.min,
|
||||
max_coin: coin?.max,
|
||||
min_price: price?.min,
|
||||
max_price: price?.max,
|
||||
min_ratio: ratio?.min,
|
||||
max_ratio: ratio?.max,
|
||||
insurance: filters.insurance.join(','),
|
||||
stamina: filters.stamina.join(','),
|
||||
load: filters.load.join(','),
|
||||
login_method: filters.loginMethod.join(','),
|
||||
skin_name: filters.skinNames.join(','),
|
||||
})
|
||||
const listingQuery = useMemo(
|
||||
() => ({
|
||||
page_size: 10,
|
||||
keyword,
|
||||
zone: zone === 'all' ? '' : zone,
|
||||
sort,
|
||||
min_coin: coin?.min,
|
||||
max_coin: coin?.max,
|
||||
min_price: price?.min,
|
||||
max_price: price?.max,
|
||||
min_ratio: ratio?.min,
|
||||
max_ratio: ratio?.max,
|
||||
min_deposit: deposit?.min,
|
||||
max_deposit: deposit?.max,
|
||||
min_total: total?.min,
|
||||
max_total: total?.max,
|
||||
min_fire_level: fireLevel?.min,
|
||||
max_fire_level: fireLevel?.max,
|
||||
min_daily_loss: dailyLoss?.min,
|
||||
max_daily_loss: dailyLoss?.max,
|
||||
min_secret_kd: secretKd?.min,
|
||||
max_secret_kd: secretKd?.max,
|
||||
resource_awmAmmo_min: awm?.min,
|
||||
resource_awmAmmo_max: awm?.max,
|
||||
insurance: filters.insurance.join(','),
|
||||
stamina: filters.stamina.join(','),
|
||||
load: filters.load.join(','),
|
||||
login_method: filters.loginMethod.join(','),
|
||||
rank: filters.ranks.join(','),
|
||||
region: filters.regions.join(','),
|
||||
skin_name: filters.skinNames.join(','),
|
||||
}),
|
||||
[
|
||||
awm,
|
||||
coin,
|
||||
dailyLoss,
|
||||
deposit,
|
||||
filters,
|
||||
fireLevel,
|
||||
keyword,
|
||||
price,
|
||||
ratio,
|
||||
secretKd,
|
||||
sort,
|
||||
total,
|
||||
zone,
|
||||
]
|
||||
)
|
||||
const listings = useInfiniteListings(listingQuery)
|
||||
|
||||
const items = listings.data?.pages.flatMap(page => page.items) ?? []
|
||||
const totalListings = listings.data?.pages[0]?.total ?? 0
|
||||
const zoneCounts = listings.data?.pages[0]?.zone_counts ?? {}
|
||||
const quickSkinGroups = (publishOptions.data?.skin_groups ?? []).filter(group =>
|
||||
['melee', 'operatorRed'].includes(group.key)
|
||||
)
|
||||
const rankOptions = publishOptions.data?.rank_options ?? []
|
||||
const regionOptions = publishOptions.data?.region_options ?? []
|
||||
|
||||
const applyFilter = () => {
|
||||
setFilters(draft)
|
||||
setFilterOpen(false)
|
||||
}
|
||||
|
||||
const resetDraft = () => setDraft(emptyListingFilters)
|
||||
const resetFilters = () => {
|
||||
setDraft(emptyListingFilters)
|
||||
setFilters(emptyListingFilters)
|
||||
setKeyword('')
|
||||
setSearchValue('')
|
||||
setZone('all')
|
||||
setSort('')
|
||||
}
|
||||
|
||||
const toggleDraft = (
|
||||
key: 'insurance' | 'stamina' | 'load' | 'loginMethod' | 'skinNames',
|
||||
option: string
|
||||
) => {
|
||||
const toggleDraft = (key: MultiFilterKey, option: string) => {
|
||||
const current = draft[key]
|
||||
setDraft({
|
||||
...draft,
|
||||
@@ -195,7 +416,7 @@ export function MobileHomePage() {
|
||||
})
|
||||
}
|
||||
|
||||
const toggleRange = (key: 'coinKey' | 'priceKey' | 'ratioKey', nextKey: string) => {
|
||||
const toggleRange = (key: RangeFilterKey, nextKey: string) => {
|
||||
setDraft({ ...draft, [key]: draft[key] === nextKey ? undefined : nextKey })
|
||||
}
|
||||
|
||||
@@ -204,44 +425,141 @@ export function MobileHomePage() {
|
||||
filters.stamina.length +
|
||||
filters.load.length +
|
||||
filters.loginMethod.length +
|
||||
filters.ranks.length +
|
||||
filters.regions.length +
|
||||
filters.skinNames.length +
|
||||
[filters.coinKey, filters.priceKey, filters.ratioKey].filter(Boolean).length
|
||||
[
|
||||
filters.coinKey,
|
||||
filters.priceKey,
|
||||
filters.ratioKey,
|
||||
filters.awmKey,
|
||||
filters.depositKey,
|
||||
filters.totalKey,
|
||||
filters.fireLevelKey,
|
||||
filters.dailyLossKey,
|
||||
filters.secretKdKey,
|
||||
].filter(Boolean).length
|
||||
|
||||
const sortLabel = sortOptions.find(option => option.value === sort)?.label ?? '综合推荐'
|
||||
const sortLabel = sortOptions.find(option => option.value === sort)?.label ?? '综合排序'
|
||||
const banners = (homeConfig.data?.banners ?? fallbackBanners)
|
||||
.filter(banner => banner.enabled !== false)
|
||||
.slice(0, 4)
|
||||
|
||||
const runBannerAction = (banner: HomeBannerItem) => {
|
||||
const action = banner.mobile?.action
|
||||
if (!action || action.type === 'none' || !action.target) return
|
||||
if (action.type === 'route') {
|
||||
navigate(action.target)
|
||||
return
|
||||
}
|
||||
window.open(action.target, action.open_new_tab ? '_blank' : '_self')
|
||||
}
|
||||
|
||||
const submitSearch = (value: string) => {
|
||||
setKeyword(value.trim())
|
||||
void listings.refetch()
|
||||
}
|
||||
|
||||
const scrollToListings = () => {
|
||||
document.getElementById('listings')?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mobile-home">
|
||||
<section className="mobile-hero">
|
||||
<div className="mobile-hero__eyebrow">JIEYOU TRADING HOUSE</div>
|
||||
<h1>
|
||||
租得明白,
|
||||
<br />
|
||||
还得安心。
|
||||
</h1>
|
||||
<p>实名审核 · 流程留痕 · 账单逐项列明</p>
|
||||
<section className="mobile-home-search">
|
||||
<div className="mobile-home-search__heading">
|
||||
<div>
|
||||
<span>解忧柜选</span>
|
||||
<strong>今天想租什么账号?</strong>
|
||||
</div>
|
||||
<Link to="/m/announcements">规则</Link>
|
||||
</div>
|
||||
<SearchBar
|
||||
className="mobile-search"
|
||||
value={searchValue}
|
||||
onChange={setSearchValue}
|
||||
onSearch={value => setKeyword(value.trim())}
|
||||
placeholder="搜索区服、段位、装备或商品号"
|
||||
onSearch={submitSearch}
|
||||
placeholder="搜编号 / 区服 / 段位 / 资产"
|
||||
searchIcon={<SearchOutline />}
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section className="mobile-trust">
|
||||
<span>实名审核</span>
|
||||
<span>交接留痕</span>
|
||||
<span>争议可申诉</span>
|
||||
<span>
|
||||
<CheckShieldOutline />
|
||||
<em>实名审核</em>
|
||||
</span>
|
||||
<span>
|
||||
<SmileOutline />
|
||||
<em>找回包赔</em>
|
||||
</span>
|
||||
<span>
|
||||
<PhoneFill />
|
||||
<em>客服护航</em>
|
||||
</span>
|
||||
<span>
|
||||
<BillOutline />
|
||||
<em>账单透明</em>
|
||||
</span>
|
||||
</section>
|
||||
|
||||
<section className="mobile-list-section">
|
||||
<div className="mobile-section-head">
|
||||
<section className="mobile-banner">
|
||||
<Swiper autoplay loop indicatorProps={{ color: 'white' }}>
|
||||
{banners.map((banner, index) => {
|
||||
const imageURL = banner.mobile?.image_url || banner.image_url
|
||||
return (
|
||||
<Swiper.Item key={`${banner.title || 'banner'}-${index}`}>
|
||||
<button
|
||||
type="button"
|
||||
className={`mobile-banner__item tone-${banner.tone || 'green'}`}
|
||||
onClick={() => runBannerAction(banner)}
|
||||
>
|
||||
{imageURL ? (
|
||||
<img src={imageURL} alt={banner.mobile?.alt || banner.title || ''} />
|
||||
) : (
|
||||
<span className="mobile-banner__copy">
|
||||
{banner.badge ? <em>{banner.badge}</em> : null}
|
||||
<strong>{banner.title || '平台担保交易'}</strong>
|
||||
<small>{banner.pill || banner.eyebrow || '实名审核 · 交接留痕'}</small>
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
</Swiper.Item>
|
||||
)
|
||||
})}
|
||||
</Swiper>
|
||||
</section>
|
||||
|
||||
<section className="mobile-quick-services" aria-label="快捷服务">
|
||||
<QuickService
|
||||
icon={<ShopbagOutline />}
|
||||
label="我要租号"
|
||||
hint="海量账号"
|
||||
onClick={scrollToListings}
|
||||
/>
|
||||
<QuickService
|
||||
to="/m/seller/listings/new"
|
||||
icon={<AddCircleOutline />}
|
||||
label="我要出号"
|
||||
hint="闲置账号出租"
|
||||
/>
|
||||
<QuickService to="/m/crash" icon={<FlagOutline />} label="撞车商城" hint="装备与现货" />
|
||||
<QuickService
|
||||
icon={<GiftOutline />}
|
||||
label={homeConfig.data?.aw_recycle.title || 'AW回收'}
|
||||
hint="查看回收说明"
|
||||
onClick={() => setEntryPreview(homeConfig.data?.aw_recycle ?? null)}
|
||||
/>
|
||||
<QuickService to="/m/messages" icon={<PhoneFill />} label="联系客服" hint="问题留痕" />
|
||||
</section>
|
||||
|
||||
<div id="listings" className="mobile-market">
|
||||
<div className="mobile-market__head">
|
||||
<div>
|
||||
<span className="mobile-eyebrow">CURATED ACCOUNTS</span>
|
||||
<h2>本周柜选</h2>
|
||||
<span>放心购</span>
|
||||
<strong>严选账号</strong>
|
||||
</div>
|
||||
<span className="mobile-count">共 {data?.total ?? 0} 件</span>
|
||||
<small>共 {totalListings} 个可租账号</small>
|
||||
</div>
|
||||
|
||||
<div className="mobile-zone-tabs">
|
||||
@@ -253,11 +571,15 @@ export function MobileHomePage() {
|
||||
onClick={() => setZone(tab.key)}
|
||||
>
|
||||
{tab.label}
|
||||
{typeof zoneCounts[tab.key] === 'number' ? <em>{zoneCounts[tab.key]}</em> : null}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mobile-list-toolbar">
|
||||
<button type="button" onClick={() => setSortOpen(true)}>
|
||||
{sortLabel} <DownOutline />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
@@ -265,74 +587,77 @@ export function MobileHomePage() {
|
||||
setFilterOpen(true)
|
||||
}}
|
||||
>
|
||||
筛选{activeCount > 0 ? ` (${activeCount})` : ''}
|
||||
</button>
|
||||
<button type="button" onClick={() => setSortOpen(true)}>
|
||||
{sortLabel} <DownOutline />
|
||||
筛选{activeCount > 0 ? ` ${activeCount}` : ''}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{isError ? (
|
||||
{listings.isError ? (
|
||||
<div className="mobile-error">
|
||||
<ErrorBlock
|
||||
status="disconnected"
|
||||
title="商品没有加载出来"
|
||||
description="后端服务可能暂时不可用,你的账号和订单不受影响。"
|
||||
/>
|
||||
<Button color="primary" size="small" onClick={() => void refetch()}>
|
||||
<Button color="primary" size="small" onClick={() => void listings.refetch()}>
|
||||
重试
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<PullToRefresh onRefresh={() => refetch().then(() => undefined)}>
|
||||
{isPending ? (
|
||||
<PullToRefresh onRefresh={() => listings.refetch().then(() => undefined)}>
|
||||
{listings.isPending ? (
|
||||
<div className="mobile-skeleton-list">
|
||||
{Array.from({ length: 3 }).map((_, index) => (
|
||||
<div className="mobile-skeleton-card" key={index}>
|
||||
<Skeleton animated className="mobile-skeleton-cover" />
|
||||
<Skeleton.Paragraph lineCount={3} animated />
|
||||
<Skeleton.Paragraph lineCount={4} animated />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : data?.items.length ? (
|
||||
<div className="mobile-listing-list">
|
||||
{data.items.map(item => (
|
||||
<MobileListingCard item={item} key={item.id} />
|
||||
))}
|
||||
</div>
|
||||
) : items.length ? (
|
||||
<>
|
||||
<div className="mobile-listing-list">
|
||||
{items.map(item => (
|
||||
<MobileListingCard item={item} key={item.id} />
|
||||
))}
|
||||
</div>
|
||||
<div className="mobile-list-more">
|
||||
{listings.hasNextPage ? (
|
||||
<Button
|
||||
block
|
||||
fill="outline"
|
||||
loading={listings.isFetchingNextPage}
|
||||
onClick={() => void listings.fetchNextPage()}
|
||||
>
|
||||
加载更多账号
|
||||
</Button>
|
||||
) : (
|
||||
<span>已经看到全部账号</span>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="mobile-empty">
|
||||
<Empty description="还没有符合条件的商品" />
|
||||
<Button
|
||||
size="small"
|
||||
color="primary"
|
||||
onClick={() => {
|
||||
setKeyword('')
|
||||
setSearchValue('')
|
||||
setFilters(emptyListingFilters)
|
||||
setZone('all')
|
||||
setSort('')
|
||||
}}
|
||||
>
|
||||
<Button size="small" color="primary" onClick={resetFilters}>
|
||||
查看全部
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</PullToRefresh>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section className="mobile-rules">
|
||||
<span className="mobile-eyebrow">RULES, IN PLAIN WORDS</span>
|
||||
<h2>先把规则说明白</h2>
|
||||
<p>押金、租金、额外消耗和退款规则都会在订单里逐项列出。结账备注不参与系统结算。</p>
|
||||
<p>押金、租金、额外消耗和退款规则都会在订单里逐项列出。</p>
|
||||
</section>
|
||||
|
||||
<Popup
|
||||
visible={filterOpen}
|
||||
onMaskClick={() => setFilterOpen(false)}
|
||||
bodyStyle={{
|
||||
height: '72vh',
|
||||
height: '82vh',
|
||||
overflowY: 'auto',
|
||||
borderTopLeftRadius: 16,
|
||||
borderTopRightRadius: 16,
|
||||
@@ -341,58 +666,65 @@ export function MobileHomePage() {
|
||||
<div className="mobile-filter-sheet">
|
||||
<div className="mobile-filter-sheet__head">
|
||||
<strong>筛选条件</strong>
|
||||
<button type="button" onClick={resetDraft}>
|
||||
<button type="button" onClick={() => setDraft(emptyListingFilters)}>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="mobile-filter-group">
|
||||
<span className="mobile-filter-group__label">哈夫币</span>
|
||||
<div className="mobile-filter-chips">
|
||||
{coinRanges.map(option => (
|
||||
<button
|
||||
key={option.key}
|
||||
type="button"
|
||||
className={`mobile-filter-chip${draft.coinKey === option.key ? ' is-active' : ''}`}
|
||||
onClick={() => toggleRange('coinKey', option.key)}
|
||||
>
|
||||
{option.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mobile-filter-group">
|
||||
<span className="mobile-filter-group__label">租金</span>
|
||||
<div className="mobile-filter-chips">
|
||||
{priceRanges.map(option => (
|
||||
<button
|
||||
key={option.key}
|
||||
type="button"
|
||||
className={`mobile-filter-chip${draft.priceKey === option.key ? ' is-active' : ''}`}
|
||||
onClick={() => toggleRange('priceKey', option.key)}
|
||||
>
|
||||
{option.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mobile-filter-group">
|
||||
<span className="mobile-filter-group__label">比例</span>
|
||||
<div className="mobile-filter-chips">
|
||||
{ratioRanges.map(option => (
|
||||
<button
|
||||
key={option.key}
|
||||
type="button"
|
||||
className={`mobile-filter-chip${draft.ratioKey === option.key ? ' is-active' : ''}`}
|
||||
onClick={() => toggleRange('ratioKey', option.key)}
|
||||
>
|
||||
{option.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<MobileRangeGroup
|
||||
label="哈夫币"
|
||||
options={coinRanges}
|
||||
activeKey={draft.coinKey}
|
||||
onSelect={key => toggleRange('coinKey', key)}
|
||||
/>
|
||||
<MobileRangeGroup
|
||||
label="租金"
|
||||
options={priceRanges}
|
||||
activeKey={draft.priceKey}
|
||||
onSelect={key => toggleRange('priceKey', key)}
|
||||
/>
|
||||
<MobileRangeGroup
|
||||
label="比例"
|
||||
options={ratioRanges}
|
||||
activeKey={draft.ratioKey}
|
||||
onSelect={key => toggleRange('ratioKey', key)}
|
||||
/>
|
||||
<MobileRangeGroup
|
||||
label="AWM"
|
||||
options={awmRanges}
|
||||
activeKey={draft.awmKey}
|
||||
onSelect={key => toggleRange('awmKey', key)}
|
||||
/>
|
||||
<MobileRangeGroup
|
||||
label="押金"
|
||||
options={depositRanges}
|
||||
activeKey={draft.depositKey}
|
||||
onSelect={key => toggleRange('depositKey', key)}
|
||||
/>
|
||||
<MobileRangeGroup
|
||||
label="合计金额"
|
||||
options={totalRanges}
|
||||
activeKey={draft.totalKey}
|
||||
onSelect={key => toggleRange('totalKey', key)}
|
||||
/>
|
||||
<MobileRangeGroup
|
||||
label="等级"
|
||||
options={fireLevelRanges}
|
||||
activeKey={draft.fireLevelKey}
|
||||
onSelect={key => toggleRange('fireLevelKey', key)}
|
||||
/>
|
||||
<MobileRangeGroup
|
||||
label="日消耗"
|
||||
options={dailyLossRanges}
|
||||
activeKey={draft.dailyLossKey}
|
||||
onSelect={key => toggleRange('dailyLossKey', key)}
|
||||
/>
|
||||
<MobileRangeGroup
|
||||
label="绝密KD"
|
||||
options={secretKdRanges}
|
||||
activeKey={draft.secretKdKey}
|
||||
onSelect={key => toggleRange('secretKdKey', key)}
|
||||
/>
|
||||
|
||||
<MobileChipGroup
|
||||
label="保险"
|
||||
@@ -418,6 +750,18 @@ export function MobileHomePage() {
|
||||
selected={draft.loginMethod}
|
||||
onToggle={option => toggleDraft('loginMethod', option)}
|
||||
/>
|
||||
<MobileChipGroup
|
||||
label="段位"
|
||||
options={rankOptions}
|
||||
selected={draft.ranks}
|
||||
onToggle={option => toggleDraft('ranks', option)}
|
||||
/>
|
||||
<MobileChipGroup
|
||||
label="IP地区"
|
||||
options={regionOptions}
|
||||
selected={draft.regions}
|
||||
onToggle={option => toggleDraft('regions', option)}
|
||||
/>
|
||||
{quickSkinGroups.map(group => (
|
||||
<MobileChipGroup
|
||||
key={group.key}
|
||||
@@ -461,6 +805,24 @@ export function MobileHomePage() {
|
||||
))}
|
||||
</div>
|
||||
</Popup>
|
||||
|
||||
<Popup
|
||||
visible={Boolean(entryPreview)}
|
||||
onMaskClick={() => setEntryPreview(null)}
|
||||
bodyStyle={{ borderTopLeftRadius: 16, borderTopRightRadius: 16 }}
|
||||
>
|
||||
{entryPreview ? (
|
||||
<div className="mobile-entry-preview">
|
||||
<strong>{entryPreview.title}</strong>
|
||||
<small>{entryPreview.subtitle}</small>
|
||||
{entryPreview.image_url ? (
|
||||
<img src={entryPreview.image_url} alt={entryPreview.title} />
|
||||
) : (
|
||||
<p>暂无更多说明</p>
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
</Popup>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,16 @@ import { useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import { BrandLogo } from '@/components/BrandLogo'
|
||||
import { useListingDetail } from '@/features/listings/api'
|
||||
import {
|
||||
banRecordText,
|
||||
faceOwnerText,
|
||||
gameNameChangeText,
|
||||
listingPriceDetail,
|
||||
listingRatioText,
|
||||
listingRentalDays,
|
||||
listingResources,
|
||||
resourceBadgeText,
|
||||
} from '@/features/listings/labels'
|
||||
import { ensureSupportConversation } from '@/features/messages/api'
|
||||
import { createOrder, useOrderAgreements, usePostRentalNotice } from '@/features/orders/api'
|
||||
import { useSessionStore } from '@/stores/session'
|
||||
@@ -143,8 +153,24 @@ export function MobileListingDetailPage() {
|
||||
? (data.asset_summary.online_time as unknown)
|
||||
: undefined
|
||||
const assetEntries = Object.entries(data.asset_summary || {}).filter(
|
||||
([key]) => key !== 'online_time'
|
||||
([key]) =>
|
||||
key !== 'online_time' &&
|
||||
key !== 'face_owner' &&
|
||||
key !== 'ban_record' &&
|
||||
key !== 'can_change_game_name' &&
|
||||
key !== 'modifiable_name' &&
|
||||
key !== 'pure_coin_price_cent' &&
|
||||
key !== 'extra_item_price_cent' &&
|
||||
key !== 'publish_ratio' &&
|
||||
key !== 'resources'
|
||||
)
|
||||
const rentalDays = listingRentalDays(data)
|
||||
const faceOwner = faceOwnerText(data.asset_summary)
|
||||
const banRecord = banRecordText(data.asset_summary)
|
||||
const gameNameChange = gameNameChangeText(data.asset_summary)
|
||||
const ratio = listingRatioText(data)
|
||||
const resources = listingResources(data.asset_summary)
|
||||
const priceDetail = listingPriceDetail(data, { compact: true })
|
||||
const isOwner = user?.id === data.owner_id
|
||||
|
||||
return (
|
||||
@@ -178,6 +204,9 @@ export function MobileListingDetailPage() {
|
||||
<div>
|
||||
<span>租金</span>
|
||||
<strong>{money(data.price_cent)}</strong>
|
||||
{priceDetail ? (
|
||||
<small className="mobile-detail__price-detail">{priceDetail}</small>
|
||||
) : null}
|
||||
</div>
|
||||
<div>
|
||||
<span>押金</span>
|
||||
@@ -197,6 +226,12 @@ export function MobileListingDetailPage() {
|
||||
<section className="mobile-detail__section">
|
||||
<h2>资产摘要</h2>
|
||||
<dl className="mobile-detail__assets">
|
||||
{ratio ? (
|
||||
<div>
|
||||
<dt>折算比</dt>
|
||||
<dd>1 元 ≈ {ratio}</dd>
|
||||
</div>
|
||||
) : null}
|
||||
{assetEntries.length ? (
|
||||
assetEntries.map(([key, value]) => (
|
||||
<div key={key}>
|
||||
@@ -210,6 +245,30 @@ export function MobileListingDetailPage() {
|
||||
<dd>未填写</dd>
|
||||
</div>
|
||||
)}
|
||||
{faceOwner ? (
|
||||
<div>
|
||||
<dt>人脸情况</dt>
|
||||
<dd>{faceOwner}</dd>
|
||||
</div>
|
||||
) : null}
|
||||
{banRecord ? (
|
||||
<div>
|
||||
<dt>封禁记录</dt>
|
||||
<dd>{banRecord}</dd>
|
||||
</div>
|
||||
) : null}
|
||||
{gameNameChange ? (
|
||||
<div>
|
||||
<dt>可改游戏名</dt>
|
||||
<dd>{gameNameChange}</dd>
|
||||
</div>
|
||||
) : null}
|
||||
{rentalDays ? (
|
||||
<div>
|
||||
<dt>预计租期</dt>
|
||||
<dd>{rentalDays} 天</dd>
|
||||
</div>
|
||||
) : null}
|
||||
<div>
|
||||
<dt>在线时间</dt>
|
||||
<dd>{assetValue(onlineTime)}</dd>
|
||||
@@ -217,6 +276,25 @@ export function MobileListingDetailPage() {
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
{resources.length ? (
|
||||
<section className="mobile-detail__section">
|
||||
<h2>仓库物资</h2>
|
||||
<dl className="mobile-detail__assets">
|
||||
{resources.map(row => (
|
||||
<div key={row.label}>
|
||||
<dt>{row.label}</dt>
|
||||
<dd>
|
||||
{row.quantity} 个
|
||||
<span className={`mobile-detail__resource-mode is-${row.mode}`}>
|
||||
{resourceBadgeText(row)}
|
||||
</span>
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
<section className="mobile-detail__notice">
|
||||
<strong>先看清规则,再决定要不要租</strong>
|
||||
<p>押金、租金、额外消耗和退款规则会在下单页逐项列出;交接、归还、结账全程留痕。</p>
|
||||
|
||||
@@ -1,7 +1,29 @@
|
||||
import { Button, List, Tag } from 'antd-mobile'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import type { ReactNode } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { Button, Dialog, Tag } from 'antd-mobile'
|
||||
import {
|
||||
AddCircleOutline,
|
||||
BillOutline,
|
||||
CheckCircleOutline,
|
||||
ClockCircleOutline,
|
||||
GiftOutline,
|
||||
GlobalOutline,
|
||||
MessageOutline,
|
||||
PayCircleOutline,
|
||||
RightOutline,
|
||||
SetOutline,
|
||||
ShopbagOutline,
|
||||
StarOutline,
|
||||
TruckOutline,
|
||||
UserCircleOutline,
|
||||
UserContactOutline,
|
||||
VideoOutline,
|
||||
} from 'antd-mobile-icons'
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
|
||||
import { BrandLogo } from '@/components/BrandLogo'
|
||||
import { fetchWalletBalance } from '@/features/wallet/api'
|
||||
import { formatMoney } from '@/shared/utils/format'
|
||||
import { useSessionStore } from '@/stores/session'
|
||||
|
||||
const realnameLabel: Record<string, string> = {
|
||||
@@ -10,61 +32,200 @@ const realnameLabel: Record<string, string> = {
|
||||
rejected: '未通过',
|
||||
}
|
||||
|
||||
interface ServiceItem {
|
||||
label: string
|
||||
icon: ReactNode
|
||||
to: string
|
||||
}
|
||||
|
||||
const buyerServices: ServiceItem[] = [
|
||||
{ label: '全部订单', icon: <BillOutline />, to: '/m/orders' },
|
||||
{ label: '待支付', icon: <ClockCircleOutline />, to: '/m/orders?tab=pending_payment' },
|
||||
{ label: '待交接', icon: <TruckOutline />, to: '/m/orders?tab=pending_handoff' },
|
||||
{ label: '使用中', icon: <VideoOutline />, to: '/m/orders?tab=renting' },
|
||||
{ label: '已完成', icon: <CheckCircleOutline />, to: '/m/orders?tab=completed' },
|
||||
{ label: '我的足迹', icon: <StarOutline />, to: '/m/listings/collections' },
|
||||
]
|
||||
|
||||
const sellerServices: ServiceItem[] = [
|
||||
{ label: '发布商品', icon: <AddCircleOutline />, to: '/m/seller/listings/new' },
|
||||
{ label: '我的商品', icon: <ShopbagOutline />, to: '/m/seller/listings' },
|
||||
{ label: '提现', icon: <PayCircleOutline />, to: '/m/wallet/withdrawal' },
|
||||
{ label: '撞车商城', icon: <GiftOutline />, to: '/m/crash' },
|
||||
]
|
||||
|
||||
const publicServices: ServiceItem[] = [
|
||||
{ label: '消息中心', icon: <MessageOutline />, to: '/m/messages' },
|
||||
{ label: '邀请好友', icon: <GiftOutline />, to: '/m/invitations' },
|
||||
{ label: '公告中心', icon: <GlobalOutline />, to: '/m/announcements' },
|
||||
{ label: '实名认证', icon: <UserContactOutline />, to: '/m/realname' },
|
||||
]
|
||||
|
||||
function ServiceGrid({ items }: { items: ServiceItem[] }) {
|
||||
return (
|
||||
<div className="mobile-service-grid">
|
||||
{items.map(item => (
|
||||
<Link to={item.to} className="mobile-service-item" key={item.label}>
|
||||
<span>{item.icon}</span>
|
||||
<strong>{item.label}</strong>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function MobileProfilePage() {
|
||||
const navigate = useNavigate()
|
||||
const user = useSessionStore(state => state.user)
|
||||
const token = useSessionStore(state => state.token)
|
||||
const logout = useSessionStore(state => state.logout)
|
||||
const wallet = useQuery({
|
||||
queryKey: ['wallet-balance', 'mobile-profile'],
|
||||
queryFn: fetchWalletBalance,
|
||||
enabled: Boolean(token),
|
||||
})
|
||||
const realnameStatus = user?.realname_status || 'unverified'
|
||||
const realnameTone =
|
||||
realnameStatus === 'verified' ? 'success' : realnameStatus === 'rejected' ? 'danger' : 'default'
|
||||
const qualityOwner = user?.quality_owner_status === 'active'
|
||||
|
||||
const handleLogout = async () => {
|
||||
const confirmed = await Dialog.confirm({
|
||||
content: '确定退出当前账号吗?',
|
||||
confirmText: '退出',
|
||||
cancelText: '取消',
|
||||
})
|
||||
if (!confirmed) return
|
||||
await logout()
|
||||
navigate('/m')
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mobile-profile">
|
||||
<section className="mobile-profile__head">
|
||||
<BrandLogo height={42} variant="seal" />
|
||||
<div>
|
||||
<h1>{user ? user.nickname || '我的商行' : '还没登录'}</h1>
|
||||
<p>{user ? user.phone : '登录后查看订单、钱包与实名状态'}</p>
|
||||
<section className={`mobile-profile-hero${user ? '' : ' is-guest'}`}>
|
||||
<div className="mobile-profile-hero__top">
|
||||
<div className="mobile-profile-avatar">
|
||||
{user ? user.nickname?.slice(0, 1) || user.phone.slice(-1) : <UserCircleOutline />}
|
||||
</div>
|
||||
<div className="mobile-profile-identity">
|
||||
<div>
|
||||
<h1>{user ? user.nickname || `用户${user.phone.slice(-6)}` : '立即登录'}</h1>
|
||||
{user ? (
|
||||
<Tag color={realnameStatus === 'verified' ? 'success' : 'default'} fill="outline">
|
||||
{realnameLabel[realnameStatus] || '未实名'}
|
||||
</Tag>
|
||||
) : null}
|
||||
{qualityOwner ? <Tag color="warning">优质号主</Tag> : null}
|
||||
</div>
|
||||
<p>
|
||||
{user
|
||||
? `ID: ${user.id} · ${user.phone.slice(0, 3)}****${user.phone.slice(-4)}`
|
||||
: '登录后查看订单、余额与账号收益'}
|
||||
</p>
|
||||
</div>
|
||||
{user ? (
|
||||
<button
|
||||
type="button"
|
||||
className="mobile-profile-settings"
|
||||
onClick={() => void handleLogout()}
|
||||
>
|
||||
<SetOutline />
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<List className="mobile-profile__list">
|
||||
<List.Item extra={user ? '已登录' : '未登录'}>账号状态</List.Item>
|
||||
<List.Item
|
||||
clickable
|
||||
onClick={() => navigate(user ? '/m/realname' : '/m/login?redirect=/m/realname')}
|
||||
extra={<Tag color={realnameTone}>{realnameLabel[realnameStatus] ?? '未实名'}</Tag>}
|
||||
>
|
||||
实名认证
|
||||
</List.Item>
|
||||
<List.Item onClick={() => navigate('/m/orders')}>我的订单</List.Item>
|
||||
<List.Item onClick={() => navigate('/m/messages')}>消息中心</List.Item>
|
||||
<List.Item
|
||||
onClick={() =>
|
||||
navigate(user ? '/m/seller/listings' : '/m/login?redirect=/m/seller/listings')
|
||||
}
|
||||
>
|
||||
卖家中心
|
||||
</List.Item>
|
||||
</List>
|
||||
|
||||
<div className="mobile-profile__actions">
|
||||
{user ? (
|
||||
<Button
|
||||
block
|
||||
onClick={async () => {
|
||||
await logout()
|
||||
navigate('/m')
|
||||
}}
|
||||
>
|
||||
退出登录
|
||||
</Button>
|
||||
<div className="mobile-profile-assets">
|
||||
<div>
|
||||
<span>账户余额</span>
|
||||
<strong>
|
||||
{wallet.data ? formatMoney(wallet.data.available_balance_cent) : '加载中'}
|
||||
</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>可用积分</span>
|
||||
<strong>{user.points_available ?? 0}</strong>
|
||||
</div>
|
||||
<button type="button" onClick={() => navigate('/m/wallet/withdrawal')}>
|
||||
提现
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<Button block color="primary" onClick={() => navigate('/m/login')}>
|
||||
登录 / 注册
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="mobile-primary-actions">
|
||||
<Link to="/m" className="mobile-primary-action is-rent">
|
||||
<span>
|
||||
<ShopbagOutline />
|
||||
</span>
|
||||
<div>
|
||||
<strong>我要租号</strong>
|
||||
<small>海量账号任你挑选</small>
|
||||
</div>
|
||||
<RightOutline />
|
||||
</Link>
|
||||
<Link to="/m/seller/listings/new" className="mobile-primary-action is-sell">
|
||||
<span>
|
||||
<AddCircleOutline />
|
||||
</span>
|
||||
<div>
|
||||
<strong>我要出号</strong>
|
||||
<small>闲置账号快速出租</small>
|
||||
</div>
|
||||
<RightOutline />
|
||||
</Link>
|
||||
</section>
|
||||
|
||||
<section className="mobile-profile-section">
|
||||
<div className="mobile-profile-section__head">
|
||||
<div>
|
||||
<span>买家中心</span>
|
||||
<strong>我的租用</strong>
|
||||
</div>
|
||||
<Link to="/m/orders">
|
||||
全部订单 <RightOutline />
|
||||
</Link>
|
||||
</div>
|
||||
<ServiceGrid items={buyerServices} />
|
||||
</section>
|
||||
|
||||
<section className="mobile-profile-section">
|
||||
<div className="mobile-profile-section__head">
|
||||
<div>
|
||||
<span>卖家中心</span>
|
||||
<strong>账号出租</strong>
|
||||
</div>
|
||||
<Link to="/m/seller/listings">
|
||||
商品管理 <RightOutline />
|
||||
</Link>
|
||||
</div>
|
||||
<ServiceGrid items={sellerServices} />
|
||||
</section>
|
||||
|
||||
<section className="mobile-profile-section">
|
||||
<div className="mobile-profile-section__head">
|
||||
<div>
|
||||
<span>公共服务</span>
|
||||
<strong>账户与服务</strong>
|
||||
</div>
|
||||
</div>
|
||||
<ServiceGrid items={publicServices} />
|
||||
</section>
|
||||
|
||||
{user ? (
|
||||
<section className="mobile-profile-account">
|
||||
<BrandLogo height={28} />
|
||||
<div>
|
||||
<strong>{user.nickname || '解忧商行用户'}</strong>
|
||||
<span>成长等级:{user.renter_growth_level_name || '普通用户'}</span>
|
||||
</div>
|
||||
<Button size="small" fill="none" onClick={() => void handleLogout()}>
|
||||
退出
|
||||
</Button>
|
||||
</section>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,12 @@ import {
|
||||
} from '@ant-design/icons'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import { listingReviewStatusMeta, listingStatusMeta } from '@/features/listings/labels'
|
||||
import {
|
||||
faceOwnerText,
|
||||
gameNameChangeText,
|
||||
listingReviewStatusMeta,
|
||||
listingStatusMeta,
|
||||
} from '@/features/listings/labels'
|
||||
import type { StatusMeta } from '@/features/admin/labels'
|
||||
import { useSessionStore } from '@/stores/session'
|
||||
import { confirmModal } from '@/shared/utils/confirm'
|
||||
@@ -328,8 +333,9 @@ export function SellerListingDetailPage({ mobile = false }: { mobile?: boolean }
|
||||
['哈夫币', coinText(listing)],
|
||||
['每日损耗', summary.daily_loss_m ? `${numberValue(summary.daily_loss_m)}M/天` : '—'],
|
||||
['在线时间', onlineTimeText(summary)],
|
||||
['人脸情况', faceOwnerText(summary) || '—'],
|
||||
['凌晨响应', stringValue(summary.early_morning_response) || '—'],
|
||||
['可改游戏名', stringValue(summary.can_change_game_name) || '—'],
|
||||
['可改游戏名', gameNameChangeText(summary) || '—'],
|
||||
['全英雄', stringValue(summary.all_hero) || '—'],
|
||||
['解锁德穆兰', stringValue(summary.unlock_demulan) || '—'],
|
||||
['下赛季通行证', stringValue(summary.next_season_pass) || '—'],
|
||||
|
||||
@@ -153,10 +153,11 @@ function ChoiceField(props: {
|
||||
required?: boolean
|
||||
value: string
|
||||
options: string[]
|
||||
optionLabels?: Record<string, string>
|
||||
placeholder?: string
|
||||
onChange: (value: string) => void
|
||||
}) {
|
||||
const { label, required, value, options, placeholder, onChange } = props
|
||||
const { label, required, value, options, optionLabels, placeholder, onChange } = props
|
||||
return (
|
||||
<div className="seller-field">
|
||||
<span className="seller-field__label">
|
||||
@@ -182,7 +183,7 @@ function ChoiceField(props: {
|
||||
onChange(option)
|
||||
}}
|
||||
>
|
||||
{option}
|
||||
{optionLabels?.[option] ?? option}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
@@ -1183,6 +1184,7 @@ export function SellerListingFormPage({ mobile = false }: { mobile?: boolean } =
|
||||
label="人脸情况"
|
||||
value={form.face_owner}
|
||||
options={options.face_options}
|
||||
optionLabels={{ 是: '本人', 否: '非本人' }}
|
||||
onChange={value => updateForm('face_owner', value)}
|
||||
/>
|
||||
<ChoiceField
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
Breadcrumb,
|
||||
Button,
|
||||
Dropdown,
|
||||
Grid,
|
||||
Layout,
|
||||
Menu,
|
||||
Tag,
|
||||
@@ -462,6 +463,15 @@ const MENU_ALIASES: Record<string, string> = {
|
||||
'/distribution/qrcodes': '/distribution/qrcode-pool',
|
||||
}
|
||||
|
||||
function resolveMenuKey(path: string) {
|
||||
const alias = MENU_ALIASES[path]
|
||||
if (alias) return alias
|
||||
if (/^\/orders\/[^/]+$/.test(path)) return '/orders'
|
||||
if (/^\/listings\/review\/[^/]+$/.test(path)) return '/listings/review'
|
||||
if (/^\/listings\/[^/]+$/.test(path)) return '/listings'
|
||||
return path
|
||||
}
|
||||
|
||||
const SUPPORT_STATUS_LABELS: Record<string, string> = {
|
||||
online: '在线',
|
||||
busy: '忙碌',
|
||||
@@ -475,6 +485,12 @@ export function AdminLayout() {
|
||||
const logout = useAdminSessionStore(state => state.logout)
|
||||
const { message } = App.useApp()
|
||||
const [collapsed, setCollapsed] = useState(false)
|
||||
const screens = Grid.useBreakpoint()
|
||||
const isMobile = screens.md === false
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof screens.md === 'boolean') setCollapsed(!screens.md)
|
||||
}, [screens.md])
|
||||
const [openKeys, setOpenKeys] = useState<string[]>([])
|
||||
const [supportStatus, setSupportStatus] = useState<'online' | 'offline' | 'busy'>(
|
||||
admin?.support_status ?? 'offline'
|
||||
@@ -500,7 +516,7 @@ export function AdminLayout() {
|
||||
location.pathname.startsWith(basePath) && location.pathname !== basePath
|
||||
? location.pathname.slice(basePath.length)
|
||||
: '/'
|
||||
const selectedKey = MENU_ALIASES[relativePath] ?? relativePath
|
||||
const selectedKey = resolveMenuKey(relativePath)
|
||||
|
||||
const can = (permission?: string) => {
|
||||
if (!permission) return true
|
||||
@@ -564,7 +580,7 @@ export function AdminLayout() {
|
||||
className="admin-sider"
|
||||
theme="light"
|
||||
width={240}
|
||||
collapsedWidth={72}
|
||||
collapsedWidth={isMobile ? 0 : 72}
|
||||
collapsed={collapsed}
|
||||
trigger={null}
|
||||
>
|
||||
@@ -588,6 +604,7 @@ export function AdminLayout() {
|
||||
onClick={({ key }) => {
|
||||
if (key.startsWith('/')) {
|
||||
navigate(key === '/' ? basePath : `${basePath}${key}`)
|
||||
if (isMobile) setCollapsed(true)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
import 'antd-mobile/es/global'
|
||||
|
||||
import { TabBar } from 'antd-mobile'
|
||||
import { AppOutline, MessageOutline, UnorderedListOutline, UserOutline } from 'antd-mobile-icons'
|
||||
import { Link, Outlet, useLocation, useNavigate } from 'react-router-dom'
|
||||
import {
|
||||
AddOutline,
|
||||
AppOutline,
|
||||
MessageOutline,
|
||||
UnorderedListOutline,
|
||||
UserOutline,
|
||||
} from 'antd-mobile-icons'
|
||||
import { Link, Outlet, useLocation } from 'react-router-dom'
|
||||
|
||||
import { BrandLogo } from '@/components/BrandLogo'
|
||||
import { useChatUnreadCount } from '@/features/messages/api'
|
||||
@@ -11,63 +16,87 @@ import { useSessionStore } from '@/stores/session'
|
||||
const tabs = [
|
||||
{ key: '/m', title: '首页', icon: <AppOutline /> },
|
||||
{ key: '/m/orders', title: '订单', icon: <UnorderedListOutline /> },
|
||||
{ key: '/m/seller/listings/new', title: '发布', icon: <AddOutline />, primary: true },
|
||||
{ key: '/m/messages', title: '消息', icon: <MessageOutline /> },
|
||||
{ key: '/m/profile', title: '我的', icon: <UserOutline /> },
|
||||
]
|
||||
|
||||
function activeTab(pathname: string) {
|
||||
if (pathname.startsWith('/m/orders') || pathname.startsWith('/m/chats')) return '/m/orders'
|
||||
if (pathname.startsWith('/m/messages')) return '/m/messages'
|
||||
if (pathname.startsWith('/m/orders') || pathname.startsWith('/m/crash/orders')) {
|
||||
return '/m/orders'
|
||||
}
|
||||
if (pathname.startsWith('/m/messages') || pathname.startsWith('/m/chats')) {
|
||||
return '/m/messages'
|
||||
}
|
||||
if (pathname.startsWith('/m/profile')) return '/m/profile'
|
||||
if (pathname.startsWith('/m/seller/listings/new')) return '/m/seller/listings/new'
|
||||
return '/m'
|
||||
}
|
||||
|
||||
export function MobileLayout() {
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
const user = useSessionStore(state => state.user)
|
||||
const chatUnread = useChatUnreadCount(Boolean(user))
|
||||
const unreadBadge = chatUnread.data && chatUnread.data > 0 ? chatUnread.data : undefined
|
||||
const hideTabbar =
|
||||
const unreadCount = chatUnread.data ?? 0
|
||||
const active = activeTab(location.pathname)
|
||||
const hideChrome =
|
||||
/^\/m\/listings\/[^/]+$/.test(location.pathname) ||
|
||||
/^\/m\/orders\/[^/]+$/.test(location.pathname) ||
|
||||
/^\/m\/messages\/[^/]+$/.test(location.pathname)
|
||||
/^\/m\/messages\/[^/]+$/.test(location.pathname) ||
|
||||
/^\/m\/crash\/[^/]+$/.test(location.pathname) ||
|
||||
location.pathname === '/m/login' ||
|
||||
location.pathname === '/m/register' ||
|
||||
location.pathname === '/m/add-home-guide'
|
||||
|
||||
return (
|
||||
<div className={`mobile-shell${hideTabbar ? ' mobile-shell--no-tabbar' : ''}`}>
|
||||
<header className="mobile-header">
|
||||
<Link to="/m" className="mobile-header__brand" aria-label="解忧商行移动端首页">
|
||||
<BrandLogo height={30} />
|
||||
</Link>
|
||||
<div className="mobile-header__right">
|
||||
{user ? (
|
||||
<Link to="/m/profile" className="mobile-header__user">
|
||||
{user.nickname || '我的'}
|
||||
<div className={`mobile-shell${hideChrome ? ' mobile-shell--detail' : ''}`}>
|
||||
{hideChrome ? null : (
|
||||
<header className="mobile-header">
|
||||
<Link to="/m" className="mobile-header__brand" aria-label="解忧商行移动端首页">
|
||||
<BrandLogo height={30} />
|
||||
</Link>
|
||||
<div className="mobile-header__right">
|
||||
<Link to="/m/messages" className="mobile-header__icon" aria-label="消息中心">
|
||||
<MessageOutline />
|
||||
{unreadCount > 0 ? (
|
||||
<em className="mobile-header__badge">{unreadCount > 99 ? '99+' : unreadCount}</em>
|
||||
) : null}
|
||||
</Link>
|
||||
) : (
|
||||
<Link to="/m/login" className="mobile-header__login">
|
||||
登录
|
||||
<Link to={user ? '/m/profile' : '/m/login'} className="mobile-header__user">
|
||||
{user ? user.nickname || '我的' : '登录'}
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
</header>
|
||||
)}
|
||||
|
||||
<main className="mobile-content">
|
||||
<Outlet />
|
||||
</main>
|
||||
|
||||
<div className="mobile-tabbar" hidden={hideTabbar}>
|
||||
<TabBar activeKey={activeTab(location.pathname)} onChange={key => navigate(key)} safeArea>
|
||||
{tabs.map(tab => (
|
||||
<TabBar.Item
|
||||
key={tab.key}
|
||||
icon={tab.icon}
|
||||
title={tab.title}
|
||||
badge={tab.key === '/m/messages' ? unreadBadge : undefined}
|
||||
/>
|
||||
))}
|
||||
</TabBar>
|
||||
</div>
|
||||
{hideChrome ? null : (
|
||||
<nav className="mobile-tabbar" aria-label="移动端主导航">
|
||||
{tabs.map(tab => {
|
||||
const selected = active === tab.key
|
||||
return (
|
||||
<Link
|
||||
key={tab.key}
|
||||
to={tab.key}
|
||||
className={`mobile-tab${selected ? ' is-active' : ''}${
|
||||
tab.primary ? ' is-primary' : ''
|
||||
}`}
|
||||
>
|
||||
<span className="mobile-tab__icon">
|
||||
{tab.icon}
|
||||
{tab.key === '/m/messages' && unreadCount > 0 ? (
|
||||
<em className="mobile-tab__badge">{unreadCount > 99 ? '99+' : unreadCount}</em>
|
||||
) : null}
|
||||
</span>
|
||||
<span className="mobile-tab__title">{tab.title}</span>
|
||||
</Link>
|
||||
)
|
||||
})}
|
||||
</nav>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@ export function getAdminHomePath() {
|
||||
return getAdminBasePath()
|
||||
}
|
||||
|
||||
export function getAdminPath(path: string) {
|
||||
const suffix = path.startsWith('/') ? path : `/${path}`
|
||||
return `${getAdminBasePath()}${suffix}`
|
||||
}
|
||||
|
||||
function isAdminLoginPage() {
|
||||
return window.location.pathname === getAdminLoginPath()
|
||||
}
|
||||
|
||||
@@ -13,6 +13,12 @@ export interface AuthUser {
|
||||
risk_status?: string
|
||||
credit_score?: number
|
||||
status?: string
|
||||
renter_growth_level?: string
|
||||
renter_growth_level_name?: string
|
||||
renter_growth_points?: number
|
||||
points_available?: number
|
||||
quality_owner_status?: string
|
||||
deposit_free_quota_cent?: number
|
||||
}
|
||||
|
||||
export interface TokenPair {
|
||||
@@ -46,6 +52,10 @@ export interface Listing {
|
||||
price_cent: number
|
||||
deposit_amount_cent: number
|
||||
is_accelerated_sale?: boolean
|
||||
is_premium?: boolean
|
||||
owner_is_quality_owner?: boolean
|
||||
compensation_plan?: string
|
||||
insurance_fee_bps?: number
|
||||
in_transaction: boolean
|
||||
status: string
|
||||
review_status: string
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { getMobilePath } from './mobileHost'
|
||||
|
||||
describe('getMobilePath', () => {
|
||||
it('maps storefront routes to the dedicated mobile tree', () => {
|
||||
expect(getMobilePath('/')).toBe('/m')
|
||||
expect(getMobilePath('/listings/12')).toBe('/m/listings/12')
|
||||
expect(getMobilePath('/orders/9')).toBe('/m/orders/9')
|
||||
expect(getMobilePath('/messages/3')).toBe('/m/messages/3')
|
||||
expect(getMobilePath('/seller/listings/new')).toBe('/m/seller/listings/new')
|
||||
expect(getMobilePath('/i/ABC123')).toBe('/m/i/ABC123')
|
||||
})
|
||||
|
||||
it('keeps mobile and admin routes unchanged', () => {
|
||||
expect(getMobilePath('/m/profile')).toBe('/m/profile')
|
||||
expect(getMobilePath('/console-jy8k3m/users')).toBe('/console-jy8k3m/users')
|
||||
})
|
||||
|
||||
it('does not invent mobile pages for unsupported static pages', () => {
|
||||
expect(getMobilePath('/rules')).toBe('/rules')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,51 @@
|
||||
import { getAdminBasePath } from '@/shared/api/adminClient'
|
||||
|
||||
export const DESKTOP_PREFERENCE_KEY = 'jieyou:prefer-desktop'
|
||||
|
||||
const mobileUserAgentPattern =
|
||||
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile/i
|
||||
|
||||
export function isMobileDevice() {
|
||||
if (typeof window === 'undefined') return false
|
||||
return mobileUserAgentPattern.test(window.navigator.userAgent) || window.innerWidth < 768
|
||||
}
|
||||
|
||||
export function prefersDesktopSite() {
|
||||
if (typeof window === 'undefined') return false
|
||||
return window.sessionStorage.getItem(DESKTOP_PREFERENCE_KEY) === '1'
|
||||
}
|
||||
|
||||
export function setDesktopPreference(enabled: boolean) {
|
||||
if (typeof window === 'undefined') return
|
||||
if (enabled) {
|
||||
window.sessionStorage.setItem(DESKTOP_PREFERENCE_KEY, '1')
|
||||
return
|
||||
}
|
||||
window.sessionStorage.removeItem(DESKTOP_PREFERENCE_KEY)
|
||||
}
|
||||
|
||||
export function getMobilePath(path: string): string {
|
||||
if (path === '/m' || path.startsWith('/m/')) return path
|
||||
|
||||
const adminBase = getAdminBasePath()
|
||||
if (path === adminBase || path.startsWith(`${adminBase}/`)) return path
|
||||
|
||||
if (path === '/') return '/m'
|
||||
if (path === '/login') return '/m/login'
|
||||
if (path === '/register') return '/m/register'
|
||||
if (path === '/realname') return '/m/realname'
|
||||
if (path === '/notifications') return '/m/notifications'
|
||||
if (path === '/invitations') return '/m/invitations'
|
||||
if (path === '/messages' || path.startsWith('/messages/')) return `/m${path}`
|
||||
if (path === '/announcements' || path.startsWith('/announcements/')) return `/m${path}`
|
||||
if (path === '/profile' || path === '/wallet') return '/m/profile'
|
||||
if (path === '/wallet/withdrawal') return '/m/wallet/withdrawal'
|
||||
|
||||
if (path === '/listings' || path.startsWith('/listings/')) return `/m${path}`
|
||||
if (path === '/orders' || path.startsWith('/orders/')) return `/m${path}`
|
||||
if (path === '/crash' || path.startsWith('/crash/')) return `/m${path}`
|
||||
if (path.startsWith('/seller/listings')) return `/m${path}`
|
||||
if (path.startsWith('/i/')) return `/m${path}`
|
||||
|
||||
return path
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
.admin-listing-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
gap: 1px;
|
||||
margin-bottom: 16px;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 12px;
|
||||
background: var(--line);
|
||||
}
|
||||
|
||||
.admin-listing-summary > div {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
padding: 14px 16px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.admin-listing-summary span {
|
||||
color: var(--ink-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-listing-summary strong {
|
||||
color: var(--ink);
|
||||
font-family: 'Inter', 'DIN Alternate', sans-serif;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.admin-resource-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.admin-resource-chip {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.admin-resource-chip > div {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.admin-resource-chip strong {
|
||||
color: var(--ink);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.admin-resource-chip span {
|
||||
color: var(--ink);
|
||||
font-family: 'Inter', 'DIN Alternate', sans-serif;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.admin-resource-chip em {
|
||||
align-self: flex-start;
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
background: #e8f7ee;
|
||||
color: #1f9d55;
|
||||
font-size: 11px;
|
||||
font-style: normal;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.admin-resource-chip.is-paid em {
|
||||
background: #fff0e6;
|
||||
color: #e8590c;
|
||||
}
|
||||
|
||||
.admin-resource-chip.is-unknown em {
|
||||
background: #f1f0e9;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.admin-skin-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.admin-screenshot-groups {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.admin-screenshot-group {
|
||||
min-width: 0;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 10px;
|
||||
background: var(--paper-warm);
|
||||
}
|
||||
|
||||
.admin-screenshot-group__title {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
color: var(--ink);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.admin-screenshot-group__title span {
|
||||
color: var(--ink-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.admin-screenshot-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.admin-screenshot-grid .ant-image {
|
||||
width: 100% !important;
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
.admin-screenshot-grid .ant-image,
|
||||
.admin-screenshot-grid img {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.admin-screenshot-grid img {
|
||||
width: 100% !important;
|
||||
height: 96px !important;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.admin-price-pipeline {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.admin-price-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 10px;
|
||||
background: #fbfaf6;
|
||||
}
|
||||
|
||||
.admin-price-card > span {
|
||||
color: var(--ink-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-price-card > strong {
|
||||
color: var(--ink);
|
||||
font-family: 'Inter', 'DIN Alternate', sans-serif;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.admin-price-card > small {
|
||||
color: var(--ink-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-price-card > div {
|
||||
color: var(--ink-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-price-card.is-buyer {
|
||||
border-color: rgba(166, 67, 50, 0.35);
|
||||
background: rgba(166, 67, 50, 0.04);
|
||||
}
|
||||
|
||||
.admin-price-card.is-buyer > strong {
|
||||
color: var(--brand-seal);
|
||||
}
|
||||
|
||||
.admin-price-arrow {
|
||||
color: var(--ink-muted);
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.admin-price-preview {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin: 0 0 16px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 10px;
|
||||
background: #f7f5ef;
|
||||
}
|
||||
|
||||
.admin-price-preview > div {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.admin-price-preview span {
|
||||
color: var(--ink-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-price-preview strong {
|
||||
color: var(--ink);
|
||||
font-family: 'Inter', 'DIN Alternate', sans-serif;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.admin-review-checklist {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.admin-review-check {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 8px 10px;
|
||||
border-radius: 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-review-check span {
|
||||
flex: 1;
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.admin-review-check em {
|
||||
color: inherit;
|
||||
font-size: 11px;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.admin-review-check.is-provided {
|
||||
background: #e8f7ee;
|
||||
color: #1f9d55;
|
||||
}
|
||||
|
||||
.admin-review-check.is-missing {
|
||||
background: #f7f5ef;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.admin-reason-pills {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.admin-reason-pill {
|
||||
padding: 5px 10px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 999px;
|
||||
background: #fff;
|
||||
color: var(--ink-secondary);
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-reason-pill.is-selected {
|
||||
border-color: var(--brand-seal);
|
||||
background: rgba(166, 67, 50, 0.08);
|
||||
color: var(--brand-seal);
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.admin-listing-summary {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.admin-price-pipeline {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.admin-price-arrow {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.admin-listing-summary {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.admin-price-pipeline,
|
||||
.admin-price-preview {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.admin-screenshot-groups {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.admin-screenshot-grid img {
|
||||
height: 78px !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
.admin-detail-toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin: 0 0 16px;
|
||||
}
|
||||
|
||||
.admin-order-metrics {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.admin-order-metric {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.admin-order-metric > span {
|
||||
color: var(--ink-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-order-metric > strong {
|
||||
color: var(--ink);
|
||||
font-size: 18px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.admin-order-metric > small {
|
||||
color: var(--ink-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-order-grid,
|
||||
.admin-listing-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.admin-order-grid > .admin-detail-card,
|
||||
.admin-listing-grid > .admin-detail-card {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.admin-detail-card--wide {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.admin-order-grid + .admin-detail-card,
|
||||
.admin-listing-grid + .admin-detail-card {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.admin-money-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.admin-money-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px dashed var(--line);
|
||||
font-size: 13px;
|
||||
color: var(--ink-secondary);
|
||||
}
|
||||
|
||||
.admin-money-row strong {
|
||||
color: var(--ink);
|
||||
font-family: 'Inter', 'DIN Alternate', sans-serif;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.admin-money-row.is-total {
|
||||
border-bottom: none;
|
||||
border-top: 1px solid var(--line);
|
||||
margin-top: 4px;
|
||||
padding-top: 12px;
|
||||
color: var(--ink);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.admin-money-row.is-total strong {
|
||||
color: var(--brand-seal);
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.admin-timeline-item {
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
|
||||
.admin-timeline-item__head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.admin-timeline-item__head span {
|
||||
color: var(--ink-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-timeline-item p {
|
||||
margin: 4px 0 0;
|
||||
color: var(--ink-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.admin-timeline-item__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 12px;
|
||||
margin-top: 4px;
|
||||
color: var(--ink-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-record-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.admin-record-item {
|
||||
padding: 12px 14px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 10px;
|
||||
background: #fbfaf6;
|
||||
}
|
||||
|
||||
.admin-record-item__head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.admin-record-item__head span {
|
||||
color: var(--ink-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-record-item__content {
|
||||
margin: 8px 0;
|
||||
color: var(--ink-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 1.7;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.admin-record-item__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 12px;
|
||||
color: var(--ink-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-snapshot-resources {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.admin-snapshot-resources span {
|
||||
padding: 4px 10px;
|
||||
border-radius: 8px;
|
||||
background: #f1f0e9;
|
||||
color: var(--ink-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-snapshot-json {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.admin-snapshot-json summary {
|
||||
cursor: pointer;
|
||||
color: var(--ink-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-snapshot-json pre {
|
||||
max-height: 320px;
|
||||
margin: 8px 0 0;
|
||||
padding: 12px;
|
||||
overflow: auto;
|
||||
border-radius: 8px;
|
||||
background: #f7f5ef;
|
||||
color: var(--ink-secondary);
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.admin-form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 0 16px;
|
||||
}
|
||||
|
||||
.admin-modal-hint {
|
||||
margin: 0 0 16px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
background: #f7f5ef;
|
||||
color: var(--ink-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.admin-detail-pre {
|
||||
margin-top: 12px;
|
||||
padding: 12px;
|
||||
border-radius: 8px;
|
||||
background: #f7f5ef;
|
||||
color: var(--ink-secondary);
|
||||
font-size: 12px;
|
||||
line-height: 1.7;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.admin-detail-evidence {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.admin-order-grid,
|
||||
.admin-listing-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.admin-form-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
@@ -2162,3 +2162,34 @@
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.admin-sider:not(.ant-layout-sider-collapsed) {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 40;
|
||||
height: 100vh;
|
||||
box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
|
||||
}
|
||||
|
||||
.admin-header {
|
||||
padding: 0 14px;
|
||||
}
|
||||
|
||||
.admin-header__left {
|
||||
min-width: 0;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.admin-header .ant-breadcrumb {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.admin-content {
|
||||
padding: 14px 12px 28px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
@import './wallet.css';
|
||||
@import './auth.css';
|
||||
@import './admin-misc.css';
|
||||
@import './admin-order-detail.css';
|
||||
@import './admin-listing-detail.css';
|
||||
@import './admin-login.css';
|
||||
@import './admin-shell.css';
|
||||
@import './admin-distribution.css';
|
||||
@@ -27,3 +29,4 @@
|
||||
@import './seller.css';
|
||||
@import './mobile-seller.css';
|
||||
@import './components.css';
|
||||
@import './mobile-refresh.css';
|
||||
|
||||
@@ -102,6 +102,15 @@
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.mobile-detail__price-detail {
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
color: var(--ink-muted);
|
||||
font-size: 9px;
|
||||
font-weight: 400;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.mobile-detail__section {
|
||||
padding: 20px 0 0;
|
||||
}
|
||||
@@ -133,6 +142,7 @@
|
||||
padding: 10px 0;
|
||||
border-bottom: 1px solid var(--line);
|
||||
font-size: 12px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.mobile-detail__assets dt {
|
||||
@@ -143,6 +153,29 @@
|
||||
margin: 0;
|
||||
color: var(--ink);
|
||||
text-align: right;
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.mobile-detail__resource-mode {
|
||||
display: inline-block;
|
||||
margin-left: 6px;
|
||||
padding: 0 6px;
|
||||
border-radius: 999px;
|
||||
background: #e8f7ee;
|
||||
color: #1f9d55;
|
||||
font-size: 11px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.mobile-detail__resource-mode.is-paid {
|
||||
background: #fff0e6;
|
||||
color: #e8590c;
|
||||
}
|
||||
|
||||
.mobile-detail__resource-mode.is-unknown {
|
||||
background: #f1f0e9;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.mobile-detail__notice {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -295,6 +295,26 @@
|
||||
color: var(--ink-secondary);
|
||||
}
|
||||
|
||||
.listing-row__resources span i {
|
||||
margin-left: 4px;
|
||||
padding: 0 4px;
|
||||
border-radius: 4px;
|
||||
background: rgba(47, 125, 92, 0.12);
|
||||
color: var(--success);
|
||||
font-size: 10px;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.listing-row__resources span.is-paid i {
|
||||
background: rgba(180, 83, 9, 0.12);
|
||||
color: #b45309;
|
||||
}
|
||||
|
||||
.listing-row__resources span.is-unknown i {
|
||||
background: rgba(0, 0, 0, 0.06);
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.listing-row__side {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -196,6 +196,24 @@
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.ld-price__detail {
|
||||
display: inline-block;
|
||||
margin-left: 6px;
|
||||
color: var(--ink-muted);
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
.ld-modal-detail {
|
||||
display: block;
|
||||
margin-top: 2px;
|
||||
color: var(--ink-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.ld-quick {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
@@ -381,13 +399,23 @@
|
||||
.ld-resource em {
|
||||
padding: 0 6px;
|
||||
border-radius: 999px;
|
||||
background: rgba(47, 125, 92, 0.12);
|
||||
color: var(--success);
|
||||
background: #e8f7ee;
|
||||
color: #1f9d55;
|
||||
font-size: 10px;
|
||||
font-style: normal;
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
.ld-resource em.is-paid {
|
||||
background: #fff0e6;
|
||||
color: #e8590c;
|
||||
}
|
||||
|
||||
.ld-resource em.is-unknown {
|
||||
background: #f1f0e9;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.ld-split {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
|
||||
Reference in New Issue
Block a user