|
|
@ -35,6 +35,11 @@ export default { |
|
|
|
components: { |
|
|
|
CircleStencil, Cropper |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
|
|
|
|
}; |
|
|
|
}, |
|
|
|
props: { |
|
|
|
isCropImageDialogActive: { |
|
|
|
type: Boolean, |
|
|
@ -49,27 +54,43 @@ export default { |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
cancelCropImage() { |
|
|
|
const deleteFile = this.cropImagePreview.split('/') |
|
|
|
const filename = deleteFile.pop() |
|
|
|
this.$axios.delete(`/users/images?filename=${filename}`) |
|
|
|
.then(response => {}) |
|
|
|
.catch(error => console.log(error)) |
|
|
|
// const deleteFile = this.cropImagePreview.split('/') |
|
|
|
// const filename = deleteFile.pop() |
|
|
|
// this.$axios.delete(`/users/images?filename=${filename}`) |
|
|
|
// .then(response => {}) |
|
|
|
// .catch(error => console.log(error)) |
|
|
|
this.$emit('close-crop-dialog') |
|
|
|
}, |
|
|
|
cropImage() { |
|
|
|
const result = this.$refs.cropper.getResult() |
|
|
|
const resultSplit = result.image.src.split('/') |
|
|
|
const fileDetails = resultSplit[resultSplit.length-1].split('.') |
|
|
|
const fileURL = result.canvas.toDataURL('image/'+fileDetails[1]) |
|
|
|
const file = this.dataURLtoFile(fileURL,fileDetails[0]+'.'+fileDetails[1]) |
|
|
|
const payload = new FormData() |
|
|
|
payload.append('file',file) |
|
|
|
this.$axios.post('/users/images',payload) |
|
|
|
.then(response => { |
|
|
|
const pictureURL = response.data.image.url |
|
|
|
this.$emit('upload-image-success',pictureURL) |
|
|
|
}) |
|
|
|
.catch(error => console.log(error)) |
|
|
|
// const result = this.$refs.cropper.getResult() |
|
|
|
// console.log(result); |
|
|
|
// const resultSplit = result.image.src.split('/') |
|
|
|
// console.log(resultSplit); |
|
|
|
// const fileDetails = resultSplit[resultSplit.length-1].split('.') |
|
|
|
// const fileURL = result.canvas.toDataURL('image/'+fileDetails[1]) |
|
|
|
// const file = this.dataURLtoFile(fileURL,fileDetails[0]+'.'+fileDetails[1]) |
|
|
|
// const payload = new FormData() |
|
|
|
// payload.append('file',file) |
|
|
|
this.$emit('upload-image-success') |
|
|
|
// this.$axios |
|
|
|
// .post( |
|
|
|
// `/trending/api/Members/UploadAvatar` |
|
|
|
// ) |
|
|
|
// .then((response) => { |
|
|
|
// //console.log(JSON.stringify(response)); |
|
|
|
// if(response && response.data && response.data.DATA && response.data.DATA.rel){ |
|
|
|
// let data = response.data.DATA.rel |
|
|
|
// if(data){ |
|
|
|
// const pictureURL = data; |
|
|
|
// console.log("change pic:" + pictureURL); |
|
|
|
// this.$emit('upload-image-success'); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// .catch((error) => { |
|
|
|
// console.log(error); |
|
|
|
// }); |
|
|
|
|
|
|
|
}, |
|
|
|
dataURLtoFile(dataurl, filename) { |
|
|
|
let arr = dataurl.split(','), |
|
|
|