refactor(index):优化首页布局与样式- 移除 Banner 组件中多余的 View 包裹层,简化结构- 调整轮播图区域样式,提升触摸交互体验
-为今日热卖和社区拼团区域添加阴影效果- 减小社区拼团图片高度,优化视觉比例 - 调整热销榜单区域间距,改善布局紧凑度- 注释未使用的吸顶状态逻辑,减少冗余代码 - 更新页面标题为更直观的首页标识- 优化首页组件结构,提升渲染性能
This commit is contained in:
@@ -99,47 +99,40 @@ const MyPage = () => {
|
|||||||
<View className="flex p-2 justify-between" style={{height: `${carouselHeight}px`}}>
|
<View className="flex p-2 justify-between" style={{height: `${carouselHeight}px`}}>
|
||||||
{/* 左侧轮播图区域 */}
|
{/* 左侧轮播图区域 */}
|
||||||
<View style={{width: '50%', height: '100%'}}>
|
<View style={{width: '50%', height: '100%'}}>
|
||||||
<View
|
<Swiper
|
||||||
|
defaultValue={0}
|
||||||
|
height={carouselHeight}
|
||||||
|
indicator
|
||||||
|
autoPlay
|
||||||
|
duration={3000}
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
height: `${carouselHeight}px`,
|
||||||
height: '100%',
|
touchAction: 'pan-y'
|
||||||
touchAction: 'pan-y',
|
|
||||||
pointerEvents: 'none'
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Swiper
|
{carouselData && carouselData?.imageList?.map((img, index) => (
|
||||||
defaultValue={0}
|
<Swiper.Item key={index}>
|
||||||
height={carouselHeight}
|
<Image
|
||||||
indicator
|
width="100%"
|
||||||
autoPlay
|
height="100%"
|
||||||
duration={3000}
|
src={img.url}
|
||||||
style={{height: `${carouselHeight}px`}}
|
mode={'scaleToFill'}
|
||||||
>
|
onClick={() => navTo(`${img.path}`)}
|
||||||
{carouselData && carouselData?.imageList?.map((img, index) => (
|
lazyLoad={false}
|
||||||
<Swiper.Item key={index}>
|
style={{
|
||||||
<Image
|
height: `${carouselHeight}px`,
|
||||||
width="100%"
|
borderRadius: '4px'
|
||||||
height="100%"
|
}}
|
||||||
src={img.url}
|
/>
|
||||||
mode={'scaleToFill'}
|
</Swiper.Item>
|
||||||
onClick={() => navTo(`${img.path}`)}
|
))}
|
||||||
lazyLoad={false}
|
</Swiper>
|
||||||
style={{
|
|
||||||
height: `${carouselHeight}px`,
|
|
||||||
borderRadius: '4px',
|
|
||||||
pointerEvents: 'auto'
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Swiper.Item>
|
|
||||||
))}
|
|
||||||
</Swiper>
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* 右侧上下图片区域 - 从API获取数据 */}
|
{/* 右侧上下图片区域 - 从API获取数据 */}
|
||||||
<View className="flex flex-col" style={{width: '50%', height: '100%'}}>
|
<View className="flex flex-col" style={{width: '50%', height: '100%'}}>
|
||||||
{/* 上层图片 - 使用今日热卖素材 */}
|
{/* 上层图片 - 使用今日热卖素材 */}
|
||||||
<View className={'ml-2 bg-white rounded-lg'}>
|
<View className={'ml-2 bg-white rounded-lg shadow-sm'}>
|
||||||
<View className={'px-3 my-2 font-bold text-sm'}>今日热卖</View>
|
<View className={'px-3 my-2 font-bold text-sm'}>今日热卖</View>
|
||||||
<View className={'px-3 flex'} style={{
|
<View className={'px-3 flex'} style={{
|
||||||
height: '110px'
|
height: '110px'
|
||||||
@@ -166,12 +159,12 @@ const MyPage = () => {
|
|||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* 下层图片 - 使用社区拼团素材 */}
|
{/* 下层图片 - 使用社区拼团素材 */}
|
||||||
<View className={'ml-2 bg-white rounded-lg mt-3'}>
|
<View className={'ml-2 bg-white rounded-lg mt-3 shadow-sm'}>
|
||||||
<View className={'px-3 my-2 font-bold text-sm'}>走进社区</View>
|
<View className={'px-3 my-2 font-bold text-sm'}>走进社区</View>
|
||||||
<View className={'rounded-lg px-3 pb-3'}>
|
<View className={'rounded-lg px-3 pb-3'}>
|
||||||
<Image
|
<Image
|
||||||
width={'100%'}
|
width={'100%'}
|
||||||
height={106}
|
height={94}
|
||||||
src={item?.image}
|
src={item?.image}
|
||||||
mode={'scaleToFill'}
|
mode={'scaleToFill'}
|
||||||
lazyLoad={false}
|
lazyLoad={false}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ const BestSellers = (props: {onStickyChange?: (isSticky: boolean) => void}) => {
|
|||||||
</Tabs>
|
</Tabs>
|
||||||
</Sticky>
|
</Sticky>
|
||||||
|
|
||||||
<View className={'flex flex-col justify-between items-center rounded-lg px-2 mt-4'}>
|
<View className={'flex flex-col justify-between items-center rounded-lg px-2 mt-2'}>
|
||||||
{/* 今日主推 */}
|
{/* 今日主推 */}
|
||||||
{tab1value == '0' && list?.map((item, index) => {
|
{tab1value == '0' && list?.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import './index.scss'
|
|||||||
|
|
||||||
function Home() {
|
function Home() {
|
||||||
// 吸顶状态
|
// 吸顶状态
|
||||||
const [stickyStatus, setStickyStatus] = useState<boolean>(false)
|
// const [stickyStatus, setStickyStatus] = useState<boolean>(false)
|
||||||
// Tabs粘性状态
|
// Tabs粘性状态
|
||||||
const [tabsStickyStatus, setTabsStickyStatus] = useState<boolean>(false)
|
const [tabsStickyStatus, setTabsStickyStatus] = useState<boolean>(false)
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ function Home() {
|
|||||||
const userId = Taro.getStorageSync('UserId');
|
const userId = Taro.getStorageSync('UserId');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: '网宿小店 - 网宿软件',
|
title: '🏠 首页 🏠',
|
||||||
path: userId ? `/pages/index/index?inviter=${userId}&source=share&t=${Date.now()}` : `/pages/index/index`,
|
path: userId ? `/pages/index/index?inviter=${userId}&source=share&t=${Date.now()}` : `/pages/index/index`,
|
||||||
success: function () {
|
success: function () {
|
||||||
console.log('首页分享成功');
|
console.log('首页分享成功');
|
||||||
@@ -81,11 +81,11 @@ function Home() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSticky = (item: IArguments) => {
|
// const onSticky = (item: IArguments) => {
|
||||||
if(item){
|
// if(item){
|
||||||
setStickyStatus(!stickyStatus)
|
// setStickyStatus(!stickyStatus)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 处理Tabs粘性状态变化
|
// 处理Tabs粘性状态变化
|
||||||
const handleTabsStickyChange = (isSticky: boolean) => {
|
const handleTabsStickyChange = (isSticky: boolean) => {
|
||||||
@@ -165,7 +165,7 @@ function Home() {
|
|||||||
) : (
|
) : (
|
||||||
<Header stickyStatus={tabsStickyStatus}/>
|
<Header stickyStatus={tabsStickyStatus}/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className={'flex flex-col mt-12'}>
|
<div className={'flex flex-col mt-12'}>
|
||||||
<Menu/>
|
<Menu/>
|
||||||
<Banner/>
|
<Banner/>
|
||||||
|
|||||||
Reference in New Issue
Block a user