son6.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <div class="son6">
  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="videoPlayBox" v-if="modelId">
  11. <iframe :src="modelId" frameborder="0"></iframe>
  12. <!-- 关闭按钮 -->
  13. <div class="close" @click="modelId = null"></div>
  14. </div>
  15. <!-- 场景 -->
  16. <div class="modelBox">
  17. <div
  18. class="modelPlay"
  19. @click="
  20. modelId =
  21. 'https://www.4dkankan.com/panorama/show.html?id=WK1526492643662524416&vr=fd720_JUXrSixwc'
  22. "
  23. ></div>
  24. <img src="../assets/img/mod1.png" alt="" />
  25. </div>
  26. <div class="shuming">场景:围馆封仓</div>
  27. <div class="sonBj1"></div>
  28. <div
  29. class="rowBox"
  30. v-for="item in data"
  31. :key="item.id"
  32. :class="{ noPad: item.pad }"
  33. >
  34. <div class="row" @click="toInfo(item.id)" :style="`width: ${item.ww};`">
  35. <img
  36. :style="`height: ${item.hh};`"
  37. :src="require(`@/assets/img/zhanpin/${item.id}.png`)"
  38. alt=""
  39. />
  40. <p>{{ item.name }}</p>
  41. </div>
  42. </div>
  43. <div class="sonBj2"></div>
  44. <!-- 视频 -->
  45. <div class="videoBox">
  46. <div class="vidPlay" @click="videoId = '3'"></div>
  47. <img src="../assets/img/vid4.png" alt="" />
  48. </div>
  49. <div class="shuming">《传讯行商》</div>
  50. </div>
  51. </template>
  52. <script>
  53. export default {
  54. name: "son6",
  55. components: {},
  56. data() {
  57. //这里存放数据
  58. return {
  59. videoId: null,
  60. modelId: null,
  61. data: [
  62. {
  63. id: 38,
  64. name: "林则徐画像",
  65. ww: "155px",
  66. hh: "183px",
  67. pad: true,
  68. },
  69. {
  70. id: 39,
  71. name: "(油画)销烟壮举",
  72. ww: "257px",
  73. hh: "190px",
  74. },
  75. ],
  76. };
  77. },
  78. //监听属性 类似于data概念
  79. computed: {},
  80. //监控data中的数据变化
  81. watch: {
  82. videoId(val) {
  83. this.$nextTick(() => {
  84. // 获取body,防止滚动
  85. let body = document.querySelector("body");
  86. if (val === null) body.style.overflow = "auto";
  87. else body.style.overflow = "hidden";
  88. });
  89. },
  90. modelId(val) {
  91. this.$nextTick(() => {
  92. // 获取body,防止滚动
  93. let body = document.querySelector("body");
  94. if (val === null) body.style.overflow = "auto";
  95. else body.style.overflow = "hidden";
  96. });
  97. },
  98. },
  99. //方法集合
  100. methods: {
  101. toInfo(id) {
  102. this.$router.push(`/info/${id}`);
  103. },
  104. },
  105. //生命周期 - 创建完成(可以访问当前this实例)
  106. created() {},
  107. //生命周期 - 挂载完成(可以访问DOM元素)
  108. mounted() {},
  109. beforeCreate() {}, //生命周期 - 创建之前
  110. beforeMount() {}, //生命周期 - 挂载之前
  111. beforeUpdate() {}, //生命周期 - 更新之前
  112. updated() {}, //生命周期 - 更新之后
  113. beforeDestroy() {}, //生命周期 - 销毁之前
  114. destroyed() {}, //生命周期 - 销毁完成
  115. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  116. };
  117. </script>
  118. <style lang='less' scoped>
  119. .son6 {
  120. .videoPlayBox {
  121. position: fixed;
  122. width: 100vw;
  123. height: 100vh;
  124. z-index: 999;
  125. top: 0;
  126. left: 0;
  127. background-color: rgba(0, 0, 0, 0.9);
  128. video {
  129. position: absolute;
  130. width: 100%;
  131. max-height: 60vh;
  132. top: 50%;
  133. transform: translateY(-50%);
  134. }
  135. .close {
  136. position: absolute;
  137. bottom: 20px;
  138. left: 50%;
  139. transform: translateX(-50%);
  140. width: 32px;
  141. height: 32px;
  142. background: url("../assets/img/close.png");
  143. background-size: 100% 100%;
  144. }
  145. iframe {
  146. width: 100%;
  147. height: 100%;
  148. }
  149. }
  150. .videoBox {
  151. position: relative;
  152. & > img {
  153. width: 100%;
  154. }
  155. .vidPlay {
  156. position: absolute;
  157. top: 50%;
  158. left: 50%;
  159. transform: translate(-50%, -50%);
  160. width: 77px;
  161. height: 77px;
  162. background: url("../assets/img/videoPlay.png");
  163. background-size: 100% 100%;
  164. }
  165. }
  166. .modelBox {
  167. position: relative;
  168. & > img {
  169. width: 100%;
  170. }
  171. .modelPlay {
  172. position: absolute;
  173. top: 50%;
  174. left: 50%;
  175. transform: translate(-50%, -50%);
  176. width: 77px;
  177. height: 77px;
  178. background: url("../assets/img/modelPlay.png");
  179. background-size: 100% 100%;
  180. }
  181. }
  182. .rowBox {
  183. padding: 0;
  184. margin-bottom: 50px;
  185. display: flex;
  186. .row {
  187. & > img {
  188. width: 100%;
  189. }
  190. & > p {
  191. color: #ffffff;
  192. font-size: 16px;
  193. text-align: center;
  194. width: 100%;
  195. padding: 10px;
  196. line-height: 24px;
  197. }
  198. }
  199. &:nth-of-type(2n) {
  200. justify-content: flex-end
  201. }
  202. }
  203. .noPad {
  204. padding: 0 24px;
  205. }
  206. }
  207. </style>