|
@@ -62,14 +62,15 @@
|
|
|
<!-- :on-preview="handlePictureCardPreview" :on-remove="handleRemove" -->
|
|
<!-- :on-preview="handlePictureCardPreview" :on-remove="handleRemove" -->
|
|
|
<el-upload style="margin-top:14px;"
|
|
<el-upload style="margin-top:14px;"
|
|
|
action="/api/index/upload/uploadImg"
|
|
action="/api/index/upload/uploadImg"
|
|
|
- :before-upload="beforeAvatarUpload"
|
|
|
|
|
|
|
+ ref="upload"
|
|
|
|
|
+ :file-list="fileList"
|
|
|
:on-change='uploadChange'
|
|
:on-change='uploadChange'
|
|
|
|
|
+ :before-upload="beforeAvatarUpload"
|
|
|
:on-success='uploadSuccess'
|
|
:on-success='uploadSuccess'
|
|
|
:on-error="uploadError"
|
|
:on-error="uploadError"
|
|
|
:on-remove="handleRemove"
|
|
:on-remove="handleRemove"
|
|
|
:auto-upload="false"
|
|
:auto-upload="false"
|
|
|
list-type="picture-card"
|
|
list-type="picture-card"
|
|
|
- ref="upload"
|
|
|
|
|
:limit="4"
|
|
:limit="4"
|
|
|
:on-exceed="handleExceed"
|
|
:on-exceed="handleExceed"
|
|
|
>
|
|
>
|
|
@@ -107,6 +108,8 @@
|
|
|
WX: '',
|
|
WX: '',
|
|
|
uploadImg: [],//上传图片的数据集合
|
|
uploadImg: [],//上传图片的数据集合
|
|
|
imgUrl:'',
|
|
imgUrl:'',
|
|
|
|
|
+ fileList: [],
|
|
|
|
|
+ isUpImg:false,
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
@@ -122,12 +125,13 @@
|
|
|
this.$message.error('请填写留言信息!');
|
|
this.$message.error('请填写留言信息!');
|
|
|
} else {
|
|
} else {
|
|
|
// 手动上传
|
|
// 手动上传
|
|
|
|
|
+ this.isUpImg = true;
|
|
|
this.$refs.upload.submit();
|
|
this.$refs.upload.submit();
|
|
|
let _this = this;
|
|
let _this = this;
|
|
|
let uid = localStorage.getItem('uid');
|
|
let uid = localStorage.getItem('uid');
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
setTimeout(function () {
|
|
|
- // console.log(this.imgUrl,"上传的图片")
|
|
|
|
|
|
|
+ console.log(this.imgUrl,"上传的图片")
|
|
|
let params = {
|
|
let params = {
|
|
|
'nick_name': _this.call,
|
|
'nick_name': _this.call,
|
|
|
'email': _this.eMail,
|
|
'email': _this.eMail,
|
|
@@ -142,6 +146,8 @@
|
|
|
if (res.data.code == 1) {
|
|
if (res.data.code == 1) {
|
|
|
_this.$message.success('留言成功')
|
|
_this.$message.success('留言成功')
|
|
|
_this.$emit('value', 10);
|
|
_this.$emit('value', 10);
|
|
|
|
|
+ this.$refs.upload.clearFiles();
|
|
|
|
|
+ this.fileList =[];
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}, 1500)
|
|
}, 1500)
|
|
@@ -185,8 +191,7 @@
|
|
|
if (!isLt1M) {
|
|
if (!isLt1M) {
|
|
|
this.$message.error('上传文件大小不能超过 2MB!');
|
|
this.$message.error('上传文件大小不能超过 2MB!');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- return isJPG && isLt1M;
|
|
|
|
|
|
|
+ return isJPG && isLt1M
|
|
|
},
|
|
},
|
|
|
// 上传成功时的回调
|
|
// 上传成功时的回调
|
|
|
uploadSuccess(res, file) {
|
|
uploadSuccess(res, file) {
|
|
@@ -209,6 +214,26 @@
|
|
|
// 每次改变图片状态返回的回调
|
|
// 每次改变图片状态返回的回调
|
|
|
uploadChange(file, fileList) {
|
|
uploadChange(file, fileList) {
|
|
|
// console.log('每次改变图片状态返回的回调', fileList)
|
|
// console.log('每次改变图片状态返回的回调', fileList)
|
|
|
|
|
+ const isJPG = file.raw.type == 'image/jpeg' || 'image/jpg' || 'image/png' || 'image/svg';
|
|
|
|
|
+ const isLt1M = file.size / 1024 / 1024 < 0.5;
|
|
|
|
|
+ if (!isJPG) {
|
|
|
|
|
+ this.$message.error('上传只能是图片格式!');
|
|
|
|
|
+ fileList.pop();
|
|
|
|
|
+ this.fileList = fileList;
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!isLt1M) {
|
|
|
|
|
+ this.$message.error('上传图片大小单张不能超过0.5MB!');
|
|
|
|
|
+ fileList.pop()
|
|
|
|
|
+ this.fileList = fileList;
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ this.$refs.upload.clearFiles();
|
|
|
|
|
+ if(!this.isUpImg){
|
|
|
|
|
+ this.fileList.push(file)
|
|
|
|
|
+ }else{
|
|
|
|
|
+ this.fileList = fileList
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|