index-pc.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. isTabs: '',
  10. imgSrcs: [
  11. {type: '0', title: '全部', url:'/images/pc/quanbu@2x.png'},{type: '1', title: '活动优惠', url:'/images/pc/huodong@2x.png'},
  12. {type: '2', title: '服务通知', url:'/images/pc/fuwu@2x.png'},{type: '3', title: '订阅消息', url:'/images/pc/dingyue@2x.png'},
  13. {type: '4', title: '项目动态', url:'/images/pc/xiangmu@2x.png'},{type: '5', title: '企业动态', url:'/images/pc/qiye@2x.png'},
  14. {type: '6', title: '分析报告', url:'/images/pc/fenxi@2x.png'},{type: '7', title: '系统通知', url:'/images/pc/xitong@2x.png'}
  15. ],
  16. tabsList: {
  17. lasts: [],
  18. lists: [],
  19. offset: 1,
  20. pageSize: 20,
  21. totals: 0,
  22. }
  23. }
  24. },
  25. created() {
  26. this.tabsCount()
  27. this.tabsData('0')
  28. },
  29. methods: {
  30. tabClick(val) {
  31. this.isTabs = val.name
  32. this.tabsList.offset = 1
  33. this.tabsData(val.name)
  34. },
  35. tabsCount() {
  36. const _this = this
  37. $.ajax({
  38. type:'GET',
  39. url:'/jymessageCenter/ClassCount',
  40. data: {},
  41. success:function (res) {
  42. if (res && res.status == 1) {
  43. _this.counts = res.data
  44. }
  45. }
  46. })
  47. },
  48. tabsData(num) {
  49. const _this = this
  50. this.loading = true
  51. $.ajax({
  52. type:'POST',
  53. url:'/jymessageCenter/messageList',
  54. data: {
  55. needFilter: 0,
  56. msgType: num,
  57. isRead: '-1',
  58. offset: this.tabsList.offset,
  59. pageSize: this.tabsList.pageSize
  60. },
  61. success:function (res) {
  62. setTimeout(() => {
  63. _this.loading = false
  64. }, 300)
  65. if (res && res.status == 1) {
  66. _this.tabsList.lists = []
  67. _this.tabsList.lasts = $.isEmptyObject(res.data.last) ? false : res.data.last
  68. _this.tabsList.lists = $.isEmptyObject(res.data.list) ? false : res.data.list
  69. _this.tabsList.totals = res.data.total
  70. }
  71. }
  72. })
  73. },
  74. onPageChange(page) {
  75. this.tabsList.offset = page
  76. this.tabsData(this.isTabs)
  77. },
  78. readed(ids, type, url) {
  79. const _this = this
  80. $.ajax({
  81. type: 'POST',
  82. url:'/jymessageCenter/markRead',
  83. data: {
  84. msgId: ids,
  85. msgType: type
  86. },
  87. success:function () {
  88. _this.tabsData(_this.isTabs)
  89. _this.tabsCount()
  90. message.checkOpened()
  91. message.checkMessage()
  92. if (url) {
  93. location.href = url
  94. }
  95. }
  96. })
  97. },
  98. clickMesg(logid) {
  99. $.ajax({
  100. type: 'GET',
  101. url: '/jymessageCenter/clickMessage',
  102. data: {
  103. msgLogId: logid,
  104. platform: '1'
  105. },
  106. success:function () {}
  107. })
  108. },
  109. linked(id, url, str, num, type, msgLogid) {
  110. this.clickMesg(msgLogid)
  111. if (str == 0) {
  112. this.readed(id, type, url)
  113. } else {
  114. if (url) {
  115. location.href = url
  116. }
  117. }
  118. }
  119. }
  120. })