调整字典及发布
This commit is contained in:
@@ -76,7 +76,7 @@ const AiImportPopup: React.FC<AiImportPopupProps> = ({
|
||||
if (Array.isArray(data) && data.length > 0) {
|
||||
setPublishData(data)
|
||||
Taro.navigateTo({
|
||||
url: '/publish_pages/publishBall/pages/publishBall?type=ai'
|
||||
url: '/publish_pages/publishBall/index?type=ai'
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -110,11 +110,13 @@ const AiImportPopup: React.FC<AiImportPopupProps> = ({
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('选择图片失败:', error)
|
||||
setUploadFailCount(prev => prev + 1)
|
||||
Taro.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'error'
|
||||
})
|
||||
if (!(typeof error === 'object' && error.errMsg && error.errMsg.includes('fail cancel'))) {
|
||||
setUploadFailCount(prev => prev + 1)
|
||||
Taro.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -96,8 +96,8 @@ const FormBasicInfo: React.FC<FormBasicInfoProps> = ({
|
||||
onChange({...value, [key]: ''});
|
||||
return;
|
||||
}
|
||||
if (numValue < 0) {
|
||||
onChange({...value, [key]: '0'});
|
||||
if (numValue <= 0) {
|
||||
onChange({...value, [key]: '1'});
|
||||
return;
|
||||
}
|
||||
if (numValue > 9999.99) {
|
||||
|
||||
@@ -1,50 +1,74 @@
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import React, { useCallback, useState, useEffect } from 'react'
|
||||
import { View, Text, Input } from '@tarojs/components'
|
||||
import { Checkbox } from '@nutui/nutui-react-taro'
|
||||
import styles from './index.module.scss'
|
||||
interface FormSwitchProps {
|
||||
value: boolean
|
||||
onChange: (checked: boolean) => void
|
||||
subTitle: string
|
||||
wechatId?: string
|
||||
|
||||
type WechatContactValue = {
|
||||
is_wechat_contact: boolean
|
||||
wechat_contact: string
|
||||
default_wechat_contact: string
|
||||
}
|
||||
|
||||
const FormSwitch: React.FC<FormSwitchProps> = ({ value, onChange, subTitle, wechatId }) => {
|
||||
interface FormSwitchProps {
|
||||
value: WechatContactValue
|
||||
wechatId: string
|
||||
onChange: (val: WechatContactValue) => void
|
||||
subTitle: string
|
||||
}
|
||||
|
||||
const FormSwitch: React.FC<FormSwitchProps> = ({ value, onChange, subTitle }) => {
|
||||
const [editWechat, setEditWechat] = useState(false)
|
||||
const [wechatIdValue, setWechatIdValue] = useState('')
|
||||
const [wechat, setWechat] = useState(wechatId)
|
||||
const [defaultWechat, setDefaultWechat] = useState('')
|
||||
const [isWechatContact, setIsWechatContact] = useState(false)
|
||||
const editWechatId = () => {
|
||||
setEditWechat(true)
|
||||
}
|
||||
const setWechatId = useCallback((e: any) => {
|
||||
const value = e.target.value
|
||||
onChange && onChange(value)
|
||||
setWechatIdValue(value)
|
||||
}, [onChange])
|
||||
const valueStr = e.target.value
|
||||
onChange && onChange({ is_wechat_contact: isWechatContact, wechat_contact: valueStr, default_wechat_contact: defaultWechat })
|
||||
setWechatIdValue(valueStr)
|
||||
}, [onChange, isWechatContact])
|
||||
|
||||
const fillWithPhone = () => {
|
||||
if (wechat) {
|
||||
setWechatIdValue(wechat)
|
||||
if (defaultWechat) {
|
||||
setWechatIdValue(defaultWechat)
|
||||
}
|
||||
}
|
||||
|
||||
const handleChange = (checked: boolean) => {
|
||||
setIsWechatContact(checked)
|
||||
onChange({ is_wechat_contact: checked, wechat_contact: wechatIdValue, default_wechat_contact: defaultWechat })
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const { is_wechat_contact, default_wechat_contact } = value || {} as any
|
||||
if (is_wechat_contact) {
|
||||
setIsWechatContact(is_wechat_contact)
|
||||
}
|
||||
if (default_wechat_contact) {
|
||||
setDefaultWechat(default_wechat_contact)
|
||||
}
|
||||
}, [value])
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={styles['wechat-contact-section']}>
|
||||
<View className={styles['wechat-contact-item']}>
|
||||
<Checkbox
|
||||
className={styles['wechat-contact-checkbox']}
|
||||
checked={value}
|
||||
onChange={onChange}
|
||||
checked={isWechatContact}
|
||||
onChange={(checked) => handleChange(checked)}
|
||||
/>
|
||||
<View className={styles['wechat-contact-content']}>
|
||||
<Text className={styles['wechat-contact-text']}>{subTitle}</Text>
|
||||
</View>
|
||||
</View>
|
||||
{
|
||||
!editWechat && wechatId && (
|
||||
!editWechat && (
|
||||
<View className={styles['wechat-contact-id']}>
|
||||
<Text className={styles['wechat-contact-text']}>微信号: {wechatId.replace(/(\d{3})(\d{4})(\d{4})/, '$1 $2 $3')}</Text>
|
||||
<Text className={styles['wechat-contact-text']}>微信号: {defaultWechat.replace(/(\d{3})(\d{4})(\d{4})/, '$1 $2 $3')}</Text>
|
||||
<View className={styles['wechat-contact-edit']} onClick={editWechatId}>修改</View>
|
||||
</View>
|
||||
)
|
||||
@@ -55,7 +79,9 @@ const FormSwitch: React.FC<FormSwitchProps> = ({ value, onChange, subTitle, wech
|
||||
<View className={styles['wechat-contact-edit-input']}>
|
||||
<Input value={wechatIdValue} onInput={setWechatId} placeholder='请输入正确微信号' />
|
||||
</View>
|
||||
<View className={styles['wechat-contact-edit']} onClick={fillWithPhone}>手机号填入:{wechat}</View>
|
||||
{defaultWechat && (
|
||||
<View className={styles['wechat-contact-edit']} onClick={fillWithPhone}>手机号填入:{defaultWechat}</View>
|
||||
)}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user