detail.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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: 200rpx;height: 200rpx" 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. import constant from "../../utils/constant";
  24. export default {
  25. name: "detail",
  26. data(){
  27. return{
  28. getUserLocalStorageInfo: getUserLocalStorageInfo(),
  29. type:'',
  30. id:'',
  31. title:'',
  32. releaseTime:'',
  33. content:'',
  34. imgUrlList:[],
  35. fileUrlList:[]
  36. }
  37. },
  38. onLoad({type}){
  39. // console.log(JSON.parse(type))
  40. const item = JSON.parse(type)
  41. this.type = item.type
  42. this.id = item.id
  43. if(item.readStatus === '1'){
  44. userNoticeAdd({
  45. noticeId:item.id,
  46. userId:this.getUserLocalStorageInfo.userId,
  47. type:item.type
  48. }).then(res=>{
  49. })
  50. }
  51. },
  52. mounted(){
  53. this.selectById()
  54. },
  55. methods:{
  56. jumpFile(item) {
  57. console.log(window.location.href)
  58. console.log(window.location.href.split('#')[0])
  59. wx.miniProgram.navigateTo({ url: '/pages/file/download?callBackUrl=' + encodeURIComponent(window.location.href.split('#')[0]) +
  60. '&url=' + item.url })
  61. },
  62. selectById() {
  63. const _this = this
  64. if (_this.type === '1') {
  65. getParkNoticeById({ id: _this.id }).then((res) => {
  66. const data = res.data
  67. _this.title = data.title
  68. if (data.content.indexOf('src=') !== -1) {
  69. data.content = data.content.replace('server', 'smartParkH5Server')
  70. }
  71. if (data.content.indexOf('width') !== -1 && data.content.indexOf('height') !== -1) {
  72. data.content = data.content.replace(/width="(\S*)"/, 'width="100%"').replace(/height="(\S*)"/, 'height="100%"')
  73. }
  74. _this.content = data.content
  75. _this.releaseTime = _this.$common.transServDate(data.releaseTime)
  76. if (data.fileUrl && data.fileUrl.length > 2) {
  77. const themeUrlList = []
  78. // const imgUrlList = []
  79. const files = JSON.parse(data.fileUrl)
  80. files.forEach(item => {
  81. if (item.url) {
  82. const ul = {
  83. name: item.name,
  84. url: item.url.replace('server', 'smartParkH5Server')
  85. }
  86. // if (item.name.indexOf('png') > -1 || item.name.indexOf('jpg') > -1 || item.name.indexOf('jpeg') > -1) {
  87. // imgUrlList.push(ul)
  88. // } else {
  89. // themeUrlList.push(ul)
  90. // }
  91. themeUrlList.push(ul)
  92. }
  93. })
  94. // if (imgUrlList.length > 0) {
  95. // _this.imgUrlList = imgUrlList
  96. // }
  97. _this.fileUrlList = themeUrlList
  98. }
  99. if (data.picture) {
  100. const imgUrlList = []
  101. data.picture.split(',').forEach(v => {
  102. if (v) {
  103. imgUrlList.push({
  104. url: constant.BASE_URI + '/FileController/download/' + v,
  105. id: v
  106. })
  107. }
  108. })
  109. _this.imgUrlList = imgUrlList
  110. }
  111. })
  112. } else {
  113. getPropertyNoticeById({ id: _this.id }).then((res) => {
  114. const data = res.data
  115. _this.title = data.title
  116. if (data.content.indexOf('src=') !== -1) {
  117. data.content = data.content.replace('server', 'smartParkH5Server').replaceAll('class="wscnph"', 'class="wscnph" width="100%"')
  118. }
  119. if (data.content.indexOf('width') !== -1 && data.content.indexOf('height') !== -1) {
  120. data.content = data.content.replace(/width="(\S*)"/, 'width="100%"').replace(/height="(\S*)"/, 'height="100%"')
  121. }
  122. _this.content = data.content
  123. _this.releaseTime = _this.$common.transServDate(data.releaseTime)
  124. if (data.fileUrl && data.fileUrl.length > 2) {
  125. const themeUrlList = []
  126. // const imgUrlList = []
  127. const files = JSON.parse(data.fileUrl)
  128. files.forEach(item => {
  129. if (item.url) {
  130. const ul = {
  131. name: item.name,
  132. url: item.url.replace('server', 'smartParkH5Server')
  133. }
  134. // if (item.name.indexOf('png') > -1 || item.name.indexOf('jpg') > -1 || item.name.indexOf('jpeg') > -1) {
  135. // imgUrlList.push(ul)
  136. // } else {
  137. // themeUrlList.push(ul)
  138. // }
  139. themeUrlList.push(ul)
  140. }
  141. })
  142. // if (imgUrlList.length > 0) {
  143. // _this.imgUrlList = imgUrlList
  144. // }
  145. _this.fileUrlList = themeUrlList
  146. }
  147. if (data.picture) {
  148. const imgUrlList = []
  149. data.picture.split(',').forEach(v => {
  150. if (v) {
  151. imgUrlList.push({
  152. url: constant.BASE_URI + '/FileController/download/' + v,
  153. id: v
  154. })
  155. }
  156. })
  157. _this.imgUrlList = imgUrlList
  158. }
  159. })
  160. }
  161. }
  162. }
  163. }
  164. </script>
  165. <style lang="scss">
  166. .detailBody{
  167. .detailBox{
  168. margin-top: 24rpx;
  169. background: white;
  170. width: 100%;
  171. height: 1424rpx;
  172. padding: 32rpx;
  173. box-sizing: border-box;
  174. .detailTitle{
  175. font-size: 32rpx;
  176. color: rgba(34, 34, 34, 1);
  177. }
  178. .detailTime{
  179. font-size: 28rpx;
  180. color: rgba(136, 136, 136, 1);
  181. padding: 16rpx 0 24rpx 0;
  182. border-bottom: 1px solid rgba(230, 230, 230, 1);
  183. }
  184. .noticeTitle{
  185. color: rgba(51, 51, 51, 1);
  186. font-size: 28rpx;
  187. padding: 28rpx 0;
  188. }
  189. .noticeInfo{
  190. line-height: 38rpx;
  191. color: rgba(51, 51, 51, 1);
  192. font-size: 28rpx;
  193. }
  194. .file{
  195. padding: 32rpx 0;
  196. font-size: 28rpx;
  197. color: rgba(51, 51, 51, 1);
  198. }
  199. }
  200. }
  201. </style>