提交 06aa3267 authored 作者: yanpeng's avatar yanpeng

制裁轮播

上级 699983ea
流水线 #288 已通过 于阶段
in 1 分 24 秒
...@@ -32,14 +32,14 @@ ...@@ -32,14 +32,14 @@
<div class="list-header"> <div class="list-header">
<div class="count">{{ sanctionList.length }}次制裁</div> <div class="count">{{ sanctionList.length }}次制裁</div>
<!-- 暂时隐藏,说这里可能是轮播图的效果 --> <!-- 暂时隐藏,说这里可能是轮播图的效果 -->
<!-- <div class="pagination"> <div class="pagination">
<div class="page-btn prev"> <div class="page-btn prev" @click="handlePrevClick">
<el-icon><ArrowLeft /></el-icon> <el-icon><ArrowLeft /></el-icon>
</div> </div>
<div class="page-btn next"> <div class="page-btn next" @click="handleNextClick">
<el-icon><ArrowRight /></el-icon> <el-icon><ArrowRight /></el-icon>
</div>
</div> </div>
</div> -->
</div> </div>
<div class="list-content" v-loading="loading"> <div class="list-content" v-loading="loading">
<div <div
...@@ -243,7 +243,7 @@ ...@@ -243,7 +243,7 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted, nextTick } from "vue"; import { ref, onMounted, nextTick, onUnmounted } from "vue";
import { ArrowLeft, ArrowRight } from "@element-plus/icons-vue"; import { ArrowLeft, ArrowRight } from "@element-plus/icons-vue";
import defaultTitle from "../../assets/default-icon2.png"; import defaultTitle from "../../assets/default-icon2.png";
import { import {
...@@ -365,15 +365,17 @@ const getDeepMiningSelectData = async () => { ...@@ -365,15 +365,17 @@ const getDeepMiningSelectData = async () => {
try { try {
const res = await getDeepMiningSelect(params); const res = await getDeepMiningSelect(params);
if (res.code === 200 && res.data && res.data.content) { if (res.code === 200 && res.data && res.data.content) {
sanctionList.value = res.data.content.map(item => ({ sanctionList.value = res.data.content
id: item.id, .map(item => ({
date: item.postDate, id: item.id,
title: item.name, date: item.postDate,
count: item.cnEntityCount, title: item.name,
unit: "家中国实体", // 接口未返回单位,暂时固定 count: item.cnEntityCount,
summary: item.summary, // 保留额外信息备用 unit: "家中国实体", // 接口未返回单位,暂时固定
techDomainList: item.techDomainList // 保留额外信息备用 summary: item.summary, // 保留额外信息备用
})); techDomainList: item.techDomainList // 保留额外信息备用
}))
.reverse();
// 默认选中第一条 // 默认选中第一条
if (sanctionList.value.length > 0) { if (sanctionList.value.length > 0) {
...@@ -396,35 +398,74 @@ const handleDateChange = () => { ...@@ -396,35 +398,74 @@ const handleDateChange = () => {
currentPage.value = 1; currentPage.value = 1;
getDeepMiningSelectData(); getDeepMiningSelectData();
}; };
// ✅ 自动轮播定时器
const autoPlayTimer = ref(null);
// ✅ 启动自动轮播
const startAutoPlay = () => {
stopAutoPlay();
if (sanctionList.value.length > 1) {
autoPlayTimer.value = setInterval(() => {
handleNextClickAuto();
}, 10000);
}
};
// 翻页 // ✅ 停止自动轮播
const handlePageChange = page => { const stopAutoPlay = () => {
if (page < 1 || page > totalPage.value) return; if (autoPlayTimer.value) {
currentPage.value = page; clearInterval(autoPlayTimer.value);
getDeepMiningSelectData(); autoPlayTimer.value = null;
}
};
// ✅ 自动下一个(支持循环)
const handleNextClickAuto = () => {
const currentIndex = sanctionList.value.findIndex(item => item.id === currentSanctionId.value);
let nextItem;
if (currentIndex < sanctionList.value.length - 1) {
nextItem = sanctionList.value[currentIndex + 1];
} else {
nextItem = sanctionList.value[0]; // 循环到第一个
}
if (nextItem) {
handleSanctionSelect(nextItem.id);
}
};
// ✅ 修改现有函数,添加重置定时器
const handlePrevClick = () => {
const currentIndex = sanctionList.value.findIndex(item => item.id === currentSanctionId.value);
if (currentIndex > 0) {
const prevItem = sanctionList.value[currentIndex - 1];
handleSanctionSelect(prevItem.id);
startAutoPlay();
}
};
const handleNextClick = () => {
const currentIndex = sanctionList.value.findIndex(item => item.id === currentSanctionId.value);
if (currentIndex < sanctionList.value.length - 1) {
const nextItem = sanctionList.value[currentIndex + 1];
handleSanctionSelect(nextItem.id);
startAutoPlay();
}
}; };
// 列表项点击事件
const handleSanctionSelect = id => { const handleSanctionSelect = id => {
currentSanctionId.value = id; currentSanctionId.value = id;
getFishboneData(); getFishboneData();
getCnEntityOnChainData(); getCnEntityOnChainData();
startAutoPlay();
}; };
const activeTab = ref(["制裁时序分析"]); const activeTab = ref(["制裁时序分析"]);
const activeIndex = ref(0); const activeIndex = ref(0);
const dateRange = ref(["2025-01-01", "2025-12-31"]); const dateRange = ref(["2025-01-01", "2025-12-31"]);
const sanctionList = ref([ const sanctionList = ref([]);
{ id: 1, date: "2025年2月8日", title: "实体清单更新", count: 2, unit: "家中国实体" },
{ id: 2, date: "2025年4月10日", title: "实体清单更新", count: 5, unit: "家中国实体" },
{ id: 3, date: "2025年6月29日", title: "实体清单更新", count: 6, unit: "家中国实体" },
{ id: 4, date: "2025年8月12日", title: "实体清单更新", count: 24, unit: "家中国实体" },
{ id: 5, date: "2025年8月19日", title: "实体清单更新", count: 11, unit: "家中国实体" },
{ id: 6, date: "2025年9月12日", title: "实体清单更新", count: 3, unit: "家中国实体" },
{ id: 7, date: "2025年9月26日", title: "实体清单更新", count: 6, unit: "家中国实体" },
{ id: 8, date: "2025年10月12日", title: "实体清单更新", count: 18, unit: "家中国实体" }
]);
const currentSanctionId = ref(5); const currentSanctionId = ref(5);
const cnEntityOnChainData = ref({}); const cnEntityOnChainData = ref({});
...@@ -479,6 +520,14 @@ onMounted(() => { ...@@ -479,6 +520,14 @@ onMounted(() => {
getDeepMiningSelectData(); getDeepMiningSelectData();
// 获取产业链信息 // 获取产业链信息
getIndustryList(); getIndustryList();
nextTick(() => {
startAutoPlay();
});
});
// 组件卸载时停止自动轮播
onUnmounted(() => {
stopAutoPlay();
}); });
</script> </script>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论