优化:用户头像上传
This commit is contained in:
parent
2e77870ab1
commit
d155f9015a
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jmal-cloud-view",
|
||||
"version": "2.1.7",
|
||||
"version": "2.1.8",
|
||||
"description": "jmal cloud",
|
||||
"author": "Jmal <zhushilun084@163.com>",
|
||||
"license": "MIT",
|
||||
|
||||
@ -48,6 +48,7 @@
|
||||
return {
|
||||
loading: true,
|
||||
cropper: null,
|
||||
filename: '',
|
||||
sourceImg: ''
|
||||
}
|
||||
},
|
||||
@ -100,6 +101,8 @@
|
||||
}
|
||||
},
|
||||
changImg(file) {
|
||||
console.log(file)
|
||||
this.filename = file.name
|
||||
if(file.size > 0){
|
||||
this.loading = true
|
||||
this.cropper.reset()
|
||||
@ -122,6 +125,7 @@
|
||||
})
|
||||
let dataURL = cro.toDataURL('image/jpeg');
|
||||
cro.toBlob((blob)=>{
|
||||
blob.name = this.filename
|
||||
this.$emit('croppedCanvas', dataURL, blob)
|
||||
})
|
||||
},
|
||||
|
||||
@ -1767,6 +1767,9 @@ export default {
|
||||
},
|
||||
// 填充数据
|
||||
loadData(res, onLoad) {
|
||||
if (!this.$refs.fileListTable) {
|
||||
return
|
||||
}
|
||||
if (onLoad) {
|
||||
res.data.forEach((file, number) => {
|
||||
file['index'] = (this.pagination.pageIndex - 1) * this.pagination.pageSize + number
|
||||
|
||||
@ -166,6 +166,7 @@
|
||||
}
|
||||
this.fileImg = files[0]
|
||||
this.dialogAvatar = true
|
||||
this.selectedImgRow = {}
|
||||
if(this.$refs.cropperDialog){
|
||||
this.$refs.cropperDialog.changImg(files[0])
|
||||
}
|
||||
@ -267,15 +268,23 @@
|
||||
return data
|
||||
},
|
||||
// 保存头像
|
||||
saveAvatar(dataURL,blob) {
|
||||
saveAvatar(dataURL, blob) {
|
||||
this.dialogAvatar = false
|
||||
this.srcImage = dataURL
|
||||
let data = new FormData();
|
||||
data.append('id', this.$store.state.user.userId)
|
||||
data.append('avatar', dataURL)
|
||||
// data.append('avatar', dataURL)
|
||||
console.log(this.blobToFile(blob))
|
||||
data.append('blobAvatar',blob)
|
||||
this.userUpdate(data,dataURL)
|
||||
},
|
||||
blobToFile(blob){
|
||||
return new window.File(
|
||||
[blob],
|
||||
blob.name,
|
||||
{ type: blob.type }
|
||||
)
|
||||
},
|
||||
// 保存不剪裁的头像
|
||||
saveNoCropAvatar(fileId) {
|
||||
this.dialogAvatar = false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user