2025-03-13 09:52:18 +08:00
|
|
|
|
<template>
|
|
|
|
|
<div class="special-column">
|
|
|
|
|
<div class="title-wrap">
|
|
|
|
|
<label>专题专栏</label>
|
|
|
|
|
<!-- 箭头 -->
|
|
|
|
|
<span/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="swiper-wrap">
|
|
|
|
|
<swiper
|
|
|
|
|
class="swiper-container"
|
|
|
|
|
ref="swiper"
|
|
|
|
|
:speed="500"
|
2025-03-13 10:14:57 +08:00
|
|
|
|
:slidesPerView="4"
|
2025-03-13 09:52:18 +08:00
|
|
|
|
:loop="true"
|
|
|
|
|
:autoplay="{
|
|
|
|
|
delay: 1500,
|
|
|
|
|
disableOnInteraction: false // 触摸后是否停止自动移动
|
|
|
|
|
}"
|
|
|
|
|
:modules="modules"
|
|
|
|
|
@mouseenter="$refs.swiper.$el.swiper.autoplay.stop()"
|
|
|
|
|
@mouseleave="$refs.swiper.$el.swiper.autoplay.start()"
|
|
|
|
|
>
|
|
|
|
|
<swiper-slide v-for="(item, index) in getIcons" :key="index">
|
|
|
|
|
<nuxt-link target="_blank" :to="JSON.parse(item.value).link">
|
|
|
|
|
<img
|
|
|
|
|
:src="getImageURL(JSON.parse(item.value).image)"
|
|
|
|
|
:alt="item.title"
|
|
|
|
|
/>
|
|
|
|
|
</nuxt-link>
|
|
|
|
|
</swiper-slide>
|
|
|
|
|
</swiper>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { Swiper, SwiperSlide } from 'swiper/vue'
|
|
|
|
|
import { Autoplay } from 'swiper/modules'
|
|
|
|
|
import 'swiper/scss'
|
|
|
|
|
import 'swiper/scss/free-mode'
|
|
|
|
|
import { getImageURL } from '@/utils/util'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'SpecialColumn',
|
|
|
|
|
components: { Swiper, SwiperSlide },
|
|
|
|
|
props: {
|
|
|
|
|
icons: {
|
|
|
|
|
default: () => {
|
|
|
|
|
return []
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
// 获取图标
|
|
|
|
|
getIcons () {
|
2025-03-13 10:14:57 +08:00
|
|
|
|
if (this.icons.length < 5 || this.icons.length > 7) {
|
2025-03-13 09:52:18 +08:00
|
|
|
|
return this.icons
|
|
|
|
|
}
|
|
|
|
|
return [...this.icons, ...this.icons]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
modules: []
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
getImageURL
|
|
|
|
|
},
|
|
|
|
|
created () {
|
|
|
|
|
this.modules = [Autoplay]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.special-column {
|
|
|
|
|
display: flex;
|
|
|
|
|
// 标题
|
|
|
|
|
.title-wrap {
|
2025-03-13 10:14:57 +08:00
|
|
|
|
height: 100px;
|
|
|
|
|
width: 40px;
|
2025-03-13 09:52:18 +08:00
|
|
|
|
margin: auto 20px auto 0;
|
2025-03-13 10:14:57 +08:00
|
|
|
|
padding: 0 14px;
|
2025-03-13 09:52:18 +08:00
|
|
|
|
background: linear-gradient(90deg, var(--primary-color-light) 0%, var(--primary-color) 100%);
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
position: relative;
|
|
|
|
|
// 箭头
|
|
|
|
|
& > span {
|
|
|
|
|
position: absolute;
|
|
|
|
|
right: -12px;
|
|
|
|
|
top: calc(50% - 10px);
|
|
|
|
|
width: 0;
|
|
|
|
|
height: 0;
|
|
|
|
|
border-bottom:10px solid transparent;
|
|
|
|
|
border-top: 10px solid transparent;
|
|
|
|
|
border-left: 12px solid var(--primary-color);
|
|
|
|
|
}
|
|
|
|
|
// 专题文字
|
|
|
|
|
label {
|
|
|
|
|
display: block;
|
|
|
|
|
color: #ffffff;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 轮播列表
|
|
|
|
|
.swiper-wrap {
|
|
|
|
|
width: calc(100% - 80px);
|
2025-03-13 10:14:57 +08:00
|
|
|
|
height: 100px;
|
2025-03-13 09:52:18 +08:00
|
|
|
|
flex-grow: 1;
|
2025-03-13 10:14:57 +08:00
|
|
|
|
overflow: hidden;
|
2025-03-13 09:52:18 +08:00
|
|
|
|
// 轮播项
|
|
|
|
|
.swiper-slide {
|
2025-03-13 10:14:57 +08:00
|
|
|
|
// 给定最大宽度,避免swiper没有计算出width时图片临时性展示过大
|
|
|
|
|
max-width: 25%;
|
2025-03-13 09:52:18 +08:00
|
|
|
|
height: 100%;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
padding: 0 10px;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
&:first-of-type {
|
|
|
|
|
padding-left: 0;
|
|
|
|
|
}
|
|
|
|
|
&:last-of-type {
|
|
|
|
|
padding-right: 0;
|
|
|
|
|
}
|
|
|
|
|
& > a {
|
|
|
|
|
display: block;
|
2025-03-13 10:14:57 +08:00
|
|
|
|
height: 100px;
|
2025-03-13 09:52:18 +08:00
|
|
|
|
cursor: pointer;
|
|
|
|
|
img {
|
2025-03-13 10:14:57 +08:00
|
|
|
|
border-radius: 20px;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
2025-03-13 09:52:18 +08:00
|
|
|
|
object-fit: cover;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-03-13 10:14:57 +08:00
|
|
|
|
</style>
|