<template>
	<view class="content">
		<view class="row1">
			<text class="tit">头像</text>
			<view class="background-img">
				<image class="background-img" :src="baseURL+userInfo.avatar" mode="aspectFill">
				</image>
			</view>
		</view>
		<view class="row b-b flex">
			<text class="tit">姓名</text>
			<input class="input" v-model="userInfo.nickname" disabled="true" type="text"
				placeholder-class="placeholder" />
		</view>
		<view class="row">
			<text class="tit">账号</text>
			<input class="input" type="text" disabled="true" v-model="userInfo.mobile"
				placeholder-class="placeholder" />
		</view>
		<view class="row">
			<text class="tit">身份</text>
			<view class="input">
				{{userInfo.user_type == 2?'老师' : '学生'}}
			</view>
		</view>
		<view class="add-btn" @click="cancel">退出登录</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import {
		logout
	} from '@/api/login.js';
	export default {
		data() {
			return {};
		},
		onLoad() {
			console.log(this.userInfo, '123456');
		},
		computed: {
			...mapState('user', ['userInfo']),
			...mapState(['baseURL'])
		},
		methods: {
			...mapMutations('user', ['logout']),
			cancel() {
				let obj = this;
				uni.showModal({
					content: '确定要退出登录么',
					success: e => {
						if (e.confirm) {
							logout({})
								.then(e => {
									obj.logout();
									uni.navigateTo({
										url: '/pages/public/login'
									});
								})
								.catch(e => {
									console.log(e);
								});
						}
					}
				});
			},
		}
	};
</script>

<style lang="scss">
	.row1 {
		display: flex;
		align-items: center;
		justify-content: space-between;
		position: relative;
		padding: 0 30upx;
		height: 110upx;
		background: #fff;
		margin-bottom: 20upx;

		.tit {
			flex-shrink: 0;
			width: 120upx;
			font-size: $font-lg;
			color: $font-color-dark;
		}

		.background-img {
			width: 80rpx;
			height: 80rpx;
			border-radius: 50%;
			background: #f2f2f2;
		}
	}

	.row {
		display: flex;
		align-items: center;
		padding: 0 30upx;
		height: 110upx;
		background: #fff;

		.tit {
			flex-shrink: 0;
			width: 120upx;
			font-size: $font-lg;
			color: $font-color-dark;
		}

		.input {
			flex: 1;
			text-align: right;
			font-size: $font-base;
			color: $color-gray;
		}
	}

	.add-btn {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 630rpx;
		height: 90rpx;
		margin: 80rpx auto 0;
		font-family: PingFang SC;
		font-weight: bold;
		background: #2a9cec;
		color: #fff;
	}

	.add-btn1 {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 630rpx;
		height: 90rpx;
		margin: 140rpx auto 0;
		font-family: PingFang SC;
		font-weight: bold;
		background: linear-gradient(90deg, #65B2E9, #CA57DC);
		color: #fff;
	}

	.out {
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 0 auto 30rpx;
		width: 560rpx;
		height: 80rpx;
		border: 1px solid #dc262b;
		background: #ffffff;
		border-radius: 40px;
		color: #dc262b;
	}

	.psw-wrapper {
		width: 548rpx;
		height: 344rpx;
		background-color: #ffffff;

		.psw-title {
			width: 100%;
			font-size: 35rpx;
			padding: 43rpx 0 49rpx;
			text-align: center;
			font-weight: 800;
		}

		.psw-ipt {
			display: block;
			background-color: #dce3ed;
			height: 90rpx;
			width: 464rpx;
			padding-left: 30rpx;
			margin: 0 auto;
			font-size: 80rpx;
		}

		.psw-btn text {
			display: inline-block;
			text-align: center;
			width: 50%;
			padding-top: 29rpx;
			font-size: 35rpx;
		}

		.psw-qd {
			color: #32c6ff;
		}
	}
</style>