index-pc.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. var vm = new Vue({
  2. el: '.mesg-container',
  3. delimiters: ['{', '}'],
  4. data: function () {
  5. return {
  6. loading: false,
  7. activeName: '-1',
  8. counts: [],
  9. // kfCount: 0,
  10. shuntData: {},
  11. shunted: true,
  12. imgSrcObj: {},
  13. tabsList: {
  14. lasts: [],
  15. lists: [],
  16. offset: 1,
  17. pageSize: 20,
  18. totals: 0,
  19. },
  20. // 全部的时候未读消息条数
  21. unread: 0
  22. }
  23. },
  24. created() {
  25. this.activeName = '-1'
  26. this.getList()
  27. // this.kfContacts()
  28. // this.kfData()
  29. },
  30. methods: {
  31. // 获取所有栏目列表数据(包括未读数量)
  32. getList (msgType) {
  33. var _this = this
  34. var type = msgType !== null && msgType !== undefined ? Number(msgType) : -1
  35. var params = {
  36. isColumn: true,
  37. isColumnNewMsg: false,
  38. isMsgList: true,
  39. msgType: type,
  40. isRead: -1,
  41. offset: this.tabsList.offset,
  42. size: this.tabsList.pageSize
  43. }
  44. this.loading = true
  45. $.ajax({
  46. url: '/jyapi/messageCenter/MessageList',
  47. type: 'POST',
  48. data: JSON.stringify(params),
  49. dataType: 'json',
  50. headers: {'Content-Type': 'application/json'},
  51. success:function (res) {
  52. setTimeout(() => {
  53. _this.loading = false
  54. }, 300)
  55. if(res.code === 0) {
  56. _this.counts = res.column || []
  57. for(var item of _this.counts) {
  58. _this.$set(_this.imgSrcObj, item.msg_type, item)
  59. }
  60. _this.tabsList.lists = []
  61. _this.tabsList.lasts = $.isEmptyObject(res.last) ? false : res.last
  62. _this.tabsList.lists = $.isEmptyObject(res.data) ? false : res.data
  63. _this.tabsList.totals = res.total
  64. if(type === -1 ) _this.unread = res.unread
  65. }
  66. },
  67. error:function () {}
  68. })
  69. },
  70. // 私信显示、隐藏
  71. // kfContacts() {
  72. // const _this = this
  73. // $.post({
  74. // url: '/jyapi/social/obtainShunt',// 分流
  75. // type: 'POST',
  76. // data: JSON.stringify({type: 'PC', isFind: true}),
  77. // contentType: 'application/json',
  78. // success: function (res) {
  79. // _this.shuntData = res.data
  80. // }
  81. // })
  82. // },
  83. // 私信数量
  84. // kfData() {
  85. // const _this = this
  86. // $.ajax({
  87. // type: 'POST',
  88. // url: '/jyapi/message/messageCount',
  89. // data: JSON.stringify({userType: 2}),
  90. // contentType: 'application/json',
  91. // success: function (res) {
  92. // _this.kfCount = res.count
  93. // }
  94. // })
  95. // },
  96. kfHref() {
  97. // 跳转到会话列表(不传userId右侧展示为缺省页)
  98. location.href = '/page_pc_social/customer?mini=1'
  99. },
  100. kfClick() {
  101. // $('.help-slide-zx.open-customer').trigger('click')
  102. goCustomerUrl({ openNewWindow: true })
  103. },
  104. tabClick(val) {
  105. this.tabsList.offset = 1
  106. this.getList(val.name)
  107. },
  108. onPageChange(page) {
  109. this.tabsList.offset = page
  110. this.getList(this.activeName)
  111. },
  112. readed(id, url) {
  113. const _this = this
  114. $.ajax({
  115. type: 'POST',
  116. url: '/jyapi/messageCenter/markRead',
  117. data: JSON.stringify({
  118. msgId: id ? Number(id) : null
  119. }),
  120. headers: {'Content-Type': 'application/json'},
  121. success: function () {
  122. window.__canNextReadMessageStatus = false
  123. if(message){
  124. message.getMessageList()
  125. }
  126. _this.getList(_this.activeName)
  127. if (url) {
  128. location.href = url
  129. }
  130. }
  131. })
  132. },
  133. // 消息统计
  134. clickMesg(logid) {
  135. $.ajax({
  136. type: 'POST',
  137. url: '/jyapi/messageCenter/msgOpenLog',
  138. data: JSON.stringify({
  139. msgLogId: logid ? Number(logid) : null,
  140. platform: 1
  141. }),
  142. headers: {'Content-Type': 'application/json'},
  143. success: function () { }
  144. })
  145. },
  146. linked(item) {
  147. if (window.__canNextReadMessageStatus) {
  148. return
  149. }
  150. window.__canNextReadMessageStatus = true
  151. this.clickMesg(item.msgLogId)
  152. if (item.isRead == 0) {
  153. this.readed(item.id, item.link)
  154. } else {
  155. window.__canNextReadMessageStatus = false
  156. if (item.link) {
  157. location.href = item.link
  158. }
  159. }
  160. },
  161. // 清楚未读
  162. cleanNoRead() {
  163. var _this = this
  164. if(!this.unread) {
  165. return
  166. }
  167. $.ajax({
  168. url: '/jyapi/messageCenter/ClearUnreadMsg',
  169. type: 'POST',
  170. success:function () {
  171. this.activeName = '-1'
  172. _this.getList()
  173. if(message){
  174. message.getMessageList()
  175. }
  176. },
  177. error:function () {}
  178. })
  179. },
  180. beforeLeave (val) {
  181. if(val === '999') {
  182. this.kfHref()
  183. return false
  184. }
  185. },
  186. jumpPushPage () {
  187. location.href = '/page_workDesktop/work-bench/app/big/push_setting'
  188. }
  189. }
  190. })