var vm = new Vue({ el: '#mesged', delimiters: ['{', '}'], data: function () { return { isToggle: false, isRow: false, lastData: [], msgList: [], timer: null, imgSrcs: [ {title: '活动优惠', url:'huodong'}, {title: '服务通知', url:'fuwu'},{title: '订阅消息', url:'dingyue'}, {title: '项目动态', url:'xiangmu'},{title: '企业动态', url:'qiye'}, {title: '分析报告', url:'fenxi'},{title: '系统通知', url:'xitong'} ] } }, created() { Object.assign(this.$data, this.$options.data()) this.lastMsg() this.msgData() let wxType = getType() if (!wxType) { checkMsgCount(true, 0) } }, mounted () { iosBackRefresh() keepQuest() }, beforeDestroy() { clearInterval(this.timer) }, methods: { // 置顶消息 lastMsg() { const _this = this $.ajax({ type:'POST', url:'/jymessageCenter/lastMessage', success:function (res) { if (res && res.status == 1) { _this.lastData = $.isEmptyObject(res.data) ? false : res.data if (res.data && res.data.content && res.data.content.length > 46) { _this.isRow = true } else { _this.isRow = false } } } }) }, // 消息列表 msgData() { const _this = this $.ajax({ type:'POST', url:'/jymessageCenter/classAndNew', success:function (res) { if (res && res.status == 1) { _this.msgList = $.isEmptyObject(res.data) ? false : res.data } } }) }, // 点击置顶消息为已读 topRead(ids, url, type) { const _this = this $.ajax({ type:'POST', url:'/jymessageCenter/markRead', data: { msgId: ids, msgType: type }, success:function () { _this.msgData() if (url) { if (getType()) { //链接中如果是www.jianyu360.cn域名,微信中会唤起app,该用window.open window.open(url) } else { location.href = url } } } }) }, platType() { let wxType = getType() if (wxType) { return 3 } else { return 2 } }, clickMesg(logid) { const _this = this $.ajax({ type: 'GET', url: '/jymessageCenter/clickMessage', data: { msgLogId: logid, platform: _this.platType() }, success:function () {} }) }, // 置顶消息跳转 msgClick(url, num, ids, type, logid) { this.clickMesg(logid) let wxType = getType() let appType = androidOrIOS() if (wxType) { if (!num) { this.topRead(ids, url.weChatUrl, type) } else { if (url.weChatUrl) { //location.href = url.weChatUrl //链接中如果是www.jianyu360.cn域名,微信中会唤起app,该用window.open window.open(url.weChatUrl); } } } else { if (appType == 'android') { if (!num) { this.topRead(ids, url.androidUrl, type) } else { if (url.androidUrl) { location.href = url.androidUrl } } } else { if (!num) { this.topRead(ids, url.iosUrl, type) } else { if (url.iosUrl) { location.href = url.iosUrl } } } } }, // 置顶消息展开,收起 toggleClick() { this.isToggle = !this.isToggle }, // 列表消息跳转详情页 msgDetailed(type, num) { let wxType = getType() if (wxType) { location.href = '/weixin/frontPage/messageCenter/sess/detail?type=' + type + '&num=' + num } else { location.href = '/jyapp/frontPage/messageCenter/sess/detail?type=' + type + '&num=' + num } } } })