修改发布增加拖动

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

@@ -1,5 +1,5 @@
import React, { useState, useCallback, useEffect } from 'react'
import { View, Text, Input, Image, Picker } from '@tarojs/components'
import { View, Text, Input, Image } from '@tarojs/components'
import PopupGameplay from '../PopupGameplay'
import img from '@/config/images';
import { FormFieldConfig } from '@/config/formSchema/publishBallFormSchema';
@@ -65,10 +65,52 @@ const FormBasicInfo: React.FC<FormBasicInfoProps> = ({
})
setShowStadiumSelector(false)
}
const handleChange = useCallback((key: string, costValue: any) => {
// 价格输入限制¥0.009999.99
console.log(costValue, 'valuevalue');
const handleChange = useCallback((key: string, value: any) => {
onChange({...value, [key]: value})
}, [onChange])
if (key === children[0]?.prop) {
// 允许清空
if (costValue === '') {
onChange({...value, [key]: ''});
return;
}
// 只允许数字和一个小数点
const filteredValue = costValue.replace(/[^\d.]/g, '');
// 确保只有一个小数点
const parts = filteredValue.split('.');
if (parts.length > 2) {
return; // 不更新,保持原值
}
// 限制小数点后最多2位
if (parts.length === 2 && parts[1].length > 2) {
return; // 不更新,保持原值
}
const numValue = parseFloat(filteredValue);
if (isNaN(numValue)) {
onChange({...value, [key]: ''});
return;
}
if (numValue < 0) {
onChange({...value, [key]: '0'});
return;
}
if (numValue > 9999.99) {
onChange({...value, [key]: '9999.99'});
return;
}
// 使用过滤后的值
onChange({...value, [key]: filteredValue});
return;
}
onChange({...value, [key]: costValue})
}, [onChange, children])
useEffect(() => {
if (children.length > 2) {
@@ -76,6 +118,10 @@ const FormBasicInfo: React.FC<FormBasicInfoProps> = ({
setPlayGame(options)
}
}, [children])
useEffect(() => {
console.log(value, 'valuevalue');
}, [value])
const renderChildren = () => {
return children.map((child: any, index: number) => {
return <View className='form-item'>
@@ -91,6 +137,7 @@ const FormBasicInfo: React.FC<FormBasicInfoProps> = ({
placeholder='请输入'
placeholderClass='title-placeholder'
type='digit'
maxlength={7}
value={value[child.prop]}
onInput={(e) => handleChange(child.prop, e.detail.value)}
/>