162 lines
3.9 KiB
Vue
162 lines
3.9 KiB
Vue
<template>
|
|
<view class="ctr" v-if="userInfo.id !== undefined">
|
|
<view class="fixed-top">
|
|
<me-top title="我的" :is-show-icon="false"></me-top>
|
|
</view>
|
|
|
|
<me-empty-space :height="listMarginTop"></me-empty-space>
|
|
<view class="header flex-l">
|
|
<view class="avatar" :style="{background: 'var(--defaultUserAvatar)'}"></view>
|
|
<view class="info">
|
|
<view class="name">{{ userInfo.name }}</view>
|
|
<view class="phone">{{ userInfo.tel }}</view>
|
|
</view>
|
|
<view class="decorate"></view>
|
|
</view>
|
|
|
|
<view class="menus">
|
|
<view class="item flex-sb" @click="logout()" hover-class="auto-mask-layer-radius8" hover-start-time="0" hover-stay-time="50">
|
|
<view class="icon flex-c">
|
|
<me-icon type="icon-logout" color="var(--descriptionColor)" size="56rpx"></me-icon>
|
|
</view>
|
|
<view class="menu flex-sb">
|
|
<view class="left flex-l">退出登录</view>
|
|
<view class="right flex-r">
|
|
<me-icon type="icon-arrow-right" color="var(--contentBgColor)" size="56rpx"></me-icon>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<me-empty-space height="100"></me-empty-space>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import {onShow} from '@dcloudio/uni-app'
|
|
import {ref, computed, inject} from 'vue'
|
|
import MeIcon from "../../components/me-icon/me-icon";
|
|
import MeEmptySpace from "../../components/me-empty-space/me-empty-space.vue";
|
|
import MeTop from "../../components/me-top/me-top.vue";
|
|
import api from "../../api/api";
|
|
import helpers from "../../utils/helpers";
|
|
|
|
const listMarginTop = computed(() => {
|
|
return (inject('globalData').statusBarH + (inject('globalData').customBarH - inject('globalData').statusBarH)) * 2
|
|
})
|
|
|
|
const userInfo = ref({})
|
|
|
|
onShow(() => {
|
|
updateUserInfo()
|
|
})
|
|
|
|
const updateUserInfo = () => {
|
|
api.userInfo().then((res) => {
|
|
uni.setStorageSync('user_info', res)
|
|
userInfo.value = res
|
|
}).catch(() => {})
|
|
}
|
|
|
|
//退出登录
|
|
const logout = () => {
|
|
uni.showLoading({
|
|
title: '退出中…'
|
|
});
|
|
api.logout().then(() => {
|
|
uni.removeStorageSync('token')
|
|
uni.removeStorageSync('user_info')
|
|
|
|
helpers.jumpToPage('login', '', 'reLaunch')
|
|
}).catch(() => {}).finally(() => {
|
|
uni.hideLoading();
|
|
})
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.ctr {
|
|
padding: 0 32rpx;
|
|
box-sizing: border-box;
|
|
.fixed-top {
|
|
position: fixed;
|
|
top: 0;
|
|
background-color: var(--pageBgColor);
|
|
width: 686rpx;
|
|
}
|
|
.header {
|
|
width: 100%;
|
|
height: 200rpx;
|
|
background: var(--containerBgColor);
|
|
border-radius: 16rpx;
|
|
padding: 40rpx 32rpx;
|
|
margin-top: 20rpx;
|
|
box-sizing: border-box;
|
|
position: relative;
|
|
.avatar {
|
|
width: 120rpx;
|
|
height: 120rpx;
|
|
border-radius: 60rpx;
|
|
}
|
|
.info {
|
|
margin-left: 20rpx;
|
|
width: 482rpx;
|
|
height: 120rpx;
|
|
.name,.phone {
|
|
width: 100%;
|
|
height: 60rpx;
|
|
line-height: 60rpx;
|
|
text-align: left;
|
|
}
|
|
.name {
|
|
font-weight: 500;
|
|
font-size: 34rpx;
|
|
color: var(--titleColor);
|
|
}
|
|
.phone {
|
|
font-size: 30rpx;
|
|
color: var(--summaryColor);
|
|
}
|
|
}
|
|
.decorate {
|
|
width: 240rpx;
|
|
height: 200rpx;
|
|
position: absolute;
|
|
right: 0;
|
|
background: url("/static/img/user-bg.png") no-repeat center / 100%;
|
|
border-radius: 0 16rpx 16rpx 0;
|
|
}
|
|
}
|
|
.menus {
|
|
margin-top: 32rpx;
|
|
width: 100%;
|
|
background: var(--containerBgColor);
|
|
border-radius: 16rpx;
|
|
padding: 20rpx;
|
|
box-sizing: border-box;
|
|
.item {
|
|
width: 100%;
|
|
height: 120rpx;
|
|
.icon {
|
|
width: 100rpx;
|
|
height: 120rpx;
|
|
}
|
|
.menu {
|
|
width: 546rpx;
|
|
height: 120rpx;
|
|
.left {
|
|
width: 266rpx;
|
|
height: 100%;
|
|
font-size: 30rpx;
|
|
color: var(--titleColor);
|
|
}
|
|
.right {
|
|
width: 280rpx;
|
|
height: 100%;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|