<template>
	<view class="login-container">
		<image class="login-imge" src="https://www.focusnu.com/media/directive/login/loading.gif" mode="widthFix"
			lazy-load="false" />
	</view>
</template>

<script setup>
	import {
		onLoad
	} from '@dcloudio/uni-app';
	import {
		reactive,
		ref
	} from 'vue';
	import {
		getOpenid,
		getMessage
	} from '@/api/loginApi.js'

	const superLogin = () => {
		uni.login({
			provider: 'weixin',
			success(res) {
				getOpenid(res.code).then(res => {
					let openid = res.data.openid
					uni.setStorageSync("openid", openid)
					getMessage(openid).then(res => {
						if (!res.result.tel) {
							uni.redirectTo({
								url: `/pages/login/xuanchuan`
							});
						} else {
							if (uni.getStorageSync('special')) {
								uni.setStorageSync('tel', res.result.tel);
								uni.setStorageSync('token', res.result.token);
								uni.setStorageSync('serverUrl', res.result.serverUrl);
								uni.setStorageSync('platId', res.result.platId);
								uni.redirectTo({
									url: `/pages/login/specialloginafther`
								});
							} else {
								uni.setStorageSync('tel', res.result.tel);
								uni.setStorageSync('token', res.result.token);
								uni.setStorageSync('serverUrl', res.result.serverUrl);
								uni.setStorageSync('platId', res.result.platId);
								uni.setStorageSync('izJg', res.result.izJg);
								uni.setStorageSync('izJs', res.result.izJs);
								uni.setStorageSync('izYg', res.result.izYg);
								switch (res.result.advisoryType) {
									case `1`:
										uni.redirectTo({
											url: `/pages/login/threeselectone`
										});
										break;
									case 2:


										break;
									case `3`:
										uni.redirectTo({
											url: `/pages/index/index`
										});
										break;
									default:
										uni.redirectTo({
											url: `/pages/login/threeselectone`
										});
								}


							}
						}
					})
				})
			},
			fail(err) {
				console.error('获取 code 失败：', err);
			}
		});
	}
	onLoad((options) => {
		if (options.type) {
			uni.setStorageSync('special', true);
		} else {
			uni.setStorageSync('special', false);
		}
		superLogin();
		
	});
</script>

<style scoped lang="scss">
	.login-imge {
		width: 440rpx;
		height: 110rpx;
	}

	.callback-container {
		padding: 24px;
	}

	.avatar {
		width: 80px;
		height: 80px;
		border-radius: 40px;
		margin-top: 12px;
	}

	.login-container {
		display: flex;
		flex-direction: column;
		min-height: 100vh;
		width: 100%;
		background-color: rgb(239, 241, 252);
		position: relative;
		justify-content: center;
		align-items: center;
	}

	.array-father {
		width: 33%;
		position: relative;
	}

	.botton-view {
		position: fixed;
		bottom: 0;
		left: 0;
		height: 200rpx;
		width: 100%;
		// background-color: greenyellow;
		display: flex;
		justify-content: space-between;
		font-weight: 500;

		.bottom-button {
			width: 100%;
			height: 100%;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.bottom-button-target {
			width: 100%;
			height: 100%;
			display: flex;
			justify-content: center;
			align-items: center;
			color: rgb(42, 133, 235);
		}

		.blue-heng {
			height: 6rpx;
			width: 150rpx;
			background-color: rgb(42, 133, 235);
			position: absolute;
			bottom: 55rpx;
			left: 50%;
			/* 左边缘到父容器左边的距离占父宽度 50% */
			transform: translateX(-50%);
		}
	}

	.imge {
		width: 240rpx;
		height: 240rpx;
		margin-bottom: 50rpx;
	}

	.font {
		font-weight: 600;
		font-size: 35rpx;
		// margin-bottom: 100rpx;
	}
</style>