zhoudw
2022-01-10 07562200a704b8eaf9c1d080bf8bd12165a97647
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<template>
  <div class="user-content">
    <div class="user-head">
      <div class="head-left">
          <van-image
          lazy-load
          :src="userLogo" rel="external nofollow"
        />
      </div>
      <div class="head-right">
        <p class="userName">{{userInfo.nickname}}</p>
        <p class="userPhone">{{userInfo.ac_name}}</p>
      </div>
    </div>
    <div class="user-body">
        <div class="list-li" @click="loginoutEvent">退出登录</div>
    </div>
    <Tabbar :active="1"></Tabbar>
  </div>
</template>
<script>
import { mapActions, mapState } from "vuex";
import Tabbar from "@/components/Tabbar";
export default {
  components: { Tabbar },
  data() {
    return {
      userLogo:require('@/assets/images/service.png'),
      userInfo:""
    };
  },
  created () {
    this.load();
  },
  computed: {
    ...mapState({ token: "token" }),
  },
  methods: {
    ...mapActions({
        loginout: "loginout", // 发送验证码
        getUserInfo:"getUserInfo", //获取用户信息
        set_token:"set_token"
    }),
    loginoutEvent(){
      let _this = this;
      _this.$dialog
        .confirm({ message: "退出登录确认" })
        .then(() => {
          _this.loginout({ query: {} }).then(() => {
            localStorage.removeItem("token");
            _this.set_token({});
            location.href = "/";
          });
        })
        .catch(() => {});
    },
    load(){
      let _this = this;
      _this.getUserInfo({query:
      {
        token:_this.token,
      }
      }).then((res) =>{
        if(res.user_info){
          _this.userInfo = res.user_info;
          if(res.user_info.head_img){
            _this.userLogo = res.user_info.head_img;
          }
        }else{
 
        }
      }).catch(err => {
        console.log(err,'失败')
        _this.$toast.fail(err.msg)
      });
    }
  }
}
</script>
<style lang="less" scoped>
.user-content{
  position: relative;
  width: 100%;
  height: 100%;
  .user-head{
    width: 750px;
    height: 360px;
    background: linear-gradient(180deg,#7ccdff, #4a90e2);
    display: flex;
    align-items: center;
    padding-left: 51px;
    .head-left{
      width: 120px;
      height: 120px;
      border-radius: 100%;
      margin-right: 28px;
      /deep/ .van-image__img{
         border-radius: 100%;
       }
    }
    .head-right{
      color: white;
      font-size: 30px;
      font-weight: 500;
      .userName{
        margin-bottom: 5px;
      }
    }
  }
  .list-li{
    background-color: white;
    height: 90px;
    text-align: center;
    line-height: 90px;
    font-size: 30px;
    color: #ff3512;
    margin-top: 20px;
  }
}
</style>