123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- var vm = new Vue({
- el: '.mesg-container',
- delimiters: ['{', '}'],
- data: function () {
- return {
- loading: false,
- activeName: '-1',
- counts: [],
- // kfCount: 0,
- shuntData: {},
- shunted: true,
- imgSrcObj: {},
- tabsList: {
- lasts: [],
- lists: [],
- offset: 1,
- pageSize: 20,
- totals: 0,
- },
- // 全部的时候未读消息条数
- unread: 0
- }
- },
- created() {
- this.init()
- // this.kfContacts()
- // this.kfData()
- },
- methods: {
- init () {
- if (getParam('type')) {
- this.activeName = getParam('type')
- window.history.replaceState({}, document.title, location.pathname);
- } else {
- this.activeName = '-1'
- }
- this.getList(this.activeName)
- },
- // 获取所有栏目列表数据(包括未读数量)
- getList (msgType) {
- var _this = this
- var type = msgType !== null && msgType !== undefined ? Number(msgType) : -1
- var params = {
- isColumn: true,
- isColumnNewMsg: false,
- isMsgList: true,
- msgType: type,
- isRead: -1,
- offset: this.tabsList.offset,
- size: this.tabsList.pageSize
- }
- this.loading = true
- $.ajax({
- url: '/jyapi/messageCenter/MessageList',
- type: 'POST',
- data: JSON.stringify(params),
- dataType: 'json',
- headers: {'Content-Type': 'application/json'},
- success:function (res) {
- if(res.code === 0) {
- _this.counts = res.column || []
- for(var item of _this.counts) {
- _this.$set(_this.imgSrcObj, item.msg_type, item)
- }
- _this.tabsList.lists = []
- _this.tabsList.lasts = $.isEmptyObject(res.last) ? false : res.last
- _this.tabsList.lists = $.isEmptyObject(res.data) ? false : res.data
- _this.tabsList.totals = res.total
- _this.unread = res.unread
- }
- },
- error:function () {},
- complete: function () {
- setTimeout(() => {
- _this.loading = false
- }, 100)
- }
- })
- },
- // 私信显示、隐藏
- // 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')
- goCustomerUrl({ openNewWindow: true })
- },
- tabClick(val) {
- this.tabsList.offset = 1
- this.activeName = val.name
- this.getList(val.name)
- },
- onPageChange(page) {
- this.tabsList.offset = page
- this.getList(this.activeName)
- },
- readed(id, url) {
- const _this = this
- $.ajax({
- type: 'POST',
- url: '/jyapi/messageCenter/markRead',
- data: JSON.stringify({
- msgId: id ? Number(id) : null
- }),
- headers: {'Content-Type': 'application/json'},
- success: function () {
- window.__canNextReadMessageStatus = false
- if(message){
- message.getMessageList()
- }
- if (url) {
- _this.init()
- location.href = url
- } else {
- _this.getList(_this.activeName)
- }
- }
- })
- },
- // 消息统计
- clickMesg(logid) {
- $.ajax({
- type: 'POST',
- url: '/jyapi/messageCenter/msgOpenLog',
- data: JSON.stringify({
- msgLogId: logid ? Number(logid) : null,
- platform: 1
- }),
- headers: {'Content-Type': 'application/json'},
- success: function () { }
- })
- },
- linked(item) {
- if (window.__canNextReadMessageStatus) {
- return
- }
- window.__canNextReadMessageStatus = true
- this.clickMesg(item.msgLogId)
- if (item.isRead == 0) {
- this.readed(item.id, item.link)
- } else {
- window.__canNextReadMessageStatus = false
- if (item.link) {
- location.href = item.link
- }
- }
- },
- // 清楚未读
- cleanNoRead() {
- var _this = this
- if(!this.unread) {
- return
- }
- $.ajax({
- url: '/jyapi/messageCenter/ClearUnreadMsg',
- type: 'POST',
- success:function () {
- _this.activeName = '-1'
- _this.getList()
- if(message){
- message.getMessageList()
- }
- },
- error:function () {}
- })
- },
- beforeLeave (val) {
- if(val === '999') {
- this.kfHref()
- return false
- }
- },
- jumpPushPage () {
- location.href = '/page_workDesktop/work-bench/app/big/push_setting'
- }
- }
- })
|