<template>
	<view>
		<view v-show="isShow">
			<view class="requires" @click="requireDetail(item)">
				<uni-row >
					<uni-col offset="1">
						<text class="fontStyle">用户ID：</text>{{item.uid}}
					</uni-col>
				</uni-row>
				<uni-row >
					<uni-col offset="1">
						<text class="fontStyle">显示名：</text> {{item.name}} <text>教员</text>
					</uni-col>
				</uni-row>
				<uni-row >
					<uni-col offset="1">
						<text class="fontStyle">当前高校：</text>{{item.school}}
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col offset="1" :span="11">
						<text class="fontStyle">当前学历：</text>{{item.education}}
					</uni-col>
					<uni-col :span="12">
						<text class="fontStyle">手机号：</text>{{item.phone}}
					</uni-col>
				</uni-row>
				<uni-row >
					<uni-col offset="1" :span="18">
						<text class="fontStyle">微信号：</text>{{item.weixinId}}
					</uni-col>
					<uni-col :span="5">
						<text class="authorize">{{authentication}}</text>
					</uni-col>
				</uni-row>
			</view>
						
		</view>
		
		<uni-fab  :pattern="pattern" horizontal="left" vertical="bottom" :content="content"
					direction="horizontal"  @trigger="trigger" />
	</view>
</template>

<script>
	import { mapState, mapMutations } from 'vuex';
	export default {
		computed: {
			...mapState('m_user', ['authentication'])
		},
		data() {
			return {
				pattern: {
					color: '#7A7E83',
					backgroundColor: '#E2F0D9',
					selectedColor: '#1296db',
					buttonColor: '#E2F0D9',
					iconColor: '#000000'
				},
				content: [{
						iconPath: '/static/authorized.png',
						selectedIconPath: '/static/authorizedd.png',
						text: '老师认证',
						active: false
					}
				],
				item: {},
				isShow: false
			};
		},
		created() {
			this.getPersonAuthorize()
		},
		onShow() {
			this.content[0].active = false
		},
		methods: {
			...mapMutations('m_user', ['updateAuthentication', 'updateAuthorizePhoto']),
			// 获取认证信息
			async getPersonAuthorize() {
				const { data: result } = await uni.$http.get('/education/teacher-certifications/findInfosByUid')
				console.log(result)
				this.item = result.data.one
				if (this.item == null) {
					this.updateAuthentication('未申请认证')
				} else {
					this.isShow = true
					this.updateAuthentication(result.data.one.verifyStatus)
				}
			},
			trigger(e) {
				this.content[e.index].active = true
				if (this.authentication === '未申请认证') {
					uni.navigateTo({
						url:'/subpkg/add_teacher_authorize/add_teacher_authorize'
					})
				} else if (this.authentication === '审核中') {
					uni.$showMsg('正在审核中…')
					this.content[e.index].active = false
					return
				} else if (this.authentication === '已通过') {
					return uni.$showMsg('你已认证过')
				} else if (this.authentication === '未通过') {
					return uni.$showMsg('认证失败')
				}
				
			},
			requireDetail(item) {
				const authorizePhoto = {
					diplomaPhoto: this.item.diplomaPhoto,
					idCardBack: this.item.idCardBack,
					idCardFront: this.item.idCardFront,
					profilePhoto: this.item.profilePhoto
				}
				this.updateAuthorizePhoto(authorizePhoto)
				uni.navigateTo({
					url: '/subpkg/teacher_authorize_detail/teacher_authorize_detail?item=' + encodeURIComponent(JSON.stringify(this.item))
				})
			}
		}
	}
</script>

<style lang="scss">
.requires {
	background-color: #FFF2CC;
	margin: 0 20rpx;
	border-radius: 10%;
	
	.fontStyle {
		font-weight: 600;
	}
	
	.authorize {
		color: red;
	}
}
</style>
