<template>
	<view class="content">
		<view class="bg-box">
			<image :src="imgPath+'/app/commonCourse/test-bg1.png'"></image>
			<view class="title-box">
				<view class="title">
					{{item.name}}
				</view>
			</view>
		</view>
		<view class="cont">
			<view class="msg-box">
				<view class="msg">{{item.msg}}</view>
			</view>
			<view class="line"></view>
			<view class="desc-box">
				<view class="desc" v-html="item.descs"> </view>
			</view>
			<view class="btn-box">
				<view class="btn" @click="navTo('/pages_index/test?tempId='+item.tempId)">立即开始</view>
			</view>
			<view class="logo">
				<image :src="imgPath+'/app/image/logo.png'"></image>
			</view>
		</view>
		
	</view> 
</template>

<script>
	import {getTestDetails} from '@/api/test.js'
	export default {
		data() {
			return {
				tempId:null,
				item:{},
			};
		},
		onLoad(option) {
			this.tempId=option.tempId;
			 
		},
		onShow() {
			this.getTestDetails();
		},
		computed: {
			imgPath() {
			  return this.$store.state.imgpath
			},
		},
		//发送给朋友
		onShareAppMessage(res) {
			if(this.$isLogin()){
				return {
					title: "健康自测",
					path: '/pages_index/testDetails?tempId='+this.tempId,
					imageUrl: this.$store.state.imgpath+'/app/image/logoshare.png' //分享图标，路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
				}
			}
			
		},
		//分享到朋友圈
		onShareTimeline(res) {
			if(this.utils.isLogin()){
				return {
					title: "健康自测",
					imageUrl: this.$store.state.imgpath+'/app/image/logoshare.png' //分享图标，路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
				}
			}
			
		},
		methods:{
			navTo(url) {
				this.$isLogin().then(
					res => {
						console.log(res)
						if(res){
							uni.navigateTo({
								url: url
							})
						}
						else{
							uni.navigateTo({
								url:'/pages/auth/login'
							})
						}
					}
				);
				
			},
			getTestDetails(){
				let data = {tempId:this.tempId};
				getTestDetails(data).then(
					res => {
						if(res.code==200){
							this.item=res.data;
							uni.setNavigationBarTitle({
							      title: this.item.name+"自测"
							});
							 
						}else{
							uni.showToast({
								icon:'none',
								title: "请求失败",
							});
						}
					},
					rej => {}
				);
			},
		}
	}
</script>

<style lang="scss">
	page{
		height: 100%;
	}
	.content{
		position: relative;
		height: 100%;
		display: flex;
		flex-direction: column;
		.bg-box{
			position: absolute;
			width: 100%;
			height: 600rpx;
			.title-box{
				top: 50rpx;
				left:50rpx;
				position: absolute;
				
				.title{
					border-radius: 5rpx;
					border: 1rpx solid #fff;
					padding: 20rpx 30rpx;
					font-size: 36rpx;
					font-family: Source Han Sans CN;
					font-weight: bold;
					color: #fff;
				}
				
				
				
			}
			image{
				position: absolute;
				width: 100%;
				height: 100%;
			}
			
		}
		.cont{
			position: relative;
			margin-top: 550rpx;
			z-index: 9999;
			padding: 30rpx;
			height: 100%;
			display: flex;
			flex-direction: column;
			padding: 30rpx;
			background-color: #fff;
			border-radius: 30rpx 30rpx 0rpx 0rpx;
			.msg-box{
				.msg{
					font-size: 36rpx;
					font-family: Source Han Sans CN;
					font-weight: bold;
					color: #111;
				}
			}
			.line{
				margin: 15rpx 0rpx;
				background-color: #F6F6F6;
				height:5rpx;
				width: 100%;
			}
			.desc-box{
				margin-top: 20rpx;
				background: #FFFFFF;
				.desc{
					color: #814E1B;
				}
			}
			.logo{
				display: flex;
				align-items: center;
				justify-content: center;
				margin: 60rpx 0rpx;
				width: 100%;
				image{
					width: 100rpx;
					height:100rpx;
				}
			}
			.btn-box{
				margin-top: 60rpx;
			 	height: 140upx;
			 	width: 100%;
			 	box-sizing: border-box;
			 	display: flex;
			 	align-items: center;
			 	justify-content: center;
				
			 	.btn{
			 		width: 100%;
			 		height: 88upx;
			 		line-height: 88upx;
			 		text-align: center;
			 		font-size: 34upx;
			 		font-family: PingFang SC;
			 		font-weight: bold;
			 		color: #FFFFFF;
			 		background: #C39A58;
			 		border-radius: 50upx;
			 	}
			 }
		}
		
		
	}
	 
</style>
