<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
			};
		},
		onShow() {
			this.getPersonAuthorize()
		},
		methods: {
			...mapMutations('m_user', ['updateAuthentication']),
			// 获取认证信息
			async getPersonAuthorize() {
				const { data: result } = await uni.$http.get('/education/teacher-certifications/findInfosByUid')
				this.item = result.data.one
				if (this.item == null) {
					this.updateAuthentication('未申请认证')
				} else {
					this.isShow = true
					if (this.item.verifyRefuseReason == null) {
						this.item.verifyRefuseReason = '无'
					}
					this.updateAuthentication(result.data.one.verifyStatus)
				}
				this.content[0].active = false
			},
			trigger(e) {
				this.content[e.index].active = true
				if (this.authentication === '未申请认证') {
					uni.navigateTo({
						url:'/subpkg/teacher/authentication/teacher_authentication_add'
					})
				} else if (this.authentication === '审核中') {
					return uni.$showMsg('正在审核中…')
				} else if (this.authentication === '已通过') {
					return uni.$showMsg('你已认证过')
				} else if (this.authentication === '未通过') {
					return uni.$showMsg('请修改认证')
				}
			},
			requireDetail(item) {
				uni.navigateTo({
					url: '/subpkg/teacher/authentication/teacher_authentication_detail?item=' + encodeURIComponent(JSON.stringify(this.item))
				})
			}
		}
	}
</script>

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