商品列表

This commit is contained in:
liu
2026-08-14 15:24:05 +08:00
parent d1d8d7ab52
commit 8d308288bb
3 changed files with 8 additions and 21 deletions
+6 -20
View File
@@ -38,7 +38,6 @@ function getStatusBarHeight(): number {
}
export default function IndexPage() {
const token = useAuthStore(s => s.token)
const addItem = useCartStore(s => s.addItem)
/** 首页配置(轮播图 / 宫格导航 / 促销卡片) */
@@ -48,17 +47,14 @@ export default function IndexPage() {
/** 搜索框输入 */
const [keyword, setKeyword] = useState('')
const loggedIn = !!token
const statusBarHeight = useMemo(() => getStatusBarHeight(), [])
useDidShow(() => {
if (loggedIn) {
loadHomeConfig()
loadRecommend()
}
loadHomeConfig()
loadRecommend()
})
/** 首页配置聚合数据(需登录) */
/** 首页配置聚合数据 */
const loadHomeConfig = useCallback(async () => {
try {
const res = await getHomeConfigApi()
@@ -68,7 +64,7 @@ export default function IndexPage() {
}
}, [])
/** 推荐商品(默认排序第一页) */
/** 推荐商品 */
const loadRecommend = useCallback(async () => {
try {
const res = await getProductListApi({ page: 1, pageSize: 10 })
@@ -235,17 +231,7 @@ export default function IndexPage() {
<Text className='home-recommend__more' onClick={() => goProduct()}> </Text>
</View>
{!loggedIn ? (
<View className='home-recommend__empty'>
<Text className='home-recommend__empty-text'></Text>
<View
className='home-recommend__login-btn'
onClick={() => Taro.navigateTo({ url: '/pages/login/index' })}
>
</View>
</View>
) : products.length === 0 ? (
{ products.length === 0 ? (
<View className='home-recommend__empty'>
<Text className='home-recommend__empty-text'></Text>
</View>
@@ -266,7 +252,7 @@ export default function IndexPage() {
{product.price !== null ? (
<Text className='product-card__price'>{product.price}</Text>
) : (
<Text className='product-card__price product-card__price--none'></Text>
<Text className='product-card__price product-card__price--none'></Text>
)}
<View className='product-card__add' onClick={e => handleQuickAdd(product, e)}>
<Text className='product-card__add-icon'></Text>