比赛
All checks were successful
Deploy to Server / deploy (push) Successful in 36s

This commit is contained in:
jeremygan2021
2026-03-10 12:35:41 +08:00
parent 417cda952d
commit 3ada996915
9 changed files with 388 additions and 11 deletions

View File

@@ -7,6 +7,7 @@ import './index.scss'
export default function CompetitionList() {
const [competitions, setCompetitions] = useState<any[]>([])
const [loading, setLoading] = useState(false)
const [debugMsg, setDebugMsg] = useState('')
useLoad(() => {
fetchCompetitions()
@@ -14,12 +15,21 @@ export default function CompetitionList() {
const fetchCompetitions = async () => {
setLoading(true)
setDebugMsg('开始加载...')
try {
console.log('Fetching competitions...')
const res = await getCompetitions()
console.log('Competitions res:', res)
setDebugMsg(`请求成功: 数量 ${res?.results?.length}`)
if (res && res.results) {
setCompetitions(res.results)
} else {
setDebugMsg(`数据格式异常: ${JSON.stringify(res)}`)
}
} catch (e) {
console.error('Fetch failed:', e)
setDebugMsg(`请求失败: ${e.errMsg || JSON.stringify(e)}`)
Taro.showToast({ title: '加载失败', icon: 'none' })
} finally {
setLoading(false)
@@ -32,6 +42,7 @@ export default function CompetitionList() {
const getStatusText = (status) => {
const map = {
'published': '即将开始',
'registration': '报名中',
'submission': '作品提交中',
'judging': '评审中',
@@ -66,7 +77,12 @@ export default function CompetitionList() {
</View>
))}
{!loading && competitions.length === 0 && (
<View className='empty'></View>
<View className='empty'>
<Text></Text>
<View style={{ marginTop: 20, color: '#666', fontSize: 12, wordBreak: 'break-all', padding: 20 }}>
: {debugMsg}
</View>
</View>
)}
</ScrollView>
</View>