From da5d41cfaaeac222611568213fa97f6f6819d94a Mon Sep 17 00:00:00 2001 From: xuan Date: Thu, 20 Oct 2022 16:53:50 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf(=E9=94=80=E5=94=AE=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1):=20=E4=BC=98=E5=8C=96=E4=B8=8B=E6=8B=89=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SelectSaleRankingIndicators/index.tsx | 1 + src/components/dropDown-item/index.tsx | 9 ++++----- src/components/infiniteScroll/index.tsx | 3 +++ src/components/popup/index.module.scss | 6 +++--- src/components/popup/index.tsx | 5 ++++- src/custom-tab-bar/index.tsx | 1 - .../shopping/components/bottomEditBar/index.tsx | 2 -- src/pages/shopping/index.tsx | 7 ++++--- src/use/useCommon.ts | 15 +++++++++++++++ 9 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/components/SelectSaleRankingIndicators/index.tsx b/src/components/SelectSaleRankingIndicators/index.tsx index 574d234..3da6d54 100644 --- a/src/components/SelectSaleRankingIndicators/index.tsx +++ b/src/components/SelectSaleRankingIndicators/index.tsx @@ -5,6 +5,7 @@ import { SaleOrderDataFormdataFormStatus } from '@/api/index' import { View } from '@tarojs/components' import styles from './index.module.scss' import classnames from 'classnames' +import { ShoppingProvider } from '@/pages/shopping/components/shoppingCart' type ChangedValue = string | number diff --git a/src/components/dropDown-item/index.tsx b/src/components/dropDown-item/index.tsx index 0b33e96..1c1e13e 100644 --- a/src/components/dropDown-item/index.tsx +++ b/src/components/dropDown-item/index.tsx @@ -69,18 +69,18 @@ export default forwardRef((props: PropsType, ref) => { } const handleClickTitle = () => { - setShowPopup(true) + setShowPopup(prev => !prev) } const handleClosePopup = () => { - if (hasBottomBtn) return false + if (hasBottomBtn) return setShowPopup(false) } const [overlayOffsetTop, setOverlayOffsetTop] = useState('unset') // 获取遮罩层的样式 const getOverlayStyle = (): React.CSSProperties => { - return { position: 'absolute', top: 0 } + return { position: !showOverlay ? 'fixed' : 'absolute', top: 0 } } // 获取整个页面的完整高度 @@ -110,7 +110,6 @@ export default forwardRef((props: PropsType, ref) => { } }, [overlayOffsetTop]) - return ( @@ -120,7 +119,7 @@ export default forwardRef((props: PropsType, ref) => { handleClosePopup()} + onClose={handleClosePopup} showOverLay={showOverlay} show={showPopup} showTitle={false} diff --git a/src/components/infiniteScroll/index.tsx b/src/components/infiniteScroll/index.tsx index f794bec..5da7475 100644 --- a/src/components/infiniteScroll/index.tsx +++ b/src/components/infiniteScroll/index.tsx @@ -3,6 +3,8 @@ import React, { memo, ReactNode, useMemo, useState } from 'react' import style from './index.module.scss' import DotLoading from '@/components/dotLoading' import LoadingCard from '../loadingCard' +import { useCustomTabItemTap } from '@/use/useCommon' +import Taro from '@tarojs/taro' export type StatusParam = 0 | 1 | 2 | 3 @@ -119,6 +121,7 @@ export default memo( return ( <> { animationEnd?.() + customStyle.overflow = 'unset' }, 260) } else { clearTimeout(animationTime.current) @@ -60,10 +61,12 @@ export default memo( return ( + {/* 遮罩层 start */} + {/* 遮罩层 end */} { const { selectedId, tabItem } = useSelector((state) => { - console.log('sdfasdfa', state) return state.tabBarData }) // const tabBarIndexMap = useMemo(() => { diff --git a/src/pages/shopping/components/bottomEditBar/index.tsx b/src/pages/shopping/components/bottomEditBar/index.tsx index 7f57da0..76d24af 100644 --- a/src/pages/shopping/components/bottomEditBar/index.tsx +++ b/src/pages/shopping/components/bottomEditBar/index.tsx @@ -1,7 +1,5 @@ -import { formatPriceDiv } from '@/common/format' import NormalButton from '@/components/normalButton' import { View, Text } from '@tarojs/components' -import { memo, SetStateAction, useMemo, useRef, useState } from 'react' import styles from './index.module.scss' import MCheckbox from '@/components/checkbox' import { usePropsValue } from '@/use/useCommon' diff --git a/src/pages/shopping/index.tsx b/src/pages/shopping/index.tsx index ced5159..5390982 100644 --- a/src/pages/shopping/index.tsx +++ b/src/pages/shopping/index.tsx @@ -52,8 +52,8 @@ const ShoppingCartContainer: FC = () => { // 管理 const onStartToManage = () => { - if(isManageStatus){ - handleSelectAllCheckbox(false) // 取消全选 + if (isManageStatus) { + handleSelectAllCheckbox(false) // 取消全选 } dispatch({ type: ShoppingDispatchType.UPDATE_MANAGE_STATUS, data: !isManageStatus }) } @@ -201,6 +201,7 @@ const ShoppingCartContainer: FC = () => { setRefreshStatus(false) } } + return ( @@ -216,7 +217,7 @@ const ShoppingCartContainer: FC = () => { - + {isPending ? ( diff --git a/src/use/useCommon.ts b/src/use/useCommon.ts index 8995b5c..1217ad8 100644 --- a/src/use/useCommon.ts +++ b/src/use/useCommon.ts @@ -1,3 +1,5 @@ +import { useSelector } from '@/reducers/hooks' +import { useRouter } from '@tarojs/taro' import dayjs from 'dayjs' import { useEffect, useRef, useState, SetStateAction, useMemo, useCallback } from 'react' @@ -174,3 +176,16 @@ export function usePropsValue(options: UsePropsValueOptions) { }, []) return [stateRef.current, setState] as const } + +// 点击自定义 tab 时触发。 +export function useCustomTabItemTap(callback) { + const { selectedId, tabItem } = useSelector(state => { + return state.tabBarData + }) + const targetPagePayload = tabItem.find(item => item.id === selectedId) + callback({ + index: targetPagePayload?.id, + pagePath: targetPagePayload?.pagePath, + text: targetPagePayload?.text, + }) +}