|
|
@@ -1,5 +1,5 @@
|
|
|
import React from 'react'
|
|
|
-import { View, Text, ScrollView } from '@tarojs/components'
|
|
|
+import { View, Text, ScrollView, Swiper, SwiperItem, Image } from '@tarojs/components'
|
|
|
import { useInfiniteQuery, useQuery } from '@tanstack/react-query'
|
|
|
import { TabBarLayout } from '@/layouts/tab-bar-layout'
|
|
|
import TDesignSearch from '@/components/tdesign/search'
|
|
|
@@ -9,7 +9,7 @@ import { goodsClient, advertisementClient } from '@/api'
|
|
|
import { InferResponseType } from 'hono'
|
|
|
import './index.css'
|
|
|
import { useAuth } from '@/utils/auth'
|
|
|
-import { Carousel } from '@/components/ui/carousel'
|
|
|
+import { Navbar } from '@/components/ui/navbar'
|
|
|
import Taro from '@tarojs/taro'
|
|
|
|
|
|
type GoodsResponse = InferResponseType<typeof goodsClient.$get, 200>
|
|
|
@@ -94,7 +94,7 @@ const HomePage: React.FC = () => {
|
|
|
const goodsList = allGoods.map(convertToGoodsData)
|
|
|
|
|
|
// 广告数据转换:提取图片URL并过滤掉没有图片的广告
|
|
|
- const finalImgSrcs = advertisementData?.data
|
|
|
+ const finalImgSrcs = advertisementData?.data || []
|
|
|
|
|
|
// 错误处理
|
|
|
if (adError) {
|
|
|
@@ -136,6 +136,13 @@ const HomePage: React.FC = () => {
|
|
|
|
|
|
return (
|
|
|
<TabBarLayout activeKey="home">
|
|
|
+ <Navbar
|
|
|
+ title="首页"
|
|
|
+ leftIcon=""
|
|
|
+ onClickLeft={() => Taro.navigateBack()}
|
|
|
+ rightIcon=""
|
|
|
+ onClickRight={() => {}}
|
|
|
+ />
|
|
|
<ScrollView
|
|
|
className="home-scroll-view"
|
|
|
scrollY
|
|
|
@@ -163,11 +170,28 @@ const HomePage: React.FC = () => {
|
|
|
<Text className="error-text">广告加载失败</Text>
|
|
|
</View>
|
|
|
) : finalImgSrcs && finalImgSrcs.length > 0 ? (
|
|
|
- <Carousel
|
|
|
- items={finalImgSrcs.filter(item => item.imageFile?.fullUrl).map((item) => ({
|
|
|
- src: item.imageFile!.fullUrl
|
|
|
- }))}
|
|
|
- />
|
|
|
+ <Swiper
|
|
|
+ className="w-full"
|
|
|
+ style={{ height: '800rpx', width: '100%' }}
|
|
|
+ autoplay={true}
|
|
|
+ circular={true}
|
|
|
+ indicatorDots={true}
|
|
|
+ indicatorColor="rgba(0, 0, 0, .3)"
|
|
|
+ indicatorActiveColor="#000"
|
|
|
+ >
|
|
|
+ {finalImgSrcs.filter(item => item.imageFile?.fullUrl).map((item, index) => (
|
|
|
+ <SwiperItem key={index} className="w-full h-full">
|
|
|
+ <View className="w-full h-full flex items-center justify-center bg-gray-100">
|
|
|
+ <Image
|
|
|
+ src={item.imageFile!.fullUrl}
|
|
|
+ mode="heightFix"
|
|
|
+ style={{ height: '800rpx', width: 'auto' }}
|
|
|
+ lazyLoad
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ </SwiperItem>
|
|
|
+ ))}
|
|
|
+ </Swiper>
|
|
|
) : (
|
|
|
<View className="empty-container">
|
|
|
<Text className="empty-text">暂无广告</Text>
|