123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <template>
- <view>
- <view class="user-banner" v-if="isLogin">
- <div>
- <image v-if="user.avatar!=null && user.avatar!=''" class="avatar" :src="user.avatar"></image>
- <image v-else class="avatar" src="../../static/avatar.png"></image>
- </div>
- <view class="name">
- {{user.realName}}
- </view>
- <view class="dept">{{user.departId_dictText}}</view>
- <view class="points">
- {{user.points}}积分
- </view>
- </view>
- <!-- 左侧显示略缩图、图标 -->
- <uni-list>
- <uni-list-item thumb-size="sm" title="修改资料" link="navigateTo" to="/pages/user/info/info">
- </uni-list-item>
- <uni-list-item thumb-size="sm" title="学习记录" link="navigateTo" to="/pages/course/my">
- </uni-list-item>
- <uni-list-item thumb-size="sm" title="我的成绩" link="navigateTo" to="/pages/paper/index">
- </uni-list-item>
- <uni-list-item thumb-size="sm" title="训练记录" link="navigateTo" to="/pages/repo/history">
- </uni-list-item>
- <uni-list-item thumb-size="sm" title="积分日志" link="navigateTo" to="/pages/user/points/points">
- </uni-list-item>
- <uni-list-item thumb-size="sm" title="密码安全" link="navigateTo" to="/pages/login/passwd">
- </uni-list-item>
- <!-- <uni-list-item
- thumb-size="sm"
- title="关于我们"
- link="navigateTo"
- to="/pages/sys/about">
- </uni-list-item> -->
- <!-- <uni-list-item thumb-size="sm" title="跳转App" link="navigateTo" to="/pages/jumpApp/index">
- </uni-list-item> -->
- <uni-list-item thumb-size="sm" title="退出登录" link="navigateTo" @click="handleLogout()">
- </uni-list-item>
- </uni-list>
- </view>
- </template>
- <script>
- import {
- logout,
- info
- } from '@/api/user'
- export default {
- components: {},
- data() {
- return {
- isLogin: false,
- user: {},
- }
- },
- onShow() {
- this.handleInfo()
- },
- methods: {
- handleInfo() {
- let token = uni.getStorageSync('token');
- info(token).then(res => {
- this.isLogin = true
- this.user = res
- })
- },
- handleLogout() {
- logout().then(res => {
- // 移除会话
- uni.removeStorageSync('token');
- // 到登录页面
- this.$navs.toLogin()
- })
- }
- }
- }
- </script>
- <style>
- .user-banner {
- height: 160px;
- display: flex;
- background: url('https://cdn.yfhl.net/static/user-bg.jpg') no-repeat;
- align-items: center;
- background-position: center;
- background-size: 100% 100%;
- justify-content: center;
- width: 100%;
- flex-direction: column;
- }
- .user-banner .avatar {
- width: 80px;
- height: 80px;
- border: #efefef 2px solid;
- border-radius: 50%;
- }
- .user-banner .points {
- position: absolute;
- top: 15px;
- right: 15px;
- color: #FDBF40;
- font-weight: bold;
- font-weight: 700;
- font-size: 16px;
- }
- .user-banner .name {
- color: #fff;
- font-weight: 700;
- font-size: 18px;
- }
- .user-banner .dept {
- color: #eee;
- font-weight: 700;
- font-size: 14px;
- }
- </style>
|