index.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. var vm = new Vue({
  2. el: '#mesged',
  3. delimiters: ['{', '}'],
  4. data: function () {
  5. return {
  6. isToggle: false,
  7. isRow: false,
  8. lastData: [],
  9. msgList: [],
  10. timer: null,
  11. imgSrcs: [
  12. {title: '活动优惠', url:'huodong'},
  13. {title: '服务通知', url:'fuwu'},{title: '订阅消息', url:'dingyue'},
  14. {title: '项目动态', url:'xiangmu'},{title: '企业动态', url:'qiye'},
  15. {title: '分析报告', url:'fenxi'},{title: '系统通知', url:'xitong'}
  16. ]
  17. }
  18. },
  19. created() {
  20. Object.assign(this.$data, this.$options.data())
  21. this.lastMsg()
  22. this.msgData()
  23. let wxType = getType()
  24. if (!wxType) {
  25. checkMsgCount(true, 0)
  26. }
  27. },
  28. mounted () {
  29. iosBackRefresh()
  30. keepQuest()
  31. },
  32. beforeDestroy() {
  33. clearInterval(this.timer)
  34. },
  35. methods: {
  36. // 置顶消息
  37. lastMsg() {
  38. const _this = this
  39. $.ajax({
  40. type:'POST',
  41. url:'/jymessageCenter/lastMessage',
  42. success:function (res) {
  43. if (res && res.status == 1) {
  44. _this.lastData = $.isEmptyObject(res.data) ? false : res.data
  45. if (res.data && res.data.content && res.data.content.length > 46) {
  46. _this.isRow = true
  47. } else {
  48. _this.isRow = false
  49. }
  50. }
  51. }
  52. })
  53. },
  54. // 消息列表
  55. msgData() {
  56. const _this = this
  57. $.ajax({
  58. type:'POST',
  59. url:'/jymessageCenter/classAndNew',
  60. success:function (res) {
  61. if (res && res.status == 1) {
  62. _this.msgList = $.isEmptyObject(res.data) ? false : res.data
  63. }
  64. }
  65. })
  66. },
  67. // 点击置顶消息为已读
  68. topRead(ids, url, type) {
  69. const _this = this
  70. $.ajax({
  71. type:'POST',
  72. url:'/jymessageCenter/markRead',
  73. data: {
  74. msgId: ids,
  75. msgType: type
  76. },
  77. success:function () {
  78. _this.msgData()
  79. if (url) {
  80. if (getType()) {
  81. //链接中如果是www.jianyu360.cn域名,微信中会唤起app,该用window.open
  82. window.open(url)
  83. } else {
  84. location.href = url
  85. }
  86. }
  87. }
  88. })
  89. },
  90. platType() {
  91. let wxType = getType()
  92. if (wxType) {
  93. return 3
  94. } else {
  95. return 2
  96. }
  97. },
  98. clickMesg(logid) {
  99. const _this = this
  100. $.ajax({
  101. type: 'GET',
  102. url: '/jymessageCenter/clickMessage',
  103. data: {
  104. msgLogId: logid,
  105. platform: _this.platType()
  106. },
  107. success:function () {}
  108. })
  109. },
  110. // 置顶消息跳转
  111. msgClick(url, num, ids, type, logid) {
  112. this.clickMesg(logid)
  113. let wxType = getType()
  114. let appType = androidOrIOS()
  115. if (wxType) {
  116. if (!num) {
  117. this.topRead(ids, url.weChatUrl, type)
  118. } else {
  119. if (url.weChatUrl) {
  120. //location.href = url.weChatUrl
  121. //链接中如果是www.jianyu360.cn域名,微信中会唤起app,该用window.open
  122. window.open(url.weChatUrl);
  123. }
  124. }
  125. } else {
  126. if (appType == 'android') {
  127. if (!num) {
  128. this.topRead(ids, url.androidUrl, type)
  129. } else {
  130. if (url.androidUrl) {
  131. location.href = url.androidUrl
  132. }
  133. }
  134. } else {
  135. if (!num) {
  136. this.topRead(ids, url.iosUrl, type)
  137. } else {
  138. if (url.iosUrl) {
  139. location.href = url.iosUrl
  140. }
  141. }
  142. }
  143. }
  144. },
  145. // 置顶消息展开,收起
  146. toggleClick() {
  147. this.isToggle = !this.isToggle
  148. },
  149. // 列表消息跳转详情页
  150. msgDetailed(type, num) {
  151. let wxType = getType()
  152. if (wxType) {
  153. location.href = '/weixin/frontPage/messageCenter/sess/detail?type=' + type + '&num=' + num
  154. } else {
  155. location.href = '/jyapp/frontPage/messageCenter/sess/detail?type=' + type + '&num=' + num
  156. }
  157. }
  158. }
  159. })