fix头像上传提交到后台没有文件名
This commit is contained in:
parent
9d1118385f
commit
5cc7f7e6ff
@ -158,7 +158,7 @@ function setLayout() {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
width: 30px;
|
width: 30px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
border-radius: 10px;
|
border-radius: 50%;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,8 +14,7 @@
|
|||||||
:autoCropHeight="options.autoCropHeight"
|
:autoCropHeight="options.autoCropHeight"
|
||||||
:fixedBox="options.fixedBox"
|
:fixedBox="options.fixedBox"
|
||||||
@realTime="realTime"
|
@realTime="realTime"
|
||||||
v-if="visible"
|
v-if="visible" />
|
||||||
/>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
|
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
|
||||||
<div class="avatar-upload-preview">
|
<div class="avatar-upload-preview">
|
||||||
@ -76,7 +75,7 @@ export default {
|
|||||||
const open = ref(false)
|
const open = ref(false)
|
||||||
const visible = ref(false)
|
const visible = ref(false)
|
||||||
const title = ref('修改头像')
|
const title = ref('修改头像')
|
||||||
|
const fileName = ref('')
|
||||||
//图片裁剪数据
|
//图片裁剪数据
|
||||||
const options = reactive({
|
const options = reactive({
|
||||||
img: store.getters.avatar, // 裁剪图片的地址
|
img: store.getters.avatar, // 裁剪图片的地址
|
||||||
@ -115,6 +114,7 @@ export default {
|
|||||||
if (file.type.indexOf('image/') == -1) {
|
if (file.type.indexOf('image/') == -1) {
|
||||||
proxy.$modal.msgError('文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。')
|
proxy.$modal.msgError('文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。')
|
||||||
} else {
|
} else {
|
||||||
|
fileName.value = file.name
|
||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
reader.readAsDataURL(file)
|
reader.readAsDataURL(file)
|
||||||
reader.onload = () => {
|
reader.onload = () => {
|
||||||
@ -126,7 +126,8 @@ export default {
|
|||||||
function uploadImg() {
|
function uploadImg() {
|
||||||
proxy.$refs.cropper.getCropBlob((data) => {
|
proxy.$refs.cropper.getCropBlob((data) => {
|
||||||
let formData = new FormData()
|
let formData = new FormData()
|
||||||
formData.append('picture', data)
|
var fileOfBlob = new File([data], fileName.value);
|
||||||
|
formData.append('picture', fileOfBlob)
|
||||||
uploadAvatar(formData).then((response) => {
|
uploadAvatar(formData).then((response) => {
|
||||||
open.value = false
|
open.value = false
|
||||||
options.img = response.data.imgUrl
|
options.img = response.data.imgUrl
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user