312 lines
6.6 KiB
Vue
312 lines
6.6 KiB
Vue
<template>
|
|
<view class="userCenter">
|
|
<u-navbar :background="background" :is-back='true' back-icon-color='#FFFFFF' :border-bottom="false" title="我的"
|
|
title-color='#FFFFFF' :title-bold='true' title-size='32'></u-navbar>
|
|
|
|
<view class="navbar">
|
|
<image src="../../static/userCenter.png" mode=""></image>
|
|
</view>
|
|
|
|
<view class="content">
|
|
<view class="userInfo">
|
|
<u-avatar :src="src" mode="square" size='104' @click='uploadAvatar'></u-avatar>
|
|
<text class="userName">{{ userName }}</text>
|
|
<text class="admin">{{ admin }}</text>
|
|
</view>
|
|
<view class="userAbility">
|
|
<view class="item">
|
|
<view class="left">
|
|
<image src="../../static/ability1.png" mode=""></image>
|
|
</view>
|
|
<view class="right">
|
|
<text>产品百科</text>
|
|
<image src="../../static/arrow.png" mode=""></image>
|
|
</view>
|
|
</view>
|
|
<view class="item" @click="toChange_password">
|
|
<view class="left">
|
|
<image src="../../static/ability2.png" mode="" style="width: 30rpx;height: 40rpx;"></image>
|
|
</view>
|
|
<view class="right">
|
|
<text>修改密码</text>
|
|
<image src="../../static/arrow.png" mode=""></image>
|
|
</view>
|
|
</view>
|
|
<view class="item">
|
|
<view class="left">
|
|
<image src="../../static/ability3.png" mode="" style="width: 35rpx;height: 40rpx;"></image>
|
|
</view>
|
|
<view class="right">
|
|
<text>关于我们</text>
|
|
<image src="../../static/arrow.png" mode=""></image>
|
|
</view>
|
|
</view>
|
|
<view class="item" @click="toSiteAdmin">
|
|
<view class="left">
|
|
<image src="../../static/ability4.png" mode="" style="width: 40rpx;height: 36rpx;"></image>
|
|
</view>
|
|
<view class="right">
|
|
<text>站点管理</text>
|
|
<image src="../../static/arrow.png" mode=""></image>
|
|
</view>
|
|
</view>
|
|
<view class="item" @click="toLogout">
|
|
<view class="left">
|
|
<image src="../../static/ability5.png" mode="" style="width: 35rpx;height: 36rpx;"></image>
|
|
</view>
|
|
<view class="right">
|
|
<text>退出登录</text>
|
|
<image src="../../static/arrow.png" mode=""></image>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
// 头部导航背景
|
|
background: {
|
|
backgroundColor: 'transparent',
|
|
},
|
|
src: '../../static/logo.png',
|
|
userName: '',
|
|
admin: '',
|
|
userid:''
|
|
};
|
|
},
|
|
mounted() {
|
|
let that = this
|
|
uni.getStorage({
|
|
key:'userid',
|
|
success:function(res){
|
|
that.userid = res.data
|
|
}
|
|
})
|
|
|
|
this.queryUserInfo()
|
|
},
|
|
methods: {
|
|
// 跳转到修改密码页面
|
|
toChange_password() {
|
|
uni.navigateTo({
|
|
url: '/pages/change_password/change_password?userid=' + this.userid
|
|
})
|
|
},
|
|
|
|
// 跳转到站点管理页面
|
|
toSiteAdmin() {
|
|
uni.navigateTo({
|
|
url: '/pages/siteAdmin/siteAdmin'
|
|
})
|
|
},
|
|
|
|
// 退出登录
|
|
toLogout() {
|
|
this.$http({
|
|
url: this.api.user_logout,
|
|
method: 'GET'
|
|
}).then(res => {
|
|
console.log(res, '退出');
|
|
if (res.code == 200) {
|
|
uni.navigateTo({
|
|
url: '/pages/login/login'
|
|
});
|
|
uni.removeStorage({
|
|
key: 'token',
|
|
success: (res) => {
|
|
// console.log(res,'removeStorage');
|
|
}
|
|
});
|
|
uni.removeStorage({
|
|
key: 'userid',
|
|
success: (res) => {
|
|
// console.log(res,'removeStorage');
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
// 上传头像
|
|
uploadAvatar() {
|
|
const that = this
|
|
uni.chooseImage({
|
|
count: 1,
|
|
sizeType: ['original', 'compressed'],
|
|
sourceType: ['album', 'camera'],
|
|
success: function(res) {
|
|
var tempFilePaths = res.tempFilePaths;
|
|
|
|
that.$http({
|
|
url: that.api.update_user,
|
|
method: 'put',
|
|
data: {
|
|
"id": that.userid,
|
|
"nickName": "",
|
|
"phone": "",
|
|
"sex": "",
|
|
"projectName": "",
|
|
"projectColor": "",
|
|
"projectLogo": tempFilePaths[0]
|
|
}
|
|
}).then(res=>{
|
|
if(res.code == 200){
|
|
that.queryUserInfo()
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
// 根据id查询用户信息
|
|
queryUserInfo() {
|
|
let that = this
|
|
uni.getStorage({
|
|
key: 'userid',
|
|
success: function(res) {
|
|
console.log(res);
|
|
that.$http({
|
|
url: that.api.sel_user,
|
|
method: 'GET',
|
|
data: {
|
|
userId: res.data
|
|
}
|
|
}).then(res => {
|
|
console.log(res);
|
|
if (res.code == 200) {
|
|
that.userName = res.data.username;
|
|
that.admin = that.user_level(res.data.userType);
|
|
that.src = res.data.projectLogo ? res.data.projectLogo : that.src
|
|
}
|
|
})
|
|
}
|
|
})
|
|
|
|
},
|
|
|
|
// 判断用户级别
|
|
user_level(le) {
|
|
if (le == '0') {
|
|
return "管理员"
|
|
} else {
|
|
return '普通用户'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.userCenter {
|
|
width: 100%;
|
|
min-height: 100vh;
|
|
background-color: #F5F6FA;
|
|
position: relative;
|
|
|
|
.navbar {
|
|
width: 100%;
|
|
height: 100%;
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
|
|
>image {
|
|
width: 750rpx;
|
|
height: 340rpx;
|
|
|
|
}
|
|
}
|
|
|
|
.content {
|
|
position: absolute;
|
|
z-index: 99999;
|
|
box-sizing: border-box;
|
|
padding: 0rpx 30rpx 30rpx;
|
|
|
|
.userInfo {
|
|
width: 100%;
|
|
height: 104rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
|
|
.userName {
|
|
font-size: 38rpx;
|
|
font-family: PingFang SC;
|
|
font-weight: bold;
|
|
color: #FFFFFF;
|
|
margin-left: 23rpx;
|
|
}
|
|
|
|
.admin {
|
|
width: 140rpx;
|
|
height: 44rpx;
|
|
background: rgba(255, 255, 255, 0.2);
|
|
border: 2px solid rgba(255, 255, 255, 0.4);
|
|
border-radius: 22rpx;
|
|
font-size: 22rpx;
|
|
font-family: PingFang SC;
|
|
font-weight: 500;
|
|
color: #FFFFFF;
|
|
margin-left: 11rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
}
|
|
|
|
.userAbility {
|
|
width: 690rpx;
|
|
height: 550rpx;
|
|
background: #FFFFFF;
|
|
border-radius: 10rpx;
|
|
margin-top: 43rpx;
|
|
box-sizing: border-box;
|
|
padding-left: 30rpx;
|
|
|
|
.item {
|
|
height: 105rpx;
|
|
|
|
display: flex;
|
|
align-items: center;
|
|
|
|
.left {
|
|
width: calc(100% - 600rpx);
|
|
|
|
>image {
|
|
width: 40rpx;
|
|
height: 34rpx;
|
|
margin-right: 19rpx;
|
|
}
|
|
}
|
|
|
|
.right {
|
|
width: 600rpx;
|
|
height: 105rpx;
|
|
border-bottom: 1rpx solid #DDDDDD;
|
|
box-sizing: border-box;
|
|
padding-right: 32rpx;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
|
|
text {
|
|
font-size: 30rpx;
|
|
font-family: PingFang SC;
|
|
font-weight: bold;
|
|
color: #333333;
|
|
}
|
|
|
|
>image {
|
|
width: 13rpx;
|
|
height: 24rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style> |