Commit 7ef8e4bf authored by 张烨's avatar 张烨

fix: 图片上传回调和预览

parent bd0ed6bb
...@@ -104,9 +104,10 @@ class PicturesWall extends React.Component<PicturesWallType> { ...@@ -104,9 +104,10 @@ class PicturesWall extends React.Component<PicturesWallType> {
if (file.status === 'done') { if (file.status === 'done') {
const files = fileList.map(item => { const files = fileList.map(item => {
const { status, data, name, thumbUrl } = item; const { status, data, name, thumbUrl } = item;
const url = thumbUrl || this.getImageUrl(data); const url = item.response && item.response.data || thumbUrl ;
return { uid: uuid(8, 16), name, status, url }; return { uid: uuid(8, 16), name, status, url };
}); });
this.setState({fileList: files})
this.props.onChange && this.props.onChange( maxLen === 1 ? files[0].url : files.map(f => f.url)); this.props.onChange && this.props.onChange( maxLen === 1 ? files[0].url : files.map(f => f.url));
} }
}; };
...@@ -137,7 +138,10 @@ class PicturesWall extends React.Component<PicturesWallType> { ...@@ -137,7 +138,10 @@ class PicturesWall extends React.Component<PicturesWallType> {
} }
getImageUrl(path){ getImageUrl(path){
if(path.indexOf('http') === 0){ if(path&&path.indexOf('http') === 0){
return path
}
if(path&&path.indexOf('data:') === 0) {
return path return path
} }
return `${window.location.origin}/${path}`.replace(/\\/g, '/') return `${window.location.origin}/${path}`.replace(/\\/g, '/')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment