<template>
	<view class="pageBgImg">
		<topNavbar title="实名认证"></topNavbar>
	</view>
</template>

<script>
	import { GetDetectInfoEnhanced, getbiztoken } from '@/config/api.js'
	import { website } from '@/config/site.config.js'
	export default {
		data() {
			return {
				userId: ''
			}
		},
		onLoad(options) {
			alert(options.userId)
			alert(options.test)
			  const routeInfo = this.$route;
			    console.log('当前页面路由信息：', routeInfo);
				 const fullPath = '/' + routeInfo.path + '?' + Object.keys(routeInfo.query).map(key => key + '=' + routeInfo.query[key]).join('&');
				    console.log('当前页面全路径：', fullPath);
					alert(fullPath)
					alert(routeInfo.query.userId)
					alert(routeInfo.query.test)
			if(options.userId) {
				this.userId = options.userId
				this.GetDetectInfoEnhancedFn()
			}
		},
		onPullDownRefresh() {
			this.GetDetectInfoEnhancedFn()
		},
		methods: {
			async GetDetectInfoEnhancedFn() {
				const data = await getbiztoken({ userId: this.userId})
				// alert(this.$store.state.school.BizToken)
				uni.showLoading({
					title: '正在检测中...'
				})
				let redirectUrl = website + '/pages/indexEntry/enroll/registInfo/registInfo'
				if(this.$store.state.user.NonPlatformStudent) {
					redirectUrl =  website + '/pages/indexEntry/NonPlatformStudent/NonPlatformStudent'
				}
				let obj = {
					ruleId: 1,
					redirectUrl,
					bizToken: data.data,
					userId: this.userId
				}
				const res = await GetDetectInfoEnhanced(obj)
				// alert(res.msg)
				// if(!res.msg) return false
				let obj2 = JSON.parse(res.data)
				await this.$store.dispatch('getUserInfo')
				uni.hideLoading()
				 if (process.env.VUE_APP_PLATFORM === 'h5') {
				        window.close(); // 关闭当前页面
				      } else {
				        // 处理其他平台下的关闭逻辑
				        console.log('当前不是 H5 环境，无法关闭页面');
				      }
				if(obj2.Text.ErrMsg=='成功') {
					this.$goPage('/pages/indexEntry/enroll/registInfo/registInfo')
				}
			
				// console.log(obj2)
				// alert('请求结果来了')
				// alert(obj2.Text.ErrMsg)
				// alert(obj2.Text.name)
				// uni.setStorageSync(obj2)
			},
		}
	}
</script>

<style>
</style>