import { useMemo, useState, type ReactNode } from 'react' import { useQuery } from '@tanstack/react-query' import { Button, Empty, ErrorBlock, Popup, PullToRefresh, SearchBar, Skeleton, Swiper, Tag, } from 'antd-mobile' 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 { 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: '夜间' }, { key: 'password', label: '账密' }, { key: 'highCoin', 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)}` } function assetText(item: Listing, key: string) { const value = item.asset_summary?.[key] if (value == null || value === '' || typeof value === 'object') return '' return String(value) } function MobileChipGroup({ label, options, selected, onToggle, }: { label: string options: string[] selected: string[] onToggle: (option: string) => void }) { if (options.length === 0) return null return (
{label}
{options.map(option => ( ))}
) } function MobileRangeGroup({ label, options, activeKey, onSelect, }: { label: string options: { key: string; label: string }[] activeKey?: string onSelect: (key: string) => void }) { return (
{label}
{options.map(option => ( ))}
) } 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 = [ { 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 (
{item.cover_url && !coverFailed ? ( {item.title} setCoverFailed(true)} /> ) : (
实拍图整理中
)} {item.is_premium || item.owner_is_quality_owner || item.compensation_plan === 'insurance' ? (
{item.owner_is_quality_owner ? 优质号主 : null} {item.is_premium ? 极品 : null} {item.compensation_plan === 'insurance' ? ( 保险 ) : null}
) : null}
{item.listing_no} {item.in_transaction ? '租赁中' : '可租'}

{item.title}

{formatCoinM(item.haf_coin_amount)} {ratio ? 1:{ratio} : null}
{specs.map(spec => ( {spec.label} {spec.value} ))} {resources.map(resource => ( {resource.label} {resource.quantity} {resourceBadgeText(resource, 'compact')} ))}
{money(item.price_cent)} 押金 {money(item.deposit_amount_cent)}
立即租
) } function QuickService({ to, icon, label, hint, onClick, }: { to?: string icon: ReactNode label: string hint: string onClick?: () => void }) { const content = ( <> {icon} {label} {hint} ) if (to) { return ( {content} ) } return ( ) } export function MobileHomePage() { const navigate = useNavigate() const [keyword, setKeyword] = useState('') const [searchValue, setSearchValue] = useState('') const [zone, setZone] = useState('all') const [sort, setSort] = useState('') const [filters, setFilters] = useState(emptyListingFilters) const [draft, setDraft] = useState(emptyListingFilters) const [filterOpen, setFilterOpen] = useState(false) const [sortOpen, setSortOpen] = useState(false) const [entryPreview, setEntryPreview] = useState(null) const homeConfig = useHomeConfig() const publishOptions = useQuery({ queryKey: ['listing-publish-options'], queryFn: fetchListingPublishOptions, staleTime: 300_000, }) 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 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 resetFilters = () => { setDraft(emptyListingFilters) setFilters(emptyListingFilters) setKeyword('') setSearchValue('') setZone('all') setSort('') } const toggleDraft = (key: MultiFilterKey, option: string) => { const current = draft[key] setDraft({ ...draft, [key]: current.includes(option) ? current.filter(item => item !== option) : [...current, option], }) } const toggleRange = (key: RangeFilterKey, nextKey: string) => { setDraft({ ...draft, [key]: draft[key] === nextKey ? undefined : nextKey }) } const activeCount = filters.insurance.length + filters.stamina.length + filters.load.length + filters.loginMethod.length + filters.ranks.length + filters.regions.length + filters.skinNames.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 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 (
解忧柜选 今天想租什么账号?
规则
} />
实名审核 找回包赔 客服护航 账单透明
{banners.map((banner, index) => { const imageURL = banner.mobile?.image_url || banner.image_url return ( ) })}
} label="我要租号" hint="海量账号" onClick={scrollToListings} /> } label="我要出号" hint="闲置账号出租" /> } label="撞车商城" hint="装备与现货" /> } label={homeConfig.data?.aw_recycle.title || 'AW回收'} hint="查看回收说明" onClick={() => setEntryPreview(homeConfig.data?.aw_recycle ?? null)} /> } label="联系客服" hint="问题留痕" />
放心购 严选账号
共 {totalListings} 个可租账号
{zoneTabs.map(tab => ( ))}
{listings.isError ? (
) : null} listings.refetch().then(() => undefined)}> {listings.isPending ? (
{Array.from({ length: 3 }).map((_, index) => (
))}
) : items.length ? ( <>
{items.map(item => ( ))}
{listings.hasNextPage ? ( ) : ( 已经看到全部账号 )}
) : (
)}
RULES, IN PLAIN WORDS

先把规则说明白

押金、租金、额外消耗和退款规则都会在订单里逐项列出。

setFilterOpen(false)} bodyStyle={{ height: '82vh', overflowY: 'auto', borderTopLeftRadius: 16, borderTopRightRadius: 16, }} >
筛选条件
toggleRange('coinKey', key)} /> toggleRange('priceKey', key)} /> toggleRange('ratioKey', key)} /> toggleRange('awmKey', key)} /> toggleRange('depositKey', key)} /> toggleRange('totalKey', key)} /> toggleRange('fireLevelKey', key)} /> toggleRange('dailyLossKey', key)} /> toggleRange('secretKdKey', key)} /> toggleDraft('insurance', option)} /> toggleDraft('stamina', option)} /> toggleDraft('load', option)} /> toggleDraft('loginMethod', option)} /> toggleDraft('ranks', option)} /> toggleDraft('regions', option)} /> {quickSkinGroups.map(group => ( toggleDraft('skinNames', option)} /> ))}
setSortOpen(false)} bodyStyle={{ borderTopLeftRadius: 16, borderTopRightRadius: 16 }} >
排序方式 {sortOptions.map(option => ( ))}
setEntryPreview(null)} bodyStyle={{ borderTopLeftRadius: 16, borderTopRightRadius: 16 }} > {entryPreview ? (
{entryPreview.title} {entryPreview.subtitle} {entryPreview.image_url ? ( {entryPreview.title} ) : (

暂无更多说明

)}
) : null}
) }