Quellcode durchsuchen

右下角弹窗

chen vor 3 Jahren
Ursprung
Commit
359cb2506b
2 geänderte Dateien mit 23 neuen und 55 gelöschten Zeilen
  1. 23 3
      src/layout/components/Navbar.vue
  2. 0 52
      src/views/dashboard/index.vue

+ 23 - 3
src/layout/components/Navbar.vue

@@ -99,6 +99,7 @@
 </template>
 
 <script>
+import { getRebateOrderMsg } from "@/api/dashboard";
 import { mapGetters } from "vuex";
 import Breadcrumb from "@/components/Breadcrumb";
 import Hamburger from "@/components/Hamburger";
@@ -111,6 +112,7 @@ import request from "@/utils/request";
 export default {
   data() {
     return {
+      intivalId: "",
       timer: "",
       noticeCount: 0,
       userInfo: "",
@@ -133,16 +135,22 @@ export default {
   mounted() {
     const that = this;
     // 开定时器轮询未读消息接口(写在全局vuex里比较好)
-    that.initNotice();
-    this.timer = setInterval(function () {
-      that.initNotice();
+    // that.initNotice();
+    that.tcMessage();
+    this.intivalId = setInterval(function () {
+      that.tcMessage();
     }, 3000);
+    // this.timer = setInterval(function () {
+    //   that.initNotice();
+    // }, 3000);
   },
   created() {
     this.userInfo = JSON.parse(localStorage.getItem("supply_user"));
   },
   beforeDestroy() {
+    window.clearInterval(this.intivalId);
     window.clearInterval(this.timer);
+
     console.log("退出清理定时器" + this.timer);
   },
   components: {
@@ -179,6 +187,18 @@ export default {
         }
       });
     },
+    async tcMessage() {
+      let res = await getRebateOrderMsg();
+      if (res.data.hasMessage) {
+        this.$notify.info({
+          title: "消息",
+          message: res.data.messages,
+          position: "bottom-right",
+          duration: 4000,
+          showClose: false,
+        });
+      }
+    },
     goNotice() {
       this.$router.push("/notice/index");
     },

+ 0 - 52
src/views/dashboard/index.vue

@@ -284,7 +284,6 @@ import {
   getNoticeDetail,
   confirmCheck,
   getRebateOrderList,
-  getRebateOrderMsg,
 } from "@/api/dashboard";
 import { mapGetters } from "vuex";
 import { getInfo, getOrder, getGoodsRank } from "@/api/dashboard";
@@ -293,62 +292,11 @@ import { dateFormat } from "@/utils/util";
 export default {
   name: "Dashboard",
   created() {
-    localStorage.setItem("tcmessage", true);
     this.getDataList({
       pageSize: this.pageSize,
       pageNum: this.currentPage,
       readFlag: false,
     });
-
-    // console.log(this.showMessages, 564456564);
-    // let that = this.$notify;
-    // let aa = function () {
-    //   that.info({
-    //     title: "自定义位置",
-    //     message: "右下角弹出的消息",
-    //     position: "bottom-right",
-    //     duration: 0,
-    //     onClose() {
-    //       console.log("关闭回调");
-    //       clearInterval(intivalId);
-    //       aa();
-    //     },
-    //   });
-    //   clearInterval(intivalId);
-    // };
-    // if (this.showMessages || localStorage.getItem("tcmessage")) {
-    //   // let intivalId = setInterval(() => {
-    //   //   this.$notify.info({
-    //   //     title: "自定义位置",
-    //   //     message: "右下角弹出的消息",
-    //   //     position: "bottom-right",
-    //   //     duration: 0,
-    //   //     onClose() {
-    //   //       console.log("关闭回调");
-    //   //       console.log(that);
-    //   //       clearInterval(intivalId);
-    //   //       aa();
-    //   //     },
-    //   //   });
-    //   //   clearInterval(intivalId);
-    //   // }, 3000);
-    //   // aa();
-    //   let intivalId = setInterval(async () => {
-    //     let res = await getRebateOrderMsg();
-    //     console.log(res, 7888777);
-    //     if (res.data.hasMessage) {
-    //       this.$notify.info({
-    //         title: "消息",
-    //         message: res.data.messages,
-    //         position: "bottom-right",
-    //         duration: 0,
-    //         onClose() {
-    //           console.log("关闭回调");
-    //         },
-    //       });
-    //     }
-    //   }, 3000);
-    // }
   },
   computed: {
     ...mapGetters(["showMessages"]),