<template>
	<!-- <view>基本考核完成</view> -->
	<view class="page po-r">
		<image src="" mode="" class="mainBg"></image>
		<view class="w-100 po-a content">
			<stepProgress :step="2"></stepProgress>

			<view class="info">
				<view class="top">
					<view class="flex-rowl top-title">
						<up-icon class="icon" name="checkmark-circle-fill" color="#FFBF60" size="34rpx"></up-icon>
						<text>基本考核答题已完成</text>
					</view>
					<view class="flex-rowl top-desc">
						<image class="icon" :src="configList.pet_base_test.paramValueImage"></image>
						<view>
							<up-parse :content="configList.pet_base_test.paramValueArea" containerStyle="{
								color: '#707070',
								fontSize: '22rpx',
								lineHeight: '29rpx',
							}"></up-parse>
						</view>
					</view>
				</view>
				<view class="info-box">
					<view class="info-box-title">
						平台&服务介绍
					</view>
					<view class="info-box-content">
						<view class="flex-colc info-item"
						v-for="item in serviceList"
						v-if="configList.pet_base_test.paramValueText == 1"
						:key="`service-${item.id}`"
						>
							<view class="video">
								<video 
									:src="item.video"
									play-btn-position="center"
									:picture-in-picture-mode="[]"
								></video>
							</view>
							<text class="desc">{{ item.title }}</text>
						</view>
					</view>
				</view>
				
				<view class="info-box">
					<view class="info-box-title">
						{{ configList.train_assessment_text.paramValueText }}
					</view>
					<view style="padding: 20rpx;">
						<up-parse :content="configList.train_assessment_text.paramValueArea" containerStyle="{
							color: '#707070',
							fontSize: '22rpx',
							lineHeight: '29rpx',
						}"></up-parse>
					</view>
				</view>
				
				
				
				<!-- <view class="info-box">
					<view class="info-box-title">
						服务培训
					</view>
					<view class="info-box-content">
						v-for="item in trainList"
						:key="`train-${item.id}`"
						@click="openPopup(item.title, item.content)"
						<view class="flex-colc info-item"
							@click="openPopup('服务培训', configList.pet_service_training.paramValueArea)"
						>
							<image :src="configList.pet_service_training.paramValueImage" mode="widthFix"></image>
							<text class="desc">{{ item.title }}</text>
						</view>
					</view>
					
					<up-popup 
						:show="popupData.show" 
						round="16rpx"
						@close="closePopup"
					>
						<view class="popup">
							<view class="popup-header">
								<text class="popup-title">{{ popupData.title }}</text>
							</view>
							<view class="popup-content">
								<up-parse class="size-28" :content="popupData.content"></up-parse>
							</view>
						</view>
					</up-popup>
				</view> -->
				<view class="flex-rowc tools">
					<view class="flex-rowc btn" @click="toNext">
						进入培训考核
					</view>
				</view>
			</view>
		</view>
	</view>
    <!-- 客服组件 -->
    <CustomerService />
</template>

<script setup>
	import { ref, reactive } from 'vue'
	import { onShow } from '@dcloudio/uni-app'
	import { store } from '@/store'
	import { getServiceList, getTrainList } from '@/api/examination'

	import stepProgress from '../components/stepProgress.vue';

	const configList = store.state.system.configList

	const toNext = () => {
		uni.navigateTo({
			url: "/otherPages/authentication/examination/train"
		})
	}

	const serviceList = ref([])
	const fetchServiceList = async () => {
		try {
			serviceList.value = await getServiceList()
		} catch (err) {

		}
	}

	// const trainList = ref([])
	// const fetchTrainList = async () => {
	// 	try {
	// 		trainList.value = await getTrainList()
	// 	} catch (err) {

	// 	}
	// }

	const popupData = reactive({
		show: false,
		title: null,
		content: null,
	})
	const openPopup = (title, content) => {
		popupData.show = true
		popupData.title = title
		popupData.content = content
	}
	const closePopup = () => {
		popupData.show = false
	}

	onShow(() => {

		fetchServiceList()
		// fetchTrainList()
	})
</script>

<style scoped lang="scss">
	.page {
		position: relative;
		width: 100vw;

		.mainBg {
			width: 100vw;
			height: 442rpx;
			background-image: linear-gradient(to bottom, #FFBF60, #f5f5f5);
		}

		.content {
			top: 0;
			left: 0;
			padding: 16rpx;
			width: 100%;
			box-sizing: border-box;
		}
	}
	
	.info{
		margin-top: 22rpx;
		box-sizing: border-box;
		width: 100%;
		height: auto;
		background-color: #FFFFFF;
		padding: 22rpx 20rpx 38rpx 20rpx;
		border-radius: 16rpx;
		
		.top{
			width: 100%;
			background-color: #FFFCF1;
			box-sizing: border-box;
			padding: 19rpx 26rpx;
			border-radius: 16rpx;
			color: #707070;

			&-title {
				font-size: 28rpx;

				.icon {
					margin-right: 5rpx;
				}
			}

			&-desc {
				margin-top: 22rpx;
				font-size: 22rpx;
				
				.icon {
					margin-right: 12rpx;
					width: 27rpx;
					height: 27rpx;
				}
			}
		}

		&-box {
			margin-top: 30rpx;

			&-title {
				display: inline-block;
				font-size: 30rpx;

				&::before {
					content: "";
					display: inline-block;
					width: 9rpx;
					height: 33rpx;
					background-color: #FFBF60;
					margin-right: 7rpx;
					border-radius: 5rpx;
				}
			}

			&-content {
				display: grid;
				grid-template-columns: repeat(2, 1fr);
				grid-column-gap: 27rpx;
			}
		}

		&-item {
			width: 100%;
			margin-top: 30rpx;

			.video {
				width: 100%;
				height: 197rpx;
				border-radius: 16rpx;
				overflow: hidden;

			}
			
			video {
				width: 100%;
				height: 100%;
			}

			image {
				width: 100%;
			}

			.desc {
				color: #707070;
				font-size: 22rpx;
				line-height: 40rpx;
			}
		}
	}

	.tools {
		margin-top: 79rpx;
	}

	.btn {
		font-size: 30rpx;
		line-height: 40rpx;
		color: #fff;
		width: 574rpx;
		padding: 27rpx 0;
		box-sizing: border-box;
		border-radius: 41rpx;
		background-color: #FFBF60;
	}

	
  .popup {
    padding: 28rpx;

    &-header {
      margin-bottom: 28rpx;
    }

		&-content {
			max-height: 80vh;
			overflow-y: auto;
		}

    &-title {
      color: #000000;
      font-weight: 700;
      font-size: 30rpx;
      line-height: 40rpx;
    }
  }
</style>