|
@@ -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{
|