修改发布增加拖动
This commit is contained in:
@@ -6,16 +6,30 @@ import { InputNumber } from '@nutui/nutui-react-taro'
|
||||
interface NumberIntervalProps {
|
||||
value: [number, number]
|
||||
onChange: (value: [number, number]) => void
|
||||
min: number
|
||||
max: number
|
||||
}
|
||||
|
||||
const NumberInterval: React.FC<NumberIntervalProps> = ({
|
||||
value,
|
||||
onChange
|
||||
onChange,
|
||||
min,
|
||||
max
|
||||
}) => {
|
||||
const [minParticipants, maxParticipants] = value || [1, 4]
|
||||
const [minParticipants, maxParticipants] = value || [1, 1]
|
||||
|
||||
const handleChange = (value: [number | string, number | string]) => {
|
||||
onChange([Number(value[0]), Number(value[1])])
|
||||
const newMin = Number(value[0])
|
||||
const newMax = Number(value[1])
|
||||
|
||||
// 确保最少人数不能大于最多人数
|
||||
if (newMin > newMax) {
|
||||
return
|
||||
}
|
||||
|
||||
onChange([newMin, newMax])
|
||||
}
|
||||
|
||||
return (
|
||||
<View className='participants-control-section'>
|
||||
<View className='participant-control'>
|
||||
@@ -24,7 +38,7 @@ const NumberInterval: React.FC<NumberIntervalProps> = ({
|
||||
<InputNumber
|
||||
className="format-width"
|
||||
defaultValue={minParticipants}
|
||||
min={minParticipants}
|
||||
min={min}
|
||||
max={maxParticipants}
|
||||
onChange={(value) => handleChange([value, maxParticipants])}
|
||||
formatter={(value) => `${value}人`}
|
||||
@@ -37,9 +51,9 @@ const NumberInterval: React.FC<NumberIntervalProps> = ({
|
||||
<InputNumber
|
||||
className="format-width"
|
||||
defaultValue={maxParticipants}
|
||||
onChange={(value) => handleChange([value, maxParticipants])}
|
||||
onChange={(value) => handleChange([minParticipants, value])}
|
||||
min={minParticipants}
|
||||
max={maxParticipants}
|
||||
max={max}
|
||||
formatter={(value) => `${value}人`}
|
||||
/>
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user