index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <div class="file-details">
  3. <div v-if="type === 'mp4'" class="video">
  4. <div ref="live1" :class="['live1', styleBig === 'live1' ? 'live-big' : styleBig === 'live2' ? 'live-small' : '']">
  5. <videoPlayer :video-src="path1" video-name="live1" @myFull="myFull"/>
  6. </div>
  7. <div ref="live2" :class="['live2', styleBig === 'live2' ? 'live-big' : styleBig === 'live1' ? 'live-small' : '']">
  8. <videoPlayer :video-src="path2" video-name="live2" @myFull="myFull"/>
  9. </div>
  10. <div v-if="styleBig" class="close" @click="close">
  11. <img :src="require(`@/assets/fileimg/cha.png`)">
  12. </div>
  13. </div>
  14. <div v-else class="photo">
  15. <el-carousel :autoplay="false" :loop="false" trigger="click" indicator-position="none" height="100%" @change="getImgInd">
  16. <el-carousel-item v-for="item in imgUrl" :key="item.id">
  17. <div :class="['photo1', styleBig === 'live1' ? 'photo-big' : styleBig === 'live2' ? 'photo-small' : '']" @click="change('live1')">
  18. <img :src="item[0].path" style="width: 100%; height: 100%;" >
  19. </div>
  20. <div :class="['photo2', styleBig === 'live2' ? 'photo-big' : styleBig === 'live1' ? 'photo-small' : '']" @click="change('live2')" >
  21. <img :src="item[1].path" style="width: 100%; height: 100%;" >
  22. </div>
  23. </el-carousel-item>
  24. </el-carousel>
  25. <div class="identification">{{ imgInd }}/{{ imgUrl.length }}</div>
  26. <div v-if="styleBig" class="close" @click="close">
  27. <img :src="require(`@/assets/fileimg/cha.png`)">
  28. </div>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. import videoPlayer from '@/components/video/video.vue'
  34. import 'video.js/dist/video-js.css'
  35. // import { videoPlayer } from 'vue-video-player'
  36. import { mapGetters } from 'vuex'
  37. export default {
  38. components: {
  39. videoPlayer
  40. },
  41. data() {
  42. return {
  43. styleBig: '',
  44. path1: '',
  45. path2: '',
  46. imgUrl: [],
  47. type: '',
  48. videoBigFlag: true,
  49. imgBigFlag: true,
  50. imgInd: 1
  51. }
  52. },
  53. computed: {
  54. ...mapGetters([
  55. 'fileDetailsList'
  56. ])
  57. },
  58. created() {
  59. this.type = this.$route.query.type
  60. // this.$route.query.followUid,
  61. this.innitData(this.$route.query.ind)
  62. },
  63. mounted() {
  64. // 监听键盘按键事件
  65. const self = this
  66. this.$nextTick(function() {
  67. document.addEventListener('keyup', function(e) {
  68. // 此处填写你的业务逻辑即可
  69. if (e.keyCode === 27) {
  70. self.close()
  71. }
  72. })
  73. })
  74. },
  75. methods: {
  76. change(live) {
  77. console.log(live)
  78. this.styleBig = live
  79. },
  80. myFull(type) {
  81. this.change(type)
  82. },
  83. close() {
  84. this.styleBig = ''
  85. },
  86. innitData(ind) {
  87. console.log(this.fileDetailsList[ind])
  88. const data = this.fileDetailsList[ind]
  89. const imgArr = data.screenshot
  90. const videoArr = data.recordFile
  91. this.path1 = videoArr[0].path
  92. this.path2 = videoArr[1].path
  93. console.log(this.path1)
  94. this.imgUrl = this.arrTrans(imgArr, 2)
  95. },
  96. getImgInd(ind) {
  97. console.log(ind)
  98. this.imgInd = ind + 1
  99. },
  100. arrTrans(arr, num) {
  101. const newArr = []
  102. arr.forEach((item, index) => {
  103. const page = Math.floor(index / num) // 计算该元素为第几个素组内
  104. if (!newArr[page]) { // 判断是否存在
  105. newArr[page] = []
  106. }
  107. newArr[page].push(item)
  108. })
  109. return newArr
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss" scope>
  115. .file-details {
  116. width: 100%;
  117. height: 100%;
  118. background: #6AA1F1;
  119. .video,
  120. .photo {
  121. width: 100%;
  122. height: 100%;
  123. position: relative;
  124. .live1 {
  125. width: 46%;
  126. height: 50%;
  127. position: absolute;
  128. left: 3%;
  129. top: 30%;
  130. }
  131. .live2 {
  132. width: 46%;
  133. height: 50%;
  134. position: absolute;
  135. left: 51%;
  136. top: 30%;
  137. }
  138. .live-big {
  139. position: absolute;
  140. left: 5%;
  141. top: 11%;
  142. width: 90%;
  143. height: 80%;
  144. }
  145. .live-small {
  146. display: none;
  147. // position: absolute;
  148. // left: 75%;
  149. // top: 15%;
  150. // width: 15%;
  151. // height: 15%;
  152. // z-index: 1;
  153. }
  154. // 图片样式
  155. .photo1 {
  156. width: 45%;
  157. height: 50%;
  158. position: absolute;
  159. left: 4%;
  160. top: 30%;
  161. background: #fff;
  162. }
  163. .photo2 {
  164. width: 45%;
  165. height: 50%;
  166. position: absolute;
  167. left: 51%;
  168. top: 30%;
  169. background: #E1E1E1;
  170. }
  171. .photo-big {
  172. position: absolute;
  173. left: 5%;
  174. top: 11%;
  175. width: 90%;
  176. height: 80%;
  177. }
  178. .photo-small {
  179. display: none;
  180. // position: absolute;
  181. // left: 75%;
  182. // top: 15%;
  183. // width: 15%;
  184. // height: 15%;
  185. // z-index: 1;
  186. }
  187. .close {
  188. position: absolute;
  189. right: 6%;
  190. top: 12%;
  191. z-index: 2;
  192. width: 32px;
  193. height: 32px;
  194. text-align: center;
  195. line-height: 32px;
  196. }
  197. .identification {
  198. position: absolute;
  199. left: 50%;
  200. bottom: 12%;
  201. width: 30px;
  202. font-size: 20px;
  203. }
  204. }
  205. }
  206. </style>
  207. <style>
  208. .el-carousel {
  209. height: 100%;
  210. }
  211. </style>