var vm = new Vue({ el: '#mesged', delimiters: ['{', '}'], data: function () { return { isToggle: false, isRow: false, lastData: [], msgList: [], timer: null, messageCount: 0, messageInfo: {}, imgSrcs: [ {title: '活动优惠', url:'huodong'}, {title: '服务通知', url:'fuwu'},{title: '订阅消息', url:'dingyue'}, {title: '项目动态', url:'xiangmu'},{title: '企业动态', url:'qiye'}, {title: '分析报告', url:'fenxi'},{title: '系统通知', url:'xitong'} ], isShowEntrance: true // 是否展示私信入口 } }, created() { Object.assign(this.$data, this.$options.data()) this.lastMsg() this.msgData() this.getPrivateLetter() 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 } } } }) }, // 获取私信 getPrivateLetter () { const _this = this $.ajax({ type:'POST', contentType: 'application/json', url:'/jyapi/message/messageCount', data: JSON.stringify({ userType: 2 }), success:function (res) { if (res && res.error_code === 0 && res.data) { _this.messageCount = res.count _this.messageInfo = res.data if(res.data && res.data.content) { if(res.data.content.search('

') !== -1) { res.data.content = res.data.content.replace(/

/g, '') } } } } }) }, // 消息列表 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, wxType) { 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, wxType) } 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, wxType) } else { if (url.androidUrl) { location.href = url.androidUrl } } } else { if (!num) { this.topRead(ids, url.iosUrl, type, wxType) } else { if (url.iosUrl) { location.href = url.iosUrl } } } } }, // 置顶消息展开,收起 toggleClick() { this.isToggle = !this.isToggle }, // 私信 msgPriDetailed () { const params= { userType: 2 } sessionStorage.removeItem('conversation-login-clear') $.ajax({ type: 'POST', url: '/jyapi/message/userList', contentType: 'application/json', data: JSON.stringify(params), success: function(res) { if (res.error_code === 0) { if (res.data && res.data.length !== 0) { const firstUser = res.data[0] location.href = `/page_social_mobile/home?receiveAppId=${firstUser.userId}&userType=${firstUser.userType}&pname=${firstUser.name}` } else { location.href = '/page_social_mobile/home?receiveAppId=455b495c5c&userType=1&pname=剑鱼标讯' } } else { location.href = '/page_social_mobile/home?receiveAppId=455b495c5c&userType=1&pname=剑鱼标讯' } } }) }, // 列表消息跳转详情页 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 } } } })