three.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div class="three">
  3. <div class="comTit">
  4. <img src="../assets/img/comBs1.png" alt="" />
  5. <span>{{ tit }}</span>
  6. <img src="../assets/img/comBs2.png" alt="" />
  7. </div>
  8. <div class="swBox" :class="{ opcBase: conShowLoad }">
  9. <div class="swiper-container">
  10. <div class="swiper-wrapper">
  11. <!-- 图片 -->
  12. <div class="swiper-slide" v-for="item in data.images" :key="item.id">
  13. <img :src="baseURL + item.filePath" alt="" />
  14. </div>
  15. <div
  16. class="swiper-slide swiperVideo"
  17. v-for="item in data.videos"
  18. :key="item.id"
  19. >
  20. <!-- 视频 -->
  21. <div class="videoName">{{ item.name }}</div>
  22. <video controls :src="baseURL + item.filePath"></video>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. <div
  28. class="main"
  29. v-html="data.content"
  30. :class="{ opcBase: conShowLoad }"
  31. ></div>
  32. <!-- 数据加载中 -->
  33. <div class="conShowLoad" v-show="conShowLoad">
  34. <img src="../assets/img/loading.gif" alt="" />
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import Swiper from "@/assets/swiper/swiper.js";
  40. import axios from "@/utils/request";
  41. export default {
  42. name: "three",
  43. props: {
  44. tit: {
  45. type: String,
  46. },
  47. data: {
  48. type: Object,
  49. default: () => {},
  50. },
  51. },
  52. components: {},
  53. data() {
  54. //这里存放数据
  55. return {
  56. conShowLoad: true,
  57. baseURL: "",
  58. };
  59. },
  60. //监听属性 类似于data概念
  61. computed: {},
  62. //监控data中的数据变化
  63. watch: {},
  64. //方法集合
  65. methods: {},
  66. //生命周期 - 创建完成(可以访问当前this实例)
  67. created() {
  68. // 获取服务器前缀地址
  69. this.baseURL = axios.defaults.baseURL;
  70. },
  71. //生命周期 - 挂载完成(可以访问DOM元素)
  72. mounted() {
  73. this.$nextTick(() => {
  74. setTimeout(() => {
  75. new Swiper(".three .swiper-container", {
  76. slidesPerView: 1.4,
  77. spaceBetween: 10,
  78. });
  79. this.conShowLoad = false;
  80. }, 1000);
  81. });
  82. },
  83. beforeCreate() {}, //生命周期 - 创建之前
  84. beforeMount() {}, //生命周期 - 挂载之前
  85. beforeUpdate() {}, //生命周期 - 更新之前
  86. updated() {}, //生命周期 - 更新之后
  87. beforeDestroy() {}, //生命周期 - 销毁之前
  88. destroyed() {}, //生命周期 - 销毁完成
  89. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  90. };
  91. </script>
  92. <style lang='less' scoped>
  93. @import "../assets/swiper/swiper.css";
  94. .three {
  95. position: relative;
  96. width: 100%;
  97. height: 100%;
  98. .main {
  99. letter-spacing: 1px;
  100. color: #8a7351;
  101. line-height: 24px;
  102. font-size: 14px;
  103. padding: 0 12px 0 20px;
  104. width: 100%;
  105. height: calc(100% - 320px);
  106. overflow-y: auto;
  107. margin-top: 20px;
  108. }
  109. .swBox {
  110. width: 100%;
  111. height: 170px;
  112. .swiper-container {
  113. width: calc(100% - 40px);
  114. margin: 0 auto;
  115. height: 170px;
  116. }
  117. .swiper-slide {
  118. width: 100%;
  119. height: 100%;
  120. img {
  121. width: 100%;
  122. height: 100%;
  123. object-fit: cover;
  124. }
  125. video {
  126. width: 100%;
  127. height: 100%;
  128. }
  129. }
  130. .swiperVideo {
  131. position: relative;
  132. width: 100%;
  133. height: 100%;
  134. background-color: rgba(0, 0, 0, 0.6);
  135. .videoName {
  136. position: absolute;
  137. top: 1px;
  138. left: 5px;
  139. color: #fff;
  140. font-size: 14px;
  141. }
  142. }
  143. }
  144. }
  145. </style>