index-pc.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. var vm = new Vue({
  2. el: '.mesg-container',
  3. delimiters: ['{', '}'],
  4. data: function () {
  5. return {
  6. loading: false,
  7. activeName: '0',
  8. counts: [],
  9. kfCount: 0,
  10. isTabs: '',
  11. shuntData: {},
  12. shunted: true,
  13. imgSrcs: [
  14. { type: '0', title: '全部', url: '/images/pc/quanbu@2x.png' }, { type: '1', title: '活动优惠', url: '/images/pc/huodong@2x.png' },
  15. { type: '2', title: '服务通知', url: '/images/pc/fuwu@2x.png' }, { type: '3', title: '订阅消息', url: '/images/pc/dingyue@2x.png' },
  16. { type: '4', title: '项目动态', url: '/images/pc/xiangmu@2x.png' }, { type: '5', title: '企业动态', url: '/images/pc/qiye@2x.png' },
  17. { type: '6', title: '分析报告', url: '/images/pc/fenxi@2x.png' }, { type: '7', title: '系统通知', url: '/images/pc/xitong@2x.png' },
  18. { type: '8', title: '私信', url: '/images/pc/sixin@2x.png' }
  19. ],
  20. tabsList: {
  21. lasts: [],
  22. lists: [],
  23. offset: 1,
  24. pageSize: 20,
  25. totals: 0,
  26. }
  27. }
  28. },
  29. created() {
  30. this.tabsCount()
  31. this.tabsData('0')
  32. this.kfContacts()
  33. this.kfData()
  34. },
  35. methods: {
  36. // 私信显示、隐藏
  37. kfContacts() {
  38. const _this = this
  39. $.post({
  40. url: '/jyapi/social/obtainShunt',// 分流
  41. type: 'POST',
  42. data: JSON.stringify({type: 'PC', isFind: true}),
  43. contentType: 'application/json',
  44. success: function (res) {
  45. _this.shuntData = res.data
  46. }
  47. })
  48. },
  49. // 私信数量
  50. kfData() {
  51. const _this = this
  52. $.ajax({
  53. type: 'POST',
  54. url: '/jyapi/message/messageCount',
  55. data: JSON.stringify({userType: 2}),
  56. contentType: 'application/json',
  57. success: function (res) {
  58. _this.kfCount = res.count
  59. }
  60. })
  61. },
  62. kfHref() {
  63. // 跳转到会话列表(不传userId右侧展示为缺省页)
  64. location.href = '/page_pc_social/customer?mini=1'
  65. },
  66. kfClick() {
  67. $('.help-slide-zx.open-customer').trigger('click')
  68. },
  69. tabClick(val) {
  70. console.log(val)
  71. this.isTabs = val.name
  72. this.tabsList.offset = 1
  73. this.tabsData(val.name)
  74. },
  75. tabsCount() {
  76. const _this = this
  77. $.ajax({
  78. type: 'GET',
  79. url: '/jymessageCenter/ClassCount',
  80. data: {},
  81. success: function (res) {
  82. if (res && res.status == 1) {
  83. _this.counts = res.data
  84. }
  85. }
  86. })
  87. },
  88. tabsData(num) {
  89. const _this = this
  90. this.loading = true
  91. $.ajax({
  92. type: 'POST',
  93. url: '/jymessageCenter/messageList',
  94. data: {
  95. needFilter: 0,
  96. msgType: num,
  97. isRead: '-1',
  98. offset: this.tabsList.offset,
  99. pageSize: this.tabsList.pageSize
  100. },
  101. success: function (res) {
  102. setTimeout(() => {
  103. _this.loading = false
  104. }, 300)
  105. if (res && res.status == 1) {
  106. _this.tabsList.lists = []
  107. _this.tabsList.lasts = $.isEmptyObject(res.data.last) ? false : res.data.last
  108. _this.tabsList.lists = $.isEmptyObject(res.data.list) ? false : res.data.list
  109. _this.tabsList.totals = res.data.total
  110. }
  111. }
  112. })
  113. },
  114. onPageChange(page) {
  115. this.tabsList.offset = page
  116. this.tabsData(this.isTabs)
  117. },
  118. readed(ids, type, url) {
  119. const _this = this
  120. $.ajax({
  121. type: 'POST',
  122. url: '/jymessageCenter/markRead',
  123. data: {
  124. msgId: ids,
  125. msgType: type
  126. },
  127. success: function () {
  128. _this.tabsData(_this.isTabs)
  129. _this.tabsCount()
  130. message.checkOpened()
  131. message.checkMessage()
  132. if (url) {
  133. location.href = url
  134. }
  135. }
  136. })
  137. },
  138. clickMesg(logid) {
  139. $.ajax({
  140. type: 'GET',
  141. url: '/jymessageCenter/clickMessage',
  142. data: {
  143. msgLogId: logid,
  144. platform: '1'
  145. },
  146. success: function () { }
  147. })
  148. },
  149. linked(id, url, str, num, type, msgLogid) {
  150. this.clickMesg(msgLogid)
  151. if (str == 0) {
  152. this.readed(id, type, url)
  153. } else {
  154. if (url) {
  155. location.href = url
  156. }
  157. }
  158. }
  159. }
  160. })