This commit is contained in:
landaiqing 2023-12-26 01:48:59 +08:00
parent 1137456a74
commit 9ae30b3e27

View File

@ -1,13 +1,14 @@
<template> <template>
<el-upload <el-upload
class="avatar-uploader" class="avatar-uploader"
action action="#"
:show-file-list="false" :show-file-list="false"
:http-request="selectPicUpload" :http-request="selectPicUpload"
:auto-upload="true" :auto-upload="true"
:before-upload="beforeAvatarUpload" :before-upload="beforeAvatarUpload"
:on-remove="handleRemove" :on-remove="handleRemove"
:limit="1" :limit="1"
name="multipartFile"
> >
<img v-if="imageUrl" width="200px" height="200px" :src="imageUrl" class="avatar" /> <img v-if="imageUrl" width="200px" height="200px" :src="imageUrl" class="avatar" />
<i v-else class="el-icon-plus avatar-uploader-icon"></i> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
@ -38,9 +39,10 @@ export default {
selectPicUpload(obj) { selectPicUpload(obj) {
// let _this = this; // let _this = this;
let fd = new FormData(); //formData let fd = new FormData(); //formData
fd.append("file", obj.file); // fd.append("multipartFile", obj.file); //
console.log(fd.get('file')); console.log(fd.get('multipartFile'))
if (localStorage.getItem('userRole') === '0'&&localStorage.getItem('Authorization')) { if (localStorage.getItem('userRole') === '0'&&localStorage.getItem('Authorization')) {
axios({ axios({
method: 'post', method: 'post',
url: '/api/uploadfile', url: '/api/uploadfile',
@ -48,8 +50,11 @@ export default {
params:{ params:{
cate:'img', cate:'img',
name:'dark_logo', name:'dark_logo',
}, },
data:fd, data:{
multipartFile:fd,
}
}).then(function (res) { }).then(function (res) {
console.log(res); console.log(res);
// if(res.data.msg!==""){ // if(res.data.msg!==""){
@ -66,9 +71,8 @@ export default {
// type: 'success', // type: 'success',
// offset: 0 // offset: 0
// }); // });
// // _this.imageUrl=_this.getImage('dark_logo'); // _this.imageUrl=_this.getImage('dark_logo');
// } // }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
Vue.prototype.$notify.error({ Vue.prototype.$notify.error({