商城测试版v8

This commit is contained in:
2022-07-26 18:36:47 +08:00
parent 341c5c2eed
commit 3009b65e00
17 changed files with 106 additions and 90 deletions
@@ -143,7 +143,7 @@
}
.list_num_shadow {
box-shadow: 0px 5px 5px #ccc;
box-shadow: 0px 3px 5px #ccc;
}
.scroll{
height: 100%;
@@ -159,7 +159,7 @@
background-color: #fff;
border-radius: 20px;
margin-bottom: 20px;
box-shadow: 0px 3px 10px 0px rgba(0,0,0,0.1) ;
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.1) ;
.product_img{
width: 100%;
height: 224px;
+14 -19
View File
@@ -13,15 +13,15 @@ import Taro, { useDidShow, usePullDownRefresh, useReady } from "@tarojs/taro";
import {GetLabProductApi} from "@/api/material"
import { dataLoadingStatus, getFilterData } from "@/common/util";
import { formatHashTag, formatImgUrl } from "@/common/fotmat";
import LoadingCard from "@/components/loadingCard";
import useLogin from "@/use/useLogin";
import { goLink } from "@/common/common";
import SelectData, {ListProps} from "./components/selectData";
import LabAndImg from "@/components/LabAndImg";
import useCheckAuthorize from "@/use/useCheckAuthorize";
export default () => {
useLogin()
const firstOpen = useRef(true)
const [showFilter, setShowFilter] = useState(false)
//搜索参数
const [searchField, setSearchField] = useState({
@@ -44,6 +44,7 @@ export default () => {
let {data} = await materialFetchData(getFilterData(searchField))
setMaterialList({list:data.list, total:data.total})
Taro.stopPullDownRefresh()
firstOpen.current = false
}
//监听筛选条件变化
@@ -61,20 +62,10 @@ export default () => {
}
}
//数据加载状态
const statusMore = useMemo(() => {
return dataLoadingStatus({list:materialList.list, total: materialList.total, status: materialState.loading})
}, [materialList])
const [scrollStatus, setScrollStatus] = useState(false)
const onscroll = useCallback((e) => {
if(e.detail.scrollTop > 20) {
setScrollStatus(true)
} else {
setScrollStatus(false)
}
},[])
}, [materialList, materialState])
const {state: colorState, measureAndGetLab} = useBluetooth()
const getLab = () => {
@@ -91,10 +82,12 @@ export default () => {
//监听lab数据变化
const [blueToothColor, setBlueToothColor] = useState('')
useEffect(() => {
if(colorState.deviceLab) {
if(colorState.deviceLab && !firstOpen.current) {
const rgb = toRgb([colorState.deviceLab.L, colorState.deviceLab.a, colorState.deviceLab.b])
setBlueToothColor(`rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`)
setSearchField({...searchField, l:rgb[0], a:rgb[1], b:rgb[2], size:10})
setSearchField({...searchField, l:rgb[0], a:rgb[1], b:rgb[2], size:10, page:1})
setMaterialList(() => ({list:[], total:0}))
pageNum.current = {size: 10, page: 1}
}
}, [colorState.deviceLab])
@@ -104,6 +97,7 @@ export default () => {
//获取筛选条件
const getFiltr = (e) => {
pageNum.current.page = 1
setMaterialList(() => ({list:[], total:0}))
const {data} = e
setSearchField({
@@ -143,15 +137,17 @@ export default () => {
collection: 'none'
})
const changeSort = (val) => {
setMaterialList(() => ({list:[], total:0}))
if(val == 1) {
const {status, value} = sortComprehensiveRef.current.changeSort()
setSortStatus((e) => ({...e, comprehensive: status, collection: 'none'}))
setSearchField((e) => ({...e, abstract_sort_key: value}))
setSearchField((e) => ({...e, abstract_sort_key: value, size:10, page:1}))
} else {
const {status, value} = sortCollectionRef.current.changeSort()
setSortStatus((e) => ({...e, collection: status, comprehensive: 'none'}))
setSearchField((e) => ({...e, abstract_sort_key: value}))
setSearchField((e) => ({...e, abstract_sort_key: value, size:10, page:1}))
}
pageNum.current = {size: 10, page: 1}
}
const labAndImgObj = useCallback((item) => {
@@ -195,11 +191,10 @@ export default () => {
</View>
</View>
<View className={styles.list}>
<View className={classnames(styles.list_num, scrollStatus&&styles.list_num_shadow)}>搜索结果 ({materialList.total}条记录)</View>
<View className={classnames(styles.list_num, styles.list_num_shadow)}>搜索结果 ({materialList.total}条记录)</View>
<View className={styles.scroll}>
<InfiniteScroll
selfonScrollToLower={getScrolltolower}
selfOnScroll={(e) => onscroll(e)}
statusMore={statusMore}
>
<View className={styles.product_list}>
+2 -2
View File
@@ -126,7 +126,7 @@
}
.list_num_shadow {
box-shadow: 0px 5px 5px #ccc;
box-shadow: 0px 3px 5px #ccc;
}
.scroll{
height: 100%;
@@ -142,7 +142,7 @@
background-color: #fff;
border-radius: 20px;
margin-bottom: 20px;
box-shadow: 0px 3px 10px 0px rgba(0,0,0,0.1) ;
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.1) ;
.product_img{
width: 100%;
height: 224px;
+6 -15
View File
@@ -68,6 +68,7 @@ export default () => {
pageNum.current.page = 1
setMaterialList(() => ({list:[], total:0}))
setSearchField((val) => ({...val, code_or_name:e, size:10}))
pageNum.current = {size: 10, page: 1}
}, [])
const goLinkPage = (item) => {
@@ -78,17 +79,7 @@ export default () => {
usePullDownRefresh(() => {
setSearchField({...searchField ,size : 10})
})
//监听滚动
const [scrollStatus, setScrollStatus] = useState(false)
const onscroll = useCallback((e) => {
if(e.detail.scrollTop > 20) {
setScrollStatus(true)
} else {
setScrollStatus(false)
}
},[])
//获取筛选条件
const getFiltr = (e) => {
pageNum.current.page = 1
@@ -129,12 +120,13 @@ export default () => {
if(val == 1) {
const {status, value} = sortComprehensiveRef.current.changeSort()
setSortStatus((e) => ({...e, comprehensive: status, collection: 'none'}))
setSearchField((e) => ({...e, abstract_sort_key: value}))
setSearchField((e) => ({...e, abstract_sort_key: value, size:10, page:1}))
} else {
const {status, value} = sortCollectionRef.current.changeSort()
setSortStatus((e) => ({...e, collection: status, comprehensive: 'none'}))
setSearchField((e) => ({...e, abstract_sort_key: value}))
setSearchField((e) => ({...e, abstract_sort_key: value, size:10, page:1}))
}
pageNum.current = {size: 10, page: 1}
}
const labAndImgObj = useCallback((item) => {
@@ -173,11 +165,10 @@ export default () => {
</View>
</View>
<View className={styles.list}>
<View className={classnames(styles.list_num, scrollStatus&&styles.list_num_shadow)}>搜索结果 ({materialList.total}条记录)</View>
<View className={classnames(styles.list_num, styles.list_num_shadow)}>搜索结果 ({materialList.total}条记录)</View>
<View className={styles.scroll}>
<InfiniteScroll
selfonScrollToLower={getScrolltolower}
selfOnScroll={onscroll}
statusMore={statusMore}
>
<View className={styles.product_list}>