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.
302 lines
7.8 KiB
302 lines
7.8 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="#0E2F9E" 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)">
|
|
<view class="cover">
|
|
<image class="img" :src="item.image"></image>
|
|
<!-- TODO 活动标签 -->
|
|
<!-- <view class="label" :class="'theme-'+ (index+1)" v-if="item.is_expired==false && item.state =='待使用'">待使用</view>
|
|
<view class="label" :class="'theme-'+ (index+1)" v-if="item.is_expired==true">已过期</view>
|
|
<view class="label" :class="'theme-'+ (index+1)" v-if="item.is_expired==false">{{item.state}}</view> -->
|
|
<!-- <view class="label theme-1">{{ showLabel(item) }}</view> -->
|
|
</view>
|
|
<view class="info">
|
|
<view class="title">{{item.name}}</view>
|
|
<view class="date">{{item.created_at}}</view>
|
|
</view>
|
|
</view>
|
|
<!-- 空数据的情况 -->
|
|
<view class="loading-more">
|
|
<text v-if="tab.list.length"
|
|
:class="{'loading-more-text': tab.loadingClass}">{{ tab.loadingText }}</text>
|
|
<lf-nocontent v-else src="/static/images/empty.png"></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: '全部',
|
|
state: '',
|
|
list: [],
|
|
..._public
|
|
},{
|
|
name: '未开始',
|
|
state: 'nstart',
|
|
list: [],
|
|
..._public
|
|
},{
|
|
name: '进行中',
|
|
state: 'ing',
|
|
list: [],
|
|
..._public
|
|
},{
|
|
name: '已过期',
|
|
state: 'end',
|
|
list: [],
|
|
..._public
|
|
}],
|
|
scrollH: 0,
|
|
nav_height: 0,
|
|
isRefresher: true,
|
|
pageSize: 10,
|
|
token: '',
|
|
show_count: 0
|
|
}
|
|
},
|
|
computed: {
|
|
autoHeight(){
|
|
return `calc(${this.scrollH}px - ${this.nav_height}px - 86rpx)`;
|
|
},
|
|
showLabel(){
|
|
return function(item){
|
|
|
|
}
|
|
}
|
|
},
|
|
onLoad(){
|
|
this.token = this.$cookieStorage.get('store_token');
|
|
let info = uni.getSystemInfoSync();
|
|
this.scrollH = info.screenHeight;
|
|
this.getMyActivity()
|
|
},
|
|
onShow(){
|
|
this.show_count++;
|
|
if(this.show_count > 1){
|
|
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.getMyActivity();
|
|
}
|
|
},
|
|
methods: {
|
|
goDetails(item) {
|
|
if(!item.is_between){
|
|
this.$url('/pages/business/activity/add?id='+ item.id);
|
|
}
|
|
// is_apply_expired: false // 活动报名结束
|
|
// is_between: false // 活动未开始,以此页面跳转可编辑
|
|
// is_between_apply: false // 活动报名期间
|
|
// is_start 活动是否开启
|
|
},
|
|
// 页面触底,加载下一页
|
|
onScrolltolower(){
|
|
let tab_item = this.tab_list[this.tab_current];
|
|
if(tab_item.isPage){
|
|
tab_item.page = tab_item.page + 1;
|
|
this.getMyActivity();
|
|
}
|
|
},
|
|
// 下拉刷新处理
|
|
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.getMyActivity(options);
|
|
},
|
|
// scroll-view 下拉刷新
|
|
onRefresherrefresh(){
|
|
this.isRefresher = true;
|
|
this.refreshFn({type: 'scrollRefresh'});
|
|
},
|
|
tabChange(event){
|
|
this.tab_current = event;
|
|
this.getMyActivity();
|
|
},
|
|
swiperChange(event){
|
|
this.tab_current = event.detail.current;
|
|
if (event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
|
|
this.getMyActivity();
|
|
},
|
|
getMyActivity(options = {}) {
|
|
let tab_item = this.tab_list[this.tab_current];
|
|
this.$http
|
|
.get({
|
|
api: 'api/supplier/activity',
|
|
data:{
|
|
status: tab_item.state,
|
|
page: tab_item.page,
|
|
page_size: this.pageSize
|
|
},
|
|
header: {
|
|
token: this.token
|
|
},
|
|
})
|
|
.then(res => {
|
|
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.data.message || '请下拉页面刷新重试',
|
|
showCancel: false
|
|
});
|
|
}
|
|
} else {
|
|
wx.showModal({
|
|
content: res.data.message || '请下拉页面刷新重试',
|
|
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;
|
|
}
|
|
.label{
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 118rpx;
|
|
height: 57rpx;
|
|
border-radius: 20rpx 0rpx 20rpx 0rpx;
|
|
text-align: center;
|
|
line-height: 57rpx;
|
|
color: #FFFFFF;
|
|
font-size: 26rpx;
|
|
}
|
|
}
|
|
.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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.theme-1{
|
|
background-color: #0E2F9E;
|
|
}
|
|
.theme-2{
|
|
background-color: #1789E4;
|
|
}
|
|
.theme-3{
|
|
background-color: #777777;
|
|
}
|
|
|
|
// 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: #0E2F9E!important;
|
|
width: 80rpx!important;
|
|
position: absolute;
|
|
left: 0;
|
|
bottom: -12rpx;
|
|
}
|
|
|
|
/deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
|
|
background-color: #0E2F9E!important;
|
|
width: 56rpx!important;
|
|
position: absolute;
|
|
height: 5rpx!important;
|
|
left: 8rpx;
|
|
bottom: -4rpx;
|
|
}
|
|
|
|
/deep/ .u-tab-item {
|
|
font-size: 28rpx!important;
|
|
}
|
|
</style>
|