修改发布增加拖动

This commit is contained in:
筱野
2025-08-31 20:19:10 +08:00
parent 721a9fab9d
commit f5aff7ce73
16 changed files with 399 additions and 115 deletions

View File

@@ -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>