son3.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <div class="son3">
  3. <!-- 点击视频播放的盒子 -->
  4. <div class="videoPlayBox" v-if="videoId">
  5. <video controls autoplay :src="`data/${videoId}.mp4`"></video>
  6. <!-- 关闭按钮 -->
  7. <div class="close" @click="videoId = null"></div>
  8. </div>
  9. <!-- 视频 -->
  10. <div class="videoBox">
  11. <div class="vidPlay" @click="videoId = '1'"></div>
  12. <!-- <video src="data/1.mp4" autoplay loop muted></video> -->
  13. <img src="../assets/img/vid1.png" alt="" />
  14. </div>
  15. <div class="shuming">《鸦片成瘾机制》</div>
  16. <div class="sonBj1"></div>
  17. <div
  18. class="rowBox"
  19. v-for="item in data"
  20. :key="item.id"
  21. :class="{ noPad: item.pad }"
  22. >
  23. <div class="row" @click="toInfo(item.id)" :style="`width: ${item.ww};`">
  24. <img
  25. :style="`height: ${item.hh};`"
  26. :src="require(`@/assets/img/zhanpin/${item.id}.png`)"
  27. alt=""
  28. />
  29. <p>{{ item.name }}</p>
  30. </div>
  31. </div>
  32. <div class="sonBj2"></div>
  33. <div class="videoBox">
  34. <div class="vidPlay" @click="videoId = '2'"></div>
  35. <img src="../assets/img/vid2.png" alt="" />
  36. </div>
  37. <div class="shuming">《鸦片走私贸易》</div>
  38. </div>
  39. </template>
  40. <script>
  41. export default {
  42. name: "son3",
  43. components: {},
  44. data() {
  45. //这里存放数据
  46. return {
  47. videoId: null,
  48. data: [
  49. {
  50. id: 9,
  51. name: "鸦片趸船",
  52. ww: "231px",
  53. hh: "143px",
  54. pad: true,
  55. },
  56. {
  57. id: 10,
  58. name: "飞剪船模型",
  59. ww: "161px",
  60. hh: "188px",
  61. pad: true,
  62. },
  63. {
  64. id: 11,
  65. name: "1864年印度到香港的鸦片保险单",
  66. ww: "194px",
  67. hh: "175px",
  68. },
  69. {
  70. id: 12,
  71. name: "1860年印度比尔把鸦片运送至香港的运单",
  72. ww: "200px",
  73. hh: "174px",
  74. },
  75. {
  76. id: 13,
  77. name: "1854年广州和香港的鸦片售卖报告",
  78. ww: "194px",
  79. hh: "305px",
  80. },
  81. {
  82. id: 14,
  83. name: "1865年香港鸦片交换支票",
  84. ww: "200px",
  85. hh: "181px",
  86. },
  87. {
  88. id: 15,
  89. name: "1855年印度比尔把鸦片运至中国的运单",
  90. ww: "194px",
  91. hh: "207px",
  92. },
  93. {
  94. id: 16,
  95. name: "1856年印度比尔把鸦片运至中国WOOSUNG的运单",
  96. ww: "200px",
  97. hh: "181px",
  98. },
  99. { id: 17, name: "1858年香港鸦片交换支票", ww: "193px", hh: "188px" },
  100. {
  101. id: 18,
  102. name: "1859年印度比尔把鸦片运至香港的运单",
  103. ww: "195px",
  104. hh: "307px",
  105. },
  106. {
  107. id: 19,
  108. name: "1855年从印度运送鸦片到香港的保险单",
  109. ww: "194px",
  110. hh: "300px",
  111. },
  112. ],
  113. };
  114. },
  115. //监听属性 类似于data概念
  116. computed: {},
  117. //监控data中的数据变化
  118. watch: {
  119. videoId(val) {
  120. this.$nextTick(() => {
  121. // 获取body,防止滚动
  122. let body = document.querySelector("body");
  123. if (val === null) body.style.overflow = "auto";
  124. else body.style.overflow = "hidden";
  125. });
  126. },
  127. },
  128. //方法集合
  129. methods: {
  130. toInfo(id) {
  131. this.$router.push(`/info/${id}`);
  132. },
  133. },
  134. //生命周期 - 创建完成(可以访问当前this实例)
  135. created() {},
  136. //生命周期 - 挂载完成(可以访问DOM元素)
  137. mounted() {},
  138. beforeCreate() {}, //生命周期 - 创建之前
  139. beforeMount() {}, //生命周期 - 挂载之前
  140. beforeUpdate() {}, //生命周期 - 更新之前
  141. updated() {}, //生命周期 - 更新之后
  142. beforeDestroy() {}, //生命周期 - 销毁之前
  143. destroyed() {}, //生命周期 - 销毁完成
  144. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  145. };
  146. </script>
  147. <style lang='less' scoped>
  148. .son3 {
  149. .videoPlayBox {
  150. position: fixed;
  151. width: 100vw;
  152. height: 100vh;
  153. overflow: hidden;
  154. z-index: 999;
  155. top: 0;
  156. left: 0;
  157. background-color: rgba(0, 0, 0, 0.9);
  158. video {
  159. position: absolute;
  160. width: 100%;
  161. max-height: 60vh;
  162. top: 50%;
  163. transform: translateY(-50%);
  164. }
  165. .close {
  166. position: absolute;
  167. bottom: 20px;
  168. left: 50%;
  169. transform: translateX(-50%);
  170. width: 32px;
  171. height: 32px;
  172. background: url("../assets/img/close.png");
  173. background-size: 100% 100%;
  174. }
  175. }
  176. .videoBox {
  177. position: relative;
  178. & > img {
  179. width: 100%;
  180. }
  181. .vidPlay {
  182. position: absolute;
  183. top: 50%;
  184. left: 50%;
  185. transform: translate(-50%, -50%);
  186. width: 77px;
  187. height: 77px;
  188. background: url("../assets/img/videoPlay.png");
  189. background-size: 100% 100%;
  190. }
  191. }
  192. .rowBox {
  193. padding: 0;
  194. margin-bottom: 50px;
  195. display: flex;
  196. .row {
  197. & > img {
  198. width: 100%;
  199. }
  200. & > p {
  201. color: #ffffff;
  202. font-size: 16px;
  203. text-align: center;
  204. width: 100%;
  205. padding: 10px;
  206. line-height: 24px;
  207. }
  208. }
  209. &:nth-of-type(2n + 1) {
  210. justify-content: flex-end
  211. }
  212. }
  213. .noPad {
  214. padding: 0 24px;
  215. }
  216. }
  217. </style>