<template>
	<view class="youyue">
		<view class="nav">
			<image src="http://t9.9026.com/imgs/logo@2x.png"></image>
		</view>
		<view class="title">
			IHG优悦会忠诚计划优悦随行悦享世界
		</view>
		<view class="detail">
			<view><text>HG优悦会是洲际酒店集团的会员忠诚计划。在全球拥有超过1亿会员。</text></view>
			<view><text> 即刻加入HG优悦会，一键开启会员专享价及会员专属礼遇。轻松赚取积分，使用灵活的积分兑换及竞拍，畅享独特且多元的犒赏体验。</text></view>
		</view>

		<view class="boxitem">
			<text class="boxitemtitle">优悦会会员权益</text>
		</view>
		<view class="boxitem" style="border-top: none;">
			<text class="boxitemtitle">入会第一天起即可臻享礼遇</text>
		</view>
		<view class="boxitem" style="border-top: none;">
			<text class="boxitemtitle">赚取酒店积分兑换奖励住宿以及更多</text>
			<text class="boxitemcontent">积分不仅可以兑换体验，目录商品等，还可以兑换全球6000等多个目的地奖励住宿</text>
			<image src="/static/icon/loginicon1.png"></image>
		</view>
		<view class="boxitem" style="border-top: none;">
			<text class="boxitemtitle">会员专享价</text>
			<text class="boxitemcontent" style="margin-bottom: 30rpx;">直接预订可享受我们会员专属的优惠房价</text>
			<image src="/static/icon/loginicon2.png"></image>
		</view>
		<view class="boxitem" style="border-top: none;">
			<text class="boxitemtitle">会员促销</text>
			<text class="boxitemcontent" style="margin-bottom: 30rpx;">尽情享受会员促销，赚取更多奖励积分</text>
			<image src="/static/icon/loginicon3.png"></image>
		</view>

		<view class="item"><text class="itemtitle">畅享网络</text></view>

		<view class="itemLast">我们所有酒店均提供免费WIFI，让您始终顺畅连通</view>

		<view class="btn" @click="goOther">
			<text>立即加入会员</text>
		</view>

		<view class="logintitle">
			<view class="line"></view>
			<view class="logintype"><text>其他登录</text></view>
			<view class="line"></view>
		</view>
		<view class="typebtn" @click="getmsg">
			<view class="item">
				<image src="/static/icon/wechart.png" mode="scaleToFill"></image>
				<text>微信登录</text>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		methods: {
			// 跳转其他小程序
			goOther() {
				wx.navigateToMiniProgram({
					appId: 'wx255b58f0992b3c53', //appid
					path: 'newUIMain/enrollment/enrollment', //path
					extraData: { //参数
						foo: 'bar'
					},
					// envVersion: 'develop', //开发版develop 开发版 trial   体验版 release 正式版 
					success(res) {
						console.log('成功')
						// 打开成功
					},
					fail(e) {
						console.log(e, '失败')
					}
				})
			},
			getCode() {
				return new Promise((resolve, reject) => {
					uni.login({
						provider: uni.$u.platform,
						success: loginRes => {
							this.code = loginRes.code
							resolve(this.code)
						}
					})
				})
			},
			//获取微信登录的code码
			getmsg() {
				uni.getUserInfo({
					success: res => {
						this.getCode().then(code => {
							const params = {
								encryptData: res.encryptedData,
								iv: res.iv,
								code: code
							}
							console.log(params);
							this.$api.my.myLogin(params).then(res => {
								let {
									token,
									user_info
								} = res.data
								this.$store.dispatch('user/info', user_info)
								this.$store.dispatch('user/token', token)
								if (token != null) {
									uni.switchTab({
										url: '/pages/my/my'
									})
								}
							})

							// this.$loading('数据刷新中...')
							// this.$api.user.update(params).then(res => {
							//   this.btnLock = false
							//   this.code = null
							//   this.$hideLoading()
							//   this.$store.dispatch('user/info', res.data)
						}).catch(() => {
							// this.code = null
							// this.$hideLoading()
						})
					}
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
	$pageColor:#F9F9F9;
	$bgColor:#FFFFFF;

	.youyue {
		height: 100%;
		background: $bgColor;
		padding: 192rpx 30rpx 140rpx 30rpx;
		position: relative;
	}

	.nav {
		position: absolute;
		top: 0rpx;
		left: 0rpx;

		image {
			width: 750rpx;
			height: 142rpx;
		}
	}

	.title {
		width: 400rpx;
		height: 120rpx;
		font-size: 44rpx;
		font-family: PingFang-SC-Bold, PingFang-SC;
		font-weight: bold;
		color: #333333;
		line-height: 60rpx;
		margin-bottom: 64rpx;
	}

	.detail {
		width: 690rpx;
		height: 220rpx;
		margin-bottom: 64rpx;

		text {
			font-size: 32rpx;
			font-family: PingFang-SC-Medium, PingFang-SC;
			font-weight: 500;
			color: #333333;
		}
	}

	.item {
		margin: 40rpx 0;

		.itemtitle {
			font-size: 32rpx;
			font-family: PingFang-SC-Bold, PingFang-SC;
			font-weight: bold;
			color: #333333;
		}
	}

	.itemLast {
		width: 690rpx;
		font-size: 24rpx;
		font-family: PingFang-SC-Medium, PingFang-SC;
		font-weight: 500;
		color: #333333;
		margin-bottom: 64rpx;
	}

	.btn {
		width: 688rpx;
		height: 92rpx;
		background: linear-gradient(270deg, #FF6200 0%, #FF9342 100%);
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 12rpx;

		text {
			font-size: 30rpx;
			font-family: PingFang-SC-Bold, PingFang-SC;
			font-weight: bold;
			color: #FFFFFF;
		}
	}

	.logintitle {
		height: 40rpx;
		width: 690rpx;
		margin-top: 64rpx;
		margin-bottom: 64rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.line {
			width: 240rpx;
			height: 2rpx;
			background: #EDEDED;
			border-radius: 1rpx;
		}

		.logintype {
			text {
				font-size: 28rpx;
				font-family: PingFang-SC-Medium, PingFang-SC;
				font-weight: 500;
				color: #333333;
			}
		}

	}

	.typebtn {
		display: flex;
		align-items: center;
		justify-content: space-around;

		.item {
			width: 140rpx;
			height: 156rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;

			image {
				width: 104rpx;
				height: 104rpx;
				margin-bottom: 12rpx;
			}

			text {
				display: block;
				font-size: 28rpx;
				font-family: PingFang-SC-Medium, PingFang-SC;
				font-weight: 500;
				color: #666666;
			}
		}
	}

	.boxitem {
		border-top: #F0F0F0 2rpx solid;
		border-bottom: #F0F0F0 2rpx solid;
		padding: 40rpx 0;
		position: relative;

		image {
			top: 35%;
			right: 0rpx;
			width: 96rpx;
			height: 96rpx;
			position: absolute;
		}

		.boxitemtitle {
			font-size: 32rpx;
			font-family: PingFang-SC-Bold, PingFang-SC;
			font-weight: bold;
			color: #333333;
		}

		.boxitemcontent {
			margin-top: 24rpx;
			width: 512rpx;
			display: block;
			font-size: 28rpx;
			font-family: PingFang-SC-Medium, PingFang-SC;
			font-weight: 500;
			color: #333333;
		}
	}
</style>
