修改发布数量
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React, { useState, useEffect } from 'react'
|
||||||
import { View, Text } from '@tarojs/components'
|
import { View, Text } from '@tarojs/components'
|
||||||
import { InputNumber } from '@nutui/nutui-react-taro'
|
import { InputNumber } from '@nutui/nutui-react-taro'
|
||||||
import { Checkbox } from '@nutui/nutui-react-taro'
|
import { Checkbox } from '@nutui/nutui-react-taro'
|
||||||
@@ -17,7 +17,19 @@ const NumberInterval: React.FC<NumberIntervalProps> = ({
|
|||||||
min,
|
min,
|
||||||
max
|
max
|
||||||
}) => {
|
}) => {
|
||||||
const { min:minParticipants, max:maxParticipants, organizer_joined } = value || { min: 1, max: 1, organizer_joined: true }
|
const [organizer_joined, setOrganizerJoined] = useState(true);
|
||||||
|
const [minParticipants, setMinParticipants] = useState(1);
|
||||||
|
const [maxParticipants, setMaxParticipants] = useState(1);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (value) {
|
||||||
|
setOrganizerJoined(value.organizer_joined);
|
||||||
|
setMinParticipants(value.min);
|
||||||
|
setMaxParticipants(value.max);
|
||||||
|
}
|
||||||
|
console.log(value, 'valuevaluevaluevaluevaluevalue');
|
||||||
|
}, [value]);
|
||||||
|
|
||||||
const handleChange = (value: { min: number | string, max: number | string, organizer_joined: boolean }) => {
|
const handleChange = (value: { min: number | string, max: number | string, organizer_joined: boolean }) => {
|
||||||
const toNumber = (v: number | string): number => typeof v === 'string' ? Number(v) : v
|
const toNumber = (v: number | string): number => typeof v === 'string' ? Number(v) : v
|
||||||
const { min, max, organizer_joined } = value;
|
const { min, max, organizer_joined } = value;
|
||||||
@@ -32,7 +44,7 @@ const NumberInterval: React.FC<NumberIntervalProps> = ({
|
|||||||
<View className='control-buttons'>
|
<View className='control-buttons'>
|
||||||
<InputNumber
|
<InputNumber
|
||||||
className="format-width"
|
className="format-width"
|
||||||
defaultValue={minParticipants}
|
value={minParticipants}
|
||||||
min={min}
|
min={min}
|
||||||
max={maxParticipants}
|
max={maxParticipants}
|
||||||
onChange={(value) => handleChange({ min: value, max: maxParticipants, organizer_joined: organizer_joined })}
|
onChange={(value) => handleChange({ min: value, max: maxParticipants, organizer_joined: organizer_joined })}
|
||||||
@@ -45,7 +57,7 @@ const NumberInterval: React.FC<NumberIntervalProps> = ({
|
|||||||
<View className='control-buttons'>
|
<View className='control-buttons'>
|
||||||
<InputNumber
|
<InputNumber
|
||||||
className="format-width"
|
className="format-width"
|
||||||
defaultValue={maxParticipants}
|
value={maxParticipants}
|
||||||
onChange={(value) => handleChange({ min: minParticipants, max: value, organizer_joined: organizer_joined })}
|
onChange={(value) => handleChange({ min: minParticipants, max: value, organizer_joined: organizer_joined })}
|
||||||
min={minParticipants}
|
min={minParticipants}
|
||||||
max={max}
|
max={max}
|
||||||
|
|||||||
@@ -208,6 +208,8 @@
|
|||||||
width: 11px;
|
width: 11px;
|
||||||
height: 11px;
|
height: 11px;
|
||||||
:global(.nut-icon-Checked){
|
:global(.nut-icon-Checked){
|
||||||
|
width: 11px;
|
||||||
|
height: 11px;
|
||||||
background: rgba(22, 24, 35, 0.75)!important;
|
background: rgba(22, 24, 35, 0.75)!important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -390,15 +390,8 @@ const PublishBall: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const initFormData = () => {
|
|
||||||
const currentInstance = Taro.getCurrentInstance()
|
const formatConfig = () => {
|
||||||
const params = currentInstance.router?.params
|
|
||||||
const userPhone = (userInfo as any)?.phone || ''
|
|
||||||
if (params?.type) {
|
|
||||||
const type = params.type as ActivityType
|
|
||||||
if (type === 'individual' || type === 'group') {
|
|
||||||
setActivityType(type)
|
|
||||||
if (type === 'group') {
|
|
||||||
const newFormSchema = publishBallFormSchema.reduce((acc, item) => {
|
const newFormSchema = publishBallFormSchema.reduce((acc, item) => {
|
||||||
if (item.prop === 'wechat') {
|
if (item.prop === 'wechat') {
|
||||||
return acc
|
return acc
|
||||||
@@ -417,6 +410,17 @@ const PublishBall: React.FC = () => {
|
|||||||
return acc
|
return acc
|
||||||
}, [] as FormFieldConfig[])
|
}, [] as FormFieldConfig[])
|
||||||
setOptionsConfig(newFormSchema)
|
setOptionsConfig(newFormSchema)
|
||||||
|
}
|
||||||
|
const initFormData = () => {
|
||||||
|
const currentInstance = Taro.getCurrentInstance()
|
||||||
|
const params = currentInstance.router?.params
|
||||||
|
const userPhone = (userInfo as any)?.phone || ''
|
||||||
|
if (params?.type) {
|
||||||
|
const type = params.type as ActivityType
|
||||||
|
if (type === 'individual' || type === 'group') {
|
||||||
|
setActivityType(type)
|
||||||
|
if (type === 'group') {
|
||||||
|
formatConfig()
|
||||||
setFormData([defaultFormData])
|
setFormData([defaultFormData])
|
||||||
setTitleBar('发布畅打活动')
|
setTitleBar('发布畅打活动')
|
||||||
} else {
|
} else {
|
||||||
@@ -427,21 +431,26 @@ const PublishBall: React.FC = () => {
|
|||||||
// 从 Store 注入 AI 生成的表单 JSON
|
// 从 Store 注入 AI 生成的表单 JSON
|
||||||
|
|
||||||
|
|
||||||
if (publishAiData) {
|
if (publishAiData && Array.isArray(publishAiData) && publishAiData.length > 0) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '智能识别成功,请完善剩余信息',
|
title: '智能识别成功,请完善剩余信息',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
if (Array.isArray(publishAiData)) {
|
|
||||||
const merged = publishAiData.map(item => mergeWithDefault(item))
|
const merged = publishAiData.map(item => mergeWithDefault(item))
|
||||||
setFormData(merged.length ? merged : [defaultFormData])
|
setFormData(merged.length ? merged : [defaultFormData])
|
||||||
|
if (merged.length === 1) {
|
||||||
|
setTitleBar('发布')
|
||||||
|
setActivityType('individual')
|
||||||
} else {
|
} else {
|
||||||
setFormData([mergeWithDefault(publishAiData)])
|
formatConfig()
|
||||||
|
setTitleBar('发布畅打活动')
|
||||||
|
setActivityType('group')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setFormData([defaultFormData])
|
setFormData([defaultFormData])
|
||||||
|
setTitleBar('发布')
|
||||||
|
setActivityType('individual')
|
||||||
}
|
}
|
||||||
setTitleBar('发布畅打活动')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user