diff --git a/.eslintrc b/.eslintrc index b9c8964..757fd8f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -15,6 +15,7 @@ "react/display-name": "off", "no-use-before-define": "off", "@typescript-eslint/no-use-before-define": "warn", - "array-callback-return": 0 + "array-callback-return": 0, + "react/prop-types": 0 } } \ No newline at end of file diff --git a/src/common/constant.ts b/src/common/constant.ts index 0667a86..52a5e1f 100644 --- a/src/common/constant.ts +++ b/src/common/constant.ts @@ -1,4 +1,4 @@ -// export const BASE_URL = CURRENT_BASE_URL +export const BASE_URL = CURRENT_BASE_URL // export const BASE_URL = `http://192.168.0.75:50001/lymarket` // export const BASE_URL = `http://192.168.0.89:50001/lymarket` // export const BASE_URL = `http://10.0.0.5:50001/lymarket` @@ -14,7 +14,7 @@ // export const BASE_URL = `http://192.168.1.5:40001/lymarket` // 王霞 // export const BASE_URL = 'http://192.168.1.7:50002/lymarket' // 添 // export const BASE_URL = 'http://192.168.1.28:50001/lymarket' // 婷 -export const BASE_URL = 'http://192.168.1.42:50002/lymarket' // 杰 +// export const BASE_URL = 'http://192.168.1.42:50002/lymarket' // 杰 // CDN // 生成密钥 diff --git a/src/pages/shopCar/components/colorCheckbox/index.tsx b/src/pages/shopCar/components/colorCheckbox/index.tsx index 52817c3..d5cf15c 100644 --- a/src/pages/shopCar/components/colorCheckbox/index.tsx +++ b/src/pages/shopCar/components/colorCheckbox/index.tsx @@ -1,4 +1,4 @@ -import { memo, useCallback } from 'react' +import { forwardRef, memo, useCallback, useImperativeHandle } from 'react' import MCheckbox from '@/components/checkbox' import type { ColorType, ProductType } from '@/context/ContextShop' import { useCurrenShop } from '@/context/ContextShop' @@ -10,19 +10,21 @@ interface IndexType { onSelect?: (val: boolean) => void checkStatus: boolean } -export default memo((props: ParamType) => { +export default memo(forwardRef((props: ParamType, ref) => { const { colorItem } = props const { state, dispatch } = useCurrenShop() const indexs = colorItem.index_str.split(',') const onSelect = useCallback((status) => { - state.list[indexs[0]].color_list[indexs[1]].checked = status + state.list[indexs[0]].color_list[indexs[1]].checked = !state.list[indexs[0]].color_list[indexs[1]].checked const tf = state.list[indexs[0]].color_list.some(item => item.checked) state.list[indexs[0]].checked = tf dispatch({ type: 'updateProduct', data: { list: state.list } }) }, [state.list[indexs[0]].color_list[indexs[1]].checked]) - + useImperativeHandle(ref, () => ({ + onSelect, + })) return -}) +})) const Index = memo((props: IndexType) => { const { checkStatus, onSelect } = props diff --git a/src/pages/shopCar/components/productItem/index.tsx b/src/pages/shopCar/components/productItem/index.tsx index 107d9d0..ce092cd 100644 --- a/src/pages/shopCar/components/productItem/index.tsx +++ b/src/pages/shopCar/components/productItem/index.tsx @@ -1,6 +1,6 @@ import { CustomWrapper, Text, View } from '@tarojs/components' import Taro from '@tarojs/taro' -import { memo, useCallback, useEffect, useMemo, useState } from 'react' +import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' import Big from 'big.js' import ColorCheckbox from '../colorCheckbox' import RecommendProduct from '../recommendProduct' @@ -92,11 +92,13 @@ const Index = memo((props: IndexItemType) => { return selectList[colorItem.sale_mode] }, [colorItem]) console.log('colorItem::', colorItem) + + const checkBoxRef = useRef(null) return <> - - + + checkBoxRef.current.onSelect()}>