// 微信端
function iosBackRefresh () {
var isPageHide = false
window.addEventListener('pageshow', function () {
if (isPageHide) {
location.reload()
}
})
window.addEventListener('pagehide', function () {
isPageHide = true
})
}
var temp = '
'
var vm = new Vue({
el: '#vue-message-index-app',
delimiters: ['@@', '@@'],
template: temp,
data: function () {
return {
lists: []
}
},
created() {
this.getList()
},
mounted() {
iosBackRefresh()
},
methods: {
getList() {
var _this = this
$.ajax({
type:'POST',
url:'/jymessageCenter/latestNews',
success:function (res) {
if (res.data) {
res.data.forEach(v => {
v.msg_type = _this.msgType(v.msg_type)
v.createtime = dateMatter(v.createtime, 'out')
})
_this.lists = res.data
}
}
})
},
topRead(ids, url, type) {
const _this = this
$.ajax({
type: 'POST',
url:'/jymessageCenter/markRead',
data: {
msgId: ids,
msgType: type
},
success:function () {
if (url) {
window.open(url)
} else {
_this.getList()
}
}
})
},
titleGoto(item) {
let wxType = getType()
let appType = androidOrIOS()
let urls = item.url
if (wxType) {
if (item.isRead == 0) {
this.topRead(item.id, urls.weChatUrl, item.msg_type)
} else {
if (urls.weChatUrl) {
//链接中如果是www.jianyu360.cn域名,微信中会唤起app,该用window.open
window.open(urls.weChatUrl)
} else {
return
}
}
} else {
if (appType == 'android') {
if (item.isRead == 0) {
this.topRead(item.id, urls.androidUrl, item.msg_type)
} else {
if (urls.androidUrl) {
location.href = urls.androidUrl
} else {
return
}
}
} else {
if (item.isRead == 0) {
this.topRead(item.id, urls.iosUrl, item.msg_type)
} else {
if (urls.iosUrl) {
location.href = urls.iosUrl
} else {
return
}
}
}
}
},
gotoUrl() {
// location.href = '/weixin/frontPage/messageCenter/sess/index?msg=2'
window.open('/weixin/frontPage/messageCenter/sess/index?msg=2')
},
msgType(val) {
const obj = {
'1': '活动优惠',
'2': '服务通知',
'3': '订阅消息',
'4': '项目动态 ',
'5': '企业动态',
'6': '分析报告 ',
'7': '系统通知',
}
return obj[val]
}
}
})