<template>
	<!-- 考场详情 -->
	<view class="pageBg">
		<view class="swiper-box"  :style="{ backgroundImage: `url(${detailInfo.images})`, backgroundSize: '100% 100%' }">
			<view class="navPoz">
				<topNavbar title=" "></topNavbar>
			</view>
			<!-- <u-swiper :list="list1" :height="261"></u-swiper> -->
			<view class="radian">
				<image :src="radianImg" mode=""></image>
			</view>
		</view>
		<view <view class="pad traTop">
			<view class="card info">
				<view class="cover">
					<image :src="detailInfo.images" mode="widthFix"></image>
				</view>
				<view class="textCon">
					<view class="name">{{detailInfo.name}}</view>
					<view class="modeCar">准考车型：{{detailInfo.carType}}</view>
				</view>
				<callPhone :servicePhone="[{name: detailInfo.phone}]">
					<view class="pozPhone">
						<image src="@/static/images/index/telephone.png" mode=""></image>
					</view>
				</callPhone>
			</view>
			<!-- 考场位置 -->
			<view class="location">
				<view class="h1">考场位置</view>
				<view class="pozLi">
					<pozCard :info="{address: detailInfo.address, lat:detailInfo.lat,lng: detailInfo.lng, distance: distance}"></pozCard>
				</view>
			</view>
			<!-- 信息资讯 -->
			<view class="news">
				<view class="flex-b">
					<view class="h1">信息资讯</view>
					<moreRight text='查看全部' @click.native="$goPage('/pages/indexEntry/examines/allNews/allNews?id='+ id)"></moreRight>
				</view>
				<view class="card" v-for="(item,index) in infoList" :key="index" style="margin-bottom: 20rpx;">
					<newItem :item="item"></newItem>
				</view>
			</view>
			<view class="btn" @click="goExamine">我要模拟</view>
		</view>
	</view>
</template>

<script>
	import newItem from '../comp/newItem'
	import { imgUrl } from '@/config/site.config.js'
	import { getExamSiteDatil, getExamSiteInfo } from '@/config/api.js'
	export default {
		components: { newItem },
		data() {
			return {
				radianImg: imgUrl+'radian.png',
				list1: [
					'https://cdn.uviewui.com/uview/swiper/swiper1.png',
					'https://cdn.uviewui.com/uview/swiper/swiper2.png',
					'https://cdn.uviewui.com/uview/swiper/swiper3.png',
				],
				detailInfo: {},
				infoList: [],
				id: '',
				params: {},
				distance: ''
			}
		},
		onLoad(options) {
			this.id = options.id
			let vuex_cityInfo = this.$store.state.user.vuex_cityInfo
			if(!vuex_cityInfo.lat) {
				this.$store.dispatch('getCity')
			}else {
				this.params.lat = vuex_cityInfo.lat
				this.params.lng = vuex_cityInfo.lng
			}
			this.getExamSiteDatilFn()
			this.getExamSiteInfoFn()
		},
		methods: {
			async getExamSiteDatilFn() {
				const {data: res} = await getExamSiteDatil( Object.assign({id: this.id, },this.params))
				this.distance = res.distance
				this.detailInfo = res.siteDO
			},
			async getExamSiteInfoFn() {
				const {data: res} = await getExamSiteInfo({id: this.id,pageNo: 1,pageSize: 2, })
				this.infoList = res.list
			},
			async goExamine() {
				// uni.navigateTo({
				// 	url: '/pages/indexEntry/enroll/enroll?tit=学员信息'
				// })
				// return
				if(this.vuex_userInfo.schoolId) {
					uni.navigateTo({
						url: '/pages/carEntry/simulateAppointment/simulateAppointment'
					})
				}
				await this.$store.dispatch('getUserInfo')
				if(this.vuex_userInfo.schoolId) {
					uni.navigateTo({
						url: '/pages/carEntry/simulateAppointment/simulateAppointment'
					})
				}else {
					// 非平台学员
					this.$store.commit('updateNonPlatformStudent', 'NonPlatformStudent')
					uni.navigateTo({
						url: '/pages/indexEntry/enroll/enroll?tit=学员信息'
					})
					
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	
	.swiper-box {
		position: relative;
		height: 500rpx;
		.navPoz {
			position: absolute;
			top: 0;
			z-index: 9;
			left: 0;
		}
		.radian {
			position: absolute;
			width: 100%;
			height: 84rpx;
			bottom: 0;
			left: 0;
			z-index: 9;
		}
	}
	.h1 {
		line-height: 96rpx;
	}
	.traTop {
		position: relative;
		top: -120rpx;
		z-index: 99;
	}

	.info {
		height: 208rpx;
		align-items: center;
		display: flex;
		justify-content: space-between;
		padding: 24rpx;
		position: relative;
		.cover {
			width: 204rpx;
			height: 140rpx;
			border-radius: 8rpx;
			overflow: hidden;
		}

		.textCon {
			flex: 1;
			padding: 0 0 0 36rpx;

			.name {
				font-size: 32rpx;
				font-weight: 600;
				margin-bottom: 20rpx;
			}

			.starBox {
				padding: 10rpx 0 20rpx 0;
			}

			.modeCar {
				font-size: 24rpx;
				color: #686B73;
			}
		}

		.pozPhone {
			position: absolute;
			top: 50%;
			right: 40rpx;
			width: 72rpx;
			height: 72rpx;
			transform: translateY(-50%);
		}
	}
	.btn {
		width: 396rpx;
		height: 72rpx;
		background: #1989FA;
		border-radius: 8rpx;
		font-size: 28rpx;
		color: #fff;
		text-align: center;
		line-height: 72rpx;
		margin: 30rpx auto;
	}
</style>