You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
239 lines
6.3 KiB
239 lines
6.3 KiB
<template>
|
|
<view>
|
|
<lf-nav title="热门活动" :showIcon="true" bgColor="#fff" @changeHeight="e => nav_height = e"></lf-nav>
|
|
<view v-if="tab_list.length">
|
|
<u-tabs :list="tab_list" active-color="#15716E" inactive-color='#777777' :is-scroll="true" :current="tab_current" @change="tabChange"></u-tabs>
|
|
</view>
|
|
<swiper :style="{height: autoHeight}" :current="tab_current" @change="swiperChange">
|
|
<swiper-item v-for="(tab, tabIndex) in tab_list" :key="tabIndex">
|
|
<scroll-view :style="{height: autoHeight}" :scroll-y="true" :refresher-enabled="true" :refresher-triggered="isRefresher"
|
|
@scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh">
|
|
<view class="scroll-content">
|
|
<view class="card" v-for="(item, index) in tab.list" :key="index" @click="goDetails(item.id)">
|
|
<view class="cover">
|
|
<image class="img" :src="item.image" mode="widthFix"></image>
|
|
</view>
|
|
<view class="info">
|
|
<view class="title">{{item.name}}</view>
|
|
<view class="date">{{item.time_start}}-{{item.time_end}}</view>
|
|
</view>
|
|
</view>
|
|
<!-- 空数据的情况 -->
|
|
<view class="loading-more">
|
|
<text v-if="tab.list.length"
|
|
:class="{'loading-more-text': tab.loadingClass}">{{ tab.loadingText }}</text>
|
|
<lf-nocontent src="/static/images/empty.png" v-else></lf-nocontent>
|
|
</view>
|
|
</view>
|
|
<view style="height: 30rpx;"></view>
|
|
</scroll-view>
|
|
</swiper-item>
|
|
</swiper>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data(){
|
|
let _public = {
|
|
page: 1,
|
|
isPage: true,
|
|
loadingClass: true,
|
|
loadingText: '正在加载中'
|
|
}
|
|
return {
|
|
tab_current: 0,
|
|
tab_list: [{
|
|
name: '正在进行',
|
|
list: [],
|
|
..._public
|
|
},{
|
|
name: '往期回顾',
|
|
list: [],
|
|
..._public
|
|
}],
|
|
scrollH: 0,
|
|
nav_height: 0,
|
|
isRefresher: true
|
|
}
|
|
},
|
|
computed: {
|
|
autoHeight(){
|
|
return `calc(${this.scrollH}px - ${this.nav_height}px - 86rpx)`;
|
|
}
|
|
},
|
|
onLoad(){
|
|
let info = uni.getSystemInfoSync();
|
|
this.scrollH = info.screenHeight;
|
|
this.getHotActivity()
|
|
},
|
|
methods: {
|
|
goDetails(id) {
|
|
console.log('当前tabcurrent',this.tab_current)
|
|
if(this.tab_current == 0) {
|
|
this.$url('/pages/index/activity/detail?enter_type=0&is_end=0&activity_id='+id)
|
|
}else {
|
|
this.$url('/pages/index/activity/detail?enter_type=0&is_end=1&activity_id='+id)
|
|
}
|
|
},
|
|
// 页面触底,加载下一页
|
|
onScrolltolower(){
|
|
let tab_item = this.tab_list[this.tab_current];
|
|
if(tab_item.isPage){
|
|
tab_item.page = tab_item.page + 1;
|
|
this.getHotActivity();
|
|
}
|
|
},
|
|
// 下拉刷新处理
|
|
refreshFn(options){
|
|
let tab_item = this.tab_list[this.tab_current];
|
|
tab_item.page = 1;
|
|
tab_item.isPage = true;
|
|
tab_item.loadingClass = true;
|
|
tab_item.list = []
|
|
tab_item.loadingText = '正在加载中';
|
|
this.getHotActivity(options);
|
|
},
|
|
// scroll-view 下拉刷新
|
|
onRefresherrefresh(){
|
|
this.isRefresher = true;
|
|
this.refreshFn({type: 'scrollRefresh'});
|
|
},
|
|
tabChange(event){
|
|
this.tab_current = event;
|
|
this.getHotActivity();
|
|
},
|
|
swiperChange(event){
|
|
this.tab_current = event.detail.current;
|
|
if (event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
|
|
this.getHotActivity();
|
|
},
|
|
getHotActivity(options = {}) {
|
|
this.$http
|
|
.get({
|
|
api: 'api/activity',
|
|
data:{
|
|
is_expired: this.tab_current+1
|
|
},
|
|
header: {
|
|
Authorization: this.$cookieStorage.get('user_token')
|
|
},
|
|
})
|
|
.then(res => {
|
|
let tab_item = this.tab_list[this.tab_current];
|
|
if (res.data.code == 200) {
|
|
if (res.data.status) {
|
|
let isPage = res.data.next_page_url == null?false:true;
|
|
tab_item.isPage = isPage;
|
|
if(!isPage) {
|
|
tab_item.loadingClass = false;
|
|
tab_item.loadingText = '没有更多数据啦~';
|
|
}
|
|
if(options.type == 'pageRefresh') {
|
|
uni.stopPullDownRefresh();
|
|
}else if(options.type == 'scrollRefresh') {
|
|
this.isRefresher = false;
|
|
}
|
|
if(tab_item.page == 1) {
|
|
tab_item.list = res.data.data.data;
|
|
}else {
|
|
tab_item.list.push(...res.data.data.data);
|
|
}
|
|
console.log('数组列表',tab_item.list)
|
|
} else {
|
|
wx.showModal({
|
|
content: res.message || '请下拉页面刷新重试',
|
|
showCancel: false
|
|
});
|
|
}
|
|
} else {
|
|
wx.showModal({
|
|
content: '请下拉页面刷新重试',
|
|
showCancel: false
|
|
});
|
|
}
|
|
wx.hideLoading();
|
|
})
|
|
.catch(() => {
|
|
wx.hideLoading();
|
|
wx.showModal({
|
|
content: '请求失败',
|
|
showCancel: false
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped="scoped">
|
|
.scroll-content{
|
|
width: 100%;
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
justify-content: center;
|
|
.card{
|
|
width: 686rpx;
|
|
height: max-content;
|
|
background-color: #FFFFFF;
|
|
box-shadow: 1rpx 1rpx 6rpx 3rpx #e5e5e5;
|
|
margin-top: 30rpx;
|
|
border-radius: 20rpx;
|
|
overflow: hidden;
|
|
.cover{
|
|
width: 686rpx;
|
|
height: 300rpx;
|
|
position: relative;
|
|
.img{
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: #EEEEEE;
|
|
}
|
|
}
|
|
.info{
|
|
width: 686rpx;
|
|
height: max-content;
|
|
padding: 20rpx 30rpx;
|
|
box-sizing: border-box;
|
|
.title{
|
|
font-size: 28rpx;
|
|
color: #222222;
|
|
font-weight: bold;
|
|
}
|
|
.date{
|
|
margin-top: 20rpx;
|
|
font-size: 24rpx;
|
|
color: #555555;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// tabs 样式修改
|
|
/deep/.u-scroll-box {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
|
|
}
|
|
/deep/.u-scroll-box .u-tab-bar {
|
|
background-color: #15716E!important;
|
|
width: 80rpx!important;
|
|
position: absolute;
|
|
left: 0;
|
|
bottom: -12rpx;
|
|
}
|
|
|
|
/deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
|
|
background-color: #15716E!important;
|
|
width: 56rpx!important;
|
|
position: absolute;
|
|
height: 5rpx!important;
|
|
left: 8rpx;
|
|
bottom: -4rpx;
|
|
}
|
|
|
|
/deep/ .u-tab-item {
|
|
font-size: 28rpx!important;
|
|
}
|
|
</style>
|