2025-06-11 19:07:30 +08:00
|
|
|
|
'use client'
|
2025-06-18 17:57:12 +08:00
|
|
|
|
import {ReactNode, useState, useEffect, MouseEvent} from 'react'
|
2025-03-24 11:45:54 +08:00
|
|
|
|
import Wrap from '@/components/wrap'
|
|
|
|
|
|
import Image from 'next/image'
|
2025-03-18 18:00:29 +08:00
|
|
|
|
import anno from '@/assets/header/product/anno.svg'
|
2025-03-24 11:45:54 +08:00
|
|
|
|
import Link from 'next/link'
|
|
|
|
|
|
import {merge} from '@/lib/utils'
|
2025-03-28 15:00:46 +08:00
|
|
|
|
import prod from '@/assets/header/product/prod.svg'
|
|
|
|
|
|
import custom from '@/assets/header/product/custom.svg'
|
2025-06-11 19:07:30 +08:00
|
|
|
|
import {useSearchParams} from 'next/navigation'
|
2025-06-12 18:51:54 +08:00
|
|
|
|
import {useRouter} from 'next/navigation'
|
2025-03-18 18:00:29 +08:00
|
|
|
|
|
|
|
|
|
|
type TabType = 'domestic' | 'oversea'
|
|
|
|
|
|
|
2025-03-28 15:00:46 +08:00
|
|
|
|
export function Tab(props: {
|
|
|
|
|
|
selected: boolean
|
|
|
|
|
|
onSelect: () => void
|
|
|
|
|
|
children: ReactNode
|
|
|
|
|
|
}) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<li role="tab">
|
|
|
|
|
|
<button
|
|
|
|
|
|
className={[
|
|
|
|
|
|
`p-8 text-lg cursor-pointer border-r`,
|
|
|
|
|
|
props.selected ? `bg-gradient-to-r from-transparent to-blue-200 border-blue-400` : `border-gray-200`,
|
|
|
|
|
|
].join(' ')}
|
|
|
|
|
|
onClick={props.onSelect}
|
|
|
|
|
|
>
|
|
|
|
|
|
{props.children}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-18 17:57:12 +08:00
|
|
|
|
export default function ProductMenu() {
|
|
|
|
|
|
const [type, setType] = useState<TabType>('domestic')
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
const checkMobile = () => {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
checkMobile()
|
|
|
|
|
|
window.addEventListener('resize', checkMobile)
|
|
|
|
|
|
return () => window.removeEventListener('resize', checkMobile)
|
|
|
|
|
|
}, [])
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Wrap className="flex">
|
|
|
|
|
|
<ul role="tablist" className="w-48">
|
|
|
|
|
|
<Tab selected={type === 'domestic'} onSelect={() => setType('domestic')}>国内代理</Tab>
|
|
|
|
|
|
<Tab selected={type === 'oversea'} onSelect={() => setType('oversea')}>海外代理</Tab>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
<div className="flex-1">
|
|
|
|
|
|
{type === 'domestic'
|
|
|
|
|
|
? (
|
|
|
|
|
|
<Domestic/>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<Oversea/>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<aside className="hidden w-64 lg:block">
|
|
|
|
|
|
<h3 className="flex gap-3 items-center mb-4">
|
|
|
|
|
|
<Image src={anno} alt="公告" className="w-10 h-10"/>
|
|
|
|
|
|
<span>网站公告</span>
|
|
|
|
|
|
</h3>
|
|
|
|
|
|
<div className="flex flex-col gap-2">
|
|
|
|
|
|
<p>官网最新上线,体验再升级!</p>
|
|
|
|
|
|
<p className="text-gray-400 text-sm">
|
|
|
|
|
|
1.新增多样使用功能,新增多样使用
|
|
|
|
|
|
新增多样使用功能
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<p className="text-gray-400 text-sm">
|
|
|
|
|
|
2.新增多样使用功能,新增多样使用
|
|
|
|
|
|
新增多样使用功能
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</aside>
|
|
|
|
|
|
</Wrap>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-28 15:00:46 +08:00
|
|
|
|
export function Domestic(props: {}) {
|
2025-06-11 19:07:30 +08:00
|
|
|
|
const searchParams = useSearchParams()
|
|
|
|
|
|
const currentType = searchParams?.get('type') || 'short'
|
2025-03-28 15:00:46 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<section role="tabpanel" className="flex gap-16 mr-16">
|
|
|
|
|
|
<div className="w-64 flex flex-col">
|
|
|
|
|
|
<h3 className="mb-6 font-bold flex items-center gap-3">
|
2025-06-07 11:49:57 +08:00
|
|
|
|
<Image src={prod} alt="产品" className="w-10 h-=10"/>
|
2025-03-28 15:00:46 +08:00
|
|
|
|
<span>代理产品</span>
|
|
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
|
|
|
|
<DomesticLink
|
2025-06-07 11:49:57 +08:00
|
|
|
|
label="动态IP"
|
|
|
|
|
|
desc="全国300+城市级定位节点"
|
2025-06-11 19:07:30 +08:00
|
|
|
|
href="/product?type=short"
|
2025-03-28 15:00:46 +08:00
|
|
|
|
discount={45}
|
2025-06-11 19:07:30 +08:00
|
|
|
|
active={currentType === 'short'}
|
2025-03-28 15:00:46 +08:00
|
|
|
|
/>
|
|
|
|
|
|
<DomesticLink
|
2025-06-07 11:49:57 +08:00
|
|
|
|
label="长效静态IP"
|
|
|
|
|
|
desc="IP 资源覆盖全国"
|
2025-06-11 19:07:30 +08:00
|
|
|
|
href="/product?type=long"
|
2025-03-28 15:00:46 +08:00
|
|
|
|
discount={45}
|
2025-06-11 19:07:30 +08:00
|
|
|
|
active={currentType === 'long'}
|
2025-03-28 15:00:46 +08:00
|
|
|
|
/>
|
|
|
|
|
|
<DomesticLink
|
2025-06-07 11:49:57 +08:00
|
|
|
|
label="固定IP"
|
|
|
|
|
|
desc="全国300+城市级定位节点"
|
2025-06-11 19:07:30 +08:00
|
|
|
|
href="/product?type=fixed"
|
2025-03-28 15:00:46 +08:00
|
|
|
|
discount={45}
|
2025-06-11 19:07:30 +08:00
|
|
|
|
active={currentType === 'fixed'}
|
2025-03-28 15:00:46 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2025-06-16 17:46:21 +08:00
|
|
|
|
<div className="w-64 flex flex-col gap-4 max-lg:hidden">
|
2025-03-28 15:00:46 +08:00
|
|
|
|
<h3 className="font-bold mb-2 flex items-center gap-3">
|
|
|
|
|
|
<Image src={custom} alt="定制" className="w-10 h-10"/>
|
|
|
|
|
|
<span>业务定制</span>
|
|
|
|
|
|
</h3>
|
|
|
|
|
|
<div className="flex flex-col gap-2">
|
|
|
|
|
|
<p>优质/企业/精选IP</p>
|
|
|
|
|
|
<p className="text-gray-400 text-sm">
|
|
|
|
|
|
超 1000 家企业共同信赖之选!大客户经理全
|
|
|
|
|
|
程 1 对 1 沟通,随时为您排忧解难,提供 24
|
|
|
|
|
|
小时不间断支持
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-24 11:45:54 +08:00
|
|
|
|
export function DomesticLink(props: {
|
|
|
|
|
|
label: string
|
|
|
|
|
|
desc: string
|
|
|
|
|
|
href: string
|
|
|
|
|
|
discount: number
|
2025-06-11 19:07:30 +08:00
|
|
|
|
active?: boolean
|
2025-03-18 18:00:29 +08:00
|
|
|
|
}) {
|
2025-06-12 18:51:54 +08:00
|
|
|
|
const router = useRouter()
|
2025-06-18 17:57:12 +08:00
|
|
|
|
// const ctx = useContext(HeaderContext)
|
|
|
|
|
|
// if (!ctx) {
|
|
|
|
|
|
// throw new Error(`HeaderContext not found`)
|
2025-06-12 18:51:54 +08:00
|
|
|
|
// }
|
2025-06-18 17:57:12 +08:00
|
|
|
|
|
|
|
|
|
|
const onClick = (e: MouseEvent) => {
|
2025-06-12 18:51:54 +08:00
|
|
|
|
e.preventDefault()
|
|
|
|
|
|
e.stopPropagation()
|
2025-06-18 17:57:12 +08:00
|
|
|
|
// ctx.setMenu(false)
|
|
|
|
|
|
router.push(props.href)
|
2025-03-24 11:45:54 +08:00
|
|
|
|
}
|
2025-03-18 18:00:29 +08:00
|
|
|
|
|
|
|
|
|
|
return (
|
2025-06-07 11:49:57 +08:00
|
|
|
|
<Link
|
|
|
|
|
|
href={props.href}
|
|
|
|
|
|
className={merge(
|
|
|
|
|
|
`transition-colors duration-150 ease-in-out`,
|
|
|
|
|
|
`p-4 rounded-lg flex flex-col gap-2 hover:bg-blue-50`,
|
2025-06-11 19:07:30 +08:00
|
|
|
|
props.active ? 'bg-blue-100' : '',
|
2025-06-07 11:49:57 +08:00
|
|
|
|
)}
|
|
|
|
|
|
onClick={onClick}>
|
2025-03-24 11:45:54 +08:00
|
|
|
|
<p className="flex gap-2">
|
|
|
|
|
|
<span>{props.label}</span>
|
|
|
|
|
|
<span className="text-orange-500 text-xs text-light px-2 py-1 bg-orange-50 rounded-full">
|
2025-06-07 11:49:57 +08:00
|
|
|
|
折扣
|
|
|
|
|
|
{props.discount}
|
|
|
|
|
|
%
|
2025-03-24 11:45:54 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<p className="text-gray-400 text-sm">
|
|
|
|
|
|
{props.desc}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</Link>
|
2025-03-18 18:00:29 +08:00
|
|
|
|
)
|
2025-03-24 11:45:54 +08:00
|
|
|
|
}
|
2025-06-18 17:57:12 +08:00
|
|
|
|
|
|
|
|
|
|
export function Oversea(props: {}) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<section role="tabpanel">
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|