Keep Douyin homeVariant BMI router intact while restoring admin join-group controls, TLS-safe config fetch, and ntfy channel labels. Co-authored-by: Cursor <cursoragent@cursor.com>
78 lines
3.0 KiB
TypeScript
78 lines
3.0 KiB
TypeScript
import { View, Text, Button, ScrollView } from '@tarojs/components'
|
||
import Taro, { useLoad, useRouter } from '@tarojs/taro'
|
||
import { useState } from 'react'
|
||
import { BrandNav, SiteFooter } from '../../components/Chrome'
|
||
import { fetchDestination, type Destination } from '../../services/api'
|
||
import './index.scss'
|
||
import { usePageTrack } from '../../hooks/usePageTrack'
|
||
|
||
function hueBg(hue = 170) {
|
||
return `linear-gradient(160deg, hsl(${hue}, 42%, 24%), hsl(${hue}, 30%, 10%))`
|
||
}
|
||
|
||
export default function DestinationPage() {
|
||
usePageTrack('pages/destination/index', '目的地详情')
|
||
const router = useRouter()
|
||
const [d, setD] = useState<Destination | null>(null)
|
||
const [err, setErr] = useState('')
|
||
|
||
useLoad(() => {
|
||
const slug = router.params.slug || ''
|
||
if (!slug) { setErr('缺少城市'); return }
|
||
fetchDestination(slug)
|
||
.then(setD)
|
||
.catch((e) => setErr(e.message || '加载失败'))
|
||
})
|
||
|
||
if (err || !d) {
|
||
return (
|
||
<View className='page-shell' style={{ padding: '64px 32px' }}>
|
||
<Text className='dest-empty'>{err || '加载中…'}</Text>
|
||
</View>
|
||
)
|
||
}
|
||
|
||
return (
|
||
<ScrollView scrollY className='page-shell' showScrollbar={false}>
|
||
<BrandNav chip='详情' />
|
||
<View className='container' style={{ paddingBottom: '48px' }}>
|
||
<Text
|
||
className='detail-nav'
|
||
onClick={() => Taro.navigateBack({ fail: () => Taro.navigateTo({ url: '/pages/destinations/index' }) })}
|
||
>
|
||
← 目的地
|
||
</Text>
|
||
|
||
<View className='detail-hero' style={{ background: hueBg(d.hue ?? 170) }}>
|
||
<Text className='dest-emoji'>{d.emoji || '🌍'}</Text>
|
||
<Text className='section-h2'>{d.name} · {d.country}</Text>
|
||
<Text className='section-p'>{d.tag || ''} · {d.nomads_count || '—'} 游民</Text>
|
||
<Text className='section-p' style={{ marginTop: '16px' }}>{d.description || d.tagline || ''}</Text>
|
||
<View className='hero-actions' style={{ marginTop: '24px' }}>
|
||
<Button className='btn btn-primary' onClick={() => Taro.showToast({ title: '登录后可收藏', icon: 'none' })}>
|
||
收藏
|
||
</Button>
|
||
<Button className='btn btn-ghost' onClick={() => Taro.navigateTo({ url: '/pages/meetups/index' })}>
|
||
同城活动
|
||
</Button>
|
||
</View>
|
||
</View>
|
||
|
||
<View className='dest-meta'>
|
||
<Text className='dest-meta-item'>💰 ¥{(d.cost || 0).toLocaleString()}/月</Text>
|
||
<Text className='dest-meta-item'>📶 {d.speed || 0}Mbps</Text>
|
||
<Text className='dest-meta-item'>🌡️ {d.temperature ?? '—'}°C</Text>
|
||
<Text className='dest-meta-item'>⭐ {d.rating ?? '—'}</Text>
|
||
</View>
|
||
|
||
<View className='filter-tags' style={{ marginTop: '16px' }}>
|
||
{(d.highlights || []).map((h) => (
|
||
<Text key={h} className='dest-tag' style={{ marginRight: '8px', marginBottom: '8px' }}>{h}</Text>
|
||
))}
|
||
</View>
|
||
</View>
|
||
<SiteFooter />
|
||
</ScrollView>
|
||
)
|
||
}
|