修改bug
This commit is contained in:
@@ -30,13 +30,12 @@ const TimeSelector: React.FC<TimeSelectorProps> = ({
|
|||||||
const handleConfirm = (date: Date) => {
|
const handleConfirm = (date: Date) => {
|
||||||
console.log('选择的日期:', date)
|
console.log('选择的日期:', date)
|
||||||
const start_time = currentTimeType === 'start' ? getDateStr(date) : value.start_time;
|
const start_time = currentTimeType === 'start' ? getDateStr(date) : value.start_time;
|
||||||
const isLater = dayjs(value.start_time).isAfter(dayjs(value.end_time));
|
const end_time = currentTimeType === 'end' ? getDateStr(date) : value.end_time;
|
||||||
|
const isLater = dayjs(start_time).isAfter(dayjs(end_time));
|
||||||
if (isLater) {
|
if (isLater) {
|
||||||
if (onChange) onChange({start_time, end_time: getEndTime(start_time)})
|
if (onChange) onChange({start_time, end_time: getEndTime(start_time)})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const initEndTime = value.end_time ? value.end_time : getEndTime(start_time)
|
|
||||||
const end_time = currentTimeType === 'end' ? getDateStr(date) : initEndTime;
|
|
||||||
if (onChange) onChange({start_time, end_time})
|
if (onChange) onChange({start_time, end_time})
|
||||||
}
|
}
|
||||||
const openPicker = (type: 'start' | 'end') => {
|
const openPicker = (type: 'start' | 'end') => {
|
||||||
@@ -87,12 +86,14 @@ const TimeSelector: React.FC<TimeSelectorProps> = ({
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<DialogCalendarCard
|
{
|
||||||
|
visible && <DialogCalendarCard
|
||||||
visible={visible}
|
visible={visible}
|
||||||
value={currentTimeValue}
|
value={currentTimeValue}
|
||||||
onChange={handleConfirm}
|
onChange={handleConfirm}
|
||||||
onClose={() => setVisible(false)}
|
onClose={() => setVisible(false)}
|
||||||
/>
|
/>
|
||||||
|
}
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #333;
|
color: #333;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
width: 50px;
|
width: 60px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
.select-stadium {
|
.select-stadium {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: calc(100vh - 10px);
|
max-height: 80vh;
|
||||||
|
min-height: 80vh;
|
||||||
background: #f5f5f5;
|
background: #f5f5f5;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -156,9 +157,9 @@
|
|||||||
.stadium-list {
|
.stadium-list {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
width: auto;
|
width: auto;
|
||||||
|
height: calc(83vh - 130px);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
|
|
||||||
.stadium-item {
|
.stadium-item {
|
||||||
padding: 16px 20px;
|
padding: 16px 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -138,8 +138,8 @@ const SelectStadium: React.FC<SelectStadiumProps> = ({
|
|||||||
const handleItemLocation = (stadium: Stadium) => {
|
const handleItemLocation = (stadium: Stadium) => {
|
||||||
if (stadium.latitude && stadium.longitude) {
|
if (stadium.latitude && stadium.longitude) {
|
||||||
Taro.openLocation({
|
Taro.openLocation({
|
||||||
latitude: stadium.latitude,
|
latitude: stadium.latitude * 1,
|
||||||
longitude: stadium.longitude,
|
longitude: stadium.longitude * 1,
|
||||||
name: stadium.name,
|
name: stadium.name,
|
||||||
address: stadium.address,
|
address: stadium.address,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
.stadium-detail {
|
.stadium-detail {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: auto;
|
|
||||||
min-height: 60vh;
|
|
||||||
background: white;
|
background: white;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
overflow: hidden;
|
overflow-y: scroll;
|
||||||
padding-bottom: env(safe-area-inset-bottom);
|
padding-bottom: env(safe-area-inset-bottom);
|
||||||
|
.stadium-detail-scroll{
|
||||||
|
height:72vh;
|
||||||
|
}
|
||||||
// 已选球场
|
// 已选球场
|
||||||
// 场馆列表
|
// 场馆列表
|
||||||
.stadium-item {
|
.stadium-item {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useState, useCallback, forwardRef, useImperativeHandle } from 'react'
|
import React, { useState, useCallback, forwardRef, useImperativeHandle } from 'react'
|
||||||
import Taro from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
import { View, Text, Image } from '@tarojs/components'
|
import { View, Text, Image, ScrollView } from '@tarojs/components'
|
||||||
import images from '@/config/images'
|
import images from '@/config/images'
|
||||||
import TextareaTag from '@/components/TextareaTag'
|
import TextareaTag from '@/components/TextareaTag'
|
||||||
// import CoverImageUpload, { type CoverImage } from '@/components/ImageUpload'
|
// import CoverImageUpload, { type CoverImage } from '@/components/ImageUpload'
|
||||||
@@ -163,6 +163,7 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
|
|||||||
console.log(stadium,'stadiumstadium');
|
console.log(stadium,'stadiumstadium');
|
||||||
return (
|
return (
|
||||||
<View className='stadium-detail'>
|
<View className='stadium-detail'>
|
||||||
|
<ScrollView className='stadium-detail-scroll' scrollY>
|
||||||
{/* 已选球场 */}
|
{/* 已选球场 */}
|
||||||
<View
|
<View
|
||||||
className={`stadium-item`}
|
className={`stadium-item`}
|
||||||
@@ -240,6 +241,7 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
|
|||||||
|
|
||||||
return null
|
return null
|
||||||
})}
|
})}
|
||||||
|
</ScrollView>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,65 +1,60 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from 'react'
|
||||||
import { View, Text, Button, Image } from "@tarojs/components";
|
import { View, Text, Button, Image } from '@tarojs/components'
|
||||||
import { Checkbox } from "@nutui/nutui-react-taro";
|
import { Checkbox } from '@nutui/nutui-react-taro'
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from '@tarojs/taro'
|
||||||
import { type ActivityType } from "@/components/ActivityTypeSwitch";
|
import { type ActivityType } from '../../components/ActivityTypeSwitch'
|
||||||
import CommonDialog from "@/components/CommonDialog";
|
import CommonDialog from '../../components/CommonDialog'
|
||||||
import { withAuth } from "@/components";
|
import { withAuth } from '@/components'
|
||||||
import PublishForm from "./publishForm";
|
import PublishForm from './publishForm'
|
||||||
import {
|
import { FormFieldConfig, publishBallFormSchema } from '../../config/formSchema/publishBallFormSchema';
|
||||||
FormFieldConfig,
|
import { PublishBallFormData } from '../../../types/publishBall';
|
||||||
publishBallFormSchema,
|
import PublishService from '@/services/publishService';
|
||||||
} from "@/config/formSchema/publishBallFormSchema";
|
import { getNextHourTime, getEndTime, delay } from '@/utils';
|
||||||
import { PublishBallFormData } from "../../../types/publishBall";
|
import images from '@/config/images'
|
||||||
import PublishService from "@/services/publishService";
|
import styles from './index.module.scss'
|
||||||
import { getNextHourTime, getEndTime, delay } from "@/utils";
|
import dayjs from 'dayjs'
|
||||||
import images from "@/config/images";
|
|
||||||
import styles from "./index.module.scss";
|
|
||||||
import dayjs from "dayjs";
|
|
||||||
|
|
||||||
const defaultFormData: PublishBallFormData = {
|
const defaultFormData: PublishBallFormData = {
|
||||||
title: "",
|
title: '',
|
||||||
image_list: [],
|
image_list: [],
|
||||||
timeRange: {
|
timeRange: {
|
||||||
start_time: getNextHourTime(),
|
start_time: getNextHourTime(),
|
||||||
end_time: getEndTime(getNextHourTime()),
|
end_time: getEndTime(getNextHourTime())
|
||||||
},
|
},
|
||||||
activityInfo: {
|
activityInfo: {
|
||||||
play_type: "不限",
|
play_type: '不限',
|
||||||
price: "",
|
price: '',
|
||||||
venue_id: null,
|
venue_id: null,
|
||||||
location_name: "",
|
location_name: '',
|
||||||
location: "",
|
location: '',
|
||||||
latitude: "",
|
latitude: '',
|
||||||
longitude: "",
|
longitude: '',
|
||||||
court_type: "",
|
court_type: '',
|
||||||
court_surface: "",
|
court_surface: '',
|
||||||
venue_description_tag: [],
|
venue_description_tag: [],
|
||||||
venue_description: "",
|
venue_description: '',
|
||||||
venue_image_list: [],
|
venue_image_list: [],
|
||||||
},
|
},
|
||||||
players: [1, 1],
|
players: [1, 1],
|
||||||
skill_level: [1.0, 5.0],
|
skill_level: [1.0, 5.0],
|
||||||
descriptionInfo: {
|
descriptionInfo: {
|
||||||
description: "",
|
description: '',
|
||||||
description_tag: [],
|
description_tag: [],
|
||||||
},
|
},
|
||||||
is_substitute_supported: true,
|
is_substitute_supported: true,
|
||||||
is_wechat_contact: true,
|
is_wechat_contact: true,
|
||||||
wechat_contact: "14223332214",
|
wechat_contact: '14223332214'
|
||||||
};
|
}
|
||||||
|
|
||||||
const PublishBall: React.FC = () => {
|
const PublishBall: React.FC = () => {
|
||||||
const [activityType, setActivityType] = useState<ActivityType>("individual");
|
const [activityType, setActivityType] = useState<ActivityType>('individual')
|
||||||
const [isSubmitDisabled, setIsSubmitDisabled] = useState(false);
|
const [isSubmitDisabled, setIsSubmitDisabled] = useState(false)
|
||||||
// 获取页面参数并设置导航标题
|
// 获取页面参数并设置导航标题
|
||||||
const [optionsConfig, setOptionsConfig] = useState<FormFieldConfig[]>(
|
const [optionsConfig, setOptionsConfig] = useState<FormFieldConfig[]>(publishBallFormSchema)
|
||||||
publishBallFormSchema,
|
|
||||||
);
|
|
||||||
const [formData, setFormData] = useState<PublishBallFormData[]>([
|
const [formData, setFormData] = useState<PublishBallFormData[]>([
|
||||||
defaultFormData,
|
defaultFormData
|
||||||
]);
|
])
|
||||||
const [checked, setChecked] = useState(true);
|
const [checked, setChecked] = useState(true)
|
||||||
|
|
||||||
// 删除确认弹窗状态
|
// 删除确认弹窗状态
|
||||||
const [deleteConfirm, setDeleteConfirm] = useState<{
|
const [deleteConfirm, setDeleteConfirm] = useState<{
|
||||||
@@ -67,225 +62,200 @@ const PublishBall: React.FC = () => {
|
|||||||
index: number;
|
index: number;
|
||||||
}>({
|
}>({
|
||||||
visible: false,
|
visible: false,
|
||||||
index: -1,
|
index: -1
|
||||||
});
|
})
|
||||||
|
|
||||||
// 更新表单数据
|
// 更新表单数据
|
||||||
const updateFormData = (
|
const updateFormData = (key: keyof PublishBallFormData, value: any, index: number) => {
|
||||||
key: keyof PublishBallFormData,
|
console.log(key, value, index, 'key, value, index');
|
||||||
value: any,
|
setFormData(prev => {
|
||||||
index: number,
|
const newData = [...prev]
|
||||||
) => {
|
newData[index] = { ...newData[index], [key]: value }
|
||||||
console.log(key, value, index, "key, value, index");
|
console.log(newData, 'newData');
|
||||||
setFormData((prev) => {
|
return newData
|
||||||
const newData = [...prev];
|
})
|
||||||
newData[index] = { ...newData[index], [key]: value };
|
}
|
||||||
console.log(newData, "newData");
|
|
||||||
return newData;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 处理活动类型变化
|
// 处理活动类型变化
|
||||||
const handleActivityTypeChange = (type: ActivityType) => {
|
const handleActivityTypeChange = (type: ActivityType) => {
|
||||||
if (type === "group") {
|
if (type === 'group') {
|
||||||
setFormData([defaultFormData]);
|
setFormData([defaultFormData])
|
||||||
} else {
|
} else {
|
||||||
setFormData([defaultFormData]);
|
setFormData([defaultFormData])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// 检查相邻两组数据是否相同
|
// 检查相邻两组数据是否相同
|
||||||
const checkAdjacentDataSame = (formDataArray: PublishBallFormData[]) => {
|
const checkAdjacentDataSame = (formDataArray: PublishBallFormData[]) => {
|
||||||
if (formDataArray.length < 2) return false;
|
if (formDataArray.length < 2) return false
|
||||||
|
|
||||||
const lastIndex = formDataArray.length - 1;
|
const lastIndex = formDataArray.length - 1
|
||||||
const secondLastIndex = formDataArray.length - 2;
|
const secondLastIndex = formDataArray.length - 2
|
||||||
|
|
||||||
const lastData = formDataArray[lastIndex];
|
const lastData = formDataArray[lastIndex]
|
||||||
const secondLastData = formDataArray[secondLastIndex];
|
const secondLastData = formDataArray[secondLastIndex]
|
||||||
|
|
||||||
// 比较关键字段是否相同
|
// 比较关键字段是否相同
|
||||||
return JSON.stringify(lastData) === JSON.stringify(secondLastData);
|
return (JSON.stringify(lastData) === JSON.stringify(secondLastData))
|
||||||
};
|
}
|
||||||
|
|
||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
// 检查最后两组数据是否相同
|
// 检查最后两组数据是否相同
|
||||||
if (checkAdjacentDataSame(formData)) {
|
if (checkAdjacentDataSame(formData)) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "信息不可与前序场完全一致",
|
title: '信息不可与前序场完全一致',
|
||||||
icon: "none",
|
icon: 'none'
|
||||||
});
|
})
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
const newStartTime = getNextHourTime();
|
const newStartTime = getNextHourTime()
|
||||||
setFormData((prev) => [
|
setFormData(prev => [...prev, {
|
||||||
...prev,
|
|
||||||
{
|
|
||||||
...defaultFormData,
|
...defaultFormData,
|
||||||
title: "",
|
title: '',
|
||||||
timeRange: {
|
timeRange: {
|
||||||
start_time: newStartTime,
|
start_time: newStartTime,
|
||||||
end_time: getEndTime(newStartTime),
|
end_time: getEndTime(newStartTime)
|
||||||
},
|
}
|
||||||
},
|
}])
|
||||||
]);
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// 复制上一场数据
|
// 复制上一场数据
|
||||||
const handleCopyPrevious = (index: number) => {
|
const handleCopyPrevious = (index: number) => {
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
setFormData((prev) => {
|
setFormData(prev => {
|
||||||
const newData = [...prev];
|
const newData = [...prev]
|
||||||
newData[index] = { ...newData[index - 1] };
|
newData[index] = { ...newData[index - 1] }
|
||||||
return newData;
|
return newData
|
||||||
});
|
})
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "复制上一场填入",
|
title: '复制上一场填入',
|
||||||
icon: "success",
|
icon: 'success'
|
||||||
});
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// 删除确认弹窗
|
// 删除确认弹窗
|
||||||
const showDeleteConfirm = (index: number) => {
|
const showDeleteConfirm = (index: number) => {
|
||||||
setDeleteConfirm({
|
setDeleteConfirm({
|
||||||
visible: true,
|
visible: true,
|
||||||
index,
|
index
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
// 关闭删除确认弹窗
|
// 关闭删除确认弹窗
|
||||||
const closeDeleteConfirm = () => {
|
const closeDeleteConfirm = () => {
|
||||||
setDeleteConfirm({
|
setDeleteConfirm({
|
||||||
visible: false,
|
visible: false,
|
||||||
index: -1,
|
index: -1
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
// 确认删除
|
// 确认删除
|
||||||
const confirmDelete = () => {
|
const confirmDelete = () => {
|
||||||
if (deleteConfirm.index >= 0) {
|
if (deleteConfirm.index >= 0) {
|
||||||
setFormData((prev) =>
|
setFormData(prev => prev.filter((_, index) => index !== deleteConfirm.index))
|
||||||
prev.filter((_, index) => index !== deleteConfirm.index),
|
closeDeleteConfirm()
|
||||||
);
|
|
||||||
closeDeleteConfirm();
|
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "已删除该场次",
|
title: '已删除该场次',
|
||||||
icon: "success",
|
icon: 'success'
|
||||||
});
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
const validateFormData = (
|
const validateFormData = (formData: PublishBallFormData, isOnSubmit: boolean = false) => {
|
||||||
formData: PublishBallFormData,
|
|
||||||
isOnSubmit: boolean = false,
|
|
||||||
) => {
|
|
||||||
const { activityInfo, image_list, title, timeRange } = formData;
|
const { activityInfo, image_list, title, timeRange } = formData;
|
||||||
const { play_type, price, location_name } = activityInfo;
|
const { play_type, price, location_name } = activityInfo;
|
||||||
if (!image_list?.length) {
|
if (!image_list?.length) {
|
||||||
if (!isOnSubmit) {
|
if (!isOnSubmit) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: `请上传活动封面`,
|
title: `请上传活动封面`,
|
||||||
icon: "none",
|
icon: 'none'
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
if (!title) {
|
if (!title) {
|
||||||
if (!isOnSubmit) {
|
if (!isOnSubmit) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: `请输入活动标题`,
|
title: `请输入活动标题`,
|
||||||
icon: "none",
|
icon: 'none'
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
if (
|
if (!price || (typeof price === 'number' && price <= 0) || (typeof price === 'string' && !price.trim())) {
|
||||||
!price ||
|
|
||||||
(typeof price === "number" && price <= 0) ||
|
|
||||||
(typeof price === "string" && !price.trim())
|
|
||||||
) {
|
|
||||||
if (!isOnSubmit) {
|
if (!isOnSubmit) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: `请输入费用`,
|
title: `请输入费用`,
|
||||||
icon: "none",
|
icon: 'none'
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
if (!play_type || !play_type.trim()) {
|
if (!play_type || !play_type.trim()) {
|
||||||
if (!isOnSubmit) {
|
if (!isOnSubmit) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: `请选择玩法类型`,
|
title: `请选择玩法类型`,
|
||||||
icon: "none",
|
icon: 'none'
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
if (!location_name || !location_name.trim()) {
|
if (!location_name || !location_name.trim()) {
|
||||||
if (!isOnSubmit) {
|
if (!isOnSubmit) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: `请选择场地`,
|
title: `请选择场地`,
|
||||||
icon: "none",
|
icon: 'none'
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
// 时间范围校验:结束时间需晚于开始时间,且至少间隔30分钟(支持跨天)
|
// 时间范围校验:结束时间需晚于开始时间,且至少间隔30分钟(支持跨天)
|
||||||
if (timeRange?.start_time && timeRange?.end_time) {
|
if (timeRange?.start_time && timeRange?.end_time) {
|
||||||
const start = dayjs(timeRange.start_time);
|
const start = dayjs(timeRange.start_time)
|
||||||
const end = dayjs(timeRange.end_time);
|
const end = dayjs(timeRange.end_time)
|
||||||
if (!end.isAfter(start)) {
|
if (!end.isAfter(start)) {
|
||||||
if (!isOnSubmit) {
|
if (!isOnSubmit) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: `结束时间需晚于开始时间`,
|
title: `结束时间需晚于开始时间`,
|
||||||
icon: "none",
|
icon: 'none'
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
if (end.isBefore(start.add(30, "minute"))) {
|
if (end.isBefore(start.add(30, 'minute'))) {
|
||||||
if (!isOnSubmit) {
|
if (!isOnSubmit) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: `时间间隔至少30分钟`,
|
title: `时间间隔至少30分钟`,
|
||||||
icon: "none",
|
icon: 'none'
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true
|
||||||
};
|
}
|
||||||
const validateOnSubmit = () => {
|
const validateOnSubmit = () => {
|
||||||
const isValid =
|
const isValid = activityType === 'individual' ? validateFormData(formData[0], true) : formData.every(item => validateFormData(item, true))
|
||||||
activityType === "individual"
|
if (!isValid) {
|
||||||
? validateFormData(formData[0], true)
|
return false
|
||||||
: formData.every((item) => validateFormData(item, true));
|
}
|
||||||
if (!isValid) {
|
return true
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 提交表单
|
// 提交表单
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
// 基础验证
|
// 基础验证
|
||||||
console.log(formData, "formData");
|
console.log(formData, 'formData');
|
||||||
if (activityType === "individual") {
|
if (activityType === 'individual') {
|
||||||
const isValid = validateFormData(formData[0]);
|
const isValid = validateFormData(formData[0])
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
const {
|
const { activityInfo, descriptionInfo, timeRange, players, skill_level,image_list, ...rest } = formData[0];
|
||||||
activityInfo,
|
|
||||||
descriptionInfo,
|
|
||||||
timeRange,
|
|
||||||
players,
|
|
||||||
skill_level,
|
|
||||||
image_list,
|
|
||||||
...rest
|
|
||||||
} = formData[0];
|
|
||||||
const options = {
|
const options = {
|
||||||
...rest,
|
...rest,
|
||||||
...activityInfo,
|
...activityInfo,
|
||||||
@@ -295,49 +265,42 @@ const PublishBall: React.FC = () => {
|
|||||||
current_players: players[0],
|
current_players: players[0],
|
||||||
skill_level_min: skill_level[0],
|
skill_level_min: skill_level[0],
|
||||||
skill_level_max: skill_level[1],
|
skill_level_max: skill_level[1],
|
||||||
image_list: image_list.map((item) => item.url),
|
image_list: image_list.map(item => item.url)
|
||||||
};
|
}
|
||||||
const res = await PublishService.createPersonal(options);
|
const res = await PublishService.createPersonal(options);
|
||||||
if (res.code === 0 && res.data) {
|
if (res.code === 0 && res.data) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "发布成功",
|
title: '发布成功',
|
||||||
icon: "success",
|
icon: 'success'
|
||||||
});
|
})
|
||||||
delay(1000);
|
delay(1000)
|
||||||
// 如果是个人球局,则跳转到详情页,并自动分享
|
// 如果是个人球局,则跳转到详情页,并自动分享
|
||||||
// 如果是畅打,则跳转第一个球局详情页,并自动分享 @刘杰
|
// 如果是畅打,则跳转第一个球局详情页,并自动分享 @刘杰
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
// @ts-expect-error: id
|
// @ts-expect-error: id
|
||||||
url: `/game_pages/detail/index?id=${res.data.id || 1}&from=publish`,
|
url: `/pages/detail/index?id=${res.data.id || 1}&from=publish&autoShare=1`
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: res.message,
|
title: res.message,
|
||||||
icon: "none",
|
icon: 'none'
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (activityType === "group") {
|
if (activityType === 'group') {
|
||||||
const isValid = formData.every((item) => validateFormData(item));
|
const isValid = formData.every(item => validateFormData(item))
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
if (checkAdjacentDataSame(formData)) {
|
if (checkAdjacentDataSame(formData)) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "信息不可与前序场完全一致",
|
title: '信息不可与前序场完全一致',
|
||||||
icon: "none",
|
icon: 'none'
|
||||||
});
|
})
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
const options = formData.map((item) => {
|
const options = formData.map((item) => {
|
||||||
const {
|
const { activityInfo, descriptionInfo, timeRange, players, skill_level, ...rest } = item;
|
||||||
activityInfo,
|
|
||||||
descriptionInfo,
|
|
||||||
timeRange,
|
|
||||||
players,
|
|
||||||
skill_level,
|
|
||||||
...rest
|
|
||||||
} = item;
|
|
||||||
return {
|
return {
|
||||||
...rest,
|
...rest,
|
||||||
...activityInfo,
|
...activityInfo,
|
||||||
@@ -347,122 +310,122 @@ const PublishBall: React.FC = () => {
|
|||||||
current_players: players[0],
|
current_players: players[0],
|
||||||
skill_level_min: skill_level[0],
|
skill_level_min: skill_level[0],
|
||||||
skill_level_max: skill_level[1],
|
skill_level_max: skill_level[1],
|
||||||
image_list: item.image_list.map((img) => img.url),
|
image_list: item.image_list.map(img => img.url)
|
||||||
};
|
}
|
||||||
});
|
})
|
||||||
const res = await PublishService.create_play_pmoothlys({ rows: options });
|
const res = await PublishService.create_play_pmoothlys({rows: options});
|
||||||
if (res.code === 0 && res.data) {
|
if (res.code === 0 && res.data) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "发布成功",
|
title: '发布成功',
|
||||||
icon: "success",
|
icon: 'success'
|
||||||
});
|
})
|
||||||
delay(1000);
|
delay(1000)
|
||||||
// 如果是个人球局,则跳转到详情页,并自动分享
|
// 如果是个人球局,则跳转到详情页,并自动分享
|
||||||
// 如果是畅打,则跳转第一个球局详情页,并自动分享 @刘杰
|
// 如果是畅打,则跳转第一个球局详情页,并自动分享 @刘杰
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
// @ts-expect-error: id
|
// @ts-expect-error: id
|
||||||
url: `/game_pages/detail/index?id=${res.data?.[0].id || 1}&from=publish`,
|
url: `/pages/detail/index?id=${res.data?.[0].id || 1}&from=publish&autoShare=1`
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: res.message,
|
title: res.message,
|
||||||
icon: "none",
|
icon: 'none'
|
||||||
});
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
const initFormData = () => {
|
const initFormData = () => {
|
||||||
const currentInstance = Taro.getCurrentInstance();
|
const currentInstance = Taro.getCurrentInstance()
|
||||||
const params = currentInstance.router?.params;
|
const params = currentInstance.router?.params
|
||||||
if (params?.type) {
|
if (params?.type) {
|
||||||
const type = params.type as ActivityType;
|
const type = params.type as ActivityType
|
||||||
if (type === "individual" || type === "group") {
|
if (type === 'individual' || type === 'group') {
|
||||||
setActivityType(type);
|
setActivityType(type)
|
||||||
if (type === "group") {
|
if (type === 'group') {
|
||||||
const newFormSchema = publishBallFormSchema.reduce((acc, item) => {
|
const newFormSchema = publishBallFormSchema.reduce((acc, item) => {
|
||||||
if (item.prop === "is_wechat_contact") {
|
if (item.prop === 'is_wechat_contact') {
|
||||||
return acc;
|
return acc
|
||||||
}
|
}
|
||||||
if (item.prop === "image_list") {
|
if (item.prop === 'image_list') {
|
||||||
if (item.props) {
|
if (item.props) {
|
||||||
item.props.source = ["album", "history"];
|
item.props.source = ['album', 'history']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (item.prop === "players") {
|
if (item.prop === 'players') {
|
||||||
if (item.props) {
|
if (item.props) {
|
||||||
item.props.max = 100;
|
item.props.max = 100
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
acc.push(item);
|
acc.push(item)
|
||||||
return acc;
|
return acc
|
||||||
}, [] as FormFieldConfig[]);
|
}, [] as FormFieldConfig[])
|
||||||
setOptionsConfig(newFormSchema);
|
setOptionsConfig(newFormSchema)
|
||||||
setFormData([defaultFormData]);
|
setFormData([defaultFormData])
|
||||||
}
|
}
|
||||||
// 根据type设置导航标题
|
// 根据type设置导航标题
|
||||||
if (type === "group") {
|
if (type === 'group') {
|
||||||
Taro.setNavigationBarTitle({
|
Taro.setNavigationBarTitle({
|
||||||
title: "发布畅打活动",
|
title: '发布畅打活动'
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
Taro.setNavigationBarTitle({
|
Taro.setNavigationBarTitle({
|
||||||
title: "发布",
|
title: '发布'
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleActivityTypeChange(type);
|
handleActivityTypeChange(type)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
const onCheckedChange = (checked: boolean) => {
|
const onCheckedChange = (checked: boolean) => {
|
||||||
setChecked(checked);
|
setChecked(checked)
|
||||||
};
|
|
||||||
useEffect(() => {
|
|
||||||
const isValid = validateOnSubmit();
|
|
||||||
if (!isValid) {
|
|
||||||
setIsSubmitDisabled(true);
|
|
||||||
} else {
|
|
||||||
setIsSubmitDisabled(false);
|
|
||||||
}
|
}
|
||||||
console.log(formData, "formData");
|
useEffect(() => {
|
||||||
}, [formData]);
|
const isValid = validateOnSubmit()
|
||||||
|
if (!isValid) {
|
||||||
|
setIsSubmitDisabled(true)
|
||||||
|
} else {
|
||||||
|
setIsSubmitDisabled(false)
|
||||||
|
}
|
||||||
|
console.log(formData, 'formData');
|
||||||
|
}, [formData])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
initFormData();
|
initFormData()
|
||||||
}, []);
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className={styles["publish-ball"]}>
|
<View className={styles['publish-ball']}>
|
||||||
{/* 活动类型切换 */}
|
{/* 活动类型切换 */}
|
||||||
<View className={styles["activity-type-switch"]}>
|
<View className={styles['activity-type-switch']}>
|
||||||
{/* <ActivityTypeSwitch
|
{/* <ActivityTypeSwitch
|
||||||
value={activityType}
|
value={activityType}
|
||||||
onChange={handleActivityTypeChange}
|
onChange={handleActivityTypeChange}
|
||||||
/> */}
|
/> */}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className={styles["publish-ball__scroll"]}>
|
<View className={styles['publish-ball__scroll']}>
|
||||||
{formData.map((item, index) => (
|
{
|
||||||
|
formData.map((item, index) => (
|
||||||
<View key={index}>
|
<View key={index}>
|
||||||
{/* 场次标题行 */}
|
{/* 场次标题行 */}
|
||||||
{activityType === "group" && index > 0 && (
|
{activityType === 'group' && index > 0 && (
|
||||||
<View className={styles["session-header"]}>
|
<View className={styles['session-header']}>
|
||||||
<View className={styles["session-title"]}>
|
<View className={styles['session-title']}>
|
||||||
第{index + 1}场
|
第{index + 1}场
|
||||||
<View
|
<View
|
||||||
className={styles["session-delete"]}
|
className={styles['session-delete']}
|
||||||
onClick={() => showDeleteConfirm(index)}
|
onClick={() => showDeleteConfirm(index)}
|
||||||
>
|
>
|
||||||
<Image
|
<Image src={images.ICON_DELETE} className={styles['session-delete-icon']} />
|
||||||
src={images.ICON_DELETE}
|
|
||||||
className={styles["session-delete-icon"]}
|
|
||||||
/>
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles["session-actions"]}>
|
<View className={styles['session-actions']}>
|
||||||
|
|
||||||
{index > 0 && (
|
{index > 0 && (
|
||||||
<View
|
<View
|
||||||
className={styles["session-action-btn"]}
|
className={styles['session-action-btn']}
|
||||||
onClick={() => handleCopyPrevious(index)}
|
onClick={() => handleCopyPrevious(index)}
|
||||||
>
|
>
|
||||||
复制上一场
|
复制上一场
|
||||||
@@ -477,16 +440,16 @@ const PublishBall: React.FC = () => {
|
|||||||
optionsConfig={optionsConfig}
|
optionsConfig={optionsConfig}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
))}
|
))
|
||||||
{activityType === "group" && (
|
}
|
||||||
<View className={styles["publish-ball__add"]} onClick={handleAdd}>
|
{
|
||||||
<Image
|
activityType === 'group' && (
|
||||||
src={images.ICON_ADD}
|
<View className={styles['publish-ball__add']} onClick={handleAdd}>
|
||||||
className={styles["publish-ball__add-icon"]}
|
<Image src={images.ICON_ADD} className={styles['publish-ball__add-icon']} />
|
||||||
/>
|
|
||||||
再添加一场
|
再添加一场
|
||||||
</View>
|
</View>
|
||||||
)}
|
)
|
||||||
|
}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* 删除确认弹窗 */}
|
{/* 删除确认弹窗 */}
|
||||||
@@ -500,32 +463,33 @@ const PublishBall: React.FC = () => {
|
|||||||
contentDesc="该操作不可恢复"
|
contentDesc="该操作不可恢复"
|
||||||
/>
|
/>
|
||||||
{/* 完成按钮 */}
|
{/* 完成按钮 */}
|
||||||
<View className={styles["submit-section"]}>
|
<View className={styles['submit-section']}>
|
||||||
<Button
|
<Button className={`${styles['submit-btn']} ${isSubmitDisabled ? styles['submit-btn-disabled'] : ''}`} onClick={handleSubmit}>
|
||||||
className={`${styles["submit-btn"]} ${isSubmitDisabled ? styles["submit-btn-disabled"] : ""}`}
|
|
||||||
onClick={handleSubmit}
|
|
||||||
>
|
|
||||||
发布
|
发布
|
||||||
</Button>
|
</Button>
|
||||||
{activityType === "individual" && (
|
{
|
||||||
<Text className={styles["submit-tip"]}>
|
activityType === 'individual' && (
|
||||||
|
<Text className={styles['submit-tip']}>
|
||||||
点击确定发布约球,即表示已经同意条款
|
点击确定发布约球,即表示已经同意条款
|
||||||
<Text className={styles["link"]}>《约球规则》</Text>
|
<Text className={styles['link']}>《约球规则》</Text>
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)
|
||||||
{activityType === "group" && (
|
}
|
||||||
<View className={styles["submit-tip"]}>
|
{
|
||||||
|
activityType === 'group' && (
|
||||||
|
<View className={styles['submit-tip']}>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
className={styles["submit-checkbox"]}
|
className={styles['submit-checkbox']}
|
||||||
checked={checked}
|
checked={checked}
|
||||||
onChange={onCheckedChange}
|
onChange={onCheckedChange}
|
||||||
/>
|
/>
|
||||||
已认证 徐汇爱打球官方球场,请严格遵守签约协议
|
已认证 徐汇爱打球官方球场,请严格遵守签约协议
|
||||||
</View>
|
</View>
|
||||||
)}
|
)
|
||||||
|
}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
)
|
||||||
};
|
}
|
||||||
|
|
||||||
export default withAuth(PublishBall);
|
export default withAuth(PublishBall)
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import React, { useState, useEffect } from 'react'
|
|||||||
import { View, Text } from '@tarojs/components'
|
import { View, Text } from '@tarojs/components'
|
||||||
import { ImageUpload, Range, TimeSelector, TextareaTag, NumberInterval, TitleTextarea, FormSwitch, UploadCover } from '@/components'
|
import { ImageUpload, Range, TimeSelector, TextareaTag, NumberInterval, TitleTextarea, FormSwitch, UploadCover } from '@/components'
|
||||||
import FormBasicInfo from './components/FormBasicInfo'
|
import FormBasicInfo from './components/FormBasicInfo'
|
||||||
import { type CoverImage } from '@/components/index.types'
|
import { type CoverImage } from '../../components/index.types'
|
||||||
import { FormFieldConfig, FieldType } from '@/config/formSchema/publishBallFormSchema'
|
import { FormFieldConfig, FieldType } from '../../config/formSchema/publishBallFormSchema'
|
||||||
import { PublishBallFormData } from '../../../types/publishBall';
|
import { PublishBallFormData } from '../../../types/publishBall';
|
||||||
import WechatSwitch from './components/WechatSwitch/WechatSwitch'
|
import WechatSwitch from './components/WechatSwitch/WechatSwitch'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
|||||||
Reference in New Issue
Block a user