newsDetail.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <view class="main">
  3. <view class="popupBottom" v-if="previewModal" @touchmove.stop.prevent="moveStop">
  4. <view class="popupSwiperBg" @click="previewModal = false"></view>
  5. <view class="swiperDotBox">
  6. <swiper class="swiperBox" @change="swiperChange" :current="previewIndex - 1">
  7. <swiper-item v-for="(item, index) in detail.clueInfoList" :key="index">
  8. <image
  9. :src="item.localUrl"
  10. class="swiperFileItem"
  11. v-if="item.type == '1'"
  12. mode="aspectFit"
  13. @click="previewModal = false"
  14. ></image>
  15. <video
  16. :src="item.localUrl"
  17. class="swiperFileItem"
  18. :show-fullscreen-btn="false"
  19. controls
  20. ></video>
  21. <video
  22. </swiper-item>
  23. </swiper>
  24. <view class="swiperPage">{{ `${previewIndex} / ${detail.clueInfoList.length}` }}</view>
  25. </view>
  26. </view>
  27. <view class="content">
  28. <view class="title">{{ formatTitle(detail.title) }}</view>
  29. <view class="fileBox">
  30. <view class="fileItem" v-for="(item, index) in detail.clueInfoList" :key="index">
  31. <image
  32. :src="item.localUrl"
  33. class="thumbnail"
  34. v-if="item.type == '1'"
  35. @click="previewFile(index)"
  36. mode="aspectFill"
  37. ></image>
  38. <view
  39. class="defaultFileItem"
  40. v-else-if="item.type == '2'"
  41. @click="previewFile(index)"
  42. >
  43. <image src="../../static/image/video.png" class="thumbnail"></image>
  44. <image src="../../static/image/playBtn.png" class="playBtn"></image>
  45. </view>
  46. <view class="defaultFileItem" v-else @click="previewFile(index)">
  47. <image src="../../static/image/music.png" class="thumbnail"></image>
  48. <image src="../../static/image/playBtn.png" class="playBtn"></image>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="newsTips">
  53. <view class="author">{{ formatName(detail.author) }}</view>
  54. <view class="time">{{ detail.modifyTime }}</view>
  55. </view>
  56. </view>
  57. <view class="seat"></view>
  58. <view class="commentBox" v-if="detail.replies.length > 0">
  59. <view class="header">回复信息</view>
  60. <view class="commentItem" v-for="item in detail.replies" :key="item.id">
  61. <view class="commentTitle">{{ item.content }}</view>
  62. <view class="commentTime">{{ item.replyTime }}</view>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. import { getClueById } from '../../network/api.js';
  69. export default {
  70. data() {
  71. return {
  72. detail: {
  73. title: '',
  74. clueInfoList: [],
  75. author: '',
  76. modifyTime: '',
  77. replies: []
  78. },
  79. previewIndex: 0,
  80. previewModal: false
  81. };
  82. },
  83. onLoad: function({ id }) {
  84. this.init(id);
  85. },
  86. methods: {
  87. formatName(name, index = 7) {
  88. return name.length > index ? name.substring(0, index -1) + '...' : name
  89. },
  90. formatTitle(title) {
  91. const reg = /1(\d{2})\d{4}(\d{4})/g;
  92. title = title.replace(reg,"1$1****$2");
  93. return title.length > 105 ? title.substring(0, 104) + '...' : title;
  94. },
  95. async init(id) {
  96. let res = await getClueById(id);
  97. if (res.data.state == 200) {
  98. let data = res.data.data;
  99. data.clueInfoList = data.clueInfoList.filter(item => item.type != 0);
  100. this.detail = data;
  101. }
  102. },
  103. previewFile(index) {
  104. this.previewIndex = index + 1;
  105. this.previewModal = true;
  106. },
  107. moveStop() {},
  108. swiperChange(e) {
  109. this.previewIndex = e.detail.current + 1;
  110. }
  111. }
  112. };
  113. </script>
  114. <style lang="scss" scoped>
  115. .main {
  116. .content {
  117. box-sizing: border-box;
  118. width: 100vw;
  119. padding: 0 15px;
  120. background-color: #ffffff;
  121. .title {
  122. margin: 16px 0;
  123. }
  124. .fileBox {
  125. display: flex;
  126. flex-wrap: wrap;
  127. margin-top: 10px;
  128. .fileItem {
  129. width: 218rpx;
  130. height: 218rpx;
  131. background-color: #a5a5a5;
  132. position: relative;
  133. margin-right: 16rpx;
  134. &:nth-child(3n) {
  135. margin-right: 0;
  136. }
  137. &:nth-child(n + 4) {
  138. margin-top: 16rpx;
  139. }
  140. .thumbnail {
  141. width: 100%;
  142. height: 100%;
  143. }
  144. .defaultFileItem {
  145. position: relative;
  146. width: 100%;
  147. height: 100%;
  148. .playBtn {
  149. position: absolute;
  150. top: 50%;
  151. left: 50%;
  152. transform: translate(-50%, -50%);
  153. width: 48rpx;
  154. height: 48rpx;
  155. }
  156. }
  157. }
  158. }
  159. .newsTips {
  160. margin: 16px 0;
  161. font-size: 12px;
  162. color: #5c5f66;
  163. display: flex;
  164. align-items: center;
  165. justify-content: space-between;
  166. }
  167. }
  168. .seat {
  169. height: 8px;
  170. width: 100%;
  171. background-color: #f7f7f9;
  172. }
  173. .commentBox {
  174. margin-top: 16px;
  175. box-sizing: border-box;
  176. width: 100vw;
  177. padding: 0 15px;
  178. background-color: #ffffff;
  179. .commentItem {
  180. margin-bottom: 10px;
  181. border-bottom: 1px solid #e8e9eb;
  182. padding: 8px 0;
  183. .commentTitle {
  184. font-size: 14px;
  185. color: #151b26;
  186. }
  187. .commentTime {
  188. font-size: 12px;
  189. color: #5c5f66;
  190. margin-top: 10px;
  191. }
  192. }
  193. }
  194. }
  195. .popupBottom {
  196. position: fixed;
  197. bottom: 0;
  198. left: 0;
  199. width: 100vw;
  200. height: 100vh;
  201. z-index: 100;
  202. display: flex;
  203. flex-direction: column;
  204. .popupBg {
  205. position: fixed;
  206. left: 0;
  207. top: 0;
  208. width: 100%;
  209. height: 100%;
  210. background: rgba(0, 0, 0, 0.5);
  211. }
  212. .popupContent {
  213. height: 40%;
  214. margin-top: auto;
  215. background-color: #fff;
  216. position: relative;
  217. z-index: 11;
  218. }
  219. .popupSwiperBg {
  220. position: fixed;
  221. left: 0;
  222. top: 0;
  223. width: 100%;
  224. height: 100%;
  225. background: rgba(0, 0, 0, 0.5);
  226. display: flex;
  227. align-items: center;
  228. }
  229. .swiperDotBox {
  230. display: flex;
  231. justify-content: center;
  232. align-items: center;
  233. height: 100%;
  234. width: 100%;
  235. flex-direction: column;
  236. .swiperBox {
  237. height: 85vh;
  238. width: 100%;
  239. }
  240. .swiperFileItem {
  241. width: 100%;
  242. height: 100%;
  243. }
  244. .swiperAudioBox {
  245. width: 100%;
  246. height: 100%;
  247. position: relative;
  248. }
  249. .swiperAudioItem {
  250. position: absolute;
  251. top: 50%;
  252. left: 50%;
  253. transform: translate(-50%, -50%);
  254. z-index: 111;
  255. }
  256. .swiperPage {
  257. position: absolute;
  258. bottom: 20rpx;
  259. width: 100%;
  260. height: 30px;
  261. text-align: center;
  262. line-height: 30px;
  263. color: #ffffff;
  264. }
  265. }
  266. }
  267. </style>