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