商品列表
This commit is contained in:
@@ -137,6 +137,7 @@
|
||||
border-radius: 20rpx;
|
||||
overflow: hidden;
|
||||
margin-bottom: 16rpx;
|
||||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -40,5 +40,5 @@ export interface HomeConfig {
|
||||
|
||||
/** 首页配置(轮播图 + 宫格导航 + 促销卡片):GET /mini/home */
|
||||
export function getHomeConfigApi() {
|
||||
return get<HomeConfig>('/mini/home')
|
||||
return get<HomeConfig>('/mini/home', { skipToken: true })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user