var vm = new Vue({ el: '.mesg-container', delimiters: ['{', '}'], data: function () { return { loading: false, activeName: '0', counts: [], kfCount: 0, isTabs: '', shuntData: {}, shunted: true, imgSrcs: [ { type: '0', title: '全部', url: '/images/pc/quanbu@2x.png' }, { type: '1', title: '活动优惠', url: '/images/pc/huodong@2x.png' }, { type: '2', title: '服务通知', url: '/images/pc/fuwu@2x.png' }, { type: '3', title: '订阅消息', url: '/images/pc/dingyue@2x.png' }, { type: '4', title: '项目动态', url: '/images/pc/xiangmu@2x.png' }, { type: '5', title: '企业动态', url: '/images/pc/qiye@2x.png' }, { type: '6', title: '分析报告', url: '/images/pc/fenxi@2x.png' }, { type: '7', title: '系统通知', url: '/images/pc/xitong@2x.png' }, { type: '8', title: '私信', url: '/images/pc/sixin@2x.png' } ], tabsList: { lasts: [], lists: [], offset: 1, pageSize: 20, totals: 0, } } }, created() { this.tabsCount() this.tabsData('0') this.kfContacts() this.kfData() }, methods: { // 私信显示、隐藏 kfContacts() { const _this = this $.post({ url: '/jyapi/social/obtainShunt',// 分流 type: 'POST', data: JSON.stringify({type: 'PC', isFind: true}), contentType: 'application/json', success: function (res) { _this.shuntData = res.data } }) }, // 私信数量 kfData() { const _this = this $.ajax({ type: 'POST', url: '/jyapi/message/messageCount', data: JSON.stringify({userType: 2}), contentType: 'application/json', success: function (res) { _this.kfCount = res.count } }) }, kfHref() { // 跳转到会话列表(不传userId右侧展示为缺省页) location.href = '/page_pc_social/customer?mini=1' }, kfClick() { $('.help-slide-zx.open-customer').trigger('click') }, tabClick(val) { console.log(val) this.isTabs = val.name this.tabsList.offset = 1 this.tabsData(val.name) }, tabsCount() { const _this = this $.ajax({ type: 'GET', url: '/jymessageCenter/ClassCount', data: {}, success: function (res) { if (res && res.status == 1) { _this.counts = res.data } } }) }, tabsData(num) { const _this = this this.loading = true $.ajax({ type: 'POST', url: '/jymessageCenter/messageList', data: { needFilter: 0, msgType: num, isRead: '-1', offset: this.tabsList.offset, pageSize: this.tabsList.pageSize }, success: function (res) { setTimeout(() => { _this.loading = false }, 300) if (res && res.status == 1) { _this.tabsList.lists = [] _this.tabsList.lasts = $.isEmptyObject(res.data.last) ? false : res.data.last _this.tabsList.lists = $.isEmptyObject(res.data.list) ? false : res.data.list _this.tabsList.totals = res.data.total } } }) }, onPageChange(page) { this.tabsList.offset = page this.tabsData(this.isTabs) }, readed(ids, type, url) { const _this = this $.ajax({ type: 'POST', url: '/jymessageCenter/markRead', data: { msgId: ids, msgType: type }, success: function () { _this.tabsData(_this.isTabs) _this.tabsCount() message.checkOpened() message.checkMessage() if (url) { location.href = url } } }) }, clickMesg(logid) { $.ajax({ type: 'GET', url: '/jymessageCenter/clickMessage', data: { msgLogId: logid, platform: '1' }, success: function () { } }) }, linked(id, url, str, num, type, msgLogid) { this.clickMesg(msgLogid) if (str == 0) { this.readed(id, type, url) } else { if (url) { location.href = url } } } } })