three.vue 3.5 KB

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