<!--科研资助体系-->
<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: 48px;height: fit-content;" v-if="containerRef" :countInfo="countInfo"
				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">
				<div v-for="(item, index) in dataList" :key="item.id" class="data-item">
					<img v-if="item.logoUrl && /\\.(jpe?g|png)$/i.test(item.logoUrl)" :src="item.logoUrl" alt="" />
					<img v-else src="./assets/images/nullcorpimg.png" alt="" />
					<div class="data-text-item">
						<div class="data-item-title">{{ item.orgName }}</div>
						<div class="data-item-name">{{ item.orgNameEn }}</div>
						<div v-if="item.orgAbbEn" class="data-item-abb">{{ item.orgAbbEn }}</div>
					</div>
					<div class="data-item-num" :style="{ color: color[index] }">{{ item.num + '项' }}</div>
				</div>
			</div>
			<!-- 最新动态 -->
			<div class="newdata" id="position1">
				<com-title title="最新动态" />
				<div class="newdata-main">
					<newData />
				</div>
			</div>
			<!-- 资讯要问 -->
			<div class="ask" id="position2">
				<com-title title="咨询要闻" />
				<div class="ask-main">
					<askPage />
				</div>
			</div>
			<!-- 数据总览 -->
			<div class="datasub" id="position3">
				<com-title title="数据总览" />
				<div class="datasub-main">
					<dataSub />
				</div>
			</div>
			<!-- 资源库 -->
			<div class="reslib" id="position4">
				<com-title title="资源库" />
				<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 HeaderMenu from "@/components/headerMenu.vue";
import headerInfo from "@/components/headerInfo.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 dataList = ref([
	{
		id: 1,
		title: "NSF",
		name: "美国国家科学基金会",
		abb: "National Science Foundation",
		num: "218项",
		image: img01,
		color: "rgb(206, 79, 81)"
	},
	{
		id: 2,
		title: "DARPA",
		name: "美国国防高级研究计划局",
		abb: "Defense Advanced Research Projects Agency",
		num: "95项",
		image: img02,
		color: "rgba(114, 46, 209, 1)"
	},
	{
		id: 3,
		title: "NIH",
		name: "美国国立卫生研究院",
		abb: "National Institutes of Health",
		num: "90项",
		image: img03,
		color: "rgba(19, 168, 168, 1)"
	},
	{
		id: 4,
		title: "NASA",
		name: "美国国家航空航天局",
		abb: "National Aeronautics and Space...",
		num: "42项",
		image: img04,
		color: "rgba(64, 150, 255, 1)"
	},
	{
		id: 5,
		title: "DOE",
		name: "美国能源部",
		abb: "Department of Energy",
		num: "95项",
		image: img05,
		color: "rgb(33, 129, 57)"
	},
	{
		id: 6,
		title: "NIST",
		name: "国家标准与技术研究院",
		abb: "National Institute of Standards and ...",
		num: "218项",
		image: img06,
		color: "rgb(5, 95, 194)"
	}
]);
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;
				}

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

				.data-item-title {
					width: 280px;
					white-space: nowrap;
					/* 保持在一行内 */
					overflow: hidden;
					/* 隐藏超出部分 */
					text-overflow: ellipsis;
					/* 超出部分显示省略号 */
					font-size: 24px;
					font-weight: 700;
					font-family: "Microsoft YaHei";
					line-height: 42px;
					color: rgb(59, 65, 75);
				}

				.data-item-name {
					font-size: 18px;
					font-weight: 700;
					font-family: "Microsoft YaHei";
					line-height: 24px;
					color: rgb(95, 101, 108);
				}

				.data-item-abb {
					position: absolute;
					top: 101px;
					left: 134px;
					font-size: 16px;
					font-weight: 700;
					font-family: "Microsoft YaHei";
					line-height: 24px;
					color: rgb(95, 101, 108);
				}

				.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;
			height: 1633px;
			margin: 0 auto 0px auto;

			.reslib-main {
				width: 1600px;
				height: 1565px;
				margin-top: 26px;
			}
		}
	}
}
</style>
