Ver Fonte

提交代码

wangxiaogang há 3 anos atrás
pai
commit
935827f58d

+ 0 - 4
src/jfw/modules/app/src/web/staticres/jyapp/css/p13.css

@@ -473,10 +473,6 @@
     white-space: nowrap;
     text-overflow: ellipsis;
 }
-.p13 .home .list-msg .l-msg .words span:hover {
-    color: #2CB7CA;
-    cursor: pointer;
-}
 .p13 .home .list-msg .l-msg .words p {
     font-size: 12px;
     color: #9B9CA3;

+ 3 - 2
src/jfw/modules/app/src/web/staticres/jyapp/js/dateFunc.js

@@ -47,14 +47,15 @@ function dateLast() {
 
 function dateMatter(time, drag = 'normal') {
   // 时间转换
+  var iosTime = time ? time.replace(/-/g, '/') : '' // 兼容ios
   var timeStr = '';
   var currentDay = dateTime(time, 'yyyy/MM/dd'); // 当前日期
 
   var lingDay = new Date(new Date().toLocaleDateString()).getTime(); // 获取当天0点
 
-  var isTime = new Date(time) - lingDay;
+  var isTime = new Date(iosTime) - lingDay;
   var diff = isTime < 0 ? '昨天' : '';
-  var isDate = new Date(time) - dateYear();
+  var isDate = new Date(iosTime) - dateYear();
 
   if (isDate < 0) {
     drag == 'normal' ? timeStr = dateTime(time) : timeStr = dateTime(time, 'yyyy年MM月dd日');

+ 4 - 8
src/jfw/modules/app/src/web/staticres/jyapp/js/message-index.js

@@ -26,17 +26,11 @@ var vm = new Vue({
               v.createtime = dateMatter(v.createtime, 'nor')
             });
             _this.lists = res.data
-            window.localStorage.setItem('noMesg',res.count)
-          } else {
-            window.localStorage.setItem('noMesg', 0)
           }
-        },
-        error:function () {
-          window.localStorage.setItem('noMesg', 0)
         }
       })
     },
