feat: 将detail迁移至mod_user目录
This commit is contained in:
@@ -10,11 +10,6 @@ export default defineAppConfig({
|
|||||||
"pages/search/index", // 搜索页
|
"pages/search/index", // 搜索页
|
||||||
"pages/searchResult/index", // 搜索结果页面
|
"pages/searchResult/index", // 搜索结果页面
|
||||||
"pages/publishBall/index",
|
"pages/publishBall/index",
|
||||||
"pages/detail/index",
|
|
||||||
// 'pages/message/index',
|
|
||||||
// 'pages/orderCheck/index',
|
|
||||||
|
|
||||||
// 'pages/mapDisplay/index',
|
|
||||||
],
|
],
|
||||||
subPackages: [
|
subPackages: [
|
||||||
{
|
{
|
||||||
@@ -22,6 +17,7 @@ export default defineAppConfig({
|
|||||||
pages: [
|
pages: [
|
||||||
"pages/myself/index", // 个人中心
|
"pages/myself/index", // 个人中心
|
||||||
"pages/edit/index", // 个人中心
|
"pages/edit/index", // 个人中心
|
||||||
|
"detail/index", // 球局详情页
|
||||||
"message/index", // 消息页
|
"message/index", // 消息页
|
||||||
"orderList/index", // 订单列表页
|
"orderList/index", // 订单列表页
|
||||||
"orderDetail/index", // 订单详情页
|
"orderDetail/index", // 订单详情页
|
||||||
|
|||||||
@@ -17,19 +17,24 @@ const ListCard: React.FC<ListCardProps> = ({
|
|||||||
play_type,
|
play_type,
|
||||||
image_list = [],
|
image_list = [],
|
||||||
court_type,
|
court_type,
|
||||||
key
|
key,
|
||||||
}) => {
|
}) => {
|
||||||
const renderItemImage = (src: string) => {
|
const renderItemImage = (src: string) => {
|
||||||
return <Image src={src} className="image" mode="aspectFill"
|
return (
|
||||||
lazyLoad
|
<Image
|
||||||
defaultSource='https://images.unsplash.com/photo-1554068865-24cecd4e34b8?w=200&h=200&fit=crop&crop=center'
|
src={src}
|
||||||
/>;
|
className="image"
|
||||||
|
mode="aspectFill"
|
||||||
|
lazyLoad
|
||||||
|
defaultSource="https://images.unsplash.com/photo-1554068865-24cecd4e34b8?w=200&h=200&fit=crop&crop=center"
|
||||||
|
/>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleViewDetail = () => {
|
const handleViewDetail = () => {
|
||||||
console.log('id', id)
|
console.log("id", id);
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url: `/pages/detail/index?id=${id || 1}&from=list&autoShare=0`,
|
url: `/mod_user/detail/index?id=${id || 1}&from=list`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -40,7 +45,9 @@ const ListCard: React.FC<ListCardProps> = ({
|
|||||||
if (image_list?.length === 1) {
|
if (image_list?.length === 1) {
|
||||||
return (
|
return (
|
||||||
<View className="single-image">
|
<View className="single-image">
|
||||||
<View className="image-container">{renderItemImage(image_list?.[0])}</View>
|
<View className="image-container">
|
||||||
|
{renderItemImage(image_list?.[0])}
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -48,8 +55,12 @@ const ListCard: React.FC<ListCardProps> = ({
|
|||||||
if (image_list?.length === 2) {
|
if (image_list?.length === 2) {
|
||||||
return (
|
return (
|
||||||
<View className="double-image">
|
<View className="double-image">
|
||||||
<View className="image-container">{renderItemImage(image_list?.[0])}</View>
|
<View className="image-container">
|
||||||
<View className="image-container">{renderItemImage(image_list?.[1])}</View>
|
{renderItemImage(image_list?.[0])}
|
||||||
|
</View>
|
||||||
|
<View className="image-container">
|
||||||
|
{renderItemImage(image_list?.[1])}
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -57,9 +68,15 @@ const ListCard: React.FC<ListCardProps> = ({
|
|||||||
// 3张或更多图片
|
// 3张或更多图片
|
||||||
return (
|
return (
|
||||||
<View className="triple-image">
|
<View className="triple-image">
|
||||||
<View className="image-container">{renderItemImage(image_list?.[0])}</View>
|
<View className="image-container">
|
||||||
<View className="image-container">{renderItemImage(image_list?.[1])}</View>
|
{renderItemImage(image_list?.[0])}
|
||||||
<View className="image-container">{renderItemImage(image_list?.[2])}</View>
|
</View>
|
||||||
|
<View className="image-container">
|
||||||
|
{renderItemImage(image_list?.[1])}
|
||||||
|
</View>
|
||||||
|
<View className="image-container">
|
||||||
|
{renderItemImage(image_list?.[2])}
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -69,14 +86,16 @@ const ListCard: React.FC<ListCardProps> = ({
|
|||||||
{/* 左侧内容区域 */}
|
{/* 左侧内容区域 */}
|
||||||
<View className="content">
|
<View className="content">
|
||||||
{/* 标题 */}
|
{/* 标题 */}
|
||||||
{title && <View className="titleWrapper">
|
{title && (
|
||||||
<Text className="title">{title}</Text>
|
<View className="titleWrapper">
|
||||||
<Image
|
<Text className="title">{title}</Text>
|
||||||
src={img.ICON_LIST_RIGHT_ARROW}
|
<Image
|
||||||
className="title-right-arrow"
|
src={img.ICON_LIST_RIGHT_ARROW}
|
||||||
mode="aspectFit"
|
className="title-right-arrow"
|
||||||
/>
|
mode="aspectFit"
|
||||||
</View>}
|
/>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* 时间信息 */}
|
{/* 时间信息 */}
|
||||||
<View className="date-time">
|
<View className="date-time">
|
||||||
@@ -86,8 +105,11 @@ const ListCard: React.FC<ListCardProps> = ({
|
|||||||
{/* 地点,室内外,距离 */}
|
{/* 地点,室内外,距离 */}
|
||||||
|
|
||||||
<View className="location">
|
<View className="location">
|
||||||
{location &&
|
{location && (
|
||||||
<Text className="location-text location-position">{location}</Text>}
|
<Text className="location-text location-position">
|
||||||
|
{location}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
<Text className="location-text location-time-distance">
|
<Text className="location-text location-time-distance">
|
||||||
{court_type && `・${court_type}`}
|
{court_type && `・${court_type}`}
|
||||||
{distance_km && `・${distance_km}km`}
|
{distance_km && `・${distance_km}km`}
|
||||||
@@ -98,17 +120,15 @@ const ListCard: React.FC<ListCardProps> = ({
|
|||||||
<View className="bottom-info">
|
<View className="bottom-info">
|
||||||
<View className="left-section">
|
<View className="left-section">
|
||||||
<View className="avatar-group">
|
<View className="avatar-group">
|
||||||
{Array.from({ length: 3 }).map(
|
{Array.from({ length: 3 }).map((_, index) => (
|
||||||
(_, index) => (
|
<View key={index} className="avatar">
|
||||||
<View key={index} className="avatar">
|
<Image
|
||||||
<Image
|
className="avatar-image"
|
||||||
className="avatar-image"
|
src="https://images.unsplash.com/photo-1554068865-24cecd4e34b8?w=200&h=200&fit=crop&crop=center"
|
||||||
src="https://images.unsplash.com/photo-1554068865-24cecd4e34b8?w=200&h=200&fit=crop&crop=center"
|
mode="aspectFill"
|
||||||
mode="aspectFill"
|
/>
|
||||||
/>
|
</View>
|
||||||
</View>
|
))}
|
||||||
)
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
@@ -120,11 +140,15 @@ const ListCard: React.FC<ListCardProps> = ({
|
|||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<View className="tag">
|
<View className="tag">
|
||||||
<Text className="tag-text">{skill_level_min} 至 {skill_level_max}</Text>
|
<Text className="tag-text">
|
||||||
|
{skill_level_min} 至 {skill_level_max}
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
{play_type && <View className="tag">
|
{play_type && (
|
||||||
<Text className="tag-text">{play_type}</Text>
|
<View className="tag">
|
||||||
</View>}
|
<Text className="tag-text">{play_type}</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@@ -135,13 +159,19 @@ const ListCard: React.FC<ListCardProps> = ({
|
|||||||
{/* 畅打球局 */}
|
{/* 畅打球局 */}
|
||||||
<View className="smoothPlayingGame">
|
<View className="smoothPlayingGame">
|
||||||
<View className="smoothWrapper">
|
<View className="smoothWrapper">
|
||||||
<Image src={img.ICON_LIST_PLAYING_GAME} className="iconListPlayingGame" />
|
<Image
|
||||||
|
src={img.ICON_LIST_PLAYING_GAME}
|
||||||
|
className="iconListPlayingGame"
|
||||||
|
/>
|
||||||
<Text className="smoothTitle">畅打球局</Text>
|
<Text className="smoothTitle">畅打球局</Text>
|
||||||
</View>
|
</View>
|
||||||
<View className="line" />
|
<View className="line" />
|
||||||
<View>场馆方:</View>
|
<View>场馆方:</View>
|
||||||
<View className="localAreaWrapper">
|
<View className="localAreaWrapper">
|
||||||
<Image className="localArea" src="https://images.unsplash.com/photo-1554068865-24cecd4e34b8?w=200&h=200&fit=crop&crop=center" />
|
<Image
|
||||||
|
className="localArea"
|
||||||
|
src="https://images.unsplash.com/photo-1554068865-24cecd4e34b8?w=200&h=200&fit=crop&crop=center"
|
||||||
|
/>
|
||||||
<Text className="localAreaText">仁恒河滨花园网球场</Text>
|
<Text className="localAreaText">仁恒河滨花园网球场</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ const SharePopup = forwardRef(
|
|||||||
// useShareAppMessage(() => {
|
// useShareAppMessage(() => {
|
||||||
// return {
|
// return {
|
||||||
// title: '分享',
|
// title: '分享',
|
||||||
// path: `/pages/detail/index?id=${id}&from=share`,
|
// path: `/mod_user/detail/index?id=${id}&from=share`,
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
@@ -176,7 +176,7 @@ const SharePopup = forwardRef(
|
|||||||
// useShareTimeline(() => {
|
// useShareTimeline(() => {
|
||||||
// return {
|
// return {
|
||||||
// title: '分享',
|
// title: '分享',
|
||||||
// path: `/pages/detail/index?id=${id}&from=share`,
|
// path: `/mod_user/detail/index?id=${id}&from=share`,
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
@@ -105,7 +105,7 @@ const OtherUserPage: React.FC = () => {
|
|||||||
// 处理球局详情
|
// 处理球局详情
|
||||||
const handle_game_detail = (game_id: string) => {
|
const handle_game_detail = (game_id: string) => {
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url: `/pages/detail/index?id=${game_id}`,
|
url: `/mod_user/detail/index?id=${game_id}&from=personal`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,60 +1,65 @@
|
|||||||
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 { FormFieldConfig, publishBallFormSchema } from '../../config/formSchema/publishBallFormSchema';
|
import {
|
||||||
import { PublishBallFormData } from '../../../types/publishBall';
|
FormFieldConfig,
|
||||||
import PublishService from '@/services/publishService';
|
publishBallFormSchema,
|
||||||
import { getNextHourTime, getEndTime, delay } from '@/utils';
|
} from "../../config/formSchema/publishBallFormSchema";
|
||||||
import images from '@/config/images'
|
import { PublishBallFormData } from "../../../types/publishBall";
|
||||||
import styles from './index.module.scss'
|
import PublishService from "@/services/publishService";
|
||||||
import dayjs from 'dayjs'
|
import { getNextHourTime, getEndTime, delay } from "@/utils";
|
||||||
|
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[]>(publishBallFormSchema)
|
const [optionsConfig, setOptionsConfig] = useState<FormFieldConfig[]>(
|
||||||
|
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<{
|
||||||
@@ -62,200 +67,225 @@ const PublishBall: React.FC = () => {
|
|||||||
index: number;
|
index: number;
|
||||||
}>({
|
}>({
|
||||||
visible: false,
|
visible: false,
|
||||||
index: -1
|
index: -1,
|
||||||
})
|
});
|
||||||
|
|
||||||
// 更新表单数据
|
// 更新表单数据
|
||||||
const updateFormData = (key: keyof PublishBallFormData, value: any, index: number) => {
|
const updateFormData = (
|
||||||
console.log(key, value, index, 'key, value, index');
|
key: keyof PublishBallFormData,
|
||||||
setFormData(prev => {
|
value: any,
|
||||||
const newData = [...prev]
|
index: number,
|
||||||
newData[index] = { ...newData[index], [key]: value }
|
) => {
|
||||||
console.log(newData, 'newData');
|
console.log(key, value, index, "key, value, index");
|
||||||
return newData
|
setFormData((prev) => {
|
||||||
})
|
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 => [...prev, {
|
setFormData((prev) => [
|
||||||
...defaultFormData,
|
...prev,
|
||||||
title: '',
|
{
|
||||||
timeRange: {
|
...defaultFormData,
|
||||||
start_time: newStartTime,
|
title: "",
|
||||||
end_time: getEndTime(newStartTime)
|
timeRange: {
|
||||||
}
|
start_time: 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 => prev.filter((_, index) => index !== deleteConfirm.index))
|
setFormData((prev) =>
|
||||||
closeDeleteConfirm()
|
prev.filter((_, index) => index !== deleteConfirm.index),
|
||||||
|
);
|
||||||
|
closeDeleteConfirm();
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '已删除该场次',
|
title: "已删除该场次",
|
||||||
icon: 'success'
|
icon: "success",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const validateFormData = (formData: PublishBallFormData, isOnSubmit: boolean = false) => {
|
const validateFormData = (
|
||||||
|
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 (!price || (typeof price === 'number' && price <= 0) || (typeof price === 'string' && !price.trim())) {
|
if (
|
||||||
|
!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 = activityType === 'individual' ? validateFormData(formData[0], true) : formData.every(item => validateFormData(item, true))
|
const isValid =
|
||||||
|
activityType === "individual"
|
||||||
|
? validateFormData(formData[0], true)
|
||||||
|
: formData.every((item) => validateFormData(item, true));
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
return true
|
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 { activityInfo, descriptionInfo, timeRange, players, skill_level,image_list, ...rest } = formData[0];
|
const {
|
||||||
|
activityInfo,
|
||||||
|
descriptionInfo,
|
||||||
|
timeRange,
|
||||||
|
players,
|
||||||
|
skill_level,
|
||||||
|
image_list,
|
||||||
|
...rest
|
||||||
|
} = formData[0];
|
||||||
const options = {
|
const options = {
|
||||||
...rest,
|
...rest,
|
||||||
...activityInfo,
|
...activityInfo,
|
||||||
@@ -265,43 +295,50 @@ 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: `/pages/detail/index?id=${res.data.id || 1}&from=publish&autoShare=1`
|
url: `/mod_user/detail/index?id=${res.data.id || 1}&from=publish`,
|
||||||
})
|
});
|
||||||
} 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 { activityInfo, descriptionInfo, timeRange, players, skill_level, ...rest } = item;
|
const {
|
||||||
return {
|
activityInfo,
|
||||||
|
descriptionInfo,
|
||||||
|
timeRange,
|
||||||
|
players,
|
||||||
|
skill_level,
|
||||||
|
...rest
|
||||||
|
} = item;
|
||||||
|
return {
|
||||||
...rest,
|
...rest,
|
||||||
...activityInfo,
|
...activityInfo,
|
||||||
...descriptionInfo,
|
...descriptionInfo,
|
||||||
@@ -310,146 +347,146 @@ 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: `/pages/detail/index?id=${res.data?.[0].id || 1}&from=publish&autoShare=1`
|
url: `/mod_user/detail/index?id=${res.data?.[0].id || 1}&from=publish`,
|
||||||
})
|
});
|
||||||
} 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(() => {
|
useEffect(() => {
|
||||||
const isValid = validateOnSubmit()
|
const isValid = validateOnSubmit();
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
setIsSubmitDisabled(true)
|
setIsSubmitDisabled(true);
|
||||||
} else {
|
} else {
|
||||||
setIsSubmitDisabled(false)
|
setIsSubmitDisabled(false);
|
||||||
}
|
}
|
||||||
console.log(formData, 'formData');
|
console.log(formData, "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 src={images.ICON_DELETE} className={styles['session-delete-icon']} />
|
<Image
|
||||||
|
src={images.ICON_DELETE}
|
||||||
</View>
|
className={styles["session-delete-icon"]}
|
||||||
</View>
|
/>
|
||||||
<View className={styles['session-actions']}>
|
|
||||||
|
|
||||||
{index > 0 && (
|
|
||||||
<View
|
|
||||||
className={styles['session-action-btn']}
|
|
||||||
onClick={() => handleCopyPrevious(index)}
|
|
||||||
>
|
|
||||||
复制上一场
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)}
|
<View className={styles["session-actions"]}>
|
||||||
<PublishForm
|
{index > 0 && (
|
||||||
formData={item}
|
<View
|
||||||
onChange={(key, value) => updateFormData(key, value, index)}
|
className={styles["session-action-btn"]}
|
||||||
optionsConfig={optionsConfig}
|
onClick={() => handleCopyPrevious(index)}
|
||||||
/>
|
>
|
||||||
</View>
|
复制上一场
|
||||||
))
|
</View>
|
||||||
}
|
)}
|
||||||
{
|
</View>
|
||||||
activityType === 'group' && (
|
</View>
|
||||||
<View className={styles['publish-ball__add']} onClick={handleAdd}>
|
)}
|
||||||
<Image src={images.ICON_ADD} className={styles['publish-ball__add-icon']} />
|
<PublishForm
|
||||||
再添加一场
|
formData={item}
|
||||||
</View>
|
onChange={(key, value) => updateFormData(key, value, index)}
|
||||||
)
|
optionsConfig={optionsConfig}
|
||||||
}
|
/>
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
|
{activityType === "group" && (
|
||||||
|
<View className={styles["publish-ball__add"]} onClick={handleAdd}>
|
||||||
|
<Image
|
||||||
|
src={images.ICON_ADD}
|
||||||
|
className={styles["publish-ball__add-icon"]}
|
||||||
|
/>
|
||||||
|
再添加一场
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* 删除确认弹窗 */}
|
{/* 删除确认弹窗 */}
|
||||||
@@ -463,33 +500,32 @@ const PublishBall: React.FC = () => {
|
|||||||
contentDesc="该操作不可恢复"
|
contentDesc="该操作不可恢复"
|
||||||
/>
|
/>
|
||||||
{/* 完成按钮 */}
|
{/* 完成按钮 */}
|
||||||
<View className={styles['submit-section']}>
|
<View className={styles["submit-section"]}>
|
||||||
<Button className={`${styles['submit-btn']} ${isSubmitDisabled ? styles['submit-btn-disabled'] : ''}`} onClick={handleSubmit}>
|
<Button
|
||||||
|
className={`${styles["submit-btn"]} ${isSubmitDisabled ? styles["submit-btn-disabled"] : ""}`}
|
||||||
|
onClick={handleSubmit}
|
||||||
|
>
|
||||||
发布
|
发布
|
||||||
</Button>
|
</Button>
|
||||||
{
|
{activityType === "individual" && (
|
||||||
activityType === 'individual' && (
|
<Text className={styles["submit-tip"]}>
|
||||||
<Text className={styles['submit-tip']}>
|
点击确定发布约球,即表示已经同意条款
|
||||||
点击确定发布约球,即表示已经同意条款
|
<Text className={styles["link"]}>《约球规则》</Text>
|
||||||
<Text className={styles['link']}>《约球规则》</Text>
|
</Text>
|
||||||
</Text>
|
)}
|
||||||
)
|
{activityType === "group" && (
|
||||||
}
|
<View className={styles["submit-tip"]}>
|
||||||
{
|
<Checkbox
|
||||||
activityType === 'group' && (
|
className={styles["submit-checkbox"]}
|
||||||
<View className={styles['submit-tip']}>
|
checked={checked}
|
||||||
<Checkbox
|
onChange={onCheckedChange}
|
||||||
className={styles['submit-checkbox']}
|
/>
|
||||||
checked={checked}
|
已认证 徐汇爱打球官方球场,请严格遵守签约协议
|
||||||
onChange={onCheckedChange}
|
</View>
|
||||||
/>
|
)}
|
||||||
已认证 徐汇爱打球官方球场,请严格遵守签约协议
|
|
||||||
</View>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default withAuth(PublishBall)
|
export default withAuth(PublishBall);
|
||||||
|
|||||||
Reference in New Issue
Block a user