<!--科研资助体系-->
<template>
	<div class="coop-page">
		<!-- 面包屑 -->
		<!-- <div class="breadcrumb">
			<div class="header-left">
				<HeaderMenu></HeaderMenu>
			</div>
			<div class="header-right">
				<headerInfo curTitleName="科研资助体系"></headerInfo>
			</div>
		</div> -->
		<!-- 主页面 -->
		<div class="main-content" ref="containerRef">
			<div class="home-top-bg"></div>
			<!-- 搜索栏部分 -->
			<SearchContainer style="margin-bottom: 52px; height: fit-content" v-if="containerRef" placeholder="搜索科研资助实体、资助记录"
				:containerRef="containerRef" areaName="" />
			<!-- <div class="search"> -->

			<!-- <div class="search-main">
					<input v-model="input" placeholder="搜索科研资助实体、资助记录" class="search-input" />
					<div class="search-btn">
						<img src="./assets/icons/search-icon.png" alt="" />
						搜索
					</div>
				</div>
				<div class="search-center">
					<div class="search-item">
						<div class="search-item-num">18</div>
						<div class="search-item-name">科研资助机构</div>
					</div>
					<div class="search-item">
						<div class="search-item-num">633</div>
						<div class="search-item-name">科研资助动态</div>
					</div>
					<div class="search-item">
						<div class="search-item-num">312</div>
						<div class="search-item-name">科研资助项目</div>
					</div>
					<div class="search-item">
						<div class="search-item-num">15,556</div>
						<div class="search-item-name">经费总额(亿美元)</div>
					</div>
				</div>
				<div class="search-bottom">
					<div class="btn" @click="scrollToTop('position1')">
						<div class="btn-text">最新动态</div>
						<div class="btn-icon">
							<img src="@/assets/icons/arrow-right-icon.png" alt="" />
						</div>
					</div>
					<div class="btn" @click="scrollToTop('position2')">
						<div class="btn-text">资讯要闻</div>
						<div class="btn-icon">
							<img src="@/assets/icons/arrow-right-icon.png" alt="" />
						</div>
					</div>
					<div class="btn" @click="scrollToTop('position3')">
						<div class="btn-text">数据总览</div>
						<div class="btn-icon">
							<img src="@/assets/icons/arrow-right-icon.png" alt="" />
						</div>
					</div>
					<div class="btn" @click="scrollToTop('position4')">
						<div class="btn-text">资源库</div>
						<div class="btn-icon">
							<img src="@/assets/icons/arrow-right-icon.png" alt="" />
						</div>
					</div>
				</div> -->
			<!-- </div> -->
			<!-- 6个数据 -->
			<div class="data" v-if="dataList.length > 0">
				<div v-for="(item, index) in dataList" :key="item.orgId || item.id" class="data-item"
					@click="handleClickOrg(item)">
					<img v-if="item.logoUrl" :src="item.logoUrl" alt="" />
					<img v-else src="./assets/images/nullcorpimg.png" alt="" />
					<div class="data-text-item">
						<div class="data-item-abb" v-if="item.orgAbbEn">{{ item.orgAbbEn }}</div>
						<div class="data-item-title">{{ item.orgName }}</div>
						<div class="data-item-name">{{ item.orgNameEn }}</div>
					</div>
					<div class="data-item-num" :style="{ color: color[index] }">{{ item.num + "项" }}</div>
				</div>
			</div>
			<!-- 最新动态 -->
			<div class="newdata" id="position1">
				<com-title title="最新动态" style="width: 1600px;" />
				<div class="newdata-main">
					<newData />
				</div>
			</div>
			<!-- 资讯要问 -->
			<div class="ask" id="position2">
				<com-title title="资讯要闻" style="width: 1600px;" />
				<div class="ask-main">
					<askPage />
				</div>
			</div>
			<!-- 数据总览 -->
			<div class="datasub" id="position3">
				<com-title title="数据总览" style="width: 1600px;" />
				<div class="datasub-main">
					<dataSub />
				</div>
			</div>
			<!-- 资源库 -->
			<div class="reslib" id="position4">
				<com-title title="资源库" style="width: 1600px;" />
				<div class="reslib-main">
					<resLib />
				</div>
			</div>
		</div>
	</div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import comTitle from "./common/comTitle.vue";
import newData from "./components/dataNew/index.vue";
import askPage from "./components/askPage/index.vue";
import dataSub from "./components/dataSub/index.vue";
import resLib from "./components/resLib/index.vue";
import scrollToTop from "@/utils/scrollToTop";

