|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <img v-bind:src="baseUrl+options.img" slot="reference" @click="editCropper()" title="点击上传头像" class="img-lg" />
|
|
|
+ <img v-bind:src="defaultAvatar" slot="reference" @click="editCropper()" title="点击上传头像" class="img-lg" />
|
|
|
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @opened="modalOpened">
|
|
|
<el-row>
|
|
|
<el-col :xs="24" :md="12" :style="{height: '350px'}">
|
|
@@ -67,6 +67,7 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ defaultAvatar: "",
|
|
|
baseUrl: "",
|
|
|
// 是否显示弹出层
|
|
|
open: false,
|
|
@@ -86,13 +87,17 @@ export default {
|
|
|
},
|
|
|
mounted() {
|
|
|
this.baseUrl = process.env.VUE_APP_BASE_API;
|
|
|
+ if(this.personal.avatar == null || this.personal.avatar == '') {
|
|
|
+ this.defaultAvatar = require('@/assets/image/avataaars.jpg')
|
|
|
+ } else {
|
|
|
+ this.defaultAvatar = this.baseUrl + this.personal.avatar
|
|
|
+ }
|
|
|
// console.log(this.baseUrl)
|
|
|
},
|
|
|
methods: {
|
|
|
// 编辑头像
|
|
|
editCropper() {
|
|
|
this.open = true;
|
|
|
- this.options.img= this.baseUrl + this.options.img
|
|
|
},
|
|
|
// 打开弹出层结束时的回调
|
|
|
modalOpened() {
|
|
@@ -136,6 +141,7 @@ export default {
|
|
|
this.open = false;
|
|
|
this.options.img = response.fileName;
|
|
|
this.personal.avatar = this.options.img;
|
|
|
+ this.defaultAvatar = this.baseUrl + this.options.img;
|
|
|
this.msgSuccess("上传成功");
|
|
|
}
|
|
|
this.visible = false;
|