index-pc.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. var vm = new Vue({
  2. el: '.mesg-container',
  3. delimiters: ['{', '}'],
  4. data: function () {
  5. return {
  6. activeName: '0',
  7. counts: [],
  8. isTabs: '',
  9. imgSrcs: [
  10. {type: '0', title: '全部', url:'/images/pc/quanbu@2x.png'},{type: '1', title: '活动优惠', url:'/images/pc/huodong@2x.png'},
  11. {type: '2', title: '服务通知', url:'/images/pc/fuwu@2x.png'},{type: '3', title: '订阅消息', url:'/images/pc/dingyue@2x.png'},
  12. {type: '4', title: '项目动态', url:'/images/pc/xiangmu@2x.png'},{type: '5', title: '企业动态', url:'/images/pc/qiye@2x.png'},
  13. {type: '6', title: '分析报告', url:'/images/pc/fenxi@2x.png'},{type: '7', title: '系统通知', url:'/images/pc/xitong@2x.png'}
  14. ],
  15. tabsList: {
  16. lasts: [],
  17. lists: [],
  18. offset: 1,
  19. pageSize: 20,
  20. totals: 0,
  21. }
  22. }
  23. },
  24. created() {
  25. this.tabsCount()
  26. this.tabsData('0')
  27. },
  28. methods: {
  29. tabClick(val) {
  30. this.isTabs = val.name
  31. this.tabsList.lists = []
  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. $.ajax({
  51. type:'POST',
  52. url:'/jymessageCenter/messageList',
  53. data: {
  54. needFilter: 0,
  55. msgType: num,
  56. isRead: '-1',
  57. offset: this.tabsList.offset,
  58. pageSize: this.tabsList.pageSize
  59. },
  60. success:function (res) {
  61. if (res && res.status == 1) {
  62. _this.tabsList.lasts = $.isEmptyObject(res.data.last) ? false : res.data.last
  63. _this.tabsList.lists = $.isEmptyObject(res.data.list) ? false : res.data.list
  64. _this.tabsList.totals = res.data.total
  65. }
  66. }
  67. })
  68. },
  69. onPageChange(page) {
  70. this.tabsList.offset = page
  71. this.tabsList.lists = []
  72. this.tabsData(this.isTabs)
  73. },
  74. readed(ids) {
  75. const _this = this
  76. $.ajax({
  77. type:'GET',
  78. url:'/jymessageCenter/markRead',
  79. data: {
  80. msgId: ids
  81. },
  82. success:function () {
  83. _this.tabsData(_this.isTabs)
  84. _this.tabsCount()
  85. message.checkOpened()
  86. }
  87. })
  88. },
  89. linked(id, url, str, num) {
  90. if (url) {
  91. location.href = url
  92. }
  93. if (num == 1) {
  94. if (url) {
  95. this.readed(id)
  96. }
  97. }
  98. if (num == 2) {
  99. if (!str) {
  100. this.readed(id)
  101. }
  102. }
  103. }
  104. }
  105. })