From 083bc1030f7dda031f04976c7f02109d31eeff0e Mon Sep 17 00:00:00 2001
From: lxp <1928192722@qq.com>
Date: 星期三, 07 八月 2024 16:06:26 +0800
Subject: [PATCH] Merge branch 'master' of http://114.132.189.42:9002/r/center-lims-before

---
 src/view/timer.vue |   72 ++++++++++++++++++++++++++++++++++++
 1 files changed, 72 insertions(+), 0 deletions(-)

diff --git a/src/view/timer.vue b/src/view/timer.vue
new file mode 100644
index 0000000..12a66ce
--- /dev/null
+++ b/src/view/timer.vue
@@ -0,0 +1,72 @@
+<template>
+  <div>
+    <el-dialog
+    title="鎻愮ず"
+    :visible.sync="dialogVisible"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    :show-close="false"
+    width="30%">
+      <div style="display: flex;align-items: center;"><i class="el-icon-warning" style="color: red;font-size: 40px;margin-right: 20px;"></i><span>浠g爜姝e湪閮ㄧ讲锛岃30鍒嗛挓鍚庨噸鏂拌繘鍏ョ郴缁燂紒</span></div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+export default {
+  data(){
+    return{
+      timer:null,
+      closeTimeout:null,
+      dialogVisible:false,
+    }
+  },
+  mounted() {
+    this.startScheduler();
+  },
+  methods: {
+    startScheduler() {
+      this.checkTime();
+      // 姣忓垎閽熸鏌ヤ竴娆�
+      this.timer = setInterval(this.checkTime, 60 * 1000);
+    },
+    checkTime() {
+      const now = new Date();
+      const hours = now.getHours();
+      const minutes = now.getMinutes();
+
+      if (hours === 20 && minutes === 0) {
+        this.performTask();
+        // 璁剧疆20鍒嗛挓鍚庢彁绀哄叧闂�
+        this.closeTimeout = setTimeout(() => {
+          this.promptToClose();
+        }, 20 * 60 * 1000); // 20鍒嗛挓
+      }
+    },
+    performTask() {
+      // 鍦ㄨ繖閲屾墽琛屼綘鎯宠鐨勫畾鏃朵换鍔�
+      console.log("浠诲姟鎵ц浜嗭紒");
+      this.dialogVisible = true;
+      // 杩欓噷鍙互瑙﹀彂涓�涓� Vuex 鍔ㄤ綔銆佸彂璧蜂竴涓� HTTP 璇锋眰锛屾垨鑰呭叾浠栨搷浣�
+    },
+    promptToClose() {
+      // 鎻愮ず鐢ㄦ埛鍏抽棴
+      // alert("璇疯寰楀湪20鍒嗛挓鍚庡叧闂换鍔★紒");
+      this.dialogVisible = true;
+    }
+  },
+  beforeDestroy() {
+    // 缁勪欢閿�姣佹椂娓呴櫎瀹氭椂鍣�
+    if (this.timer) {
+      clearInterval(this.timer);
+    }
+    if (this.closeTimeout) {
+      clearTimeout(this.closeTimeout);
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+</style>

--
Gitblit v1.9.3