import { getFundSourceOrg } from "@/api/scientificFunding/overview";

import { useContainerScroll } from "@/hooks/useScrollShow";

import img01 from "./assets/images/img01.png";
import img02 from "./assets/images/img02.png";
import img03 from "./assets/images/img03.png";
import img04 from "./assets/images/img04.png";
import img05 from "./assets/images/img05.png";
import img06 from "./assets/images/img06.png";
let containerRef = ref(null);
let countInfo = ref([
	{
		name: "科研资助机构",
		count: 18
	},
	{
		name: "科研资助动态",
		count: 633
	},
	{
		name: "科研资助项目",
		count: 312
	},
	{
		name: "经费总额(亿美元)",
		count: "15,556"
	}
]);
// 搜索框
const input = ref("");

const router = useRouter();
// 返回首页
const handleBackHome = () => {
	router.push({
		path: "/overview"
	});
};

// 点击机构卡片跳转机构详情
const handleClickOrg = (item) => {
	const orgId = item?.orgId;
	if (!orgId) return;
	// Institution 路由开启了 dynamicTitle，这里提前写入标题，避免沿用上一次的“白宫”等旧值
	const title = item?.orgName || "";
	window.sessionStorage.setItem("institutionTabName", title);
	window.sessionStorage.setItem("curTabName", title);
	const route = router.resolve({
		path: "/institution",
		query: { id: orgId, name: title }
	});
	window.open(route.href, "_blank");
};
// 固定数据
const dataList = ref([

]);
const color = ref([
	"rgb(206, 79, 81)",
	"rgba(114, 46, 209, 1)",
	"rgba(19, 168, 168, 1)",
	"rgba(64, 150, 255, 1)",
	"rgb(33, 129, 57)",
	"rgb(5, 95, 194)"
]);
//// 来源机构列表
const handleGetFundSourceOrg = async () => {
	try {
		const res = await getFundSourceOrg();
		console.log("来源机构列表", res);
		if (res.code === 200 && res.data) {
			dataList.value = res.data;
		}
	} catch (error) {
		console.error("获取来源机构列表error", error);
	}
};

onMounted(async () => {
	handleGetFundSourceOrg();
});
</script>

<style scoped lang="scss">
* {
	margin: 0;
	padding: 0;
}

