旅游教育出版社-数字教材移动端
QYF-GitLab1
昨天 8e3ee81b6ed824866734b7034604121f370f4201
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<template>
  <div class="personInfor">
    <van-nav-bar
      title="个人信息"
      left-text
      left-arrow
      @click-left="onClickLeft"
    />
    <ul class="listInfor">
      <li class="firstLi">
        <span style="font-size:14px;color:#333;">头像</span>
        <div>
          <img v-if="userInfo.icon" :src="userInfo.icon" alt="" />
          <img v-else src="@/assets/images/default_avatar.png" alt="" />
        </div>
      </li>
      <li>
        <div style="display:flex;justify-content: space-between;">
          <span class="title">用户名:</span>
          <div>
            <span class="content">{{ userInfo.name }}</span>
          </div>
        </div>
      </li>
      <li>
        <div style="display:flex;justify-content: space-between;">
          <span class="title">手机号:</span>
          <div>
            <span class="content">{{ phone }}</span>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>
 
<script>
import { mapState } from "vuex";
 
export default {
  data() {
    return {
      avatarIcon: "",
      username: "",
      phone: ""
    };
  },
  created() {
    // this.getUserInfo();
  },
  computed: {
    ...mapState(["userInfo"])
  },
 
  mounted() {
    this.teacherInfo = JSON.parse(this.userInfo.data)
    this.phone = this.teacherInfo.phone ? this.teacherInfo.phone : "-"
  },
 
  methods: {
    evil(fn) {
      let Fn = Function; // 一个变量指向Function,防止有些前端编译工具报错
      return new Fn("return " + fn)();
    },
    //获取用户信息
    getUserInfo() {
      let that = this;
      that.request.get("/api/user/info").then(res => {
        if (res.headImgUrl && res.headImgUrl != "") {
          if (res.headImgUrl.indexOf("https") > -1) {
            that.avatarIcon = res.headImgUrl;
          } else {
            that.avatarIcon =
              that.config.requestCtx +
              "/fileDownload.ashx?md5=" +
              res.headImgUrl +
              "&appId=" +
              that.config.appId;
          }
        } else {
          that.avatarIcon = require("@/assets/images/default_avatar.png");
        }
        that.phone = res.mobile;
        that.username = res.account && res.account != "" ? res.account : "";
        if (res.roles.indexOf("Teacher") != -1) {
          that.request
            .post("/api/EduTeacher/getTeacherInfo", {
              appId: that.config.appId
            })
            .then(res => {
              res.nickName =
                res.nickName && res.nickName != ""
                  ? that.evil("'" + res.nickName + "'")
                  : "";
              that.userInfo = res;
            });
        } else if (res.roles.indexOf("Student") != -1) {
          that.getStudentInfo();
        }
      });
    },
    // 获取学生基本信息
    getStudentInfo() {
      let that = this;
      that.request
        .post("/api/EduStudent/getStudentInfo", { appId: that.config.appId })
        .then(res => {
          if (res) {
            res.nickName =
              res.nickName && res.nickName != ""
                ? that.evil("'" + res.nickName + "'")
                : "";
            that.userInfo = res;
          }
        });
    },
    onClickLeft() {
      var that = this;
      that.$router.push({
        path: "/personalCenter"
      });
    }
  }
};
</script>
 
<style scoped>
.listInfor {
  padding-top: 38px;
}
 
.listInfor img {
  width: 65px;
  height: 65px;
  display: inline-block;
  border-radius: 100%;
}
 
.listInfor li {
  border-bottom: 1px solid #f6f6f6;
  padding: 0 15px;
}
 
.firstLi {
  height: 85px;
  line-height: 85px;
  display: flex;
  justify-content: space-between;
}
li + li {
  height: 48px;
  line-height: 48px;
}
 
li + li:last-child {
  margin-bottom: 30px;
}
 
.title {
  font-size: 14px;
  color: #333333;
}
 
.content {
  color: #999999;
  font-size: 14px;
}
</style>
 
<style>
.personInfor .van-nav-bar {
  position: fixed;
  width: 100%;
}
</style>