<template>
	<view class="seting-body">
		<view class="cell-container">
			<view class="cell-item flex ac">
				<view class="cell-label">头像</view>
				<view class="cell-value oneflex">
					<image style="width: 60rpx;height: 60rpx;border-radius: 20rpx;" :src="user.headPhoto"></image>
				</view>
			</view>
			<view class="cell-item flex">
				<view class="cell-label">账号</view>
				<view class="cell-value oneflex">
					{{user.username}}
					<uni-icons type="right" size="20" color="#999999"></uni-icons>
				</view>
			</view>
			 <view class="cell-item flex">
			 	<view class="cell-label">昵称</view>
			 	<view class="cell-value oneflex">
			 		{{user.name}}
			 		<uni-icons type="right" size="20" color="#999999"></uni-icons>
			 	</view>
			 </view>  
		</view>
		<!-- <view class="cell-container">
			<view class="cell-item flex ac">
				<view class="cell-label">版本号</view>
				<view class="cell-value oneflex">1.0.0</view>
			</view>
		</view> -->
		<view class="seting-footer flex jc">
			<view @click="OUT" class="seting-footer-button flex ac jc">退出登录</view>
		</view>
	</view>
</template>

<script>
import loginApi from '@/api/login.js';
export default {
	data() {
		return {
			user: uni.getStorageSync('user'),
		};
	},
	methods: {
		loginOut() {
			loginApi.logoutAuthSystem().then((res) => {
				if (res.code === 20000) {
					uni.clearStorage();
					uni.reLaunch({
						url: '/pages/login/index'
					});
				}
			});
		},
		OUT() {
			let that = this;
			uni.showModal({
				title: '确认要退出登录吗？',
				success(res) {
					if (res.confirm) {
						that.loginOut();
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			});
		}
	}
};
</script>

<style lang="scss">
@import 'index.scss';
</style>