Merge branch 'feat/liujie'
This commit is contained in:
@@ -22,8 +22,9 @@ export interface UploadCoverProps {
|
|||||||
value: CoverImageValue[]
|
value: CoverImageValue[]
|
||||||
onChange: (value: CoverImageValue[] | ((prev: CoverImageValue[]) => CoverImageValue[])
|
onChange: (value: CoverImageValue[] | ((prev: CoverImageValue[]) => CoverImageValue[])
|
||||||
) => void
|
) => void
|
||||||
source: source
|
source?: source
|
||||||
maxCount: number
|
maxCount?: number
|
||||||
|
align?: 'center' | 'left'
|
||||||
}
|
}
|
||||||
|
|
||||||
// const values = [
|
// const values = [
|
||||||
@@ -51,9 +52,11 @@ export default function UploadCover(props: UploadCoverProps) {
|
|||||||
const {
|
const {
|
||||||
value = [],
|
value = [],
|
||||||
onChange = () => void 0,
|
onChange = () => void 0,
|
||||||
source = ['album', 'history', 'preset'],
|
source = ['album', 'history', 'preset'] as source,
|
||||||
maxCount = 9,
|
maxCount = 9,
|
||||||
|
align = 'center',
|
||||||
} = props
|
} = props
|
||||||
|
|
||||||
const [visible, setVisible] = useState(false)
|
const [visible, setVisible] = useState(false)
|
||||||
|
|
||||||
const onAdd = useCallback((images: CoverImageValue[]) => {
|
const onAdd = useCallback((images: CoverImageValue[]) => {
|
||||||
@@ -64,7 +67,6 @@ export default function UploadCover(props: UploadCoverProps) {
|
|||||||
const onWxAdd = useCallback((images: CoverImageValue[], onFileUploaded: Promise<{ id: string, data: uploadFileResponseData }[]>) => {
|
const onWxAdd = useCallback((images: CoverImageValue[], onFileUploaded: Promise<{ id: string, data: uploadFileResponseData }[]>) => {
|
||||||
onAdd(images)
|
onAdd(images)
|
||||||
onFileUploaded.then(res => {
|
onFileUploaded.then(res => {
|
||||||
console.log(res, 11111)
|
|
||||||
onAdd(res.map(item => ({
|
onAdd(res.map(item => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
url: item.data.file_path,
|
url: item.data.file_path,
|
||||||
@@ -102,7 +104,7 @@ export default function UploadCover(props: UploadCoverProps) {
|
|||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
</CommonPopup>
|
</CommonPopup>
|
||||||
<div className={`upload-cover-root ${value.length === 0 ? 'upload-cover-act-center' : ''}`}>
|
<div className={`upload-cover-root ${value.length === 0 && align === 'center' ? 'upload-cover-act-center' : ''}`}>
|
||||||
{value.length < maxCount && (
|
{value.length < maxCount && (
|
||||||
<div className="upload-cover-act" onClick={() => setVisible(true)}>
|
<div className="upload-cover-act" onClick={() => setVisible(true)}>
|
||||||
<Image className='upload-cover-act-icon' src={img.ICON_ADD} />
|
<Image className='upload-cover-act-icon' src={img.ICON_ADD} />
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ export default function UploadFromWx(props: UploadFromWxProps) {
|
|||||||
id: (Date.now() + count++).toString(),
|
id: (Date.now() + count++).toString(),
|
||||||
}))
|
}))
|
||||||
const onFileUploaded = uploadApi.batchUpload(files)
|
const onFileUploaded = uploadApi.batchUpload(files)
|
||||||
onAdd(res.tempFiles.map(item => ({
|
onAdd(files.map(item => ({
|
||||||
id: Date.now().toString(),
|
id: item.id,
|
||||||
url: item.path,
|
url: item.filePath,
|
||||||
})), onFileUploaded) // TODO: add loading state
|
})), onFileUploaded) // TODO: add loading state
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ import Taro from '@tarojs/taro'
|
|||||||
import { View, Text, Image } from '@tarojs/components'
|
import { View, Text, Image } from '@tarojs/components'
|
||||||
import images from '@/config/images'
|
import images from '@/config/images'
|
||||||
import TextareaTag from '@/components/TextareaTag'
|
import TextareaTag from '@/components/TextareaTag'
|
||||||
import CoverImageUpload, { type CoverImage } from '@/components/ImageUpload'
|
// import CoverImageUpload, { type CoverImage } from '@/components/ImageUpload'
|
||||||
|
import UploadCover, { type CoverImageValue } from '@/components/UploadCover'
|
||||||
import { useDictionaryActions } from '@/store/dictionaryStore'
|
import { useDictionaryActions } from '@/store/dictionaryStore'
|
||||||
import './StadiumDetail.scss'
|
import './StadiumDetail.scss'
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ export interface Stadium {
|
|||||||
court_surface?: string
|
court_surface?: string
|
||||||
description?: string
|
description?: string
|
||||||
description_tag?: string[]
|
description_tag?: string[]
|
||||||
venue_image_list?: CoverImage[]
|
venue_image_list?: CoverImageValue[]
|
||||||
}
|
}
|
||||||
|
|
||||||
interface StadiumDetailProps {
|
interface StadiumDetailProps {
|
||||||
@@ -103,7 +104,7 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
|
|||||||
court_type: court_type[0] || '',
|
court_type: court_type[0] || '',
|
||||||
court_surface: court_surface[0] || '',
|
court_surface: court_surface[0] || '',
|
||||||
additionalInfo: '',
|
additionalInfo: '',
|
||||||
venue_image_list: [] as CoverImage[],
|
venue_image_list: [] as CoverImageValue[],
|
||||||
description:{
|
description:{
|
||||||
description: '',
|
description: '',
|
||||||
description_tag: []
|
description_tag: []
|
||||||
@@ -208,9 +209,21 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
|
|||||||
if (item.type === 'image') {
|
if (item.type === 'image') {
|
||||||
return (
|
return (
|
||||||
<SectionContainer key={item.label} title={item.label} prop={item.prop}>
|
<SectionContainer key={item.label} title={item.label} prop={item.prop}>
|
||||||
<CoverImageUpload
|
<UploadCover
|
||||||
images={formData[item.prop]}
|
value={formData[item.prop]}
|
||||||
onChange={(images) => updateFormData(item.prop, images)}
|
onChange={(value) => {
|
||||||
|
console.log(value, 'value')
|
||||||
|
if (value instanceof Function) {
|
||||||
|
const newValue = value(formData[item.prop])
|
||||||
|
console.log(newValue, 'newValue')
|
||||||
|
updateFormData(item.prop, newValue)
|
||||||
|
} else {
|
||||||
|
updateFormData(item.prop, value)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
maxCount={9}
|
||||||
|
source={['album', 'history', 'preset']}
|
||||||
|
align='left'
|
||||||
/>
|
/>
|
||||||
</SectionContainer>
|
</SectionContainer>
|
||||||
)
|
)
|
||||||
@@ -222,4 +235,4 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
export default StadiumDetail
|
export default StadiumDetail
|
||||||
Reference in New Issue
Block a user