-    topRead(ids, type, url) {
+    topRead(ids, url, type) {
       const _this = this
       $.ajax({
         type: 'POST',
@@ -50,6 +44,7 @@ var vm = new Vue({
             location.href = url
           } else {
             _this.getList()
+            return
           }
         }
       })
@@ -92,7 +87,8 @@ var vm = new Vue({
       }
     },
     gotoUrl() {
-      location.href = '/jyapp/frontPage/messageCenter/sess/index'
+      // location.href = '/jyapp/frontPage/messageCenter/sess/index'
+      window.open('/jyapp/frontPage/messageCenter/sess/index')
     },
     msgType(val) {
       const obj = {

+ 2 - 8
src/web/staticres/common-module/messageCenter/js/message-template-index.js

@@ -1,5 +1,5 @@
 // 微信端
-var temp = '<div class="side-line" v-if="lists.length"><div class="list-msg"><div class="l-msg"><div class="words" v-for="item in lists" :key="item.id"><img class="dot-img" src="../image/no-read-dot.png" v-if="item.isRead == 0"><img class="dot-img" src="../image/read-dot.png" v-else><h3 :class="{isActive: item.isRead == 0}">@@item.msg_type@@</h3><span @click="titleGoto(item)">@@item.title@@</span><p>@@item.createtime@@</p></div></div><img @click="gotoUrl" class="r-msg" src="../image/jyxia.png"></div></div>'
+var temp = '<div class="side-line" v-if="lists.length"><div class="list-msg"><div class="l-msg"><div class="words" v-for="item in lists" :key="item.id"><img class="dot-img" src="../images/no-read-dot.png" v-if="item.isRead == 0"><img class="dot-img" src="../images/read-dot.png" v-else><h3 :class="{isActive: item.isRead == 0}">@@item.msg_type@@</h3><span @click="titleGoto(item)">@@item.title@@</span><p>@@item.createtime@@</p></div></div><img @click="gotoUrl" class="r-msg" src="../images/jyxia.png"></div></div>'
 
 var vm = new Vue({
   el: '#vue-message-index-app',
@@ -24,15 +24,9 @@ var vm = new Vue({
             res.data.forEach(v => {
               v.msg_type = _this.msgType(v.msg_type)
               v.createtime = dateMatter(v.createtime, 'out')
-            });
+            })
             _this.lists = res.data
-            window.localStorage.setItem('noMesg',res.count)
-          } else {
-            window.localStorage.setItem('noMesg', 0)
           }
-        },
-        error:function () {
-          window.localStorage.setItem('noMesg', 0)
         }
       })
     },

BIN
src/web/staticres/images/jyxia.png


BIN
src/web/staticres/images/no-read-dot.png


BIN
src/web/staticres/images/read-dot.png


+ 1 - 1
src/web/staticres/js/index_content.js

@@ -111,7 +111,7 @@ $("#index .ser").bind("input propertychange",function(){
   function judgeTop(){
       for(var j=0; j<num.length;j++){
           if (num[j] >= wScrollTop && num[j] < (wScrollTop+wH-50)) {
-            console.log(j)
+            // console.log(j)
               if(j == 0){
                 obj.eq(j).css({
                     'animation-name':'CfadeInUp',

+ 37 - 20
src/web/staticres/js/login.js

@@ -389,40 +389,56 @@ function checkMenuForEnt () {
         }
     })
 }
-var timer = null
+function toReaded(ids, type, url) {
+    const _this = this
+    $.ajax({
+        type: 'POST',
+        url:'/jymessageCenter/markRead',
+        data: {
+            msgId: ids,
+            msgType: type
+        },
+        success:function () {
+            if (url) {
+                location.href = url
+            } else {
+                return
+            }
+        }
+    })
+}
+var msgTimer = null
 // 查看是否有新消息
 function checkCounts() {
     Notification.requestPermission(function(status) {
         console.info(status, '----------')
         if(status === 'granted'){
-            clearInterval(timer)
-            timer = setInterval(function () {
+            clearInterval(msgTimer)
+            msgTimer = setInterval(function () {
                 $.ajax({
                     type: 'POST',
-                    url: '/jymessageCenter/latestNews?t=' + Date.now(),
+                    url: '/jymessageCenter/lastNewMessage?t=' + Date.now(),
                     success: function (r) {
                         var num = r.count
                         var isMsg = window.localStorage.getItem('noMesg')
                         if (num !== Number(isMsg)) {
-                            var datas = r.data[0]
-                            var notify = new Notification(datas.title,{
-                                icon: '../images/t3_new.jpg',
-                                body: datas.content
-                            })
+                            var datas = r.data
+                            if (datas) {
+                                var notify = new Notification(datas.title,{
+                                    icon: '../images/t3_new.jpg',
+                                    body: datas.content
+                                })
 
-                            // 点击时桌面消息时触发
-                            notify.onclick = () => {
-                                if (datas.link) {
-                                    location.href = datas.link
-                                } else {
-                                    return
+                                // 点击时桌面消息时触发
+                                notify.onclick = () => {
+                                    toReaded(r.data.id, r.data.msg_type, r.data.link)
                                 }
                             }
                             localStorage.setItem('noMesg', num)
                         }
                     },
                     error: function () {
-                        clearInterval(timer)
+                        clearInterval(msgTimer)
                     }
                 })
             }, 10000)
@@ -529,10 +545,10 @@ var logic = function(data,num){
 			infoListCss();
 			commonMouseEvent();
             message.init()
-            initIndexMsgList()
             checkCounts()
-		}catch(e){ console.log(e) }
+            initIndexMsgList()
         $(".newNotice").css('marginTop', '112px')
+		}catch(e){ console.log(e) }
 	}
 }
 
@@ -738,7 +754,7 @@ var signout = function(){
 			}
             window.localStorage.removeItem('bus-key-group-SCOPE')
             window.localStorage.removeItem('noMesg')
-            clearInterval(timer)
+            clearInterval(msgTimer)
 		}
 	})
 }
@@ -843,8 +859,9 @@ var haslogin = function(num,kyorpn,url){
 				infoListCss();
 				commonMouseEvent();
                 message.init()
-                initIndexMsgList()
                 checkCounts()
+                initIndexMsgList()
+                $(".newNotice").css('marginTop', '112px')
 			}catch(e){}
 		}
 		else{

+ 48 - 4
src/web/staticres/js/pc-message-index.js

@@ -7,18 +7,20 @@ var vmMesg = new Vue({
   data: function () {
     return {
       el: '#vue-message-index-pc',
-      lists: []
+      lists: [],
+      timer: null
     }
   },
   mounted: function () {
     this.getList()
+    // this.checkCounts()
   },
   methods: {
     getList() {
-      var _this = this
+      const _this = this
       $.ajax({
         type: 'POST',
-        url: '/jymessageCenter/latestNews?t=' + Date.now(),
+        url: '/jymessageCenter/latestNews',
         success:function (res) {
           if (res.data) {
             res.data.forEach(v => {
@@ -26,7 +28,9 @@ var vmMesg = new Vue({
               v.createtime = dateMatter(v.createtime)
             });
             _this.lists = res.data
-            window.localStorage.setItem('noMesg',res.count)
+            // _this.lists = []
+            window.localStorage.setItem('noMesg', res.count)
+            // window.localStorage.setItem('noMesg', 0)
           } else {
             window.localStorage.setItem('noMesg', 0)
           }
@@ -63,6 +67,46 @@ var vmMesg = new Vue({
         }
       }
     },
+    checkCounts() {
+      const _this = this
+      Notification.requestPermission(function(status) {
+        console.info(status, '----------')
+        if(status === 'granted'){
+          clearInterval(_this.timer)
+          _this.timer = setInterval(function () {
+            $.ajax({
+              type: 'POST',
+              url: '/jymessageCenter/lastNewMessage?t=' + Date.now(),
+              success: function (r) {
+                var num = r.count
+                var isMsg = window.localStorage.getItem('noMesg')
+                if (num !== Number(isMsg)) {
+                  var datas = r.data
+                  var notify = new Notification(datas.title,{
+                      icon: '../images/t3_new.jpg',
+                      body: datas.content
+                  })
+                  // 点击时桌面消息时触发
+                  notify.onclick = () => {
+                    if (datas.link) {
+                      location.href = datas.link
+                    } else {
+                      return
+                    }
+                  }
+                  localStorage.setItem('noMesg', num)
+                }
+              },
+              error: function () {
+                clearInterval(_this.timer)
+              }
+            })
+          }, 3000)
+        } else {
+            Notification.requestPermission()
+        }
+      })
+    },
     gotoUrl() {
       location.href = '/swordfish/frontPage/messageCenter/sess/index'
     },

+ 4 - 4
src/web/templates/pc/index.html

@@ -1092,12 +1092,12 @@ $('.carousel-one').carousel({
 })
 //最新公告信息
 var noMesg = window.localStorage.getItem('noMesg')
-console.info(noMesg, 'pppppppppppppppp')
-if (noMesg == 0 || noMesg == undefined || !noMesg) {
+console.log(noMesg, '===============')
+if (noMesg == 0 || noMesg == undefined || noMesg == null || !noMesg) {
+  $('.jy-banner').css('marginTop', '56px')
   $(".newNotice").css('marginTop', '192px')
-  $('#vue-message-index-pc').css('marginTop', '56px')
 } else {
-  $('#vue-message-index-pc').css('marginTop', '28px')
+  $('.jy-banner').css('marginTop', '28px')
   $(".newNotice").css('marginTop', '112px')
 }