person.vue 1.6 KB
Newer Older
1 2 3 4 5 6 7
<template>
  <div>
    <div class="fl-left left-mg-xs">
      <el-upload
        :headers="{'x-token':token}"
        :on-success="handleAvatarSuccess"
        :show-file-list="false"
8
        :action="`${path}/user/uploadHeaderImg`"
9 10 11
        class="avatar-uploader"
        name="headerImg"
      >
12
        <CustomPic picType="img"/>
13 14 15 16 17 18 19 20 21 22 23 24
      </el-upload>

      <!-- <el-avatar :size="120" :src="userInfo.headerImg" shape="square"></el-avatar> -->
    </div>
    <div class="fl-left left-mg-lg">
      <div>用户ID:{{userInfo.uuid}}</div>
      <div>用户昵称:{{userInfo.nickName}}</div>
      <div>用户组:{{userInfo.authority&&userInfo.authority.authorityName}}</div>
    </div>
  </div>
</template>
<script>
25
import CustomPic from '@/components/customPic'
Mr.奇淼('s avatar
Mr.奇淼( 已提交
26
import { mapGetters, mapMutations } from 'vuex'
27
const path = process.env.VUE_APP_BASE_API
28 29
export default {
  name: 'Person',
30 31 32 33 34
  data(){
    return {
      path:path
    }
  },
35 36 37
  components: {
		CustomPic
	},
38 39 40 41
  computed: {
    ...mapGetters('user', ['userInfo', 'token'])
  },
  methods:{
Mr.奇淼('s avatar
Mr.奇淼( 已提交
42 43 44
    ...mapMutations('user',['ResetUserInfo']),
      handleAvatarSuccess(res){
        this.ResetUserInfo({headerImg:res.data.user.headerImg})
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
      }
  }
}
</script>
<style lang="scss">
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>