123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- <template>
- <div class="son3">
- <!-- 点击视频播放的盒子 -->
- <div class="videoPlayBox" v-if="videoId">
- <video controls autoplay :src="`data/${videoId}.mp4`"></video>
- <!-- 关闭按钮 -->
- <div class="close" @click="videoId = null"></div>
- </div>
- <!-- 视频 -->
- <div class="videoBox">
- <div class="vidPlay" @click="videoId = '1'"></div>
- <!-- <video src="data/1.mp4" autoplay loop muted></video> -->
- <img src="../assets/img/vid1.png" alt="" />
- </div>
- <div class="shuming">《鸦片成瘾机制》</div>
- <div class="sonBj1"></div>
- <div
- class="rowBox"
- v-for="item in data"
- :key="item.id"
- :class="{ noPad: item.pad }"
- >
- <div class="row" @click="toInfo(item.id)" :style="`width: ${item.ww};`">
- <img
- :style="`height: ${item.hh};`"
- :src="require(`@/assets/img/zhanpin/${item.id}.png`)"
- alt=""
- />
- <p>{{ item.name }}</p>
- </div>
- </div>
- <div class="sonBj2"></div>
- <div class="videoBox">
- <div class="vidPlay" @click="videoId = '2'"></div>
- <img src="../assets/img/vid2.png" alt="" />
- </div>
- <div class="shuming">《鸦片走私贸易》</div>
- </div>
- </template>
- <script>
- export default {
- name: "son3",
- components: {},
- data() {
- //这里存放数据
- return {
- videoId: null,
- data: [
- {
- id: 9,
- name: "鸦片趸船",
- ww: "231px",
- hh: "143px",
- pad: true,
- },
- {
- id: 10,
- name: "飞剪船模型",
- ww: "161px",
- hh: "188px",
- pad: true,
- },
- {
- id: 11,
- name: "1864年印度到香港的鸦片保险单",
- ww: "194px",
- hh: "175px",
- },
- {
- id: 12,
- name: "1860年印度比尔把鸦片运送至香港的运单",
- ww: "200px",
- hh: "174px",
- },
- {
- id: 13,
- name: "1854年广州和香港的鸦片售卖报告",
- ww: "194px",
- hh: "305px",
- },
- {
- id: 14,
- name: "1865年香港鸦片交换支票",
- ww: "200px",
- hh: "181px",
- },
- {
- id: 15,
- name: "1855年印度比尔把鸦片运至中国的运单",
- ww: "194px",
- hh: "207px",
- },
- {
- id: 16,
- name: "1856年印度比尔把鸦片运至中国WOOSUNG的运单",
- ww: "200px",
- hh: "181px",
- },
- { id: 17, name: "1858年香港鸦片交换支票", ww: "193px", hh: "188px" },
- {
- id: 18,
- name: "1859年印度比尔把鸦片运至香港的运单",
- ww: "195px",
- hh: "307px",
- },
- {
- id: 19,
- name: "1855年从印度运送鸦片到香港的保险单",
- ww: "194px",
- hh: "300px",
- },
- ],
- };
- },
- //监听属性 类似于data概念
- computed: {},
- //监控data中的数据变化
- watch: {
- videoId(val) {
- this.$nextTick(() => {
- // 获取body,防止滚动
- let body = document.querySelector("body");
- if (val === null) body.style.overflow = "auto";
- else body.style.overflow = "hidden";
- });
- },
- },
- //方法集合
- methods: {
- toInfo(id) {
- this.$router.push(`/info/${id}`);
- },
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {},
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {},
- beforeCreate() {}, //生命周期 - 创建之前
- beforeMount() {}, //生命周期 - 挂载之前
- beforeUpdate() {}, //生命周期 - 更新之前
- updated() {}, //生命周期 - 更新之后
- beforeDestroy() {}, //生命周期 - 销毁之前
- destroyed() {}, //生命周期 - 销毁完成
- activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
- };
- </script>
- <style lang='less' scoped>
- .son3 {
- .videoPlayBox {
- position: fixed;
- width: 100vw;
- height: 100vh;
- overflow: hidden;
- z-index: 999;
- top: 0;
- left: 0;
- background-color: rgba(0, 0, 0, 0.9);
- video {
- position: absolute;
- width: 100%;
- max-height: 60vh;
- top: 50%;
- transform: translateY(-50%);
- }
- .close {
- position: absolute;
- bottom: 20px;
- left: 50%;
- transform: translateX(-50%);
- width: 32px;
- height: 32px;
- background: url("../assets/img/close.png");
- background-size: 100% 100%;
- }
- }
- .videoBox {
- position: relative;
- & > img {
- width: 100%;
- }
- .vidPlay {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- width: 77px;
- height: 77px;
- background: url("../assets/img/videoPlay.png");
- background-size: 100% 100%;
- }
- }
- .rowBox {
- padding: 0;
- margin-bottom: 50px;
- display: flex;
- .row {
- & > img {
- width: 100%;
- }
- & > p {
- color: #ffffff;
- font-size: 16px;
- text-align: center;
- width: 100%;
- padding: 10px;
- line-height: 24px;
- }
- }
- &:nth-of-type(2n + 1) {
- justify-content: flex-end
- }
- }
- .noPad {
- padding: 0 24px;
- }
- }
- </style>
|