Commit de80c1ec by chenyu

update: update

parent 9c1b38ae
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<div class="dialog-img"></div> <div class="dialog-img"></div>
</div> </div>
</draggable> </draggable>
<el-upload :limit="5" multiple :file-list="giftFormFileList" :action="uploadAction" :headers="headersUpload" list-type="picture-card" :on-preview="handlePictureCardPreview" :on-exceed="handlePictrueExceed" :before-upload="beforeUpload" :on-success="uploadSuccess" with-credentials :show-file-list="false" v-show="uploadStatus" style="display: inline-block;vertical-align: top;"> <el-upload ref="giftFormUpload" :limit="5 - this.giftForm.images.length" multiple :file-list="giftFormFileList" :action="uploadAction" :headers="headersUpload" list-type="picture-card" :on-preview="handlePictureCardPreview" :on-exceed="handlePictrueExceed" :before-upload="beforeUpload" :on-success="uploadSuccess" with-credentials :show-file-list="false" v-show="uploadStatus">
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
</el-upload> </el-upload>
</div> </div>
...@@ -1515,11 +1515,13 @@ export default { ...@@ -1515,11 +1515,13 @@ export default {
}, },
// 图片上传超出数量限制 // 图片上传超出数量限制
handlePictrueExceed(files, fileList) { handlePictrueExceed(files, fileList) {
if (5 - this.giftForm.images.length - files.length < 0) {
this.$message.warning('最多上传5张商品主图'); this.$message.warning('最多上传5张商品主图');
this.$refs['giftFormUpload'].abort();
}
}, },
// 上传图片前 // 上传图片前
beforeUpload(file) { beforeUpload(file) {
console.log(file);
if (this.giftForm.images === null) { if (this.giftForm.images === null) {
this.giftForm.images = []; this.giftForm.images = [];
} }
...@@ -1561,14 +1563,13 @@ export default { ...@@ -1561,14 +1563,13 @@ export default {
}, },
// 上传图片成功 // 上传图片成功
uploadSuccess(response, file, fileList) { uploadSuccess(response, file, fileList) {
console.log(response);
if (response.errorCode === 0) { if (response.errorCode === 0) {
this.giftForm.images.push({ this.giftForm.images.push({
imageUrl: response.result[0].qcloudImageUrl, imageUrl: response.result[0].qcloudImageUrl,
imageCode: response.result[0].imageFiledCode imageCode: response.result[0].imageFiledCode
}); });
this.$message.success('上传成功'); this.$message.success('上传成功');
if (this.giftForm.images.length === 5) { if (this.giftForm.images.length >= 5) {
this.uploadStatus = false; this.uploadStatus = false;
} else { } else {
this.uploadStatus = true; this.uploadStatus = true;
......
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