diff --git a/src/pages/publishBall/components/SelectStadium/StadiumDetail.tsx b/src/pages/publishBall/components/SelectStadium/StadiumDetail.tsx index 00ec828..e864a11 100644 --- a/src/pages/publishBall/components/SelectStadium/StadiumDetail.tsx +++ b/src/pages/publishBall/components/SelectStadium/StadiumDetail.tsx @@ -98,8 +98,8 @@ const StadiumDetail = forwardRef(({ const [formData, setFormData] = useState({ name: stadium.name, address: stadium.address, - latitude: stadium.longitude, - longitude: stadium.latitude, + latitude: stadium.latitude, + longitude: stadium.longitude, istance: stadium.distance_km, court_type: court_type[0] || '', court_surface: court_surface[0] || '', diff --git a/src/pages/publishBall/components/WechatSwitch/WechatSwitch.tsx b/src/pages/publishBall/components/WechatSwitch/WechatSwitch.tsx index 1088f68..d422422 100644 --- a/src/pages/publishBall/components/WechatSwitch/WechatSwitch.tsx +++ b/src/pages/publishBall/components/WechatSwitch/WechatSwitch.tsx @@ -11,13 +11,23 @@ interface FormSwitchProps { const FormSwitch: React.FC = ({ value, onChange, subTitle, wechatId }) => { const [editWechat, setEditWechat] = useState(false) + const [wechatIdValue, setWechatIdValue] = useState('') + const [wechat, setWechat] = useState(wechatId) const editWechatId = () => { - + setEditWechat(true) } const setWechatId = useCallback((e: any) => { const value = e.target.value - onChange(value) - }, []) + onChange && onChange(value) + setWechatIdValue(value) + }, [onChange]) + + const fillWithPhone = () => { + if (wechat) { + setWechatIdValue(wechat) + } + } + return ( <> @@ -32,7 +42,7 @@ const FormSwitch: React.FC = ({ value, onChange, subTitle, wech { - wechatId && ( + !editWechat && wechatId && ( 微信号: {wechatId.replace(/(\d{3})(\d{4})(\d{4})/, '$1 $2 $3')} 修改 @@ -41,8 +51,11 @@ const FormSwitch: React.FC = ({ value, onChange, subTitle, wech } { editWechat && ( - - + + + + + 手机号填入:{wechat} ) } diff --git a/src/pages/publishBall/components/WechatSwitch/index.module.scss b/src/pages/publishBall/components/WechatSwitch/index.module.scss index 655a7dc..cb42f1e 100644 --- a/src/pages/publishBall/components/WechatSwitch/index.module.scss +++ b/src/pages/publishBall/components/WechatSwitch/index.module.scss @@ -1,3 +1,5 @@ +@use '~@/scss/themeColor.scss' as theme; + .wechat-contact-section { background: #fff; border-radius: 12px; @@ -86,6 +88,13 @@ border-radius: 100px; border: 0.5px solid rgba(0, 0, 0, 0.06); } + .wechat-contact-edit-input { + max-width: 200px; + font-size: 12px; + .input-placeholder{ + color: theme.$textarea-placeholder-color; + } + } } } \ No newline at end of file diff --git a/src/pages/publishBall/index.tsx b/src/pages/publishBall/index.tsx index f4c2bd8..f983208 100644 --- a/src/pages/publishBall/index.tsx +++ b/src/pages/publishBall/index.tsx @@ -11,6 +11,7 @@ import PublishService from '@/services/publishService'; import { getNextHourTime, getEndTime, delay } from '@/utils'; import images from '@/config/images' import styles from './index.module.scss' +import dayjs from 'dayjs' const defaultFormData: PublishBallFormData = { title: '', @@ -163,7 +164,7 @@ const PublishBall: React.FC = () => { } const validateFormData = (formData: PublishBallFormData, isOnSubmit: boolean = false) => { - const { activityInfo, image_list, title } = formData; + const { activityInfo, image_list, title, timeRange } = formData; const { play_type, price, location_name } = activityInfo; if (!image_list?.length) { if (!isOnSubmit) { @@ -210,6 +211,30 @@ const PublishBall: React.FC = () => { } return false } + // 时间范围校验:结束时间需晚于开始时间,且至少间隔30分钟(支持跨天) + if (timeRange?.start_time && timeRange?.end_time) { + const start = dayjs(timeRange.start_time) + const end = dayjs(timeRange.end_time) + if (!end.isAfter(start)) { + if (!isOnSubmit) { + Taro.showToast({ + title: `结束时间需晚于开始时间`, + icon: 'none' + }) + } + return false + } + if (end.isBefore(start.add(30, 'minute'))) { + if (!isOnSubmit) { + Taro.showToast({ + title: `时间间隔至少30分钟`, + icon: 'none' + }) + } + return false + } + } + return true } const validateOnSubmit = () => { diff --git a/src/pages/publishBall/publishForm.tsx b/src/pages/publishBall/publishForm.tsx index eb7b8b6..c53f6e0 100644 --- a/src/pages/publishBall/publishForm.tsx +++ b/src/pages/publishBall/publishForm.tsx @@ -136,7 +136,6 @@ const PublishForm: React.FC<{ - // 获取动态表单配置 const dynamicConfig = getDynamicFormConfig() diff --git a/src/services/publishService.ts b/src/services/publishService.ts index 24d55d9..6cec553 100644 --- a/src/services/publishService.ts +++ b/src/services/publishService.ts @@ -34,6 +34,7 @@ export interface createGameData extends PublishBallData { status: string, created_at: string, updated_at: string, + id?: string | number, } // 响应接口