import { useState, type CSSProperties } from 'react' import { Video } from '@tarojs/components' import { useSocialContent } from '@/hooks/useSocialContent' import Taro from '@tarojs/taro' import { SOCIAL_COPY, type SocialLandingCopy } from '@/data/socialSeed' import { goSocialPage as goPage } from '@/utils/socialNavigation' import { SocialAvatar } from './SocialAvatar' import { FloatingEmojiField } from './SocialExperience' import { H5El } from './H5El' const NODES = [ { member: 0, x: 22, y: 22, rotate: -8 }, { member: 1, x: 79, y: 26, rotate: 7 }, { member: 4, x: 85, y: 65, rotate: -6 }, { member: 3, x: 18, y: 69, rotate: 6 }, ] const ORBIT_SVG = `` const isH5 = process.env.TARO_ENV === 'h5' export function ConnectionHero({ onJoin, promoUrl, copy = SOCIAL_COPY, }: { onJoin: () => void promoUrl: string copy?: SocialLandingCopy }) { const [videoOpen, setVideoOpen] = useState(false) const { roster, buttonOn, sectionOn, featureOn } = useSocialContent() return ( <> 游民社区{' '} {copy.socialEyebrow} {copy.socialHeroLine1} 还好 {copy.socialHeroAccent} 不远 。 {copy.socialHeroLead} {buttonOn('heroJoin') && featureOn('joinPay') ? ( {copy.socialJoinCta} ↗ ) : null} {buttonOn('heroChat') ? ( goPage('/pages/social/chat/index')} trackLabel='social_film_chat' > 💬 群组聊天 ) : null} {buttonOn('heroDate') ? ( goPage('/pages/social/date/index')} trackLabel='social_film_date' > 💕 认识一下 ) : null} {buttonOn('heroStory') && sectionOn('promo') ? ( setVideoOpen(true)} trackLabel='social_film_story' > ▶ 社区故事 ) : null} {roster.slice(0, 5).map((m) => ( ))} 同频的人,正在这里相遇 自由职业 · 远程工作 · 出来见一面 🌐 不止在线,更在身边 {isH5 ? ( ) : null} ✨ 同频,自有引力 想见的人 {NODES.slice(0, roster.length).map(({ member, x, y, rotate }, i) => { const m = roster[member % roster.length]! const style = { ['--node-x' as string]: `${x}%`, ['--node-y' as string]: `${y}%`, ['--node-rotate' as string]: `${rotate}deg`, ['--node-delay' as string]: `${i * -1.4}s`, } as CSSProperties return ( goPage('/pages/social/people/index')} aria-label={`认识${m.name},${m.title}`} > {m.name} ↗ {m.title} {m.city.split('·')[0]?.trim()} ) })} 18.79° N · 清迈 25.60° N · 大理 ☕ 下一杯咖啡,和新朋友。 ↗ 连接没有边界 先用示例看看感觉 { if (process.env.TARO_ENV === 'h5' && typeof document !== 'undefined') { document.getElementById('people')?.scrollIntoView({ behavior: 'smooth' }) } else { const query = Taro.createSelectorQuery() query.select('#people').boundingClientRect() query.selectViewport().scrollOffset() query.exec((res) => { const rect = res?.[0] as { top?: number } | undefined const offset = res?.[1] as { scrollTop?: number } | undefined if (!rect || typeof rect.top !== 'number') return Taro.pageScrollTo({ scrollTop: Math.max(0, (offset?.scrollTop || 0) + rect.top - 72), duration: 300, }) }) } }} > ↓ 继续往下看 认识人 · 开视频 · 见一面 {videoOpen ? ( setVideoOpen(false)} > event.stopPropagation()} > 游民社区 · 社区故事 setVideoOpen(false)} aria-label='关闭'> ✕ ) : null} ) } export function ConnectionWays({ copy = SOCIAL_COPY }: { copy?: SocialLandingCopy }) { const { buttonOn, sectionOn } = useSocialContent() if (!sectionOn('ways')) return null const ways = [ { id: '01', path: '/pages/social/chat/index', emoji: '💬', title: copy.socialWayGroup, sub: '大家一起聊 · 先打个招呼', cta: '进群聊', className: 'mint', button: 'wayGroup' as const, }, { id: '02', path: '/pages/social/date/index', emoji: '💕', title: copy.socialWayDate, sub: '左右滑,慢慢认识', cta: '开始看看', className: 'coral', button: 'wayDate' as const, }, { id: '03', path: '/pages/social/meetup/index', emoji: '📡', title: copy.socialWayChat, sub: '聊天群组 · 语音视频', cta: '去聊聊', className: 'mint', button: 'wayMeetup' as const, }, { id: '04', path: '/pages/social/people/index?mode=cafe', emoji: '☕', title: copy.socialWayCafe, sub: copy.socialOfflineTitle, cta: '选城市', className: 'yellow', button: 'wayCafe' as const, }, { id: '05', path: '/pages/social/team/index', emoji: '🚀', title: copy.socialWayTeam, sub: copy.socialTeamTitle, cta: '看看机会', className: 'mint', button: 'wayTeam' as const, }, ].filter((way) => buttonOn(way.button)) if (!ways.length) return null return ( {ways.map((way, index) => ( goPage(way.path)} trackLabel={`social_way_${way.id}`} > {way.id} {way.emoji} {way.title} {way.sub} {way.cta} ↗ ))} ) }