diff --git a/src/components/UploadCover/index.tsx b/src/components/UploadCover/index.tsx index 5698f0a..e2982b3 100644 --- a/src/components/UploadCover/index.tsx +++ b/src/components/UploadCover/index.tsx @@ -22,8 +22,9 @@ export interface UploadCoverProps { value: CoverImageValue[] onChange: (value: CoverImageValue[] | ((prev: CoverImageValue[]) => CoverImageValue[]) ) => void - source: source - maxCount: number + source?: source + maxCount?: number + align?: 'center' | 'left' } // const values = [ @@ -51,9 +52,11 @@ export default function UploadCover(props: UploadCoverProps) { const { value = [], onChange = () => void 0, - source = ['album', 'history', 'preset'], + source = ['album', 'history', 'preset'] as source, maxCount = 9, + align = 'center', } = props + const [visible, setVisible] = useState(false) 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 }[]>) => { onAdd(images) onFileUploaded.then(res => { - console.log(res, 11111) onAdd(res.map(item => ({ id: item.id, url: item.data.file_path, @@ -102,7 +104,7 @@ export default function UploadCover(props: UploadCoverProps) { } -
+
{value.length < maxCount && (
setVisible(true)}> diff --git a/src/components/UploadCover/upload-from-wx.tsx b/src/components/UploadCover/upload-from-wx.tsx index 05c0351..841c27b 100644 --- a/src/components/UploadCover/upload-from-wx.tsx +++ b/src/components/UploadCover/upload-from-wx.tsx @@ -33,9 +33,9 @@ export default function UploadFromWx(props: UploadFromWxProps) { id: (Date.now() + count++).toString(), })) const onFileUploaded = uploadApi.batchUpload(files) - onAdd(res.tempFiles.map(item => ({ - id: Date.now().toString(), - url: item.path, + onAdd(files.map(item => ({ + id: item.id, + url: item.filePath, })), onFileUploaded) // TODO: add loading state }) } diff --git a/src/pages/publishBall/components/SelectStadium/StadiumDetail.tsx b/src/pages/publishBall/components/SelectStadium/StadiumDetail.tsx index 07d8f98..85bf43c 100644 --- a/src/pages/publishBall/components/SelectStadium/StadiumDetail.tsx +++ b/src/pages/publishBall/components/SelectStadium/StadiumDetail.tsx @@ -3,7 +3,8 @@ import Taro from '@tarojs/taro' import { View, Text, Image } from '@tarojs/components' import images from '@/config/images' 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 './StadiumDetail.scss' @@ -18,7 +19,7 @@ export interface Stadium { court_surface?: string description?: string description_tag?: string[] - venue_image_list?: CoverImage[] + venue_image_list?: CoverImageValue[] } interface StadiumDetailProps { @@ -103,7 +104,7 @@ const StadiumDetail = forwardRef(({ court_type: court_type[0] || '', court_surface: court_surface[0] || '', additionalInfo: '', - venue_image_list: [] as CoverImage[], + venue_image_list: [] as CoverImageValue[], description:{ description: '', description_tag: [] @@ -208,9 +209,21 @@ const StadiumDetail = forwardRef(({ if (item.type === 'image') { return ( - updateFormData(item.prop, images)} + { + 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' /> ) @@ -222,4 +235,4 @@ const StadiumDetail = forwardRef(({ ) }) -export default StadiumDetail \ No newline at end of file +export default StadiumDetail \ No newline at end of file