|
@@ -12,6 +12,7 @@
|
|
|
class="avatar-uploader"
|
|
|
action=""
|
|
|
:show-file-list="false"
|
|
|
+ accept=".jpg,.png"
|
|
|
:http-request="uploadFile"
|
|
|
:before-upload="beforeFileUpload">
|
|
|
<img v-if="authentication.IDCardPhoto" :src="authentication.IDCardPhoto" class="avatar">
|
|
@@ -209,7 +210,25 @@ export default {
|
|
|
//return this.$confirm(`确定移除 ${file.name}?`)
|
|
|
},
|
|
|
//文件上传前的响应函数
|
|
|
- beforeFileUpload () {
|
|
|
+ beforeFileUpload (file) {
|
|
|
+ // 文件大小不能超过10M
|
|
|
+ if (file.size > 10 * 1000 * 1000){
|
|
|
+ notify('error', '单个文件大小不能超过10M')
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let fileName = file.name
|
|
|
+ let index = fileName.lastIndexOf('.');
|
|
|
+ // 文件不能没有后缀
|
|
|
+ if (index <= 0){
|
|
|
+ notify('error', '只能上传png/jpg格式的文件')
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let fileSuffix = fileName.substr(index)
|
|
|
+ // 文件后缀必须是.png或者.jpg
|
|
|
+ if (fileSuffix !== '.jpg' && fileSuffix !== '.png') {
|
|
|
+ notify('error', '只能上传png/jpg格式的文件')
|
|
|
+ return false;
|
|
|
+ }
|
|
|
},
|
|
|
//上传文件,此处为上传图片
|
|
|
uploadFile (param) {
|