🐞 fix(ID1000657): 修复新版内部商城购物车的数字框无法输入的问题
This commit is contained in:
parent
215e180003
commit
176470d110
@ -38,7 +38,6 @@ export default forwardRef((props: params, ref) => {
|
|||||||
customTextClass = '',
|
customTextClass = '',
|
||||||
hiddenCheckboxIcon = false,
|
hiddenCheckboxIcon = false,
|
||||||
} = props
|
} = props
|
||||||
console.log('Rerender component: checkbox', status)
|
|
||||||
const [selected, setSelected] = usePropsValue({
|
const [selected, setSelected] = usePropsValue({
|
||||||
value: status,
|
value: status,
|
||||||
defaultValue: false
|
defaultValue: false
|
||||||
|
@ -15,7 +15,6 @@ type params = {
|
|||||||
disable?: boolean, //是否禁用
|
disable?: boolean, //是否禁用
|
||||||
}
|
}
|
||||||
export default ({minNum = 0, maxNum = 10000, step=1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '', disable = false}: params) => {
|
export default ({minNum = 0, maxNum = 10000, step=1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '', disable = false}: params) => {
|
||||||
console.log('Rerender component: Counter');
|
|
||||||
const [value, setValue] = useState<any>({count:defaultNum})
|
const [value, setValue] = useState<any>({count:defaultNum})
|
||||||
|
|
||||||
const onPlus = (event) => {
|
const onPlus = (event) => {
|
||||||
@ -34,7 +33,7 @@ export default ({minNum = 0, maxNum = 10000, step=1, digits = 0, defaultNum = 0,
|
|||||||
if(disable) return false
|
if(disable) return false
|
||||||
let {count} = value
|
let {count} = value
|
||||||
let num_res = Big(count).minus(step).toNumber()
|
let num_res = Big(count).minus(step).toNumber()
|
||||||
num_res = num_res < minNum?minNum:num_res
|
num_res = num_res < minNum ? minNum : num_res
|
||||||
setValue({...value, count:num_res})
|
setValue({...value, count:num_res})
|
||||||
onChange?.(parseFloat(num_res))
|
onChange?.(parseFloat(num_res))
|
||||||
onClickBtn?.(parseFloat(num_res))
|
onClickBtn?.(parseFloat(num_res))
|
||||||
@ -93,6 +92,8 @@ export default ({minNum = 0, maxNum = 10000, step=1, digits = 0, defaultNum = 0,
|
|||||||
|
|
||||||
const onBluerEven = () => {
|
const onBluerEven = () => {
|
||||||
let num = parseFloat(value.count)
|
let num = parseFloat(value.count)
|
||||||
|
console.log('onInputEven res===>', num)
|
||||||
|
|
||||||
if (!isNaN(num)) {
|
if (!isNaN(num)) {
|
||||||
let count = formatDigits(num)
|
let count = formatDigits(num)
|
||||||
count = checkData(count)
|
count = checkData(count)
|
||||||
|
@ -20,7 +20,6 @@ type PropsType = {
|
|||||||
|
|
||||||
const ColorCard: FC<PropsType> = params => {
|
const ColorCard: FC<PropsType> = params => {
|
||||||
const { item = {}, index, onTakeColor, onPreviewRgb, currentTakeColorIndex, measureAndGetLab, bluetoothState } = params
|
const { item = {}, index, onTakeColor, onPreviewRgb, currentTakeColorIndex, measureAndGetLab, bluetoothState } = params
|
||||||
console.log('Rerender component: ColorCard', params)
|
|
||||||
console.log('item===>', item)
|
console.log('item===>', item)
|
||||||
const truncation = ev => {
|
const truncation = ev => {
|
||||||
if (ev) {
|
if (ev) {
|
||||||
|
@ -5,7 +5,7 @@ import { FC, forwardRef, memo, useCallback } from 'react'
|
|||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import { debounce } from '@/common/util'
|
import { debounce } from '@/common/util'
|
||||||
import { formatImgUrl, formatPriceDiv } from '@/common/format'
|
import { formatImgUrl, formatMeterDiv, formatMeterMul, formatPriceDiv } from '@/common/format'
|
||||||
import { EnumSaleMode } from '@/common/Enumerate'
|
import { EnumSaleMode } from '@/common/Enumerate'
|
||||||
import { selectList } from '../../config'
|
import { selectList } from '../../config'
|
||||||
import { AdjestShoppingCartApi } from '@/api/shopping/index'
|
import { AdjestShoppingCartApi } from '@/api/shopping/index'
|
||||||
@ -25,7 +25,6 @@ type PropsType = {
|
|||||||
|
|
||||||
let ColorKindItem: FC<PropsType> = props => {
|
let ColorKindItem: FC<PropsType> = props => {
|
||||||
const { state, purchaserId, itemData, orderType = EnumSaleMode.Bulk } = props
|
const { state, purchaserId, itemData, orderType = EnumSaleMode.Bulk } = props
|
||||||
console.log('Rerender component: ColorKindItem', itemData.id)
|
|
||||||
const dispatch = useShoppingDispatch()
|
const dispatch = useShoppingDispatch()
|
||||||
// console.log('checked==>', checked)
|
// console.log('checked==>', checked)
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ let ColorKindItem: FC<PropsType> = props => {
|
|||||||
|
|
||||||
//格式化数量
|
//格式化数量
|
||||||
const formatCount = itemData => {
|
const formatCount = itemData => {
|
||||||
return itemData.sale_mode == EnumSaleMode.Bulk ? itemData.roll : itemData.length / 100
|
return itemData.sale_mode == EnumSaleMode.Bulk ? itemData.roll : formatMeterDiv(itemData.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
//格式化单位
|
//格式化单位
|
||||||
@ -68,6 +67,7 @@ let ColorKindItem: FC<PropsType> = props => {
|
|||||||
|
|
||||||
// 调整条数/米数的接口 并在调整完成后重新请求整个购物车页面
|
// 调整条数/米数的接口 并在调整完成后重新请求整个购物车页面
|
||||||
const getInputValue = debounce(async (num, itemData) => {
|
const getInputValue = debounce(async (num, itemData) => {
|
||||||
|
console.log('num===>', num)
|
||||||
const targetColor: Record<string, any> = {
|
const targetColor: Record<string, any> = {
|
||||||
product_color_id: itemData.product_color_id,
|
product_color_id: itemData.product_color_id,
|
||||||
roll: 0,
|
roll: 0,
|
||||||
@ -78,7 +78,7 @@ let ColorKindItem: FC<PropsType> = props => {
|
|||||||
targetColor.roll = num
|
targetColor.roll = num
|
||||||
} else {
|
} else {
|
||||||
itemData.length = num
|
itemData.length = num
|
||||||
targetColor.length = num
|
targetColor.length = formatMeterMul(num)
|
||||||
}
|
}
|
||||||
const res = await fetchData({
|
const res = await fetchData({
|
||||||
color_list: [targetColor],
|
color_list: [targetColor],
|
||||||
@ -89,7 +89,7 @@ let ColorKindItem: FC<PropsType> = props => {
|
|||||||
if (res.success) {
|
if (res.success) {
|
||||||
state?.Observer?.notify(purchaserId)
|
state?.Observer?.notify(purchaserId)
|
||||||
}
|
}
|
||||||
}, 400)
|
}, 460)
|
||||||
const labAndImgObj = useCallback(item => {
|
const labAndImgObj = useCallback(item => {
|
||||||
return { lab: item.lab, rgb: item.rgb, texture_url: item.product_color_texture_url }
|
return { lab: item.lab, rgb: item.rgb, texture_url: item.product_color_texture_url }
|
||||||
}, [])
|
}, [])
|
||||||
@ -102,8 +102,6 @@ let ColorKindItem: FC<PropsType> = props => {
|
|||||||
customTextClass={styles.colorKindItem}>
|
customTextClass={styles.colorKindItem}>
|
||||||
<View className={styles['colorKindItem__left']}>
|
<View className={styles['colorKindItem__left']}>
|
||||||
<LabAndImg value={labAndImgObj(itemData)} />
|
<LabAndImg value={labAndImgObj(itemData)} />
|
||||||
|
|
||||||
{/* <Image className={styles['colorKindItem__left--image']} mode='aspectFill' src={formatImgUrl(itemData.product_color_texture_url)}></Image> */}
|
|
||||||
</View>
|
</View>
|
||||||
<View className={styles['colorKindItem__center']}>
|
<View className={styles['colorKindItem__center']}>
|
||||||
<Text className={styles['colorKindItem__center--title']}>
|
<Text className={styles['colorKindItem__center--title']}>
|
||||||
@ -124,8 +122,8 @@ let ColorKindItem: FC<PropsType> = props => {
|
|||||||
digits={selectList[orderType].digits}
|
digits={selectList[orderType].digits}
|
||||||
onClickBtn={e => getInputValue(e, itemData)}
|
onClickBtn={e => getInputValue(e, itemData)}
|
||||||
unit={formatUnit(itemData)}
|
unit={formatUnit(itemData)}
|
||||||
minNum={itemData.min_num}
|
minNum={itemData.sale_mode == EnumSaleMode.Bulk ? itemData.min_num : formatMeterDiv(itemData.min_num)}
|
||||||
maxNum={itemData.max_num}
|
maxNum={itemData.sale_mode == EnumSaleMode.Bulk ? itemData.max_num : formatMeterDiv(itemData.max_num)}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
@ -89,7 +89,6 @@ let ShoppingCartItem: FC<PropsType> = props => {
|
|||||||
dispatch({ type: ShoppingDispatchType.UPDATE_MULTIPLE_SELECTION, data: false })
|
dispatch({ type: ShoppingDispatchType.UPDATE_MULTIPLE_SELECTION, data: false })
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Rerender component: shoppingCartItem')
|
|
||||||
|
|
||||||
const handleClickLayout = () => {
|
const handleClickLayout = () => {
|
||||||
if (currentCheckedPurchaserId === itemData?.purchaser_id) {
|
if (currentCheckedPurchaserId === itemData?.purchaser_id) {
|
||||||
@ -288,7 +287,6 @@ interface GoodsListPropType {
|
|||||||
startTransition: React.TransitionStartFunction
|
startTransition: React.TransitionStartFunction
|
||||||
}
|
}
|
||||||
const GoodsList = memo<GoodsListPropType>(props => {
|
const GoodsList = memo<GoodsListPropType>(props => {
|
||||||
console.log('Rerender component: GoodsList', props)
|
|
||||||
const { itemData, selected, isPending, startTransition, multipleSelection } = props
|
const { itemData, selected, isPending, startTransition, multipleSelection } = props
|
||||||
|
|
||||||
const currentSelected = useRef<EnumSaleMode | null>(null)
|
const currentSelected = useRef<EnumSaleMode | null>(null)
|
||||||
@ -302,6 +300,7 @@ const GoodsList = memo<GoodsListPropType>(props => {
|
|||||||
setComponent(
|
setComponent(
|
||||||
itemData?.[BackEndSaleModeListFieldMap[selected]].length !== 0 ? (
|
itemData?.[BackEndSaleModeListFieldMap[selected]].length !== 0 ? (
|
||||||
itemData?.[BackEndSaleModeListFieldMap[selected]].map(item => {
|
itemData?.[BackEndSaleModeListFieldMap[selected]].map(item => {
|
||||||
|
console.log('item===>', item)
|
||||||
return <ColorKindItem purchaserId={itemData.purchaser_id} key={item.id} itemData={item} orderType={selected}></ColorKindItem>
|
return <ColorKindItem purchaserId={itemData.purchaser_id} key={item.id} itemData={item} orderType={selected}></ColorKindItem>
|
||||||
})
|
})
|
||||||
) : (
|
) : (
|
||||||
@ -367,10 +366,6 @@ const GoodsList = memo<GoodsListPropType>(props => {
|
|||||||
const withStateSlice = (comp, slice) => {
|
const withStateSlice = (comp, slice) => {
|
||||||
const MemoComp = memo(comp, (prevProps, nextProps) => {
|
const MemoComp = memo(comp, (prevProps, nextProps) => {
|
||||||
let needMemo = true
|
let needMemo = true
|
||||||
console.log('---------------props-----------------------')
|
|
||||||
console.log('props prevProps==>', prevProps.itemData)
|
|
||||||
console.log('props nextProps==>', nextProps.itemData)
|
|
||||||
console.log('-----------------props---------------------')
|
|
||||||
if (JSON.stringify(prevProps.itemData) !== JSON.stringify(nextProps.itemData)) {
|
if (JSON.stringify(prevProps.itemData) !== JSON.stringify(nextProps.itemData)) {
|
||||||
needMemo = false
|
needMemo = false
|
||||||
}
|
}
|
||||||
@ -381,7 +376,6 @@ const withStateSlice = (comp, slice) => {
|
|||||||
})
|
})
|
||||||
const Wrapper = (props, ref) => {
|
const Wrapper = (props, ref) => {
|
||||||
const state = useShoppingState()
|
const state = useShoppingState()
|
||||||
console.log('state===>', state)
|
|
||||||
return <MemoComp ref={ref} state={slice(state, props)} {...props} />
|
return <MemoComp ref={ref} state={slice(state, props)} {...props} />
|
||||||
}
|
}
|
||||||
return memo(forwardRef(Wrapper))
|
return memo(forwardRef(Wrapper))
|
||||||
|
@ -69,7 +69,6 @@ const ShoppingCartContainer: FC<InternalContainer> = () => {
|
|||||||
fetchData(searchOptions)
|
fetchData(searchOptions)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log('Rerender component: ShoppingCartContainer')
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('useEffect fetchData')
|
console.log('useEffect fetchData')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user