index-pc.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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.init()
  26. // this.kfContacts()
  27. // this.kfData()
  28. },
  29. methods: {
  30. init () {
  31. this.activeName = '-1'
  32. this.getList()
  33. },
  34. // 获取所有栏目列表数据(包括未读数量)
  35. getList (msgType) {
  36. var _this = this
  37. var type = msgType !== null && msgType !== undefined ? Number(msgType) : -1
  38. var params = {
  39. isColumn: true,
  40. isColumnNewMsg: false,
  41. isMsgList: true,
  42. msgType: type,
  43. isRead: -1,
  44. offset: this.tabsList.offset,
  45. size: this.tabsList.pageSize
  46. }
  47. this.loading = true
  48. $.ajax({
  49. url: '/jyapi/messageCenter/MessageList',
  50. type: 'POST',
  51. data: JSON.stringify(params),
  52. dataType: 'json',
  53. headers: {'Content-Type': 'application/json'},
  54. success:function (res) {
  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. complete: function () {
  69. setTimeout(() => {
  70. _this.loading = false
  71. }, 100)
  72. }
  73. })
  74. },
  75. // 私信显示、隐藏
  76. // kfContacts() {
  77. // const _this = this
  78. // $.post({
  79. // url: '/jyapi/social/obtainShunt',// 分流
  80. // type: 'POST',
  81. // data: JSON.stringify({type: 'PC', isFind: true}),
  82. // contentType: 'application/json',
  83. // success: function (res) {
  84. // _this.shuntData = res.data
  85. // }
  86. // })
  87. // },
  88. // 私信数量
  89. // kfData() {
  90. // const _this = this
  91. // $.ajax({
  92. // type: 'POST',
  93. // url: '/jyapi/message/messageCount',
  94. // data: JSON.stringify({userType: 2}),
  95. // contentType: 'application/json',
  96. // success: function (res) {
  97. // _this.kfCount = res.count
  98. // }
  99. // })
  100. // },
  101. kfHref() {
  102. // 跳转到会话列表(不传userId右侧展示为缺省页)
  103. location.href = '/page_pc_social/customer?mini=1'
  104. },
  105. kfClick() {
  106. // $('.help-slide-zx.open-customer').trigger('click')
  107. goCustomerUrl({ openNewWindow: true })
  108. },
  109. tabClick(val) {
  110. this.tabsList.offset = 1
  111. this.getList(val.name)
  112. },
  113. onPageChange(page) {
  114. this.tabsList.offset = page
  115. this.getList(this.activeName)
  116. },
  117. readed(id, url) {
  118. const _this = this
  119. $.ajax({
  120. type: 'POST',
  121. url: '/jyapi/messageCenter/markRead',
  122. data: JSON.stringify({
  123. msgId: id ? Number(id) : null
  124. }),
  125. headers: {'Content-Type': 'application/json'},
  126. success: function () {
  127. window.__canNextReadMessageStatus = false
  128. if(message){
  129. message.getMessageList()
  130. }
  131. if (url) {
  132. _this.init()
  133. location.href = url
  134. } else {
  135. _this.getList(_this.activeName)
  136. }
  137. }
  138. })
  139. },
  140. // 消息统计
  141. clickMesg(logid) {
  142. $.ajax({
  143. type: 'POST',
  144. url: '/jyapi/messageCenter/msgOpenLog',
  145. data: JSON.stringify({
  146. msgLogId: logid ? Number(logid) : null,
  147. platform: 1
  148. }),
  149. headers: {'Content-Type': 'application/json'},
  150. success: function () { }
  151. })
  152. },
  153. linked(item) {
  154. if (window.__canNextReadMessageStatus) {
  155. return
  156. }
  157. window.__canNextReadMessageStatus = true
  158. this.clickMesg(item.msgLogId)
  159. if (item.isRead == 0) {
  160. this.readed(item.id, item.link)
  161. } else {
  162. window.__canNextReadMessageStatus = false
  163. if (item.link) {
  164. location.href = item.link
  165. }
  166. }
  167. },
  168. // 清楚未读
  169. cleanNoRead() {
  170. var _this = this
  171. if(!this.unread) {
  172. return
  173. }
  174. $.ajax({
  175. url: '/jyapi/messageCenter/ClearUnreadMsg',
  176. type: 'POST',
  177. success:function () {
  178. this.activeName = '-1'
  179. _this.getList()
  180. if(message){
  181. message.getMessageList()
  182. }
  183. },
  184. error:function () {}
  185. })
  186. },
  187. beforeLeave (val) {
  188. if(val === '999') {
  189. this.kfHref()
  190. return false
  191. }
  192. },
  193. jumpPushPage () {
  194. location.href = '/page_workDesktop/work-bench/app/big/push_setting'
  195. }
  196. }
  197. })