<template>
	<view class="amms-page">
		<view class="bj">
			<view class="searchs">
				<view class="s_le">
					<view class="title">
						<view class="ti1">AMMS</view>
						<view class="ti2">AMMS</view>
					</view>
					<view class="subtitle">海航技术移动生产门户平台</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import appIcon from '../static/img/personalCenter/appIcon.png'
	export default {
		data() {
			return {
				logoImg: appIcon,
			};
		},
		mounted() {
			// 若存在token,则第一次进入app时进行指纹解锁
			if (!!uni.getStorageSync('access_token')) {
				// #ifdef APP-PLUS
				this.checkIsSoterEnrolledInDeviceFingerPrint();
				// #endif
				// #ifdef H5
				uni.redirectTo({
					url: '/pages/home/homeIndex'
				});
				// #endif
			} else {
				uni.redirectTo({
					url: '/pages/login/index'
				})
			}
		},
		methods: {
			// 检查是否支持指纹录入
			checkIsSoterEnrolledInDeviceFingerPrint() {
				let vm = this;
				uni.checkIsSoterEnrolledInDevice({
					checkAuthMode: 'fingerPrint',
					success(res) {
						console.log(res)
						if (res.isEnrolled) {
							vm.startSoterAuthenticationFingerPrint()
						} else {
							uni.redirectTo({
								url: '/pages/home/homeIndex'
							});
						}
						
					},
					fail(err) {
						console.log(err)
						uni.redirectTo({
							url: '/pages/home/homeIndex'
						});
					},
					complete(res) {
						console.log(res);
					}
				})
			},
			// 开始指纹认证
			startSoterAuthenticationFingerPrint() {
				let vm = this;
				uni.startSoterAuthentication({
					requestAuthModes: ['fingerPrint'],
					challenge: '123456',
					authContent: '请用指纹解锁',
					success(res) {
						uni.redirectTo({
							url: '/pages/home/homeIndex'
						});
					},
					fail(err) {
						uni.showToast({
							title: '指纹认证失败，请重新登录',
							icon: 'none'
						});
						setTimeout(() => {
							uni.redirectTo({
								url: '/pages/login/index'
							})
						}, 500);
					},
					complete(res) {
						console.log(res);
					}
				});
			}
		}
	}
</script>

<style lang="less" scoped>
	.bj {
		background: linear-gradient(-90deg, #168AFF 0%, #0E57FF 100%);
		border-radius: 0rpx 0rpx 32rpx 32rpx;
		padding-bottom: 125rpx;
		padding-right: 32rpx;
		padding-left: 32rpx;
		// padding-top: 80rpx;
		position: relative;
		box-sizing: border-box;
	
		.container {
			padding: 0rpx 32rpx;
			box-sizing: border-box;
			position: relative;
		}
	
		.searchs {
			display: flex;
			align-items: center;
			justify-content: space-between;
	
			.s_le {
				margin-top: 32rpx;
				width: 100%;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
	
				.title {
					position: relative;
	
					.ti1 {
						font-size: 108rpx;
						font-family: Alibaba-PuHuiTi-B, Alibaba-PuHuiTi;
						font-weight: bold;
						color: #FFFFFF;
						position: absolute;
						top: 14rpx;
						left: 30rpx;
					}
	
					.ti2 {
						font-size: 132rpx;
						font-family: Alibaba-PuHuiTi-B, Alibaba-PuHuiTi;
						-webkit-text-fill-color: transparent;
						-webkit-text-stroke: 1rpx rgba(255, 255, 255, 0.3);
						font-weight: normal;
						color: rgba(255, 255, 255, 0.5);
					}
				}
	
				.subtitle {
					font-size: 30rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
				}
	
				.search {
					width: 400rpx;
					background: #FFFFFF;
					border-radius: 40px;
					display: flex;
					align-items: center;
					padding: 20rpx 32rpx;
					margin-top: 32rpx;
	
					.content {
						font-size: 28rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #CCCCCC;
						margin-left: 16rpx;
					}
	
					.pic {
						width: 40rpx;
						height: 40rpx;
					}
				}
			}
	
			.s_ri {
				.pic {
					width: 267rpx;
					height: 286rpx;
				}
			}
		}
	}
</style>
