<template>
	<view>
		<vie style="    width: 100%;
    height: 100px;
    display: block;
    background: #ffffff;"></vie>
		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30">
			<view class="avatarContainer">
				<img  :src="vuex_user.avatar" class='avatar'>
			</view>
			<view class="u-flex-1">
				<view class="u-font-18 u-p-b-20 u-p-t-20 userName">{{vuex_user.name}}</view>
				<view class="u-font-14 u-type-info deptName">{{vuex_user.username}}-{{vuex_user.dept_name}}</view>
				<!-- <view class="u-font-14 u-tips-color" v-if="vuex_user.wxmp_openid">已绑定微信</view> -->
			</view>
			</view>
		<view class="u-m-t-20 u-m-l-20 u-m-r-20" style="position: relative;top:-50px">
			<u-cell-group style="border-radius: 20rpx;">
				<u-cell-item icon="weixin-fill" title="绑定微信" :arrow="false" @click="bindMP" v-if="!vuex_user.wxmp_openid"></u-cell-item>
				<u-cell-item icon="list-dot" title="考试记录" @click="examRecord"></u-cell-item>
				<u-cell-item icon="backspace" title="退出" @click="Logout"></u-cell-item>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pic:'https://uviewui.com/common/logo.png',
				show:true
			}
		},
		onLoad() {
			
		},
		methods: {
			Logout(){
				this.$u.api.unbindmp().then(res=>{
					this.$u.vuex('vuex_token', '')
					uni.redirectTo({
						url: '/pages/login/login'
					});
				}
				)
			},
			bindMP(){
				uni.login({
				  provider: 'weixin',
				  success: (loginRes)=>{
					  this.$u.api.bindmp({code:loginRes.code}).then(res=>{
						  this.$u.toast('绑定成功');
						  this.$u.vuex('vuex_user.wxmp_openid', res.data.wxmp_openid)
						  uni.reLaunch({
						  	url:'/pages/my/my'
						  })
					  }).catch(e=>{})
				  }
				});
			},
			examRecord(){
				uni.navigateTo({
					url:'/pages/exam/record'
				})
			},
		
		}
	}
</script>

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

.camera{
	width: 54px;
	height: 44px;
	
	&:active{
		background-color: #ededed;
	}
}
.user-box{
	    // background-color: #2581e4;
	    // background-color: rgba(37,129,228,0.9);
		background-image: linear-gradient(45deg, #2581e4, #253a54);
	    padding-top: 24rpx;
	    width: 94%;
	    margin: auto;
	    border-radius: 10rpx;
	    position: relative;
	    top: -110rpx;
		padding-top:80rpx;
}
.avatarContainer{
	    width: 150rpx;
	    height: 150rpx;
	    border-radius: 75rpx;
	    position: absolute;
	    top: -32%;
	    left: 50%;
	    padding: 50rpx 10rpx;
	    background: #ffffff;
	    -webkit-transform: translate(-50%);
	    transform: translate(-50%);
}
.avatar{
	width: 130rpx;
	    height: 67rpx;
}
.userName,.deptName{
	color: #ffffff;
	    text-align: center;
}
</style>
