123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- <template>
- <div class="swiper-container">
- <swiper
- ref="listSwiper"
- class="swiper-wrapper swiper-wrapper-n"
- :options="swiperOption"
- >
- <swiper-slide
- class="swiper-slide"
- v-for="(item, index) in cards"
- :key="index"
- >
- <div
- class="card"
- @click="
- $router.push({
- name: 'Scene',
- query: { id: item.id },
- params: { link: item.link },
- })
- "
- >
- <img class="logo" src="../../assets/images/card-img.png" />
- <div class="txt">{{item.name}}</div>
- <div class="maskss"></div>
- </div>
- </swiper-slide>
- <div class="swiper-pagination" slot="pagination"></div>
- <div class="swiper-button-next"></div>
- <div class="swiper-button-prev"></div>
- </swiper>
- </div>
- </template>
- <script>
- import { Swiper, SwiperSlide, directive } from "vue-awesome-swiper";
- import "swiper/css/swiper.css";
- export default {
- computed: {
- swiper() {
- return this.$refs.listSwiper.$swiper;
- },
- swiperOption() {
- // let that = this
- let getIndex = (range, length, current) => {
- let next =
- current + range > length ? current + range - length : current + range;
- let prev =
- current - range < 0 ? current - range + length : current - range;
- return {
- prev,
- next,
- };
- };
- let setClass = (range, length, current, that, cls) => {
- let { prev, next } = getIndex(range, length, current);
- let p = that.slides.eq(prev);
- let n = that.slides.eq(next);
- let cur = that.slides.eq(current);
- p.find(".maskss").removeClass("mask mask1 mask2");
- n.find(".maskss").removeClass("mask mask1 mask2");
- cur.find(".maskss").removeClass("mask mask1 mask2");
- p.find(".maskss").addClass(cls);
- n.find(".maskss").addClass(cls);
- };
- return {
- watchSlidesProgress: true,
- slidesPerView: "auto",
- centeredSlides: true,
- initialSlide: 2,
- // loop: true,
- // loopedSlides: 9,
- navigation: {
- nextEl: ".swiper-button-next",
- prevEl: ".swiper-button-prev",
- },
- pagination: {
- el: ".swiper-pagination",
- clickable: true //允许分页点击跳转
- },
- on: {
- click: function () {
- if (this.clickedIndex >= 0) {
- this.slideTo(this.clickedIndex, 500, () => {
- this.lazy.load();
- });
- }
- },
- transitionEnd: function () {
- let length = this.slides.length;
- for (let i = 0; i < length; i++) {
- var slide = this.slides.eq(i);
- let classNames = slide[0].className;
- if (classNames.indexOf("active") > -1) {
- setClass(1, length, i, this, "mask");
- setClass(2, length, i, this, "mask1");
- setClass(3, length, i, this, "mask2");
- }
- }
- },
- progress: function () {
- for (let i = 0; i < this.slides.length; i++) {
- var slide = this.slides.eq(i);
- var slideProgress = this.slides[i].progress;
- var modify = 1;
- if (Math.abs(slideProgress) > 1) {
- modify = (Math.abs(slideProgress) - 1) * 0.3 + 1;
- }
- let translate = slideProgress * modify * 140 + "px";
- let scale = 1 - Math.abs(slideProgress) / 5;
- let zIndex = 999 - Math.abs(Math.round(10 * slideProgress));
- // let opacity = 1 - Math.min(Math.abs(slideProgress / 2), 1);
- slide.transform(
- "translateX(" + translate + ") scale(" + scale + ")"
- );
- slide.css({
- zIndex: zIndex,
- opacity: 1,
- "pointer-events": "auto",
- });
- if (Math.abs(slideProgress) > 3) {
- slide.css({
- // "opacity":0,
- "pointer-events": "none",
- });
- }
- }
- },
- setTransition: function (transition) {
- for (var i = 0; i < this.slides.length; i++) {
- var slide = this.slides.eq(i);
- slide.transition(transition);
- }
- },
- },
- };
- },
- },
- props: ["list"],
- data() {
- let cards = [
- {
- img: 1,
- id: 8,
- link: "http://www.4dmodel.com/SuperTwo/index.html?m=1017",
- name: "万山海战遗址",
- },
- {
- img: 2,
- id: 3,
- link: "http://www.4dmodel.com/SuperTwo582/vtour/tour.html",
- name: "杨匏安陈列馆",
- },
- {
- img: 1,
- id: 4,
- link: "http://www.4dmodel.com/SuperTwo/index.html?m=1016",
- name: "林伟民与中国早期工人运动史迹陈列馆",
- },
- {
- img: 2,
- id: 9,
- link: "http://www.4dmodel.com/SuperTwo/index.html?m=1018",
- name: "中共小濠冲党史教育基地",
- },
- {
- img: 1,
- id: 5,
- link: "http://www.4dmodel.com/SuperTwo/index.html?m=997",
- name: "苏兆征故居陈列馆",
- },
- {
- img: 2,
- id: 7,
- link: "http://www.4dmodel.com/SuperTwo/index.html?m=1015",
- name: "市退役军人事务局",
- }
- ];
- return {
- cards,
- };
- },
- methods: {
- goto(url) {
- window.open(url, "_blank");
- },
- },
- components: {
- Swiper,
- SwiperSlide,
- },
- directives: {
- swiper: directive,
- },
- mounted() {},
- };
- </script>
- <style lang="less" scoped>
- .swiper-container {
- position: relative;
- width: 100%;
- margin: 0 auto;
- }
- .swiper-wrapper {
- margin-top: 10px;
- padding: 20px 0;
- }
- .swiper-slide {
- width: 384px;
- cursor: pointer;
- font-size: 0;
- position: relative;
- }
- .swiper-slide .card {
- width: 100%;
- height: 500px;
- background:url('../../assets/images/card-bg.png') center center no-repeat;
- }
- .swiper-slide img {
- width: 100%;
- height: 75%;
- padding: 5px;
- }
- .swiper-slide .maskss {
- width: 100%;
- height: 100%;
- position: absolute;
- left: 0;
- top: 0;
- overflow: hidden;
- }
- .swiper-slide .mask {
- background: #804d28;
- opacity: 0.5;
- }
- .swiper-slide .mask1 {
- background: #6e4029;
- opacity: 0.65;
- }
- .swiper-slide .mask2 {
- background: #4b2b13;
- opacity: 0.65;
- }
- /deep/ .swiper-pagination-fraction, .swiper-pagination-custom, .swiper-container-horizontal > .swiper-pagination-bullets {
- bottom:0;
- }
- .swiper-slide .txt {
- position:absolute;
- bottom:10%;
- text-align:center;
- width:100%;
- font-size: 32px;
- font-family: Source Han Sans CN;
- font-weight: bold;
- line-height: 32px;
- color: #FCD67B;
- opacity: 1;
- padding: 0 5px;
- }
- @media screen and (max-width: 1600px) {
- .swiper-slide {
- width: 350px;
- }
- }
- </style>
|