index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <div class="swiper-container">
  3. <swiper
  4. ref="listSwiper"
  5. class="swiper-wrapper swiper-wrapper-n"
  6. :options="swiperOption"
  7. >
  8. <swiper-slide
  9. class="swiper-slide"
  10. v-for="(item, index) in cards"
  11. :key="index"
  12. >
  13. <div
  14. class="card"
  15. @click="
  16. $router.push({
  17. name: 'Scene',
  18. query: { id: item.id },
  19. params: { link: item.link },
  20. })
  21. "
  22. >
  23. <img class="logo" src="../../assets/images/card-img.png" />
  24. <div class="txt">{{item.name}}</div>
  25. <div class="maskss"></div>
  26. </div>
  27. </swiper-slide>
  28. <div class="swiper-pagination" slot="pagination"></div>
  29. <div class="swiper-button-next"></div>
  30. <div class="swiper-button-prev"></div>
  31. </swiper>
  32. </div>
  33. </template>
  34. <script>
  35. import { Swiper, SwiperSlide, directive } from "vue-awesome-swiper";
  36. import "swiper/css/swiper.css";
  37. export default {
  38. computed: {
  39. swiper() {
  40. return this.$refs.listSwiper.$swiper;
  41. },
  42. swiperOption() {
  43. // let that = this
  44. let getIndex = (range, length, current) => {
  45. let next =
  46. current + range > length ? current + range - length : current + range;
  47. let prev =
  48. current - range < 0 ? current - range + length : current - range;
  49. return {
  50. prev,
  51. next,
  52. };
  53. };
  54. let setClass = (range, length, current, that, cls) => {
  55. let { prev, next } = getIndex(range, length, current);
  56. let p = that.slides.eq(prev);
  57. let n = that.slides.eq(next);
  58. let cur = that.slides.eq(current);
  59. p.find(".maskss").removeClass("mask mask1 mask2");
  60. n.find(".maskss").removeClass("mask mask1 mask2");
  61. cur.find(".maskss").removeClass("mask mask1 mask2");
  62. p.find(".maskss").addClass(cls);
  63. n.find(".maskss").addClass(cls);
  64. };
  65. return {
  66. watchSlidesProgress: true,
  67. slidesPerView: "auto",
  68. centeredSlides: true,
  69. initialSlide: 2,
  70. // loop: true,
  71. // loopedSlides: 9,
  72. navigation: {
  73. nextEl: ".swiper-button-next",
  74. prevEl: ".swiper-button-prev",
  75. },
  76. pagination: {
  77. el: ".swiper-pagination",
  78. clickable: true //允许分页点击跳转
  79. },
  80. on: {
  81. click: function () {
  82. if (this.clickedIndex >= 0) {
  83. this.slideTo(this.clickedIndex, 500, () => {
  84. this.lazy.load();
  85. });
  86. }
  87. },
  88. transitionEnd: function () {
  89. let length = this.slides.length;
  90. for (let i = 0; i < length; i++) {
  91. var slide = this.slides.eq(i);
  92. let classNames = slide[0].className;
  93. if (classNames.indexOf("active") > -1) {
  94. setClass(1, length, i, this, "mask");
  95. setClass(2, length, i, this, "mask1");
  96. setClass(3, length, i, this, "mask2");
  97. }
  98. }
  99. },
  100. progress: function () {
  101. for (let i = 0; i < this.slides.length; i++) {
  102. var slide = this.slides.eq(i);
  103. var slideProgress = this.slides[i].progress;
  104. var modify = 1;
  105. if (Math.abs(slideProgress) > 1) {
  106. modify = (Math.abs(slideProgress) - 1) * 0.3 + 1;
  107. }
  108. let translate = slideProgress * modify * 140 + "px";
  109. let scale = 1 - Math.abs(slideProgress) / 5;
  110. let zIndex = 999 - Math.abs(Math.round(10 * slideProgress));
  111. // let opacity = 1 - Math.min(Math.abs(slideProgress / 2), 1);
  112. slide.transform(
  113. "translateX(" + translate + ") scale(" + scale + ")"
  114. );
  115. slide.css({
  116. zIndex: zIndex,
  117. opacity: 1,
  118. "pointer-events": "auto",
  119. });
  120. if (Math.abs(slideProgress) > 3) {
  121. slide.css({
  122. // "opacity":0,
  123. "pointer-events": "none",
  124. });
  125. }
  126. }
  127. },
  128. setTransition: function (transition) {
  129. for (var i = 0; i < this.slides.length; i++) {
  130. var slide = this.slides.eq(i);
  131. slide.transition(transition);
  132. }
  133. },
  134. },
  135. };
  136. },
  137. },
  138. props: ["list"],
  139. data() {
  140. let cards = [
  141. {
  142. img: 1,
  143. id: 8,
  144. link: "http://www.4dmodel.com/SuperTwo/index.html?m=1017",
  145. name: "万山海战遗址",
  146. },
  147. {
  148. img: 2,
  149. id: 3,
  150. link: "http://www.4dmodel.com/SuperTwo582/vtour/tour.html",
  151. name: "杨匏安陈列馆",
  152. },
  153. {
  154. img: 1,
  155. id: 4,
  156. link: "http://www.4dmodel.com/SuperTwo/index.html?m=1016",
  157. name: "林伟民与中国早期工人运动史迹陈列馆",
  158. },
  159. {
  160. img: 2,
  161. id: 9,
  162. link: "http://www.4dmodel.com/SuperTwo/index.html?m=1018",
  163. name: "中共小濠冲党史教育基地",
  164. },
  165. {
  166. img: 1,
  167. id: 5,
  168. link: "http://www.4dmodel.com/SuperTwo/index.html?m=997",
  169. name: "苏兆征故居陈列馆",
  170. },
  171. {
  172. img: 2,
  173. id: 7,
  174. link: "http://www.4dmodel.com/SuperTwo/index.html?m=1015",
  175. name: "市退役军人事务局",
  176. }
  177. ];
  178. return {
  179. cards,
  180. };
  181. },
  182. methods: {
  183. goto(url) {
  184. window.open(url, "_blank");
  185. },
  186. },
  187. components: {
  188. Swiper,
  189. SwiperSlide,
  190. },
  191. directives: {
  192. swiper: directive,
  193. },
  194. mounted() {},
  195. };
  196. </script>
  197. <style lang="less" scoped>
  198. .swiper-container {
  199. position: relative;
  200. width: 100%;
  201. margin: 0 auto;
  202. }
  203. .swiper-wrapper {
  204. margin-top: 10px;
  205. padding: 20px 0;
  206. }
  207. .swiper-slide {
  208. width: 384px;
  209. cursor: pointer;
  210. font-size: 0;
  211. position: relative;
  212. }
  213. .swiper-slide .card {
  214. width: 100%;
  215. height: 500px;
  216. background:url('../../assets/images/card-bg.png') center center no-repeat;
  217. }
  218. .swiper-slide img {
  219. width: 100%;
  220. height: 75%;
  221. padding: 5px;
  222. }
  223. .swiper-slide .maskss {
  224. width: 100%;
  225. height: 100%;
  226. position: absolute;
  227. left: 0;
  228. top: 0;
  229. overflow: hidden;
  230. }
  231. .swiper-slide .mask {
  232. background: #804d28;
  233. opacity: 0.5;
  234. }
  235. .swiper-slide .mask1 {
  236. background: #6e4029;
  237. opacity: 0.65;
  238. }
  239. .swiper-slide .mask2 {
  240. background: #4b2b13;
  241. opacity: 0.65;
  242. }
  243. /deep/ .swiper-pagination-fraction, .swiper-pagination-custom, .swiper-container-horizontal > .swiper-pagination-bullets {
  244. bottom:0;
  245. }
  246. .swiper-slide .txt {
  247. position:absolute;
  248. bottom:10%;
  249. text-align:center;
  250. width:100%;
  251. font-size: 32px;
  252. font-family: Source Han Sans CN;
  253. font-weight: bold;
  254. line-height: 32px;
  255. color: #FCD67B;
  256. opacity: 1;
  257. padding: 0 5px;
  258. }
  259. @media screen and (max-width: 1600px) {
  260. .swiper-slide {
  261. width: 350px;
  262. }
  263. }
  264. </style>