detail.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div class="detailBody">
  3. <div class="detailBox">
  4. <div class="detailTitle">{{title}}</div>
  5. <div class="detailTime">{{releaseTime}}</div>
  6. <!-- <div class="noticeTitle">这是通知内容</div>-->
  7. <!-- 这里用v-html-->
  8. <div class="noticeInfo" v-html="content"></div>
  9. <div class="file">
  10. 附件:
  11. <div style="width: 100%;height: 100%" class="img-list" v-if="imgUrlList.length>0">
  12. <img style="width: 100%;height: 100%" v-for="item in imgUrlList" :src="item.url" alt="" />
  13. </div>
  14. <div v-for="item in fileUrlList" style=" font-size: 16px; margin: 10px;color: #0000FF" @click="jumpFile(item)">
  15. {{item.name}}
  16. </div>
  17. </div>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. import { userNoticeAdd,getUserLocalStorageInfo,getParkNoticeById,getPropertyNoticeById } from "@/js_sdk/http";
  23. export default {
  24. name: "detail",
  25. data(){
  26. return{
  27. getUserLocalStorageInfo: getUserLocalStorageInfo(),
  28. type:'',
  29. id:'',
  30. title:'',
  31. releaseTime:'',
  32. content:'',
  33. imgUrlList:[],
  34. fileUrlList:[]
  35. }
  36. },
  37. onLoad({type}){
  38. // console.log(JSON.parse(type))
  39. const item = JSON.parse(type)
  40. this.type = item.type
  41. this.id = item.id
  42. if(item.readStatus === '1'){
  43. userNoticeAdd({
  44. noticeId:item.id,
  45. userId:this.getUserLocalStorageInfo.userId,
  46. type:item.type
  47. }).then(res=>{
  48. })
  49. }
  50. },
  51. mounted(){
  52. this.selectById()
  53. },
  54. methods:{
  55. jumpFile(item) {
  56. console.log(window.location.href)
  57. console.log(window.location.href.split('#')[0])
  58. wx.miniProgram.navigateTo({ url: '/pages/file/download?callBackUrl=' + encodeURIComponent(window.location.href.split('#')[0]) +
  59. '&url=' + item.url })
  60. },
  61. selectById() {
  62. const _this = this
  63. if (_this.type === '1') {
  64. getParkNoticeById({ id: _this.id }).then((res) => {
  65. const data = res.data
  66. _this.title = data.title
  67. if (data.content.indexOf('src=') !== -1) {
  68. data.content = data.content.replace('server', 'smartParkH5Server')
  69. }
  70. if (data.content.indexOf('width') !== -1 && data.content.indexOf('height') !== -1) {
  71. data.content = data.content.replace(/width="(\S*)"/, 'width="100%"').replace(/height="(\S*)"/, 'height="100%"')
  72. }
  73. _this.content = data.content
  74. _this.releaseTime = _this.$common.transServDate(data.releaseTime)
  75. if (data.fileUrl && data.fileUrl.length > 2) {
  76. const themeUrlList = []
  77. const imgUrlList = []
  78. const files = JSON.parse(data.fileUrl)
  79. files.forEach(item => {
  80. if (item.url) {
  81. const ul = {
  82. name: item.name,
  83. url: item.url.replace('server', 'smartParkH5Server')
  84. }
  85. if (item.name.indexOf('png') > -1 || item.name.indexOf('jpg') > -1 || item.name.indexOf('jpeg') > -1) {
  86. imgUrlList.push(ul)
  87. } else {
  88. themeUrlList.push(ul)
  89. }
  90. }
  91. })
  92. if (imgUrlList.length > 0) {
  93. _this.imgUrlList = imgUrlList
  94. }
  95. _this.fileUrlList = themeUrlList
  96. }
  97. })
  98. } else {
  99. getPropertyNoticeById({ id: _this.id }).then((res) => {
  100. const data = res.data
  101. _this.title = data.title
  102. if (data.content.indexOf('src=') !== -1) {
  103. data.content = data.content.replace('server', 'smartParkH5Server').replaceAll('class="wscnph"', 'class="wscnph" width="100%"')
  104. }
  105. if (data.content.indexOf('width') !== -1 && data.content.indexOf('height') !== -1) {
  106. data.content = data.content.replace(/width="(\S*)"/, 'width="100%"').replace(/height="(\S*)"/, 'height="100%"')
  107. }
  108. _this.content = data.content
  109. _this.releaseTime = _this.$common.transServDate(data.releaseTime)
  110. if (data.fileUrl && data.fileUrl.length > 2) {
  111. const themeUrlList = []
  112. const imgUrlList = []
  113. const files = JSON.parse(data.fileUrl)
  114. files.forEach(item => {
  115. if (item.url) {
  116. const ul = {
  117. name: item.name,
  118. url: item.url.replace('server', 'smartParkH5Server')
  119. }
  120. if (item.name.indexOf('png') > -1 || item.name.indexOf('jpg') > -1 || item.name.indexOf('jpeg') > -1) {
  121. imgUrlList.push(ul)
  122. } else {
  123. themeUrlList.push(ul)
  124. }
  125. }
  126. })
  127. if (imgUrlList.length > 0) {
  128. _this.imgUrlList = imgUrlList
  129. }
  130. _this.fileUrlList = themeUrlList
  131. }
  132. })
  133. }
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss">
  139. .detailBody{
  140. .detailBox{
  141. margin-top: 24rpx;
  142. background: white;
  143. width: 100%;
  144. height: 1424rpx;
  145. padding: 32rpx;
  146. box-sizing: border-box;
  147. .detailTitle{
  148. font-size: 32rpx;
  149. color: rgba(34, 34, 34, 1);
  150. }
  151. .detailTime{
  152. font-size: 28rpx;
  153. color: rgba(136, 136, 136, 1);
  154. padding: 16rpx 0 24rpx 0;
  155. border-bottom: 1px solid rgba(230, 230, 230, 1);
  156. }
  157. .noticeTitle{
  158. color: rgba(51, 51, 51, 1);
  159. font-size: 28rpx;
  160. padding: 28rpx 0;
  161. }
  162. .noticeInfo{
  163. line-height: 38rpx;
  164. color: rgba(51, 51, 51, 1);
  165. font-size: 28rpx;
  166. }
  167. .file{
  168. padding: 32rpx 0;
  169. font-size: 28rpx;
  170. color: rgba(51, 51, 51, 1);
  171. }
  172. }
  173. }
  174. </style>