|
@@ -476,38 +476,42 @@
|
|
|
upload (e) {
|
|
upload (e) {
|
|
|
this.isShowLoading = true
|
|
this.isShowLoading = true
|
|
|
let file = e.target.files[0]
|
|
let file = e.target.files[0]
|
|
|
- if (file.size > 5 * 1024 * 1024) {
|
|
|
|
|
- this.uploadFileChecked = false
|
|
|
|
|
- this.isShowLoading = false
|
|
|
|
|
- } else {
|
|
|
|
|
- let param = new FormData()
|
|
|
|
|
- param.append('image', file, file.name)
|
|
|
|
|
- let config = {
|
|
|
|
|
- headers: {'Content-Type': 'multipart/form-data'}
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (file) {
|
|
|
|
|
+ if (file.size > 5 * 1024 * 1024) {
|
|
|
|
|
+ this.uploadFileChecked = false
|
|
|
|
|
+ this.isShowLoading = false
|
|
|
|
|
+ } else {
|
|
|
|
|
+ let param = new FormData()
|
|
|
|
|
+ param.append('image', file, file.name)
|
|
|
|
|
+ let config = {
|
|
|
|
|
+ headers: {'Content-Type': 'multipart/form-data'}
|
|
|
|
|
+ }
|
|
|
// 图片上传接口
|
|
// 图片上传接口
|
|
|
- this.$http.post('/api/userspace/upload', param, config)
|
|
|
|
|
- .then(response => {
|
|
|
|
|
- this.isShowLoading = false
|
|
|
|
|
- if (response.data.success) {
|
|
|
|
|
- let path = response.data.content
|
|
|
|
|
- if (path.slice(path.lastIndexOf('.')).toLowerCase() === '.pdf') {
|
|
|
|
|
- this.isPdf = true
|
|
|
|
|
|
|
+ this.$http.post('/api/userspace/upload', param, config)
|
|
|
|
|
+ .then(response => {
|
|
|
|
|
+ this.isShowLoading = false
|
|
|
|
|
+ if (response.data.success) {
|
|
|
|
|
+ let path = response.data.content
|
|
|
|
|
+ if (path.slice(path.lastIndexOf('.')).toLowerCase() === '.pdf') {
|
|
|
|
|
+ this.isPdf = true
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.isPdf = false
|
|
|
|
|
+ }
|
|
|
|
|
+ this.changeManager.businessCodeImage = response.data.content
|
|
|
|
|
+ this.uploadFileChecked = true
|
|
|
} else {
|
|
} else {
|
|
|
- this.isPdf = false
|
|
|
|
|
|
|
+ this.uploadFileChecked = false
|
|
|
|
|
+ return Promise.reject(response.data)
|
|
|
}
|
|
}
|
|
|
- this.changeManager.businessCodeImage = response.data.content
|
|
|
|
|
- this.uploadFileChecked = true
|
|
|
|
|
- } else {
|
|
|
|
|
- this.uploadFileChecked = false
|
|
|
|
|
- return Promise.reject(response.data)
|
|
|
|
|
- }
|
|
|
|
|
- }).catch(err => {
|
|
|
|
|
- console.log(err)
|
|
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ console.log(err)
|
|
|
// this.$message.error(err.errMsg)
|
|
// this.$message.error(err.errMsg)
|
|
|
- this.isShowLoading = false
|
|
|
|
|
- this.uploadFileChecked = false
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ this.isShowLoading = false
|
|
|
|
|
+ this.uploadFileChecked = false
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.isShowLoading = false
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
// 地址选择
|
|
// 地址选择
|