<template>
	<view class="content">
		<view class="container">
			<view class="my-header">
				<view class="my-icons"> </view>
				<view class="my-text"></view>
				<view class="my-icons"></view>
			</view>
			<view class="top-box"></view>
			<!-- 顶部区域 -->

			<button class="dl-box" open-type='getPhoneNumber' @getphonenumber="getPhone">手机号快捷登录</button>
			<button class="kk-box" @click="goback">我再看看</button>
			<view class="dbottom">
				<view class="quanzi" v-if="qindex == false " @click="qindex =! qindex"></view>
				<view class="lanquanzi" v-if="qindex == true" @click="qindex =! qindex"><u-icon name="checkbox-mark"
						color="#ffffff" size="14"></u-icon></view>
				<text>请仔细阅读</text>
				<text class="lan">《用户协议》</text>
				<text>和</text>
				<text class="lan">《隐私政策》</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '',
				qindex: false,
				baseUrl: this.$baseUrl,
			}
		},
		onLoad() {
			console.log(this.$baseUrl);

		},
		components: {},
		methods: {
			wxlogin() {},
			getPhone(e) {
				let that = this
				// if (this.privacyPolicyChecked == false) {
				// 	uni.showToast({
				// 		icon: "none",
				// 		title: "请阅读并勾选用户协议",
				// 		duration: 2000
				// 	})
				// 	return;
				// }
				uni.login({
					provider: 'weixin',
					success(res) {
						if (res.code) {
							uni.setStorageSync('c1', res.code);
							console.log('weixin', res.code);
						} else {
							console.log('登录失败!' + res.errMsg)
						}

						console.log(e);
						uni.checkSession({
							success: () => {
								uni.request({
									url: that.baseUrl + "clientApi/sign/mpWxLogin",
									method: "POST",
									data: {
										code: uni.getStorageSync('c1'),
										encryptedIv: e.detail.iv,
										encryptedData: e.detail.encryptedData,
										userInfo: {
											storeId: 0,
											staffId: "",
											phone: '18457621459'
										},

										type: 'phone',
										inviteId: uni.getStorageSync('inviteId') ? uni
											.getStorageSync(
												'inviteId') : null
									},
									success: (rex) => {
										console.log('请求成功', rex)
										if (rex.data.code == 200) {

											uni.setStorageSync('App-Token', rex.data.data
												.token);
											uni.setStorageSync('chainStoreId', rex.data
												.data
												.chainStoreId);

											uni.navigateTo({
												url: '/pages/index/index'
											})
										}
										console.log("swq", uni.getStorageSync(
											'App-Token'));
									},
									fail: (res) => {
										console.log("fail", res);
										uni.showToast({
											icon: "error",
											title: "登录失败,请重新点击并授权!",
											duration: 2000
										})
									}
								})
							},
							fail: () => {
								uni.showToast({
									icon: 'error',
									duration: 2000,
									title: "登录状态过期,重新登录"
								});
							}
						})
					}
				})
			},
			goback() {
				uni.navigateBack()
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		background: #ffffff;

	}

	.container {
		width: 100%;
		height: 100vh;
		box-sizing: border-box;
		padding-top: 88px;
	}

	.my-header {
		width: 100%;
		height: 88px;
		background: #3c91f4;
		display: flex;
		align-items: center;
		justify-content: space-between;
		color: #000;
		box-sizing: border-box;
		padding: 0px 15px;
		padding-top: 40px;
		z-index: 99999;

		.my-icons {
			width: 20px;

		}

		position: fixed;
		top: 0px;
	}

	.dl {
		height: 40px;
		background: #2F72F7;
		border-radius: 50px;


	}

	.top-box {
		width: 100%;
		height: 60vh;
		background: url('http://47.95.206.185:83/lgoin.png')center no-repeat;
		background-size: 100% 100%;
		background-attachment: fixed;

	}

	.dl-box {
		width: 80%;
		height: 45px;
		background: #2F72F7;
		color: white;
		border-radius: 50px;
	}

	.kk-box {
		width: 80%;
		height: 45px;
		background: #F0F3FA;
		color: #333333;
		border-radius: 50px;
		border: 1px solid #F0F3FA;
		margin: 10px auto;
	}

	.dbottom {
		width: 100%;
		text-align: center;
		font-size: 12px;
		color: #333333;
		margin-top: 40px;
		position: fixed;
		bottom: 45px;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.quanzi {
		width: 14px;
		height: 14px;
		border: 1px solid #666666;
		border-radius: 50%;
		margin-right: 10px;
	}

	.lanquanzi {
		width: 14px;
		height: 14px;
		border: 1px solid #0078FF;
		border-radius: 50%;
		margin-right: 10px;
		background: #0078FF;
		color: white;
	}

	.lan {
		color: #0078FF;
	}

	.jiuzhong {
		width: 90%;
		margin: 10px auto;
		display: flex;
		align-items: center;
	}

	.dist {
		display: flex;
		align-items: center;
		margin: 0px 10px;
	}

	.d-zi {
		font-size: 14px;
	}

	.d-qian {
		width: 14px;
		height: 14px;
		margin-right: 5px;
		overflow: hidden;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		border: 1px solid #666666;
		color: white;
	}

	.d-qian-lan {
		width: 14px;
		height: 14px;
		margin-right: 5px;
		overflow: hidden;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		background: #0078FF;
		border: 1px solid #0078FF;
		color: white;
	}
</style>