xiaodai2022 2 years ago
parent
commit
a9699926dc
4 changed files with 66 additions and 50 deletions
  1. 0 1
      public/index.html
  2. 65 47
      src/layout/components/Navbar.vue
  3. 0 1
      src/main.js
  4. 1 1
      src/store/modules/user.js

+ 0 - 1
public/index.html

@@ -58,7 +58,6 @@
       <!-- <p style="width: 100%;text-align: center;color: #606266;">努力加载中...</p> -->
     </div>
   </div>
-  <!-- built files will be auto injected -->
 </body>
 
 </html>

+ 65 - 47
src/layout/components/Navbar.vue

@@ -14,7 +14,7 @@
         <i
           v-if="isShow"
           class="el-icon-message-solid right-menu-item hover-effect shake"
-          @click="openNotice"
+          @click="openNotice()"
           style="height: 50px; width: 40px; line-height: 52px; font-size: 22px"
         />
         <screenfull id="screenfull" class="right-menu-item hover-effect" />
@@ -157,79 +157,97 @@ export default {
     };
   },
   mounted() {
-    this.openNotice(1);
+    this.openNotice(true);
   },
   methods: {
-    async openNotice(type) {
+    async openNotice(is) {
       if (getNotice() && getNotice().length > 0) {
         this.lastNotice = JSON.parse(getNotice());
       } else {
         this.lastNotice = null;
       }
-      console.log(this.lastNotice);
-      this.loading = true;
-      const { code, data } = await asyncRequest.list(this.parmValue);
+      const { code, count, item, message } = await this.initData();
       if (code === 0) {
-        const { list, count } = data;
-        if (count !== 0) {
-          this.activeMsg = list[0];
-          this.isShow = true;
-          if (this.lastNotice + "" !== "null") {
-            const { type, addtime, sys_type } = this.activeMsg;
-            if (
-              addtime === this.lastNotice.addtime &&
-              sys_type === this.lastNotice.sys_type
-            ) {
-              if (type === "1") {
-                this.checked = true;
-              } else {
-                this.checked = false;
-              }
+        if (count != 0) {
+          this.activeMsg = item;
+          if (this.lastNotice + "" === "null") {
+            this.showModel = true;
+          } else {
+            if (is) {
+              this.typeShow();
             } else {
-              this.checked = false;
+              this.showModel = true;
             }
-          } else {
-            this.page_set_notice();
-            this.checked = false;
-          }
-          if (type === 1) {
-            this.typeShow();
-          } else {
-            this.showModel = true;
           }
         } else {
-          this.$message.warning("暂无信息推送!");
+          this.$message.warning("暂无系统消息!");
         }
       } else if (code >= 100 && code <= 104) {
         await this.logout();
       } else {
-        this.activeMsg = null;
-        this.isShow = false;
+        this.$message.warning(message);
       }
+    },
+
+    async initData() {
+      let res = {
+        code: 0,
+        count: 0,
+        item: {},
+        message: "",
+      };
+
+      this.loading = true;
+      const { code, data, message } = await asyncRequest.list(this.parmValue);
       this.loading = false;
+      res.code = code;
+      res.message = message;
+      if (code === 0) {
+        const { list, count } = data;
+        res.count = count;
+        if (count !== 0) {
+          res.item = JSON.parse(JSON.stringify(list[0]));
+        }
+      }
+      return res;
     },
     typeShow() {
+      const {
+        addtime: laddtime,
+        type: ltype,
+        sys_type: lsys_type,
+      } = this.lastNotice;
+      const { sys_type, addtime } = this.activeMsg;
+      if (laddtime === addtime && lsys_type === sys_type) {
+        if (ltype === "1") {
+          this.showModel = this.is_Tips();
+        } else {
+          this.showModel = true;
+        }
+      } else {
+        this.showModel = true;
+      }
+    },
+    is_Tips() {
       let nowtime = new Date().valueOf();
-      if (this.activeMsg.sys_type === "VER") {
-        this.statsTime = new Date(this.activeMsg.addtime).valueOf();
+      console.log(this.lastNotice);
+      const { sys_type, addtime } = this.activeMsg;
+      let timeV = new Date(addtime).valueOf();
+      if (sys_type === "VER") {
+        this.statsTime = timeV;
         this.endTime = this.statsTime + 1000 * 60 * 60 * 24 * 7;
-
-        if (
-          nowtime > this.statsTime &&
-          nowtime < this.endTime &&
-          !this.checked
-        ) {
-          this.showModel = true;
+        if (nowtime >= this.statsTime && nowtime <= this.endTime) {
+          return false;
         } else {
-          this.showModel = false;
+          return true;
         }
       } else {
         this.statsTime = 0;
-        this.endTime = new Date(this.activeMsg.addtime).valueOf();
-        if (nowtime < this.endTime && !this.checked) {
-          this.showModel = true;
+        this.endTime = timeV;
+        if (nowtime <= this.endTime) {
+          return false;
         } else {
-          this.showModel = false;
+          return true;
         }
       }
     },

+ 0 - 1
src/main.js

@@ -60,7 +60,6 @@ Vue.use(PuzzleVerification)
 
 // register global utility filters
 Object.keys(filters).forEach(key => {
-  console.log("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",key)
   Vue.filter(key, filters[key])
 })
 

+ 1 - 1
src/store/modules/user.js

@@ -193,7 +193,7 @@ const actions = {
               })
               arrag.push(pItem)
             })
-            console.log(arrag);
+            // console.log(arrag);
 
             list.forEach(asd => {
               // console.log(asd);