From 21b4f9df8c60171d8ace82f5a865bddcd54ef89e Mon Sep 17 00:00:00 2001 From: Haiyi <1021441632@qq.com> Date: Wed, 14 Dec 2022 18:29:35 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(=E7=83=AD=E9=97=A8=E6=90=9C?= =?UTF-8?q?=E7=B4=A2):=E6=9B=B4=E6=8D=A2=E7=AD=9B=E9=80=89=E5=BC=B9?= =?UTF-8?q?=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/searchPopup/index.module.scss | 207 ++++++++++++++++++ .../components/searchPopup/index.tsx | 168 ++++++++++++++ src/pages/classList/index.tsx | 22 +- 3 files changed, 395 insertions(+), 2 deletions(-) create mode 100644 src/pages/classList/components/searchPopup/index.module.scss create mode 100644 src/pages/classList/components/searchPopup/index.tsx diff --git a/src/pages/classList/components/searchPopup/index.module.scss b/src/pages/classList/components/searchPopup/index.module.scss new file mode 100644 index 0000000..49291d3 --- /dev/null +++ b/src/pages/classList/components/searchPopup/index.module.scss @@ -0,0 +1,207 @@ +.main { + .topBox { + display: flex; + padding-left: 48px; + margin-top: 20px; + .leftTop { + .lefttopTitle { + font-size: 28px; + + font-weight: 500; + color: #000000; + margin-bottom: 24px; + } + .inputBox { + padding-left: 20px; + display: flex; + align-items: center; + width: 654px; + height: 68px; + background: #e9e9e9; + border-radius: 8px; + background-color: #f6f6f6; + margin-right: 48px; + .inputClass { + width: 624px; + } + } + .lefttopSelectBox { + display: flex; + align-items: center; + width: 330px; + height: 68px; + background: #f6f6f6; + border-radius: 8px; + justify-content: space-between; + margin-right: 16px; + .inputstyle { + padding-left: 20px; + } + .danwei { + color: #676767; + font-size: 28px; + font-weight: 400; + margin-right: 16px; + } + .lefttopSelectNameactive { + font-size: 28px; + + font-weight: 400; + color: #8b8b8b; + margin-left: 24px; + } + + .lefttopSelectName { + font-size: 28px; + + font-weight: 400; + color: #000000; + margin-left: 24px; + } + + .icon_more { + margin-right: 24px; + font-size: 30px; + } + } + + .activelefttopSelectBox { + width: 319px; + height: 68px; + background: rgba(51, 127, 255, 0.1); + border-radius: 8px; + border: 1px solid #337fff; + display: flex; + align-items: center; + justify-content: space-between; + margin-right: 16px; + + .lefttopSelectName { + font-size: 28px; + + font-weight: 400; + color: #337fff; + margin-left: 24px; + } + + .icon_more { + margin-right: 24px; + font-size: 30px; + color: #337fff; + } + } + } + } + .thirdBox { + margin-top: 30px; + padding-left: 48px; + .thirdTopfont { + font-size: 28px; + + font-weight: 500; + color: #000000; + } + + .flexModebox { + min-width: 152px; + margin-top: 24px; + display: flex; + flex-wrap: wrap; + .activemodeBox { + min-width: 152px; + margin-bottom: 16px; + margin-right: 16px; + padding: 10px; + // width: 152px; + // height: 68px; + background: rgba(51, 127, 255, 0.1); + border-radius: 8px; + font-size: 28px; + + font-weight: 400; + color: #337fff; + text-align: center; + line-height: 68px; + border: 1px solid #337fff; + box-sizing: border-box; + } + + .modeBox { + min-width: 152px; + margin-bottom: 16px; + margin-right: 16px; + // width: 152px; + // height: 68px; + padding: 10px; + background: #f6f6f6; + border-radius: 8px; + font-size: 28px; + border: 1px solid #f6f6f6; + font-weight: 400; + color: #7d7d7d; + text-align: center; + line-height: 68px; + box-sizing: border-box; + // opacity: 0.4; + } + } + } + .safeBox { + height: 160px; + } + .bottomBox { + width: 100%; + height: 160px; + background: #ffffff; + z-index: 99; + position: fixed; + bottom: 0; + padding-bottom: 30px; + display: flex; + align-items: center; + justify-content: space-between; + + .resetBox { + margin-left: 48px; + width: 311px; + height: 80px; + border-radius: 44px; + border: 1px solid #087eff; + font-size: 28px; + + font-weight: 500; + color: #337fff; + text-align: center; + line-height: 80px; + background-color: #fff; + } + + .button { + margin-right: 32px; + width: 311px; + height: 80px; + background: #68b4ff; + border-radius: 44px; + font-size: 32px; + + font-weight: 500; + color: #ffffff; + text-align: center; + line-height: 80px; + } + + .activeButton { + margin-right: 32px; + width: 311px; + height: 80px; + background: #337fff; + border-radius: 44px; + font-size: 32px; + border: 1px solid #337fff; + font-weight: 500; + color: #fff; + text-align: center; + line-height: 80px; + } + } +} diff --git a/src/pages/classList/components/searchPopup/index.tsx b/src/pages/classList/components/searchPopup/index.tsx new file mode 100644 index 0000000..2020db0 --- /dev/null +++ b/src/pages/classList/components/searchPopup/index.tsx @@ -0,0 +1,168 @@ +import { Button, Image, Input, ScrollView, Text, View } from '@tarojs/components' +import Taro, { useDidShow, usePullDownRefresh, useReady } from '@tarojs/taro' +import classnames from 'classnames' +import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' +import styles from './index.module.scss' +import Popup from '@/components/popup' +import { GetProductKindListApi } from '@/api/material' +import { getFilterData } from '@/common/util' +import { alert } from '@/common/common' + +interface Props { + showPopup: boolean + closePopup: () => void + handSearch: (any) => void +} + +const SearchPopup = (props: Props) => { + const [searchObj, setsearchObj] = useState({ + width: '', + weight_density: '', + product_kind_ids: '', + component: '', + }) + + // 获取系列 + const { fetchData: kindFetchData } = GetProductKindListApi() + const [kindList, setKindList] = useState([]) + const getCategoryList = async() => { + const { data } = await kindFetchData() + setKindList(data.list) + } + + useEffect(() => { + getCategoryList() + }, []) + + const handCheckMode = (it) => { + kindList.map((item) => { + if (item.id == it.id) { + item.check = true + } + else { + item.check = false + } + return item + }) + setKindList([...kindList]) + // const arr: number[] = [] + const res = kindList.filter((item) => { return item.check }) + // res.forEach((kb) => { + // arr.push(kb.id) + // }) + // setsearchObj(val => ({ ...val, product_kind_ids: arr.toString() })) + setsearchObj(val => ({ ...val, product_kind_ids: res[0]?.id })) + } + + const handBlur = (e, index) => { + if (index == 1) { + setsearchObj(val => ({ ...val, width: Number(e.detail.value) })) + } + if (index == 2) { + setsearchObj(val => ({ ...val, weight_density: Number(e.detail.value) })) + } + if (index == 3) { + setsearchObj(val => ({ ...val, component: e.detail.value })) + } + } + + const handReset = () => { + kindList.map((item) => { + item.check = false + return item + }) + setKindList([...kindList]) + setsearchObj({ + width: '', + weight_density: '', + product_kind_ids: '', + component: '', + }) + } + + const handSure = () => { + // if (searchObj.width === '' + // && searchObj.weight_density === '' + // && searchObj.product_kind_ids === '' + // && searchObj.component === '' + // ) { + // alert.error('请选择筛选内容') + // return true + // } + props.handSearch(getFilterData(searchObj)) + } + + return ( + props.closePopup?.()}> + + + + 系列名称 + + {kindList.map((item, index) => { + return ( + { + handCheckMode(item) + }} + className={classnames(item.check ? styles.activemodeBox : styles.modeBox)} + key={index} + > + {item.name} + + ) + })} + + + + + 幅宽 + + handBlur(e, 1)} placeholder="请输入幅宽"> + CM + + + + 克重 + + handBlur(e, 2)} placeholder="请输入克重"> + KG + + + + + + 成分 + + handBlur(e, 3)} placeholder="请输入成分"> + + + + + + + + + + + + ) +} +export default memo(SearchPopup) diff --git a/src/pages/classList/index.tsx b/src/pages/classList/index.tsx index c188493..411f8b1 100644 --- a/src/pages/classList/index.tsx +++ b/src/pages/classList/index.tsx @@ -5,6 +5,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import type { ListProps } from '../searchList/components/selectData' import SelectData from '../searchList/components/selectData' import styles from './index.module.scss' +import SearchPopup from './components/searchPopup' import Search from '@/components/search' import Product from '@/components/product' import InfiniteScroll from '@/components/infiniteScroll' @@ -117,6 +118,22 @@ export default () => { pageNum.current = { size: 10, page: 1 } } + const [showsearchPopup, setshowsearchPopup] = useState(false) + + const handSearch = (val) => { + pageNum.current.page = 1 + setCategoryList(() => ({ list: [], total: 0 })) + setSearchField({ + ...searchField, + width: val?.width, + weight_density: val?.weight_density, + size: 10, + component: val?.component, + product_kind_id: val?.product_kind_ids, + }) + setshowsearchPopup(false) + } + return ( @@ -128,7 +145,7 @@ export default () => { 综合 - setShowPopup(true)}> + setshowsearchPopup(true)}> 筛选 @@ -142,7 +159,8 @@ export default () => { - setShowPopup(false)} onFiltr={getFiltr} /> + {/* setShowPopup(false)} onFiltr={getFiltr} /> */} + setshowsearchPopup(false)} handSearch={val => handSearch(val)}> ) }