detail.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. var vm = new Vue({
  2. el: '#detailed',
  3. delimiters: ['{', '}'],
  4. data () {
  5. return {
  6. tit: '',
  7. imgSrcs: [
  8. {title: '活动优惠', url:'huodong'},
  9. {title: '服务通知', url:'fuwu'},{title: '订阅消息', url:'dingyue'},
  10. {title: '项目动态', url:'xiangmu'},{title: '企业动态', url:'qiye'},
  11. {title: '分析报告', url:'fenxi'},{title: '系统通知', url:'xitong'}
  12. ],
  13. lists: [],
  14. tabsList: {
  15. offset: 1,
  16. pageSize: 20,
  17. totals: 0,
  18. loading: true,
  19. finished: false
  20. }
  21. }
  22. },
  23. created() {
  24. let indx = getQueryString('type')
  25. let nums = getQueryString('num')
  26. if (nums != 0) {
  27. this.setRead(indx)
  28. }
  29. setTimeout(() => {
  30. let wxType = getType()
  31. if (!wxType) {
  32. checkMsgCount(true, 0)
  33. }
  34. }, 300)
  35. this.tit = this.imgSrcs[indx - 1].title
  36. document.title = this.imgSrcs[indx - 1].title
  37. },
  38. mounted () {
  39. iosBackRefresh()
  40. },
  41. updated() {
  42. let el = document.getElementById('descri')
  43. el.scrollTop = el.scrollHeight
  44. },
  45. methods: {
  46. platType() {
  47. let wxType = getType()
  48. if (wxType) {
  49. return 3
  50. } else {
  51. return 2
  52. }
  53. },
  54. // 点击分类修改分类下的消息为已读
  55. setRead(val) {
  56. const _this = this
  57. $.ajax({
  58. type:'POST',
  59. url:'/jymessageCenter/setReadStatus',
  60. data: {
  61. msgType: val
  62. },
  63. success:function () {
  64. // try {
  65. // JyObj.refreshAppointTab('search', 1)
  66. // } catch (error) {
  67. // console.log(error)
  68. // }
  69. }
  70. })
  71. },
  72. appMesg(type) {
  73. const _this = this
  74. $.ajax({
  75. type: 'GET',
  76. url: '/jymessageCenter/appClickMessage',
  77. data: {
  78. msgType: type,
  79. platform: _this.platType(),
  80. offset: this.tabsList.offset,
  81. pageSize: this.tabsList.pageSize
  82. },
  83. success:function () {}
  84. })
  85. },
  86. // 消息详情
  87. msgData() {
  88. const _this = this
  89. this.appMesg(getQueryString('type'))
  90. $.ajax({
  91. type: 'POST',
  92. url: '/jymessageCenter/messageList',
  93. data: {
  94. needFilter: 0,
  95. msgType: getQueryString('type'),
  96. isRead: '-1',
  97. offset: this.tabsList.offset,
  98. pageSize: this.tabsList.pageSize
  99. },
  100. success: function (r) {
  101. if (r && r.status == 1) {
  102. _this.tabsList.offset++
  103. if (_this.tabsList.offset === 1) {
  104. if (r.data.total || r.data.total === 0) {
  105. _this.tabsList.total = r.data.total
  106. } else {
  107. _this.tabsList.finished = true
  108. }
  109. }
  110. if (Array.isArray(r.data.list) && r.data.list.length !== 0) {
  111. setTimeout(() => {
  112. r.data.list.map(function (v) {
  113. _this.lists.unshift({
  114. id: v.id,
  115. msg_type: v.msg_type,
  116. title: v.title,
  117. content: v.content,
  118. createtime: v.createtime,
  119. link: v.link,
  120. url: v.url
  121. })
  122. })
  123. }, 200)
  124. } else {
  125. _this.tabsList.finished = true
  126. }
  127. // _this.tabsList.loading = false
  128. if (_this.tabsList.total !== -1 && _this.tabsList.total <= _this.lists.length) {
  129. _this.tabsList.finished = true
  130. }
  131. }
  132. }
  133. })
  134. },
  135. msgClick(url) {
  136. let wxType = getType()
  137. let appType = androidOrIOS()
  138. if (wxType) {
  139. if (url.weChatUrl) {
  140. //location.href = url.weChatUrl
  141. //链接中如果是www.jianyu360.cn域名,微信中会唤起app,该用window.open
  142. window.open(url.weChatUrl);
  143. } else {
  144. return
  145. }
  146. } else {
  147. const toLink = appType == 'android' ? url.androidUrl : url.iosUrl
  148. if (toLink) {
  149. // 检查是否 tabbar 页面
  150. const tabbarKey = utils.checkNowInAppTabbarPage(toLink)
  151. if (tabbarKey) {
  152. try {
  153. // 刷新对应 tabbar 并切换
  154. JyObj.refreshAppointTab(tabbarKey,1)
  155. JyObj.skipAppointTab(tabbarKey)
  156. } catch (e) {
  157. console.warn(e)
  158. }
  159. } else {
  160. location.href = toLink
  161. }
  162. }
  163. return
  164. }
  165. }
  166. }
  167. })