You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
< template >
< view class = "profile-container" >
< view class = "avatar-section" >
< image class = "avatar" : src = "userInfo.avatar || '/static/profile/avatar.png'" mode = "aspectFill" > < / image >
< / view >
< view class = "info-section" >
< view class = "info-item" >
< text class = "label" > 用户名 : < / text >
< text class = "value" > { { userInfo . username || '-' } } < / text >
< / view >
< view class = "info-item" >
< text class = "label" > 姓名 : < / text >
< text class = "value" > { { userInfo . name || '-' } } < / text >
< / view >
< view class = "info-item" >
< text class = "label" > 部门 : < / text >
< text class = "value" > { { ( userInfo . department && userInfo . department . name ) || '-' } } < / text >
< / view >
< / view >
< button class = "logout-btn" @click ="logout" > 退 出 登 录 < / button >
< / view >
< / template >
< script >
import { getUserInfo } from '@/api.js'
export default {
data ( ) {
return {
userInfo : { }
}
} ,
onShow ( ) {
getUserInfo ( ) . then ( response => {
if ( response . data ) {
console . log ( "返回数据" , response . data )
this . userInfo = response . data
} else {
uni . showToast ( {
title : response . data . errmsg || '获取信息失败' ,
icon : 'none'
} )
}
} ) . catch ( ( ) => {
uni . showToast ( { title : '网络错误' , icon : 'none' } )
} )
} ,
methods : {
logout ( ) {
uni . removeStorageSync ( 'token' ) ;
uni . reLaunch ( { url : '/pages/login/login' } ) ;
}
}
}
< / script >
< style >
. profile - container {
min - height : 100 vh ;
background : # f5f6fa ;
display : flex ;
flex - direction : column ;
align - items : center ;
padding - top : 80 rpx ;
}
. avatar - section {
display : flex ;
flex - direction : column ;
align - items : center ;
margin - bottom : 40 rpx ;
}
. avatar {
width : 140 rpx ;
height : 140 rpx ;
border - radius : 50 % ;
background : # fff ;
margin - bottom : 20 rpx ;
}
. username {
font - size : 32 rpx ;
color : # 333 ;
font - weight : bold ;
}
. info - section {
width : 80 % ;
background : # fff ;
border - radius : 16 rpx ;
box - shadow : 0 2 rpx 10 rpx rgba ( 0 , 0 , 0 , 0.05 ) ;
padding : 30 rpx ;
margin - bottom : 60 rpx ;
}
. info - item {
display : flex ;
flex - direction : row ;
margin - bottom : 20 rpx ;
}
. info - item : last - child {
margin - bottom : 0 ;
}
. label {
color : # 888 ;
font - size : 28 rpx ;
width : 120 rpx ;
}
. value {
color : # 333 ;
font - size : 28 rpx ;
}
. logout - btn {
width : 80 % ;
height : 90 rpx ;
line - height : 90 rpx ;
background : # ff4d4f ;
color : # fff ;
font - size : 32 rpx ;
border - radius : 45 rpx ;
font - weight : bold ;
margin - top : 40 rpx ;
}
. logout - btn : active {
background : # d9363e ;
}
< / style >