浏览代码

提交代码

wangxiaogang 3 年之前
父节点
当前提交
cd29fc18af
共有 1 个文件被更改,包括 51 次插入22 次删除
  1. 51 22
      src/components/work-desktop/MessageTips.vue

+ 51 - 22
src/components/work-desktop/MessageTips.vue

@@ -7,10 +7,9 @@
     <div class="list-msg">
       <div class="words" v-for="item in lists" :key="item.id">
         <div class="l-msg">
-          <i v-show="item.isRead == 1"></i>
-          <h3 :class="{isActive: item.isRead == 0}">{{item.msg_type}}</h3>
-          <a :href="item.url.link" v-if="item.url.link" target="_blank">{{item.title}}</a>
-          <a v-else>{{item.title}}</a>
+          <i v-show="item.isRead == 0"></i>
+          <h3 :class="{isActive: item.isRead == 1}">{{item.msg_type}}</h3>
+          <span @click="titleGoto(item)">{{item.title}}</span>
         </div>
         <p>{{item.createtime}}</p>
       </div>
@@ -28,34 +27,65 @@ export default {
       conts: 0
     }
   },
-  created() {
+  created () {
     this.messageList()
   },
   methods: {
-    messageList() {
+    messageList () {
       latestNews().then(res => {
-        if (res.status == 1) {
+        if (res.status === 1) {
           this.conts = res.count
-          if (!$.isEmptyObject(res.data)){
+          if (!$.isEmptyObject(res.data)) {
             res.data.forEach(v => {
               v.msg_type = this.msgType(v.msg_type)
               v.createtime = dateMatter(v.createtime)
-              v.url.link = ''
-            });
+            })
             this.lists = res.data
           }
         }
       })
     },
-    msgType(val) {
+    aHref (url) {
+      const a1 = document.createElement('a')
+      a1.href = url
+      a1.click()
+    },
+    readed (ids, type, url) {
+      const _this = this
+      $.ajax({
+        type: 'POST',
+        url: '/jymessageCenter/markRead',
+        data: {
+          msgId: ids,
+          msgType: type
+        },
+        success: function () {
+          if (url) {
+            _this.aHref(url)
+          } else {
+            _this.messageList()
+          }
+        }
+      })
+    },
+    titleGoto (item) {
+      if (item.isRead === 0) {
+        this.readed(item.id, item.msg_type, item.link)
+      } else {
+        if (item.link) {
+          this.aHref(item.link)
+        }
+      }
+    },
+    msgType (val) {
       const obj = {
-        '1': '活动优惠',
-        '2': '服务通知',
-        '3': '订阅消息',
-        '4': '项目动态 ',
-        '5': '企业动态',
-        '6': '分析报告 ',
-        '7': '系统通知',
+        1: '活动优惠',
+        2: '服务通知',
+        3: '订阅消息',
+        4: '项目动态 ',
+        5: '企业动态',
+        6: '分析报告 ',
+        7: '系统通知'
       }
       return obj[val]
     }
@@ -117,7 +147,7 @@ export default {
       }
     }
   }
-  
+
   .list-msg {
     display: flex;
     flex-direction: column;
@@ -149,7 +179,7 @@ export default {
     color: #2CB7CA;
     line-height: 24px;
   }
-  .list-msg .words .l-msg a {
+  .list-msg .words .l-msg span {
     font-size: 14px;
     color: #1D1D1D;
     line-height: 22px;
@@ -157,7 +187,6 @@ export default {
     &:hover {
       color: #2CB7CA!important;
       cursor: pointer;
-      text-decoration: none;
     }
   }
   .list-msg .words p {
@@ -169,4 +198,4 @@ export default {
     margin-left: 15px;
   }
 }
-</style>
+</style>