zan-upload
Advanced tools
@@ -237,3 +237,5 @@ 'use strict'; | ||
onSelectMedia: this.selectMedia, | ||
selectedItems: selectedItems, | ||
selectedItems: selectedItems.map(function (item) { | ||
return item.attachmentId; | ||
}), | ||
onPlayVoice: this.playVoice | ||
@@ -243,3 +245,5 @@ }) : _react2['default'].createElement(_ImageList2['default'], { | ||
options: options, | ||
selectedItems: selectedItems, | ||
selectedItems: selectedItems.map(function (item) { | ||
return item.attachmentId; | ||
}), | ||
onSelectMedia: this.selectMedia | ||
@@ -288,3 +292,5 @@ }), | ||
var maxAmount = options.maxAmount; | ||
var selectedIndex = selectedItems.indexOf(media.attachmentId); | ||
var selectedIndex = selectedItems.map(function (item) { | ||
return item.attachmentId; | ||
}).indexOf(media.attachmentId); | ||
var isMediaSelected = selectedIndex > -1; | ||
@@ -301,5 +307,5 @@ if (!isMediaSelected && maxAmount > 1 && selectedItems.length >= maxAmount) { | ||
// 只能选择一张特殊处理 | ||
selectedItems.splice(0, 1, media.attachmentId); | ||
selectedItems.splice(0, 1, media); | ||
} else { | ||
selectedItems.push(media.attachmentId); | ||
selectedItems.push(media); | ||
} | ||
@@ -314,7 +320,3 @@ this.setState({ | ||
value: function confirm() { | ||
var selectedImages = this.state.mediaList.filter(function (media) { | ||
return media.selected; | ||
}).sort(function (a, b) { | ||
return a.selectedIndex < b.selectedIndex ? -1 : 1; | ||
}); | ||
var selectedItems = this.state.selectedItems; | ||
var _props = this.props, | ||
@@ -325,3 +327,3 @@ options = _props.options, | ||
if (typeof options.onSuccess === 'function') { | ||
options.onSuccess(selectedImages.map(function (item) { | ||
options.onSuccess(selectedItems.map(function (item) { | ||
return (0, _utils.responseParse)(item); | ||
@@ -328,0 +330,0 @@ })); |
{ | ||
"name": "zan-upload", | ||
"version": "5.3.4", | ||
"version": "5.3.5", | ||
"description": "这是一个React组件", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -93,4 +93,10 @@ ## zan-upload | ||
class Simple extends React.Component { | ||
uploadSuccess(data) { | ||
console.log(data); // eslint-disable-line | ||
state = { | ||
selectedItems: [] | ||
}; | ||
uploadSuccess = (data) => { | ||
this.setState({ | ||
selectedItems: data | ||
}); | ||
} | ||
@@ -103,9 +109,27 @@ | ||
render() { | ||
return <Upload | ||
tips="建议尺寸:640 x 640 像素;您可以拖拽图片调整图片顺序。" | ||
materials | ||
imgcdn="https://img.yzcdn.cn" | ||
mediaListUrl="mock/upload-mediaList.json" | ||
categoryListUrl="mock/upload-categoryList.json" | ||
onSuccess={this.uploadSuccess} />; | ||
const { selectedItems } = this.state; | ||
return ( | ||
<div> | ||
{selectedItems.map((item, index) => ( | ||
<img | ||
key={index} | ||
src={item.attachment_full_url} | ||
width="80" | ||
height="80" | ||
style={{ | ||
display: 'inline-block', | ||
marginRight: 10 | ||
}} | ||
/> | ||
))} | ||
<Upload | ||
tips="建议尺寸:640 x 640 像素;您可以拖拽图片调整图片顺序。" | ||
materials | ||
triggerInline | ||
imgcdn="https://img.yzcdn.cn" | ||
mediaListUrl="mock/upload-mediaList.json" | ||
categoryListUrl="mock/upload-categoryList.json" | ||
onSuccess={this.uploadSuccess} /> | ||
</div> | ||
); | ||
} | ||
@@ -322,5 +346,5 @@ } | ||
#### 5.3.3 (2018-01-03) | ||
#### 5.3.5 (2018-01-04) | ||
- 素材银行支持翻页选择 | ||
- 对话框改成mask点击不消失,防止误操作 |
Sorry, the diff of this file is too big to display
914337
0.08%25828
0.02%348
7.41%