301 lines
9.2 KiB
JavaScript
301 lines
9.2 KiB
JavaScript
const act = {
|
|
template: /*language=HTML*/ `
|
|
<!-- 活动 -->
|
|
<div class="section-wrapper">
|
|
<div class="section-act">
|
|
<!-- 标题 -->
|
|
<div class="section-act-title">
|
|
<span>工会活动</span>
|
|
</div>
|
|
|
|
<!-- Swiper容器 -->
|
|
<div class="activity-swiper-container">
|
|
<!-- 活动数据 - Swiper -->
|
|
<div class="swiper activity-swiper">
|
|
<div class="swiper-wrapper">
|
|
<div class="swiper-slide" v-for="(activity, index) in actList" :key="activity.id">
|
|
<div class="item" @click="go(activity)">
|
|
<div class="img-box">
|
|
<img :src="activity.cover || 'https://www.ncu.edu.cn/__local/8/52/2C/644986B4C9A030F7B65300178A6_8679CB08_18467.jpg'"
|
|
alt="">
|
|
<span class="status">
|
|
{{getStatusText(activity)}}
|
|
</span>
|
|
</div>
|
|
<h4 class="title">
|
|
{{ activity.name}}
|
|
</h4>
|
|
<!--报名时间-->
|
|
<div class="time">
|
|
<p>
|
|
<i class="fa fa-clock-o"></i>
|
|
时间:{{ activity.startDate }}至{{ activity.endDate }}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 导航按钮 -->
|
|
<div class="swiper-button-next"></div>
|
|
<div class="swiper-button-prev"></div>
|
|
|
|
<!-- 进度条 -->
|
|
<div class="swiper-pagination"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`,
|
|
data() {
|
|
return {
|
|
actList: [],
|
|
swiper: null
|
|
}
|
|
},
|
|
methods: {
|
|
/*查询活动*/
|
|
listAct() {
|
|
this.$axios.post("/platform/home/listHomeActivity").then((res) => {
|
|
if (res.code === 0) {
|
|
// for (let i = 0; i < 10; i++) {
|
|
// this.actList = this.actList.concat(res.data)
|
|
// }
|
|
this.actList = res.data
|
|
// 数据加载完成后初始化Swiper
|
|
this.$nextTick(() => {
|
|
this.initSwiper()
|
|
})
|
|
}
|
|
})
|
|
},
|
|
/*初始化Swiper*/
|
|
initSwiper() {
|
|
this.swiper = new Swiper('.activity-swiper', {
|
|
slidesPerView: 'auto',
|
|
spaceBetween: 30,
|
|
centeredSlides: false,
|
|
loop: false,
|
|
navigation: {
|
|
nextEl: '.swiper-button-next',
|
|
prevEl: '.swiper-button-prev',
|
|
},
|
|
pagination: {
|
|
el: '.swiper-pagination',
|
|
type: 'progressbar',
|
|
},
|
|
breakpoints: {
|
|
768: {
|
|
slidesPerView: 2,
|
|
},
|
|
1024: {
|
|
slidesPerView: 3,
|
|
},
|
|
1200: {
|
|
slidesPerView: 4,
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
// 活动状态
|
|
getStatusText(item) {
|
|
if (this.$moment().unix() > this.$moment(item.endDate).unix()) {
|
|
return "已结束"
|
|
} else if (this.$moment().unix() < this.$moment(item.startDate).unix()) {
|
|
return "未开始"
|
|
} else {
|
|
return "进行中"
|
|
}
|
|
},
|
|
|
|
go(act) {
|
|
if (!act.url) {
|
|
this.$message.warning("管理员未配置活动链接")
|
|
return
|
|
}
|
|
window.open(act.url)
|
|
}
|
|
},
|
|
mounted() {
|
|
this.listAct()
|
|
},
|
|
style: /*language=CSS*/ `
|
|
.section-wrapper {
|
|
width: 100%;
|
|
}
|
|
|
|
.section-act {
|
|
width: 80%;
|
|
max-width: 80%;
|
|
margin: 30px auto;
|
|
}
|
|
|
|
.section-act .section-act-title span {
|
|
font-size: 30px;
|
|
color: #000000;
|
|
display: block;
|
|
font-weight: bold;
|
|
position: relative;
|
|
text-align: center;
|
|
padding: 40px 0;
|
|
}
|
|
|
|
/*.section-act .section-act-title span:hover {
|
|
color: var(--color-primary);
|
|
cursor: pointer;
|
|
}*/
|
|
|
|
/deep/ .section-act .section-act-title span::before {
|
|
content: '';
|
|
width: 24px;
|
|
height: 11px;
|
|
background: url(https://www.ncu.edu.cn/images/titl.svg) no-repeat center;
|
|
background-size: 24px 11px;
|
|
display: inline-block;
|
|
margin-right: 0;
|
|
vertical-align: middle;
|
|
}
|
|
|
|
/deep/ .section-act .section-act-title span::after {
|
|
content: '';
|
|
width: 24px;
|
|
height: 11px;
|
|
background: url(https://www.ncu.edu.cn/images/titr.svg) no-repeat center;
|
|
background-size: 24px 11px;
|
|
display: inline-block;
|
|
margin-left: 0;
|
|
vertical-align: middle;
|
|
}
|
|
|
|
/* Swiper容器样式 */
|
|
.activity-swiper-container {
|
|
position: relative;
|
|
width: 100%;
|
|
margin-top: 30px;
|
|
}
|
|
|
|
.activity-swiper {
|
|
width: 100%;
|
|
padding: 0 50px 20px 50px;
|
|
}
|
|
|
|
.activity-swiper .swiper-slide {
|
|
height: auto;
|
|
}
|
|
|
|
/* 导航按钮样式 */
|
|
.activity-swiper-container .swiper-button-next,
|
|
.activity-swiper-container .swiper-button-prev {
|
|
color: var(--color-primary);
|
|
background: white;
|
|
width: 40px;
|
|
height: 40px;
|
|
border-radius: 50%;
|
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.activity-swiper-container .swiper-button-next:hover,
|
|
.activity-swiper-container .swiper-button-prev:hover {
|
|
background: var(--color-primary);
|
|
color: white;
|
|
transform: scale(1.1);
|
|
}
|
|
|
|
/deep/ .activity-swiper-container .swiper-button-next::after,
|
|
/deep/ .activity-swiper-container .swiper-button-prev::after {
|
|
font-size: 16px;
|
|
font-weight: bold;
|
|
}
|
|
|
|
/* 进度条样式 */
|
|
.activity-swiper-container .swiper-pagination {
|
|
position: relative;
|
|
margin-top: 30px;
|
|
height: 4px;
|
|
}
|
|
|
|
.activity-swiper-container .swiper-pagination-progressbar {
|
|
background: #e0e0e0;
|
|
border-radius: 2px;
|
|
}
|
|
|
|
.activity-swiper-container .swiper-pagination-progressbar-fill {
|
|
background: var(--color-primary);
|
|
border-radius: 2px;
|
|
}
|
|
|
|
.activity-swiper .swiper-slide .item {
|
|
height: auto;
|
|
position: relative;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.activity-swiper .swiper-slide .item .img-box {
|
|
width: 100%;
|
|
height: 200px;
|
|
overflow: hidden;
|
|
position: relative;
|
|
}
|
|
|
|
.activity-swiper .swiper-slide .item .img-box .status {
|
|
position: absolute;
|
|
left: 0;
|
|
top: 0;
|
|
background: #c11623;
|
|
padding: 6px 2px;
|
|
min-width: 50px;
|
|
color: #ffffff;
|
|
border-radius: 0 0 50% 0;
|
|
}
|
|
|
|
|
|
.activity-swiper .swiper-slide .item .img-box img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
transition: transform 0.3s ease;
|
|
}
|
|
|
|
.activity-swiper .swiper-slide .item:hover .img-box img {
|
|
transform: scale(1.1);
|
|
}
|
|
|
|
.activity-swiper .swiper-slide .item h4 {
|
|
font-size: 20px;
|
|
margin-top: 10px;
|
|
height: 60px;
|
|
color: #333;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 2;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
line-height: 1.5;
|
|
text-align: left;
|
|
transition: color 0.3s ease;
|
|
}
|
|
|
|
.activity-swiper .swiper-slide .item:hover h4 {
|
|
color: var(--color-primary);
|
|
}
|
|
|
|
.activity-swiper .swiper-slide .item .time {
|
|
margin-top: 8px;
|
|
}
|
|
|
|
.activity-swiper .swiper-slide .item .time p {
|
|
font-size: 14px;
|
|
margin: 0;
|
|
line-height: 1.5;
|
|
color: #666;
|
|
}
|
|
|
|
.activity-swiper .swiper-slide .item .time i {
|
|
margin-right: 5px;
|
|
color: var(--color-primary);
|
|
}
|
|
`
|
|
}
|