<template>
	<view class="index" :style="'padding-top:'+padtop+'px'">
		<!-- 头部 -->
		<navbar :back="false" title="扫码登录" :bgcolor="backgroundColor" color="#fff" fixed zIndex="1010" :center="true"
			:custom='true' @getTop="getTop" back="true" />
		<view class="header">
			<img :src="subimg" alt="" class="img">
			<span class="sapn">扫码成功</span>
			<view class="sub_txt">请确认授权登录</view>
		</view>
		<view class="naver" @click="smit">
			授权登录
		</view>
	</view>
</template>

<script>
	import url from "@/util/url";
	let {
		host
	} = url
	export default {
		data() {
			return {
				type: 0, //判断是否是登录页面跳转的
				telephone: '',
				subimg: require("@/static/images/submit.png"),
				padtop: this.$http._GET.customBarH || 0,
				backgroundColor: 'linear-gradient(90deg, #A00517, #E93030)',
			};
		},
		onLoad(e) {
			console.log(e)
			this.type = e.code
			// this.telephone = 15855353281
			this.telephone = uni.getStorageSync('phone')
		},
		onUnload() {
			uni.switchTab({
				url: '/pages/tab/about_we',
			})
		},

		methods: {
			getTop(e) {
				this.padtop = e
			},
			smit() {
				var _this = this
				let object = {
					"uuid": _this.type,
					"phone": _this.telephone,
					// cardType:'ID_CARD',
				};
				uni.request({
					url: host + '/scanCode/phoneScanLogin', 
					method: 'POST',
					data: JSON.stringify(object),
					header: {
						'Content-Type': 'application/json',
					},
					success: function(res) {
						console.log(res)
						if (res.data.code == "200") {
							uni.showToast({
								title: '登录成功',
								duration: 1000,
								icon: 'none'
							});
							setTimeout(() => {
								uni.navigateBack({
									delta: 2
								})
							}, 1000)
						} else {
							uni.showToast({
								title: res.msg,
								duration: 1000,
								icon: 'none'
							});
						}
					},
					fail: function(error) {
						uni.showToast({
							title: error.msg,
							duration: 1000,
							icon: 'none'
						});
					}
				})
				// console.log(object)
				// this.$http.post("scanCode/phoneScanLogin",JSON.stringify(object),true).then(res => {
				// 	console.log(res)
				// 	if(res.code=="200"){
				// 		uni.showToast({
				// 			title: '登录成功',
				// 			duration: 1000,
				// 			icon: 'none'
				// 		});
				// 		setTimeout(() => {
				// 			uni.navigateBack({
				// 				delta:2
				// 			})
				// 		},1000)
				// 	}else {
				// 		uni.showToast({
				// 			title: res.msg,
				// 			duration: 1000,
				// 			icon: 'none'
				// 		});
				// 	}
				// })
			}
		}
	}
</script>

<style lang="scss">
	.index {
		height: 100vh;

		// background-color: #dbebf8;
		.header {
			display: flex;
			flex-direction: column;
			align-items: center;
			padding-top: 132upx;
			box-sizing: border-box;

			.img {
				width: 238rpx;
				height: 256rpx;
				display: block;
				margin: 0 auto 56rpx;
				// width: 400upx;
			}

			span {
				font-size: 35upx;
				color: #666;
				width: 414upx;
				text-align: center;
				line-height: 50upx;

			}

			.sapn {
				font-size: 42upx;
				color: #333;
				// width: 414upx;
				font-weight: 700;
				text-align: center;
				line-height: 50upx;
				margin-bottom: 15upx;

			}

			.sapnteo {
				font-size: 28upx;
				color: #666;
				// width: 414upx;
				// font-weight: 700;
				text-align: center;
				line-height: 50upx;
			}
		}

	}

	.sub_txt {
		font-size: 26rpx;
		color: #666666;
		text-align: center;
		width: 260rpx;
		margin: 0 auto 90rpx;
	}

	.naver {
		width: 416rpx;
		height: 84rpx;
		width: 208px;
		height: 42px;
		background: linear-gradient(90deg, #A00517, #E93030);
		border-radius: 21px;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 30rpx;
		color: #ffffff;
		margin: 0 auto 0;
	}
</style>
