<template>
	<view class="mine">
		<view class="top">
			<view class="info" >
				<view class="img" :style="{backgroundImage:'url('+ (mine.type_model? mine.type_model.headimg : '../../static/images/avator.png') +')'}">
					<!-- <image :src="mine.type_model? mine.type_model.headimg : '../../static/images/avator.png'" mode=""></image> -->
				</view>
				<view class="info_name">
					{{mine.type_model ? mine.type_model.truename :'--'}}
				</view>
				<view class="edit" @click="edit">
					<text>编辑资料</text>
					<image src="../../static/images/edit_arrow.png" mode=""></image>
				</view>
			</view>
			
		</view>
		<view class="content">
			<view class="header">
				<view class="header_wrap">
					<view class="right first">
						<view class="dot">
							
						</view>
						<view class="text">
							<text>学科：</text>
							{{mine.type_model ? mine.type_model.subject :'--'}}
						</view>						
					</view>
					<view class="right">
						<view class="dot">
							
						</view>
						<view class="text">
							<text>账号：</text>
							{{mine.type_model ? mine.type_model.account :'--'}}
						</view>						
					</view>
					<view class="right third">
						<view class="dot">
							
						</view>
						<view class="text">
							<text>毕业院校：</text>
							{{mine.type_model ? mine.type_model.school :'--'}}
						</view>						
					</view>
					<!-- <view class="right">
						<view class="dot">
							
						</view>
						<view class="text">
							<text>职称：</text>
							{{mine.type_model ? mine.type_model.rank :'--'}}
						</view>						
					</view> -->
				</view>				
				<view class="tip">
					<view class="item">
						<view class="nums">
							{{statistical.subscribe_nums}}
						</view>
						<view class="text">
							学生人数
						</view>
					</view>
					<view class="item">
						<view class="nums">
							{{statistical.activity_nums}}
						</view>
						<view class="text">
							发布活动
						</view>
					</view>
					<view class="item">
						<view class="nums">
							{{statistical.scheduling_nums}}
						</view>
						<view class="text">
							值班次数
						</view>
					</view>
				
				</view>
			</view>
			<view class="list">
				
				<view class="item" @click="record" v-if="$transformAuth('100202')">
					<view class="left">
						<image src="../../static/images/list_1.png" mode=""></image>
						<text>我的值班</text>
					</view>
					<view class="right">
						<image src="../../static/images/list_arrow.png" mode=""></image>
					</view>
				</view>
				<view class="item" @click="notice">
					<view class="left">
						<image class="item_2" src="../../static/images/list_2.png" mode=""></image>
						<text>通知公告</text>
					</view>
					<view class="right">
						<image src="../../static/images/list_arrow.png" mode=""></image>
					</view>
				</view>
				<view class="item" @click="history">
					<view class="left">
						<image class="item_3" src="../../static/images/list_3.png" mode=""></image>
						<text>历史发布</text>
					</view>
					<view class="right">
						<image src="../../static/images/list_arrow.png" mode=""></image>
					</view>
				</view>
				<view class="item" v-if="Isopen && type==1" @click="to_pingjia">
					<view class="left">
						<image class="item_3" src="../../static/images/wenjuan.png" mode=""></image>
						<text>导师量化自评</text>
					</view>
					<view class="right">
						<image src="../../static/images/list_arrow.png" mode=""></image>
					</view>
				</view>
				<view class="item" @click="to_liuyan" v-if="$transformAuth('101100')">
					<view class="left">
						<image class="item_3" src="../../static/images/liuyan.png" mode=""></image>
						<text>留言列表</text>
					</view>
					<view class="right">
						<image src="../../static/images/list_arrow.png" mode=""></image>
					</view>
				</view>
				<view class="item" @click="to_shuangchuang" v-if="$transformAuth('101702')">
					<view class="left">
						<image class="item_3" src="../../static/images/chuang.png" mode=""></image>
						<text>双创列表</text>
					</view>
					<view class="right">
						<image src="../../static/images/list_arrow.png" mode=""></image>
					</view>
				</view>
				<view class="item" @click="change_password">
					<view class="left">
						<image class="item_3" src="../../static/images/change_pwd.png" mode=""></image>
						<text>修改密码</text>
					</view>
					<view class="right">
						<image src="../../static/images/list_arrow.png" mode=""></image>
					</view>
				</view>
			</view>
		</view>
		<view class="exit" @click="exit">
			退出登录
		</view>
		<view class="banben">v1.0.1</view>
		<tab-bar :current="4"></tab-bar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background: 'rgba(255,255,255,0)',
				mine: '',
				statistical: '', //统计信息
				Isopen:false,
				type:''
			}
		},
		onShow() {
			if (this.is_weixin()) {
				this.navTitle()
			}
			console.log(this.$store.state.vuex_user)
			this.$u.get('/base/auth/me').then(res => {
				this.mine = res.data
				if(this.mine.type_model){
					this.type = this.mine.type_model.type
				}
				console.log(this.mine,'mine')
			})
			this.getStatistical()
		},
		onLoad() {
			this.getIsopen()
		},
		methods: {
			//判断是否是微信
			is_weixin() {
				let ua = navigator.userAgent.toLowerCase();
				return ua.indexOf('micromessenger') != -1;
			},
			navTitle() {
				let navTitle = document.getElementsByTagName('uni-page-head');
				navTitle[0].style.display = 'none'
			},
			//统计信息
			getStatistical() {
				this.$u.get('/statistical').then(res => {
					console.log(res, 'ppp')
					this.statistical = res.data
				})
			},
			notice() {
				uni.navigateTo({

					url: './notice'
				})
			},
			//历史发布
			history() {
				uni.navigateTo({
					url: '../activity/history'
				})
			},
			record() {
				uni.navigateTo({
					url: './record'
				})
			},
			//退出登录
			exit() {
				this.$u.get('/base/auth/logout').then(res => {
					this.$u.vuex('vuex_token', '');
					this.$u.vuex('vuex_user', '');
					uni.reLaunch({
						url: '../login/index'
					})
				})
			},
			//编辑资料

			edit() {
				uni.navigateTo({
					url: '../index/realname?type=0'
				})
			},
			to_pingjia(){
				console.log(this.mine.type_model.id,'this.mine.type_model.id')
				uni.navigateTo({
					url:'../wenjuan/wenjuan?id='+this.mine.type_model.id
				})
			},
			getIsopen(){
				this.$u.get('/answer/is-answer-display-status').then(res => {
					console.log(res, '=======')
					this.Isopen = res.data.status
				})
			},
			change_password(){
				uni.navigateTo({
					url:'change_pwd'
				})
			},
			to_liuyan(){
				uni.navigateTo({
					url:'liuyan?tea_id='+this.mine.type_id
				})
			},
			to_shuangchuang(){
				uni.navigateTo({
					url:'shuangchuang'
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #eee;
		padding-bottom: 70px;
	}

	.mine {
		.top {
			height:214px;
			background: url(../../static/images/mine_bg.png);
			.info{
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				padding-top: 38px;
				.img{
					width: 60px;
					height: 60px;
					border-radius: 50%;
					overflow: hidden;
					margin-bottom: 2px;
					background-position: center;
					background-repeat: no-repeat;
					background-size: cover;
					// image{
					// 	width: 60px;
					// 	height: 60px;
					// }
				}
				.info_name{
					font-weight: 500;
					font-size: 18px;
					line-height: 25px;
					color: #FFFFFF;
				}
				.edit {
					height: 17px;
					color: #fff;
					opacity: 0.8;
					font-weight: normal;
					font-size: 12px;
					line-height: 17px;
					margin-left: 3px;
					image{
						display: inline-block;
						vertical-align: middle;
						width: 4px;
						height: 6px;
						margin-left: 5px;
					}
				}
			}
			
		}

		.content {

			padding: 0 15px;
			margin-top: -60px;
			z-index: 2;
			.header {
				padding: 20px 15px 0;
				background-color: #fff;
				width: 100%;
				border-radius: 4px;
				.header_wrap{
					display: flex;
					flex-wrap: wrap;
					align-items: center;
					justify-items: center;					
				}
				image {
					flex: 0 0 68px;
					height: 68px;
					width: 68px;
					margin-right: 16px;
					border-radius: 50%;
				}

				.right {
					width: 45%;
					display: flex;
					align-items: center;					
					.dot{
						width: 5px;
						height: 5px;
						border-radius: 50%;
						background-color: #F1A321;
						margin-right: 8px;
						display: inline-block;
						flex-shrink: 0;
					}
					.text{
						overflow: hidden; //超出部分隐藏
						text-overflow: ellipsis; //超出部分使用省略号
						display: -webkit-box;//布局
						-webkit-line-clamp: 1;
						line-clamp: 1;//设置两行显示
						-webkit-box-orient: vertical;
						 word-break: break-all;
						 font-weight: normal;
						 font-size: 13px;
						 line-height: 14px;						 
						 color: #222222;
						 opacity: 0.8;
						 text{
							 font-weight: normal;
							 font-size: 13px;
							 line-height: 14px;							 
							 color: #666666;
							 opacity: 0.8;
						 }
					}
					
				}
				.first{
					width: 55%;
				}
				.third{
					width: 100%;
					margin-bottom: 20px;
					margin-top: 10px;
				}
				.tip {
					padding: 30px 0;
					display: flex;
					align-items: center;
					justify-content: space-around;
					padding: 15px 0 25px 0;
					border-top: 1px solid #DDDDDD;
					.item {
						text-align: center;
						.nums {
							margin-right: 6px;
							font-weight: 500;
							font-size: 18px;
							line-height: 25px;							
							color: #138E57;

						}
				
						.text {
							font-weight: normal;
							font-size: 14px;
							line-height: 20px;
							color: #353535;
						}
					}
				}
			}
			

			.list {
				background-color: #fff;
				padding: 0 16px;
				margin-top: 15px;
				.item {
					height:55px;
					line-height: 55px;
					display: flex;
					align-items: center;
					border-bottom: 1px solid rgba(238, 238, 238, .53);

					.left {
						font-weight: normal;
						font-size: 15px;
						flex: 1;
						color: #0C0C0C;
						display: flex;
						align-items: center;
						image{
							width: 24px;
							height: 24px;
							margin-right: 10px;
						}
						
					}
					.right{
						flex-shrink: 0;
						image{
							width: 4px;
							height: 6px;
						}
					}
				}
			}
		}

		.exit {
			font-size: 18px;
			font-family: PingFang SC;
			font-weight: bold;
			line-height: 20px;
			color: #393939;
			padding: 18px 0;
			text-align: center;
			margin: 20px 16px 0;
			background-color: #fff;
		}
		.banben{
			text-align: center;
			color: #999999;
			font-size: 12px;
			margin-top: 20px;
			margin-bottom: 10px;
		}
	}
</style>
