<template>
	<view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
		<cus-header title='创衡正念企业教练' :showback="false"></cus-header>
		<div class="content">
			<image src="@/static/logo.png"></image>
			<div class="title">Hi，我是企业教练～</div>
			<div class="tip">很高兴遇见你！作为你的AI教练，我随时可以回答您的问题</div>
			<div class="item adf">
				<image src="@/static/qa.png"></image>
				<div class="qa">
					<p>智能问答</p>
					<p>正念修己 教练达人，知识推理整合，要点清晰呈现，助力企业打造高价值团队</p>
				</div>
			</div>
			<div class="item adf">
				<image src="@/static/qs.png"></image>
				<div class="qa">
					<p>PERILL模型问题库</p>
					<p>作为团队成员，您可以对所在团队相关描述的体验进行评分，帮助团队有效评估团队的现状</p>
				</div>
			</div>
			<button class="zt_btn" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">手机号一键登录</button>
			<div class="qx_btn" @click="cancelLogin">取消</div>
		</div>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				
			}
		},
		methods:{
			decryptPhoneNumber(e){
				if(uni.getStorageSync('token')){
					uni.reLaunch({
						url:'/pages/dialog'
					})
					return
				}
				if(e.detail.code) this.wxLogin(e.detail.code);
			},
			wxLogin(code){
				uni.showLoading({ title:'登录中' });
				let that = this;
				wx.login({
					success(res){
						that.$api.get('/wx/login',{
							code:res.code,
							phoneCode:code
						},false).then(res=>{
							if(res.data.code===0){
								uni.setStorageSync('token',res.data.data.token);
								uni.setStorageSync('userInfo',JSON.stringify({
									id:res.data.data.id,
									gender:res.data.data.gender,
									realName:res.data.data.realName,
									mobile:res.data.data.mobile,
									headUrl:res.data.data.headUrl,
									teamId:res.data.data.teamId,
									enterpriseId:res.data.data.enterpriseId
								}));
								
								uni.hideLoading();
								that.$showToast('登录成功');
								setTimeout(()=>{
									uni.reLaunch({ url:'/pages/dialog' })
								},1500)
							}else that.$showToast(res.data.msg)
						})
					}
				})
			},
			cancelLogin(){
				uni.exitMiniProgram();
			}
		}
	}
</script>

<style scoped lang="scss">
	.page{
		background: #FFFFFF;
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		.content{
			padding: 0 45rpx;
			flex: 1;
			overflow-y: auto;
			
			&>image{
				width: 88rpx;
				height: 88rpx;
				margin-top: 100rpx;
			}
			.title{
				font-family: PingFang-SC, PingFang-SC;
				font-weight: bold;
				font-size: 48rpx;
				color: #252525;
				line-height: 67rpx;
				margin-top: 36rpx;
			}
			.tip{
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 30rpx;
				color: #646464;
				line-height: 47rpx;
				margin-top: 20rpx;
			}
			.item{
				margin-top: 64rpx;
				&>image{
					width: 64rpx;
					height: 64rpx;
				}
				.qa{
					width: calc(100% - 64rpx);
					padding-left: 24rpx;
					box-sizing: border-box;
					p{
						font-family: PingFang-SC, PingFang-SC;
						font-weight: bold;
						font-size: 32rpx;
						color: #252525;
						line-height: 45rpx;
						&:last-child{
							font-weight: 400;
							font-size: 28rpx;
							color: #646464;
							line-height: 47rpx;
						}
					}
				}
			}
			.zt_btn{
				margin-top: 216rpx;
			}
			.qx_btn{
				margin-top: 36rpx;
			}
		}
	}
</style>