🎈 perf(首页优化页面基本完成,未对接):
This commit is contained in:
@@ -1,27 +1,30 @@
|
||||
import { Image, View } from "@tarojs/components"
|
||||
import styles from './index.module.scss'
|
||||
import { Image, View } from '@tarojs/components'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
export default () => {
|
||||
|
||||
return (
|
||||
<View className={styles.products_list}>
|
||||
{new Array(10).fill('').map(item => {
|
||||
return <View className={styles.products_item}>
|
||||
<View className={styles.item_img}>
|
||||
<Image src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2Ftp01%2F1ZZQ214233446-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651827249&t=b2fc2a3672dc8ced9e0f37ce7e2ff901"/>
|
||||
<View className={styles.num}>230色</View>
|
||||
</View>
|
||||
<View className={styles.item_con}>
|
||||
<View className={styles.title}><text>0770#</text>21S单面平纹(食毛)</View>
|
||||
<View className={styles.tag_list}>
|
||||
<View className={styles.tag}>160cm</View>
|
||||
<View className={styles.tag}>110g</View>
|
||||
</View>
|
||||
<View className={styles.introduce}>67.6%棉24%涤纶6.4%氨纶</View>
|
||||
<View className={styles.des}>产品描述产品描述产品描述产品描述产品描述</View>
|
||||
</View>
|
||||
</View>
|
||||
})}
|
||||
</View>
|
||||
)
|
||||
return (
|
||||
<View className={styles.products_list}>
|
||||
{new Array(10).fill('').map((item) => {
|
||||
return (
|
||||
<View className={styles.products_item}>
|
||||
<View className={styles.item_img}>
|
||||
<Image src='https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2Ftp01%2F1ZZQ214233446-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651827249&t=b2fc2a3672dc8ced9e0f37ce7e2ff901' />
|
||||
<View className={styles.num}>230色</View>
|
||||
</View>
|
||||
<View className={styles.item_con}>
|
||||
<View className={styles.title}>
|
||||
<text>0770#</text>21S单面平纹(食毛)
|
||||
</View>
|
||||
<View className={styles.tag_list}>
|
||||
<View className={styles.tag}>160cm</View>
|
||||
<View className={styles.tag}>110g</View>
|
||||
</View>
|
||||
<View className={styles.introduce}>67.6%棉24%涤纶6.4%氨纶</View>
|
||||
<View className={styles.des}>产品描述产品描述产品描述产品描述产品描述</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
.product_class_main_line {
|
||||
width: 100%;
|
||||
height: 80px;
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
background-color: #fff;
|
||||
.product_class_scroll {
|
||||
padding: 0 88px 0 19px;
|
||||
box-sizing: border-box;
|
||||
.product_class_list {
|
||||
white-space: nowrap;
|
||||
display: flex;
|
||||
box-sizing: border-box;
|
||||
.product_class_item {
|
||||
min-width: 170px;
|
||||
height: 56px;
|
||||
background: #f5f5f5;
|
||||
border-radius: 29px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24px;
|
||||
color: rgba(0, 0, 0, 0.8);
|
||||
box-sizing: border-box;
|
||||
&:nth-last-child(n + 1) {
|
||||
margin-right: 16px;
|
||||
}
|
||||
}
|
||||
.product_class_item_selected {
|
||||
border: 1px solid #3c78f4;
|
||||
color: #3c78f4;
|
||||
background: #ecf2ff;
|
||||
}
|
||||
}
|
||||
}
|
||||
.product_class_more {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
width: 88px;
|
||||
height: 100%;
|
||||
background-color: #fff;
|
||||
box-shadow: -7px 0px 7px -5px rgba(0, 0, 0, 0.16);
|
||||
line-height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.product_class_more_icon {
|
||||
margin-left: 20px;
|
||||
display: inline-block;
|
||||
transform: rotate(90deg);
|
||||
font-size: 30px;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.product_class_main_block {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
.product_class_block_con {
|
||||
max-height: 500px;
|
||||
background-color: #fff;
|
||||
z-index: 999;
|
||||
position: relative;
|
||||
}
|
||||
.product_class_scroll {
|
||||
box-sizing: border-box;
|
||||
max-height: 500px;
|
||||
padding: 20px 20px 0 20px;
|
||||
.product_class_list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
box-sizing: border-box;
|
||||
.product_class_item {
|
||||
min-width: 167px;
|
||||
height: 56px;
|
||||
background: #ecf2ff;
|
||||
border: 1px solid #3c78f4;
|
||||
border-radius: 29px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24px;
|
||||
color: #3c78f4;
|
||||
margin: 0 6px 20px 6px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.product_class_close {
|
||||
font-size: 24px;
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
text-align: center;
|
||||
padding-bottom: 20px;
|
||||
.product_class_close_icon {
|
||||
display: inline-block;
|
||||
transform: rotate(-90deg);
|
||||
font-size: 27px;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
padding: 0 10px;
|
||||
}
|
||||
}
|
||||
.product_class_block_mask {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 100;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
import { ScrollView, Text, View } from '@tarojs/components'
|
||||
import styles from './index.module.scss'
|
||||
import classnames from 'classnames'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
|
||||
type Param = {
|
||||
open: boolean
|
||||
onOpenClick?: (val: boolean) => void
|
||||
onSelect?: (val: number) => void
|
||||
}
|
||||
|
||||
type ParamProduct = Omit<Param, 'open'> & {
|
||||
defaultSelectIded: number
|
||||
}
|
||||
|
||||
export default (option: Param) => {
|
||||
const { open = false, onOpenClick, onSelect } = option
|
||||
const [defaultSelectIded, setDefaultSelectIded] = useState(-1)
|
||||
return (
|
||||
<>
|
||||
{open ? (
|
||||
<ProductClassBlock defaultSelectIded={defaultSelectIded} onSelect={onSelect} onOpenClick={(val) => onOpenClick?.(val)}></ProductClassBlock>
|
||||
) : (
|
||||
<ProductClassLine defaultSelectIded={defaultSelectIded} onSelect={onSelect} onOpenClick={(val) => onOpenClick?.(val)}></ProductClassLine>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
const ProductClassLine = (option: ParamProduct) => {
|
||||
const { onOpenClick, defaultSelectIded = -1, onSelect } = option
|
||||
const [selectInfo, setSelectInfo] = useState({
|
||||
selected: -1, //当前选中的id
|
||||
tabId: '', //需要滚动到的id
|
||||
})
|
||||
|
||||
const list = useMemo(() => {
|
||||
const data = new Array(10).fill('').map((item, index) => {
|
||||
return { id: index, name: '二级分类' + index }
|
||||
})
|
||||
data.unshift({ id: -1, name: '全部' })
|
||||
return data
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
let data: { item: any; index: number } = {}
|
||||
list.filter((item, index) => {
|
||||
if (item.id == defaultSelectIded) {
|
||||
data = { item, index }
|
||||
}
|
||||
})
|
||||
clickEvent(data)
|
||||
}, [defaultSelectIded])
|
||||
|
||||
const clickEvent = ({ item, index }: { item: any; index: number }) => {
|
||||
const num = index > 0 ? index - 1 : 0
|
||||
setSelectInfo((e) => ({ ...e, tabId: list[num].id.toString(), selected: item.id }))
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={styles.product_class_main_line}>
|
||||
<ScrollView scrollX scrollWithAnimation={true} className={styles.product_class_scroll} scrollIntoView={`tabs_${selectInfo.tabId}`}>
|
||||
<View className={styles.product_class_list}>
|
||||
{list.map((item, index) => (
|
||||
<View
|
||||
id={`tabs_${item.id}`}
|
||||
className={classnames(styles.product_class_item, item.id == selectInfo.selected ? styles.product_class_item_selected : '')}
|
||||
onClick={() => clickEvent({ item, index })}>
|
||||
{item.name + item.id}
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</ScrollView>
|
||||
<View className={styles.product_class_more} onClick={() => onOpenClick?.(true)}>
|
||||
<Text className={classnames('iconfont icon-a-moreback', styles.product_class_more_icon)}></Text>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
const ProductClassBlock = (option: ParamProduct) => {
|
||||
const { onOpenClick } = option
|
||||
const [selectInfo, setSelectInfo] = useState(-1)
|
||||
const list = useMemo(() => {
|
||||
const data = new Array(10).fill('').map((item, index) => {
|
||||
return { id: index, name: '二级分类' + index }
|
||||
})
|
||||
data.unshift({ id: -1, name: '全部' })
|
||||
return data
|
||||
}, [])
|
||||
|
||||
const clickEvent = (item) => {
|
||||
setSelectInfo(item.id)
|
||||
}
|
||||
return (
|
||||
<View className={styles.product_class_main_block}>
|
||||
<View className={styles.product_class_block_con}>
|
||||
<ScrollView scrollY className={styles.product_class_scroll}>
|
||||
<View className={styles.product_class_list}>
|
||||
{list.map((item, index) => (
|
||||
<View className={styles.product_class_item} onClick={() => clickEvent(item)}>
|
||||
{item.name}
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</ScrollView>
|
||||
<View className={styles.product_class_close} onClick={() => onOpenClick?.(false)}>
|
||||
点击收起<Text className={classnames('iconfont icon-a-moreback', styles.product_class_close_icon)}></Text>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.product_class_block_mask} onClick={() => onOpenClick?.(false)}></View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
.main {
|
||||
background-color: $color_bg_one;
|
||||
background-color: #f6f6f6;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.header {
|
||||
background-color: #fff;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
.search {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
@@ -29,5 +33,12 @@
|
||||
flex: 1;
|
||||
height: 0;
|
||||
margin-top: 20px;
|
||||
.product_right_con {
|
||||
position: relative;
|
||||
.product_class {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import Taro, { Events, useDidShow, usePullDownRefresh } from '@tarojs/taro'
|
||||
import { GetProductKindListApi, GetProductListApi } from '@/api/material'
|
||||
import useLogin from '@/use/useLogin'
|
||||
import { dataLoadingStatus } from '@/common/util'
|
||||
import ProductClass from './components/productClass'
|
||||
|
||||
export default () => {
|
||||
useLogin()
|
||||
@@ -84,13 +85,14 @@ export default () => {
|
||||
return (
|
||||
<MoveBtn onClick={() => setShowShopCart(!showShopCart)}>
|
||||
<View className={styles.main}>
|
||||
<View className={styles.search}>
|
||||
<View className={styles.search_input} onClick={() => goLink('/pages/searchList/search')}>
|
||||
<Search disabled={true} style={{ width: '263rpx' }} borderRadius='16rpx' placeholder='请输入搜索布料' />
|
||||
<View className={styles.header}>
|
||||
<View className={styles.search}>
|
||||
<View className={styles.search_input} onClick={() => goLink('/pages/searchList/search')}>
|
||||
<Search disabled={true} style={{ width: '263rpx' }} borderRadius='16rpx' placeholder='请输入搜索布料' />
|
||||
</View>
|
||||
</View>
|
||||
<Banner />
|
||||
</View>
|
||||
<Banner />
|
||||
|
||||
<View className={styles.products}>
|
||||
<SideBar
|
||||
list={kindData.list}
|
||||
|
||||
@@ -26,7 +26,7 @@ export default () => {
|
||||
const router = useRouter()
|
||||
useEffect(() => {
|
||||
if (router?.params.status != undefined && router?.params.status !== '') {
|
||||
setSearchField((e) => ({ ...e, status: router?.params.status as number }))
|
||||
setSearchField((e) => ({ ...e, status: router?.params.status as unknown as number }))
|
||||
} else {
|
||||
setSearchField((e) => ({ ...e, status: -1 }))
|
||||
}
|
||||
@@ -200,7 +200,7 @@ export default () => {
|
||||
<View className={styles.order_list_main}>
|
||||
<View className={styles.title}>
|
||||
<Search placeIcon='out' placeholder='搜索商品/名称/颜色/订单号' showBtn={true} changeOnSearch={getSearchData} debounceTime={300} />
|
||||
<OrderStatusList list={statusList} onSelect={changeStatus} defaultId={router?.params.status as number} />
|
||||
<OrderStatusList list={statusList} onSelect={changeStatus} defaultId={router?.params.status as unknown as number} />
|
||||
</View>
|
||||
<View className={styles.order_list}>
|
||||
<InfiniteScroll
|
||||
|
||||
Reference in New Issue
Block a user