.coop-page {
	width: 100%;
	height: 100%;

	// .breadcrumb {
	// 	width: 100%;
	// 	height: 64px;
	// 	background-image: url("./assets/images/bread-bg.png");
	// 	background-size: cover;
	// 	display: flex;
	// 	justify-content: space-between;
	// 	padding: 0 160px;
	// }

	.main-content {
		overflow: hidden;
		overflow-y: auto;
		width: 100%;
		height: 100%;
		// background: url("./assets/images/background.png");
		// background-size: 100% 100%;
		padding: 44px 0 30px 0;
		position: relative;

		.home-top-bg {
			background:
				url("./assets/images/background.png"),
				linear-gradient(180deg, rgba(229, 241, 254, 1) 0%, rgba(246, 251, 255, 0) 30%);
			background-size: 100% 100%;
			position: absolute;
			width: 100%;
			height: 100%;
			z-index: -100;
			top: -64px;
		}

		.search {
			width: 960px;
			height: 168px;
			margin: 0 auto 122px auto;

			.search-main {
				display: flex;
				padding-right: 3px;
				align-items: center;
				justify-content: space-between;
				box-shadow: 0px 0px 20px 0px rgba(25, 69, 130, 0.1);
				width: 960px;
				height: 48px;
				background-color: rgba(255, 255, 255, 0.65);
				border-radius: 10px;
				border: 1px solid #fff;

				&:hover {
					border: 1px solid var(--color-main-active);
				}

				.search-input {
					border: none;
					outline: none;
					width: 800px;
					height: 48px;
					background-color: transparent;
					font-size: 16px;
					padding: 12px 16px;
					font-weight: 400;
					font-family: "Microsoft YaHei";
					line-height: 24px;
					color: rgb(132, 136, 142);
				}

				.search-btn {
					cursor: pointer;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 120px;
					height: 46px;
					margin-right: -3px;
					border-radius: 8px;
					background-color: rgb(5, 95, 194);
					font-size: 18px;
					font-weight: 400;
					font-family: "Microsoft YaHei";
					line-height: 24px;
					color: #fff;

					img {
						width: 22px;
						height: 22px;
						margin-right: 8px;
					}
				}
			}

			.search-center {
				width: 680px;
				height: 57px;
				margin: 36px auto;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.search-item {
					box-sizing: border-box;
					width: 120px;
					height: 57px;

					.search-item-num {
						width: 120px;
						height: 22px;
						font-size: 36px;
						font-weight: 700;
						font-family: "Microsoft YaHei";
						line-height: 22px;
						color: rgb(5, 95, 194);
						text-align: center;
						cursor: pointer;
					}

					.search-item-name {
						width: 128px;
						height: 24px;
						margin-top: 11px;
						font-size: 16px;
						font-weight: 400;
						font-family: "Microsoft YaHei";
						line-height: 24px;
						color: rgb(95, 101, 108);
						text-align: center;
					}
				}
			}

			.search-bottom {
				width: 688px;
				height: 48px;
				margin: 0 auto;
				margin-top: 36px;
				display: flex;
				justify-content: space-between;

				// gap: 16px;
				.btn {
					display: flex;
					align-items: center;
					gap: 9px;
					width: 160px;
					height: 48px;
					border: 1px solid #aed6ff;
					box-sizing: border-box;
					border-radius: 24px;
					background: #e7f3ff;
					cursor: pointer;
					position: relative;

					&:hover {
						background: #cae3fc;
					}

					.btn-text {
						width: 80px;
						color: var(--color-main-active);
						font-family: Microsoft YaHei;
						font-size: 20px;
						font-weight: 400;
						line-height: 48px;
						margin-left: 36px;
						text-align: center;
					}

					.btn-icon {
						position: absolute;
						top: 16px;
						right: 19px;
						width: 6px;
						height: 12px;

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

		.data {
			width: 1600px;
			height: 316px;
			margin: 0 auto 64px auto;
			display: flex;
			justify-content: space-between;
			align-content: space-between;
			flex-wrap: wrap;

			.data-item {
				width: 520px;
				height: 150px;
				background-color: #fff;
				border-radius: 10px;
				box-shadow: 0px 0px 20px 0px rgba(25, 69, 130, 0.1);
				box-sizing: border-box;
				position: relative;
				cursor: pointer;
				transition:
					transform 0.3s ease,
					box-shadow 0.3s ease;
				display: flex;
				align-items: center;
				padding: 0px 24px;

				&:hover {
					transform: translateY(-3px);
					box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
				}

				.data-text-item {
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: flex-start;
					height: 100%;
					margin-left: 16px;
					margin-bottom: 4px;

					.data-item-abb {

						font-family: "Source Han Sans CN", sans-serif;
						font-weight: 700;
						/* 对应 Bold 字重 */
						font-size: 32px;
						line-height: 48px;
						letter-spacing: 0px;
						text-align: left;
						/* 左对齐 */
						color: rgb(59, 65, 75);
					}

					.data-item-title {
						width: 280px;
						white-space: nowrap;
						/* 保持在一行内 */
						overflow: hidden;
						/* 隐藏超出部分 */
						text-overflow: ellipsis;
						/* 超出部分显示省略号 */
						font-family: "Source Han Sans CN", sans-serif;
						font-weight: 700;
						font-size: 18px;
						line-height: 24px;
						letter-spacing: 0px;
						text-align: justify;
						color: rgb(95, 101, 108);
					}

					.data-item-name {
						font-family: "Source Han Sans CN", sans-serif;
						font-weight: 700;
						font-size: 16px;
						line-height: 24px;
						letter-spacing: 0px;
						text-align: justify;
						color: rgb(95, 101, 108);
					}
				}

				img {
					width: 88px;
					height: 88px;
				}






				.data-item-num {
					position: absolute;
					top: 19px;
					right: 25px;
					font-size: 32px;
					font-weight: 700;
					font-family: "Microsoft YaHei";
					line-height: 42px;
					color: rgb(95, 101, 108);
				}
			}
		}

		.newdata {
			width: 1600px;
			height: 538px;
			margin: 36px auto 64px auto;

			.newdata-main {
				width: 1600px;
				height: 460px;
				margin-top: 36px;
			}
		}

		.ask {
			width: 1600px;
			height: 528px;
			margin: 0 auto 64px auto;

			.ask-main {
				width: 1600px;
				height: 450px;
				margin-top: 36px;
			}
		}

		.datasub {
			width: 1600px;
			height: 1014px;
			margin: 0 auto 88px auto;

			.datasub-main {
				width: 1600px;
				height: 936px;
				margin-top: 36px;
			}
		}

		.reslib {
			width: 1600px;

			margin: 0 auto 0px auto;

			.reslib-main {
				width: 1600px;

				margin-top: 26px;
			}
		}
	}
}
</style>
