Merge remote-tracking branch 'origin/publish_hanxia'
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 { InputNumber } from '@nutui/nutui-react-taro'
|
||||
import { Checkbox } from '@nutui/nutui-react-taro'
|
||||
@@ -17,7 +17,19 @@ const NumberInterval: React.FC<NumberIntervalProps> = ({
|
||||
min,
|
||||
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 toNumber = (v: number | string): number => typeof v === 'string' ? Number(v) : v
|
||||
const { min, max, organizer_joined } = value;
|
||||
@@ -32,7 +44,7 @@ const NumberInterval: React.FC<NumberIntervalProps> = ({
|
||||
<View className='control-buttons'>
|
||||
<InputNumber
|
||||
className="format-width"
|
||||
defaultValue={minParticipants}
|
||||
value={minParticipants}
|
||||
min={min}
|
||||
max={maxParticipants}
|
||||
onChange={(value) => handleChange({ min: value, max: maxParticipants, organizer_joined: organizer_joined })}
|
||||
@@ -45,7 +57,7 @@ const NumberInterval: React.FC<NumberIntervalProps> = ({
|
||||
<View className='control-buttons'>
|
||||
<InputNumber
|
||||
className="format-width"
|
||||
defaultValue={maxParticipants}
|
||||
value={maxParticipants}
|
||||
onChange={(value) => handleChange({ min: minParticipants, max: value, organizer_joined: organizer_joined })}
|
||||
min={minParticipants}
|
||||
max={max}
|
||||
|
||||
@@ -89,7 +89,7 @@ const PublishMenu: React.FC<PublishMenuProps> = () => {
|
||||
<Image src={images.ICON_GROUP} />
|
||||
</View>
|
||||
</View>
|
||||
<View
|
||||
{/* <View
|
||||
className={`${styles.menuItem} ${styles.aiItem}`}
|
||||
onClick={() => handleMenuItemClick('ai')}
|
||||
>
|
||||
@@ -105,7 +105,7 @@ const PublishMenu: React.FC<PublishMenuProps> = () => {
|
||||
<View className={styles.menuIcon}>
|
||||
<Image src={images.ICON_IMPORTANT_BTN} />
|
||||
</View>
|
||||
</View>
|
||||
</View> */}
|
||||
</View>
|
||||
)}
|
||||
|
||||
|
||||
@@ -208,6 +208,8 @@
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
:global(.nut-icon-Checked){
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
background: rgba(22, 24, 35, 0.75)!important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,15 +390,8 @@ const PublishBall: React.FC = () => {
|
||||
}
|
||||
}
|
||||
|
||||
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') {
|
||||
|
||||
const formatConfig = () => {
|
||||
const newFormSchema = publishBallFormSchema.reduce((acc, item) => {
|
||||
if (item.prop === 'wechat') {
|
||||
return acc
|
||||
@@ -417,6 +410,17 @@ const PublishBall: React.FC = () => {
|
||||
return acc
|
||||
}, [] as FormFieldConfig[])
|
||||
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])
|
||||
setTitleBar('发布畅打活动')
|
||||
} else {
|
||||
@@ -427,21 +431,26 @@ const PublishBall: React.FC = () => {
|
||||
// 从 Store 注入 AI 生成的表单 JSON
|
||||
|
||||
|
||||
if (publishAiData) {
|
||||
if (publishAiData && Array.isArray(publishAiData) && publishAiData.length > 0) {
|
||||
Taro.showToast({
|
||||
title: '智能识别成功,请完善剩余信息',
|
||||
icon: 'none'
|
||||
})
|
||||
if (Array.isArray(publishAiData)) {
|
||||
const merged = publishAiData.map(item => mergeWithDefault(item))
|
||||
setFormData(merged.length ? merged : [defaultFormData])
|
||||
if (merged.length === 1) {
|
||||
setTitleBar('发布')
|
||||
setActivityType('individual')
|
||||
} else {
|
||||
setFormData([mergeWithDefault(publishAiData)])
|
||||
formatConfig()
|
||||
setTitleBar('发布畅打活动')
|
||||
setActivityType('group')
|
||||
}
|
||||
} else {
|
||||
setFormData([defaultFormData])
|
||||
setTitleBar('发布')
|
||||
setActivityType('individual')
|
||||
}
|
||||
setTitleBar('发布畅打活动')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user