From 25628dccdc642723d64e77f4ff8b984043b98a95 Mon Sep 17 00:00:00 2001 From: xuan Date: Wed, 21 Sep 2022 12:48:05 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(=E5=8F=91=E8=B4=A7=E5=88=97?= =?UTF-8?q?=E8=A1=A8):=20=E5=AE=8C=E6=88=90=E5=8F=91=E8=B4=A7=E5=88=97?= =?UTF-8?q?=E8=A1=A8UI=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Filter/index.module.scss | 64 +++++- .../delivery/components/Filter/index.tsx | 197 ++++++++++-------- src/pages/delivery/index.tsx | 6 +- .../components/shoppingCartItem/index.tsx | 1 + 4 files changed, 170 insertions(+), 98 deletions(-) diff --git a/src/pages/delivery/components/Filter/index.module.scss b/src/pages/delivery/components/Filter/index.module.scss index c8d3e6f..6a57756 100644 --- a/src/pages/delivery/components/Filter/index.module.scss +++ b/src/pages/delivery/components/Filter/index.module.scss @@ -1,4 +1,3 @@ - .filterItem { margin: 24px 48px; &--title { @@ -15,7 +14,6 @@ .filter { &--time { grid-template-columns: 1fr 1fr 1fr 1fr; - } &--inputBar { } @@ -23,19 +21,67 @@ grid-template-columns: 1fr 1fr; } } -.filterTypeButton{ +.filterTypeButton { padding: 0 24px; font-size: 28px; - } -.filterTypeText{ +.filterTypeText { color: #6e6e6e !important; } -.filterTimeButton{ - padding: 0 24px; - font-size: 28px; +.filterTimeButton { grid-column-start: span 2; } -.selected{ +.selected { background-color: #eaf2ff; } + +.filterButton { + display: flex; + flex-flow: row nowrap; + align-items: center; + justify-content: center; + padding: 0 20px; + box-sizing: border-box; + border: 0 solid transparent; + background-color: #f6f6f6; + border-radius: 8px; + font-size: 28px; + height: 72px; + &--text { + color: #909090; + display: flex; + flex-flow: row nowrap; + justify-content: center; + align-items: center; + } + &:hover { + opacity: 0.7; + } + &--active { + border: 1px solid $color_main; + background-color: #eaf2ff; + .filterButton--text { + color: $color_main; + } + } +} +.filterController { + width: 100%; + display: flex; + flex-flow: row nowrap; + align-items: center; + justify-content: space-around; + padding-bottom: constant(safe-area-inset-bottom); + padding-bottom: env(safe-area-inset-bottom); + + btn:hover{ + filter: blur(.7); + } + + .rest_btn { + font-size: 28px; + } + .verify_btn { + font-size: 28px; + } +} diff --git a/src/pages/delivery/components/Filter/index.tsx b/src/pages/delivery/components/Filter/index.tsx index 7909818..8d63a82 100644 --- a/src/pages/delivery/components/Filter/index.tsx +++ b/src/pages/delivery/components/Filter/index.tsx @@ -1,15 +1,17 @@ -import NormalButton from "@/components/normalButton" -import Popup from "@/components/popup" -import { View } from "@tarojs/components" -import classnames from "classnames" +import NormalButton from '@/components/normalButton' +import Popup from '@/components/popup' +import { View } from '@tarojs/components' +import classnames from 'classnames' import styles from './index.module.scss' -import { FC, memo, useEffect, useState } from 'react' -import Search from "@/components/search" -import IconFont from "@/components/iconfont/iconfont" -import {EnumDeliveryNoticeTypeList} from '@/api/index' +import React, { FC, memo, useEffect, useState } from 'react' +import Search from '@/components/search' +import IconFont from '@/components/iconfont/iconfont' +import { EnumDeliveryNoticeTypeList } from '@/api/index' +import dayjs from 'dayjs' type SearchFilter = { type?: number + timeKey?: string } const scanIcon = () => { @@ -23,17 +25,18 @@ const scanIcon = () => { } const DeliveryFilter: FC = memo(() => { + const { fetchData } = EnumDeliveryNoticeTypeList() - const {fetchData} = EnumDeliveryNoticeTypeList() - - const [searchFilter, useSearchFilter] = useState({ - + const [searchFilter, setSearchFilter] = useState({ + type: undefined, + timeKey: '0', }) const handleSelectedType = (type: string | number) => { + console.log('type==>', type) if (typeof type === 'string' && type === 'default') { - // setSearch((e) => ({ ...e })) + setSearchFilter((e) => ({ ...e, type: undefined })) } else { - // setSearch((e) => ({ ...e, type: type as number })) + setSearchFilter((e) => ({ ...e, type: type as number })) } } @@ -41,72 +44,76 @@ const DeliveryFilter: FC = memo(() => { useEffect(() => { getEnumData() - }, []) - - const [typeList, setTypeList] = useState<{id: number, name: string}[]>() + const [typeList, setTypeList] = useState<{ id: number; name: string }[]>() const getEnumData = async () => { const res = await fetchData() setTypeList(res.data.list) } - + + const [customTime, setCustomTime] = useState({ + date_min: undefined, + date_max: undefined, + }) + + const filterTimeOptions = { + 0: { + name: '不限', + date_min: undefined, + date_max: undefined, + }, + 1: { + name: '今天', + date_min: `${dayjs(new Date()).add(0, 'day').format('YYYY-MM-DD')} 00:00:00`, + date_max: `${dayjs(new Date()).add(1, 'day').format('YYYY-MM-DD')} 00:00:00`, + }, + 2: { + name: '昨日', + date_min: `${dayjs(new Date()).add(0, 'day').format('YYYY-MM-DD')} 00:00:00`, + date_max: `${dayjs(new Date()).add(-1, 'day').format('YYYY-MM-DD')} 00:00:00`, + }, + 3: { + name: '近7日', + date_min: `${dayjs(new Date()).add(0, 'day').format('YYYY-MM-DD')} 00:00:00`, + date_max: `${dayjs(new Date()).add(-7, 'day').format('YYYY-MM-DD')} 00:00:00`, + }, + 4: { + name: '近30日', + date_min: `${dayjs(new Date()).add(0, 'day').format('YYYY-MM-DD')} 00:00:00`, + date_max: `${dayjs(new Date()).add(-30, 'day').format('YYYY-MM-DD')} 00:00:00`, + }, + 5: { + name: '近90日', + date_min: `${dayjs(new Date()).add(0, 'day').format('YYYY-MM-DD')} 00:00:00`, + date_max: `${dayjs(new Date()).add(-90, 'day').format('YYYY-MM-DD')} 00:00:00`, + }, + } + + const handleSelectedTime = (timeOptionId) => { + setSearchFilter((e) => ({ ...e, timeKey: timeOptionId })) + } + + const handleReset = () => {} + const handleConfirm = () => {} return ( <> 发货类型 - handleSelectedType('default')}> + handleSelectedType('default')}> 不限 - - {!!typeList?.length && typeList?.map(item => { - return ( - handleSelectedType(item?.id)}> - {item.name} - - ) - })} - {/* handleSelectedType(1)}> - 销售发货单 - - handleSelectedType(2)}> - 调拨发货单 - - handleSelectedType(3)}> - 采购退货单 - */} + + {!!typeList?.length && + typeList?.map((item) => { + return ( + handleSelectedType(item?.id)}> + {item.name} + + ) + })} @@ -123,30 +130,46 @@ const DeliveryFilter: FC = memo(() => { 查询日期 - - 不限 - - - 今天 - - - 昨日 - - - 近7日 - - - 近30日 - - - 近90日 - - - 自定义起始时间{} - + {Object.entries(filterTimeOptions).map(([key, value]) => { + return ( + handleSelectedTime(key)}> + {value.name} + + ) + })} + handleSelectedTime('6')}> + 自定义时间 + + + + 重置 + + + 确认 + + ) }) + +interface PropsType { + isActive: boolean + onClick?: Function + children?: React.ReactNode + customClassName?: string +} + +const FilterButton: FC = ({ onClick, children, isActive = false, customClassName }) => { + const handleClick = () => { + onClick?.() + } + return ( + + {children} + + ) +} + export default DeliveryFilter diff --git a/src/pages/delivery/index.tsx b/src/pages/delivery/index.tsx index 9ebd542..ac3aed4 100644 --- a/src/pages/delivery/index.tsx +++ b/src/pages/delivery/index.tsx @@ -171,7 +171,9 @@ const Delivery: FC = () => { setShowFilter(true) } - + const handlePopupClose = () => { + setShowFilter(false) + } return ( @@ -201,7 +203,7 @@ const Delivery: FC = () => { })} - + diff --git a/src/pages/shopping/components/shoppingCartItem/index.tsx b/src/pages/shopping/components/shoppingCartItem/index.tsx index 6f962bb..c02a6ab 100644 --- a/src/pages/shopping/components/shoppingCartItem/index.tsx +++ b/src/pages/shopping/components/shoppingCartItem/index.tsx @@ -138,6 +138,7 @@ export default memo((props) => { + {/* 减少节点渲染 */} {openDetail && (