编辑球局
This commit is contained in:
@@ -89,7 +89,7 @@ const PublishMenu: React.FC<PublishMenuProps> = () => {
|
|||||||
<Image src={images.ICON_GROUP} />
|
<Image src={images.ICON_GROUP} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
{/* <View
|
<View
|
||||||
className={`${styles.menuItem} ${styles.aiItem}`}
|
className={`${styles.menuItem} ${styles.aiItem}`}
|
||||||
onClick={() => handleMenuItemClick('ai')}
|
onClick={() => handleMenuItemClick('ai')}
|
||||||
>
|
>
|
||||||
@@ -105,7 +105,7 @@ const PublishMenu: React.FC<PublishMenuProps> = () => {
|
|||||||
<View className={styles.menuIcon}>
|
<View className={styles.menuIcon}>
|
||||||
<Image src={images.ICON_IMPORTANT_BTN} />
|
<Image src={images.ICON_IMPORTANT_BTN} />
|
||||||
</View>
|
</View>
|
||||||
</View> */}
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,8 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
|
|||||||
description:{
|
description:{
|
||||||
description: '',
|
description: '',
|
||||||
description_tag: []
|
description_tag: []
|
||||||
}
|
},
|
||||||
|
venue_id: stadium.id
|
||||||
})
|
})
|
||||||
|
|
||||||
// 暴露方法给父组件
|
// 暴露方法给父组件
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
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 dayjs from 'dayjs'
|
||||||
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'
|
||||||
@@ -15,8 +16,8 @@ import GeneralNavbar from "@/components/GeneralNavbar"
|
|||||||
import images from '@/config/images'
|
import images from '@/config/images'
|
||||||
import { useUserInfo } from '@/store/userStore'
|
import { useUserInfo } from '@/store/userStore'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { usePublishBallData } from '@/store/publishBallStore'
|
import { usePublishBallData } from '@/store/publishBallStore'
|
||||||
|
import DetailService from "@/services/detailService";
|
||||||
|
|
||||||
const defaultFormData: PublishBallFormData = {
|
const defaultFormData: PublishBallFormData = {
|
||||||
title: '',
|
title: '',
|
||||||
@@ -171,17 +172,17 @@ const PublishBall: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const validateFormData = (formData: PublishBallFormData, isOnSubmit: boolean = false) => {
|
const validateFormData = (formData: PublishBallFormData, isOnSubmit: boolean = false) => {
|
||||||
const { activityInfo, title, timeRange } = formData;
|
const { activityInfo, title, timeRange, image_list } = formData;
|
||||||
const { play_type, price, location_name } = activityInfo;
|
const { play_type, price, location_name } = activityInfo;
|
||||||
// if (!image_list?.length) {
|
if (!image_list?.length && activityType === 'group') {
|
||||||
// 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({
|
||||||
@@ -252,10 +253,17 @@ const PublishBall: React.FC = () => {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getParams = () => {
|
||||||
|
const currentInstance = Taro.getCurrentInstance()
|
||||||
|
const params = currentInstance.router?.params
|
||||||
|
return params
|
||||||
|
}
|
||||||
// 提交表单
|
// 提交表单
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
// 基础验证
|
// 基础验证
|
||||||
console.log(formData, 'formData');
|
console.log(formData, 'formData');
|
||||||
|
const params = getParams()
|
||||||
|
const { republish } = params || {};
|
||||||
if (activityType === 'individual') {
|
if (activityType === 'individual') {
|
||||||
const isValid = validateFormData(formData[0])
|
const isValid = validateFormData(formData[0])
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
@@ -277,10 +285,11 @@ const PublishBall: React.FC = () => {
|
|||||||
is_wechat_contact: wechat.is_wechat_contact,
|
is_wechat_contact: wechat.is_wechat_contact,
|
||||||
wechat_contact: wechat.wechat_contact || wechat.default_wechat_contact,
|
wechat_contact: wechat.wechat_contact || wechat.default_wechat_contact,
|
||||||
}
|
}
|
||||||
const res = await PublishService.createPersonal(options);
|
const res = republish === '0' ? await PublishService.gamesUpdate(options) : await PublishService.createPersonal(options);
|
||||||
|
const successText = republish === '0' ? '更新成功' : '发布成功';
|
||||||
if (res.code === 0 && res.data) {
|
if (res.code === 0 && res.data) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '发布成功',
|
title: successText,
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
})
|
})
|
||||||
delay(1000)
|
delay(1000)
|
||||||
@@ -325,10 +334,11 @@ const PublishBall: React.FC = () => {
|
|||||||
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 successText = republish === '0' ? '更新成功' : '发布成功';
|
||||||
|
const res = republish === '0' ? await PublishService.gamesUpdate(options[0]) : 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: successText,
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
})
|
})
|
||||||
delay(1000)
|
delay(1000)
|
||||||
@@ -346,9 +356,11 @@ const PublishBall: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mergeWithDefault = (data: any): PublishBallFormData => {
|
const mergeWithDefault = (data: any): PublishBallFormData => {
|
||||||
const userPhone = (userInfo as any)?.phone || ''
|
const userPhone = (userInfo as any)?.phone || ''
|
||||||
const { start_time, end_time, play_type, price,
|
const { start_time, end_time, play_type, price, venue_id, location_name, location, latitude,
|
||||||
|
longitude, court_type, court_surface, venue_description_tag, venue_description, venue_image_list,
|
||||||
description, description_tag, max_players, min_players, skill_level_max, skill_level_min,
|
description, description_tag, max_players, min_players, skill_level_max, skill_level_min,
|
||||||
venueDtl
|
venueDtl
|
||||||
} = data;
|
} = data;
|
||||||
@@ -377,6 +389,16 @@ const PublishBall: React.FC = () => {
|
|||||||
...defaultFormData.activityInfo,
|
...defaultFormData.activityInfo,
|
||||||
...(play_type ? { play_type } : {}),
|
...(play_type ? { play_type } : {}),
|
||||||
...((price) ? { price } : {}),
|
...((price) ? { price } : {}),
|
||||||
|
...(venue_id ? { venue_id } : {}),
|
||||||
|
...(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 } : {}),
|
||||||
...activityInfo
|
...activityInfo
|
||||||
},
|
},
|
||||||
descriptionInfo: {
|
descriptionInfo: {
|
||||||
@@ -390,7 +412,6 @@ const PublishBall: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const formatConfig = () => {
|
const formatConfig = () => {
|
||||||
const newFormSchema = publishBallFormSchema.reduce((acc, item) => {
|
const newFormSchema = publishBallFormSchema.reduce((acc, item) => {
|
||||||
if (item.prop === 'wechat') {
|
if (item.prop === 'wechat') {
|
||||||
@@ -412,8 +433,7 @@ const PublishBall: React.FC = () => {
|
|||||||
setOptionsConfig(newFormSchema)
|
setOptionsConfig(newFormSchema)
|
||||||
}
|
}
|
||||||
const initFormData = () => {
|
const initFormData = () => {
|
||||||
const currentInstance = Taro.getCurrentInstance()
|
const params = getParams()
|
||||||
const params = currentInstance.router?.params
|
|
||||||
const userPhone = (userInfo as any)?.phone || ''
|
const userPhone = (userInfo as any)?.phone || ''
|
||||||
if (params?.type) {
|
if (params?.type) {
|
||||||
const type = params.type as ActivityType
|
const type = params.type as ActivityType
|
||||||
@@ -429,8 +449,6 @@ const PublishBall: React.FC = () => {
|
|||||||
}
|
}
|
||||||
} else if (type === 'ai') {
|
} else if (type === 'ai') {
|
||||||
// 从 Store 注入 AI 生成的表单 JSON
|
// 从 Store 注入 AI 生成的表单 JSON
|
||||||
|
|
||||||
|
|
||||||
if (publishAiData && Array.isArray(publishAiData) && publishAiData.length > 0) {
|
if (publishAiData && Array.isArray(publishAiData) && publishAiData.length > 0) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '智能识别成功,请完善剩余信息',
|
title: '智能识别成功,请完善剩余信息',
|
||||||
@@ -453,7 +471,33 @@ const PublishBall: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (params?.gameId) {
|
||||||
|
getGameDetail(params.gameId)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const getGameDetail = async (gameId) => {
|
||||||
|
if (!gameId) return;
|
||||||
|
try {
|
||||||
|
const res = await DetailService.getDetail(Number(gameId));
|
||||||
|
if (res.code === 0) {
|
||||||
|
const merged = mergeWithDefault(res.data)
|
||||||
|
setFormData([merged])
|
||||||
|
if (merged.activityInfo.play_type === '个人球局') {
|
||||||
|
setTitleBar('发布')
|
||||||
|
setActivityType('individual')
|
||||||
|
} else {
|
||||||
|
setTitleBar('发布畅打活动')
|
||||||
|
setActivityType('group')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (e.message === '球局不存在') {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
const onCheckedChange = (checked: boolean) => {
|
const onCheckedChange = (checked: boolean) => {
|
||||||
setChecked(checked)
|
setChecked(checked)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,6 +154,12 @@ class PublishService {
|
|||||||
showToast: false,
|
showToast: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
async gamesUpdate(data: PublishBallData): Promise<ApiResponse<createGameData>> {
|
||||||
|
return httpService.post('/games/update', data, {
|
||||||
|
showLoading: true,
|
||||||
|
loadingText: '发布中...'
|
||||||
|
})
|
||||||
|
}
|
||||||
async getPictures(req) {
|
async getPictures(req) {
|
||||||
const { type, tag, otherReq = {} } = req
|
const { type, tag, otherReq = {} } = req
|
||||||
if (type === 'history') {
|
if (type === 'history') {
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import { PublishBallFormData } from "../../types/publishBall";
|
|
||||||
|
type PublishData = {
|
||||||
|
game_type: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
interface PublishBallState {
|
interface PublishBallState {
|
||||||
// 待注入到发布页面的表单数据(支持单场或多场)
|
// 待注入到发布页面的表单数据(支持单场或多场)
|
||||||
publishData: PublishBallFormData | PublishBallFormData[] | null;
|
publishData: PublishData[] | null;
|
||||||
|
|
||||||
// 赋值/覆盖整份数据
|
// 赋值/覆盖整份数据
|
||||||
setPublishData: (
|
setPublishData: (
|
||||||
data: PublishBallFormData | PublishBallFormData[] | null
|
data: PublishData[] | null
|
||||||
) => void;
|
) => void;
|
||||||
|
|
||||||
// 读取当前数据
|
// 读取当前数据
|
||||||
getPublishData: () => PublishBallFormData | PublishBallFormData[] | null;
|
getPublishData: () => PublishData[] | null;
|
||||||
|
|
||||||
// 清空
|
// 清空
|
||||||
clearPublishData: () => void;
|
clearPublishData: () => void;
|
||||||
|
|||||||
Reference in New Issue
Block a user