商品列表

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
+1
View File
@@ -137,6 +137,7 @@
border-radius: 20rpx; border-radius: 20rpx;
overflow: hidden; overflow: hidden;
margin-bottom: 16rpx; margin-bottom: 16rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
&:last-child { &:last-child {
margin-bottom: 0; margin-bottom: 0;
+6 -20
View File
@@ -38,7 +38,6 @@ function getStatusBarHeight(): number {
} }
export default function IndexPage() { export default function IndexPage() {
const token = useAuthStore(s => s.token)
const addItem = useCartStore(s => s.addItem) const addItem = useCartStore(s => s.addItem)
/** 首页配置(轮播图 / 宫格导航 / 促销卡片) */ /** 首页配置(轮播图 / 宫格导航 / 促销卡片) */
@@ -48,17 +47,14 @@ export default function IndexPage() {
/** 搜索框输入 */ /** 搜索框输入 */
const [keyword, setKeyword] = useState('') const [keyword, setKeyword] = useState('')
const loggedIn = !!token
const statusBarHeight = useMemo(() => getStatusBarHeight(), []) const statusBarHeight = useMemo(() => getStatusBarHeight(), [])
useDidShow(() => { useDidShow(() => {
if (loggedIn) { loadHomeConfig()
loadHomeConfig() loadRecommend()
loadRecommend()
}
}) })
/** 首页配置聚合数据(需登录) */ /** 首页配置聚合数据 */
const loadHomeConfig = useCallback(async () => { const loadHomeConfig = useCallback(async () => {
try { try {
const res = await getHomeConfigApi() const res = await getHomeConfigApi()
@@ -68,7 +64,7 @@ export default function IndexPage() {
} }
}, []) }, [])
/** 推荐商品(默认排序第一页) */ /** 推荐商品 */
const loadRecommend = useCallback(async () => { const loadRecommend = useCallback(async () => {
try { try {
const res = await getProductListApi({ page: 1, pageSize: 10 }) const res = await getProductListApi({ page: 1, pageSize: 10 })
@@ -235,17 +231,7 @@ export default function IndexPage() {
<Text className='home-recommend__more' onClick={() => goProduct()}> </Text> <Text className='home-recommend__more' onClick={() => goProduct()}> </Text>
</View> </View>
{!loggedIn ? ( { products.length === 0 ? (
<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 ? (
<View className='home-recommend__empty'> <View className='home-recommend__empty'>
<Text className='home-recommend__empty-text'></Text> <Text className='home-recommend__empty-text'></Text>
</View> </View>
@@ -266,7 +252,7 @@ export default function IndexPage() {
{product.price !== null ? ( {product.price !== null ? (
<Text className='product-card__price'>{product.price}</Text> <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)}> <View className='product-card__add' onClick={e => handleQuickAdd(product, e)}>
<Text className='product-card__add-icon'></Text> <Text className='product-card__add-icon'></Text>
+1 -1
View File
@@ -40,5 +40,5 @@ export interface HomeConfig {
/** 首页配置(轮播图 + 宫格导航 + 促销卡片):GET /mini/home */ /** 首页配置(轮播图 + 宫格导航 + 促销卡片):GET /mini/home */
export function getHomeConfigApi() { export function getHomeConfigApi() {
return get<HomeConfig>('/mini/home') return get<HomeConfig>('/mini/home', { skipToken: true })
} }