<template>
	<view>
		<u-navbar :is-back="false" title="我的" :border-bottom="false">
		</u-navbar>
		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30">
			<view class="u-m-r-10">
				<u-avatar :src="userInfo.avatar" size="140"></u-avatar>
			</view>
			<view class="u-flex-1">
				<view class="u-font-18 u-p-b-20">{{userInfo.nickName?userInfo.nickName:'暂无'}}</view>
				<view class="u-font-14 u-tips-color">{{userInfo.dept.deptName?userInfo.dept.deptName:'暂无'}}</view>
			</view>
			<view class="u-m-l-10 u-p-10">
				<u-icon name="scan" color="#969799" size="28"></u-icon>
			</view>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="rmb-circle" title="电子钱包" @click="toWlletinfo"></u-cell-item>
			</u-cell-group>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="lock" title="修改密码" @click="toPassword"></u-cell-item>
				<u-cell-item icon="info-circle" title="关于我们" @click="openAbout"></u-cell-item>
				<u-modal v-model="showAbout" :show-title="false" :show-confirm-button="false" :mask-close-able="true">
					<view class="u-text-center">
						<rich-text>
							<view class="u-padding-5">
								<image class="app-logo" src="../../static/logo.png"></image>
							</view>
							<text class="u-padding-5">广东五华云计算有限公司</text>
						</rich-text>
					</view>
				</u-modal>
			</u-cell-group>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item :value-style="{'text-align':'center'}"  :arrow="false" value="退出登录" @click="openLogout" ></u-cell-item>
			</u-cell-group>
		</view>
		<u-modal v-model="showLogout" content="确认退出登录吗？" show-cancel-button="true" @confirm="logout" @cancel="cancelLogout"></u-modal>
		<u-gap height="70"></u-gap>
	</view>
</template>

<script>
import _config from 'config.js'
	export default {
		data() {
			return {
				userInfo: {},
				showLogout: false,
				showAbout: false,
			}
		},
		onReady() {
			this.userInfo = this.vuex_userInfo;
			console.log("当前登录用户对象",this.userInfo);
		},
		methods: {
			openLogout() {
				this.showLogout = true;
			},
			logout() {
				uni.clearStorageSync()
				uni.clearStorage()
				this.$u.vuex('vuex_user','');
				this.$u.vuex('vuex_token','');
				this.$u.route('/pages/login');
			},
			cancelLogout() {
				this.showLogout = false;
			},
			//弹出关于我们
			openAbout() {
				this.showAbout= true;
			},
			//修改密码
			toPassword(){
				this.$u.route({
					url: '/pages/center/password',
					animationType: 'slide-in-bottom'
				});
			},
			//电子钱包
			toWlletinfo(){
				this.$u.route({
					url: '/pages/center/walletinfo',
					animationType: 'slide-in-bottom'
				});
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #ededed;
	}
	
	.user-box{
		background-color: #fff;
	}
	
	.app-logo{
		
		width: 185rpx;
		height: 185rpx;
		margin: 0px auto;
	}
</style>

