import { View, Text, Image, ScrollView, Button } from '@tarojs/components' import Taro, { useLoad } from '@tarojs/taro' import { useState, useEffect } from 'react' import { getConfigs } from '../../api' import ParticleBackground from '../../components/ParticleBackground' import './index.scss' export default function Index() { const [products, setProducts] = useState([]) const [typedText, setTypedText] = useState('') const [loading, setLoading] = useState(true) const [error, setError] = useState('') const fullText = "未来已来 AI 核心驱动" useLoad(() => { fetchProducts() }) useEffect(() => { let i = 0 const interval = setInterval(() => { i++ setTypedText(fullText.slice(0, i)) if (i >= fullText.length) clearInterval(interval) }, 150) return () => clearInterval(interval) }, []) const fetchProducts = async () => { setLoading(true) setError('') try { const res: any = await getConfigs() const list = Array.isArray(res) ? res : (res.results || res.data || []) setProducts(list) } catch (err: any) { console.error(err) setError(err.errMsg || '加载失败,请检查网络') } finally { setLoading(false) } } const goToDetail = (id: number) => { Taro.navigateTo({ url: `/pages/goods/detail?id=${id}` }) } return ( QUANT SPEED {typedText} | 量迹 AI 硬件为您提供最强大的边缘计算能力 {loading ? ( {[1, 2, 3].map(i => ( ))} ) : error ? ( {error} ) : ( {products.map((item, index) => ( goToDetail(item.id)} > {item.static_image_url ? ( ) : ( )} {item.name} ¥{item.price} {item.description} {item.chip_type} {item.has_camera && Camera} {item.has_microphone && Mic} ))} )} ) }