index-pc.js 5.3 KB

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