diff --git a/src/view/work.vue b/src/view/work.vue index cc04340..f585254 100644 --- a/src/view/work.vue +++ b/src/view/work.vue @@ -2,12 +2,23 @@
-
+
-
+
教育
-
+
医疗
-
+
-
+
困难残疾人
-
+
困难军人
-
+
困难职工
@@ -89,7 +117,11 @@
-
+
发起单位:
{{ item.fqdw }}
@@ -197,7 +229,7 @@ const getData = async () => { await http.get("/api/ggfwyth/succour").then((res) => { if (res.code == 200) { console.log(res.data); - data.diversification.hszhxms = res.data.diversification.hszhxms + data.diversification.hszhxms = res.data.diversification.hszhxms; // 专项救助模块 // 教育&医疗 data.education.data = res.data.specialAssistance.education.data; @@ -221,9 +253,42 @@ const getData = async () => { } }); }; + +//自动滚动 +const mainRef = ref(null); +let isAutoScrolling = true; + +const stopAutoScroll = () => { + isAutoScrolling = false; +}; + +const startAutoScroll = () => { + isAutoScrolling = true; + autoScroll(); +}; + +const autoScroll = () => { + if (!isAutoScrolling) return; + + const mainEl = mainRef.value; + mainEl.scrollTop += 1; // 每次滚动的距离 + + if (mainEl.scrollTop + 1 >= mainEl.scrollHeight - mainEl.clientHeight) { + setTimeout(() => { + mainEl.scrollTo({ top: 0, behavior: "smooth" }); + setTimeout(autoScroll, 2000); // 2秒后再次滚动到底部 + }, 1000); // 暂停1秒后开始快速滚回顶部 + } else { + requestAnimationFrame(autoScroll); + } +}; + onBeforeMount(() => { getData(); }); +onMounted(() => { + startAutoScroll(); +});