import { View, Text, Button, ScrollView } from '@tarojs/components' import Taro, { useLoad } from '@tarojs/taro' import { useMemo, useState } from 'react' import { BrandNav, SiteFooter } from '../../components/Chrome' import { fetchMeetups, type Meetup } from '../../services/api' import './index.scss' import { usePageTrack } from '../../hooks/usePageTrack' export default function MeetupsPage() { usePageTrack('pages/meetups/index', '活动') const [list, setList] = useState([]) const [mode, setMode] = useState<'all' | 'online' | 'offline' | 'hybrid'>('all') const [fromLocal, setFromLocal] = useState(false) const [loading, setLoading] = useState(true) useLoad(() => { fetchMeetups() .then(({ data, fromLocal: local }) => { setList(data) setFromLocal(local) setLoading(false) }) .catch(() => { // fetchMeetups already falls back; keep empty only if catalog missing setList([]) setFromLocal(true) setLoading(false) }) }) const filtered = useMemo(() => { if (mode === 'all') return list return list.filter((m) => (m.mode || '').toLowerCase() === mode) }, [list, mode]) return ( 🎉 MEETUPS 游民活动 {fromLocal ? '本地精选活动(网络不可用时展示)· 登录后可 RSVP' : '同城与线上 · 登录后可 RSVP'} {([ ['all', '全部'], ['online', '线上'], ['offline', '线下'], ['hybrid', '混合'], ] as const).map(([k, label]) => ( ))} {loading ? 加载中… : null} {filtered.map((m) => ( {m.emoji || '🎉'} {m.title} {m.city || '—'} · {m.date || ''} {m.time || ''} · {m.mode || 'offline'} {m.description || ''} {m.venue ? 📍 {m.venue} : null} {m.organizer ? 主办:{m.organizer} : null} {(m.tags || []).map((tag) => ( {tag} ))} {m.rsvp_count ?? m.attendees ?? 0}/{m.max_attendees || '∞'} 人 {m.destination_slug ? ( ) : null} ))} {!loading && !filtered.length ? ( 该筛选下暂无活动,试试「全部」 ) : null} ) }