Quellcode durchsuchen

修改上传前的默认头像

Alex vor 4 Jahren
Ursprung
Commit
5f2f8fb984

BIN
src/assets/image/avataaars.jpg


BIN
src/assets/image/profile.jpg


+ 8 - 2
src/views/system/appUser/detail/appUserAvatar.vue

@@ -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;

+ 0 - 4
src/views/system/appUser/index.vue

@@ -439,7 +439,6 @@ export default {
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
-      debugger
       this.readonly = true;
       this.reset();
       const id = row.userId || this.ids;
@@ -510,7 +509,6 @@ export default {
     }
     ,
     getQrcodeImg(id) {
-      debugger
       const uid = id;
       // 是否有个人生平数据
       var url = null;
@@ -587,13 +585,11 @@ export default {
     familySizeChange: function(size) {
       this.familyParams.pageSize =  size
       var uid = this.familyParams.userId;
-      debugger
       this.getMyFamilys(uid);
     },
     familyCurrentChange: function(currentPage) {
       this.familyParams.pageNum = currentPage
       var uid = this.familyParams.userId;
-      debugger
       this.getMyFamilys(uid);
     },
   }

+ 8 - 3
src/views/system/family/detail/familyAvatar.vue

@@ -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,16 @@ export default {
   },
   mounted() {  
     this.baseUrl = process.env.VUE_APP_BASE_API;
-    //  console.log(this.family)
+    if(this.family.avatar == null || this.family.avatar == '') {
+      this.defaultAvatar = require('@/assets/image/avataaars.jpg')
+    } else {
+      this.defaultAvatar = this.baseUrl + this.family.avatar
+    }
   },
   methods: {
     // 编辑头像
     editCropper() {
       this.open = true;
-      this.options.img= this.baseUrl + this.options.img 
     },
     // 打开弹出层结束时的回调
     modalOpened() {
@@ -136,6 +140,7 @@ export default {
             this.open = false;
             this.options.img = response.fileName;
             this.family.avatar = this.options.img;
+            this.defaultAvatar = this.baseUrl + this.options.img;
             this.msgSuccess("上传成功");
           }
           this.visible = false;

+ 1 - 0
src/views/system/family/index.vue

@@ -201,6 +201,7 @@
 
     <!-- 添加或修改家族对话框 -->
     <el-dialog
+      v-if="open"
       :title="title"
       :visible.sync="open"
       width="750px"