index.vue 2.58 KB
<template>
	<view class="personalData-v">
		<u-cell-group>
			<u-cell-item title="头像" :arrow="false">
				<u-avatar :src="baseUrl+userInfo.headIcon" size="64" slot="right-icon"></u-avatar>
			</u-cell-item>
			<u-cell-item title="姓名" :value="userInfo.userInfo.userAccount" :arrow="false"></u-cell-item>
			<u-cell-item title="性别" :value="gender" :arrow="false"></u-cell-item>
			<u-cell-item title="所属公司" :value="userInfo.userInfo.organizeName" :arrow="false" v-if="userInfo.userInfo.userId !== '360267753694692613'"></u-cell-item>
			<!-- <u-cell-item title="手机号" :value="userInfo.mobilePhone" :arrow="false"></u-cell-item> -->
			<!-- <u-cell-item title="邮箱" :value="userInfo.email" :arrow="false"></u-cell-item> -->
		</u-cell-group>
		<button type="primary" style="width: 90%;margin: 0 auto;border-radius: 20rpx; background-color: #D32D25;color: white;margin-top: 100rpx;" @click="loginOut">退出登录</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				gender: '',
				birthday: '',
				userInfo: {},
				baseUrl:'http://deyanggaoxin.fengshiyun.com',
				
			}
		},
		computed: {
			baseURL() {
				return this.define.baseURL
			}
		},
		onLoad() {
			this.userInfo = uni.getStorageSync('user') || {};
			
			console.log(this.userInfo)
			this.gender = this.userInfo.gender == 1 ? '男' : this.userInfo.gender == 2 ? '女' : '保密'
			this.birthday = this.userInfo.birthday ? this.$u.timeFormat(this.userInfo.birthday, 'yyyy-mm-dd') : ''
		},
		methods:{
			// 退出登录
			loginOut(){
				console.log('1111')
				
				uni.showModal({
					title: '提示',
					content: '确定退出当前账号吗?',
					success: res => {
						if (res.confirm) {
							uni.removeStorage({
								key: 'user',
								// success: function (res) {
								// 	uni.showToast({
								// 		icon:'success',
								// 		title:'已退出登录',
								// 		duration:'1'
								// 	})
								// }
							});
							uni.removeStorage({
								key: 'AuthToken_KEY',
								success: function (res) {
									console.log(res)
									// uni.showToast({
									// 	icon:'success',
									// 	title:'已退出登录'
									// })
								}
							});
							uni.removeStorage({
								key: 'token',
								success: function (res) {
									console.log(res)
									// uni.showToast({
									// 	icon:'success',
									// 	title:'已退出登录'
									// })
								}
							});
							uni.reLaunch({
								url:'/pages/home/home'
							})
						}
					}
				})
				
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f0f2f6;
	}
</style>