2025-03-30 18:00:11 +08:00
|
|
|
<template>
|
2025-03-31 14:29:15 +08:00
|
|
|
<view class="page">
|
2025-04-06 12:46:05 +08:00
|
|
|
<!-- 筛选导航 -->
|
|
|
|
<view class="filter-tabs">
|
|
|
|
<view class="tabs-content">
|
|
|
|
<view
|
|
|
|
class="tab-item"
|
|
|
|
:class="{'active-tag': queryForm.orderType == 'latest'}"
|
|
|
|
@click="changeOrder('latest')"
|
|
|
|
>最新发布</view>
|
|
|
|
<view
|
|
|
|
class="tab-item"
|
|
|
|
:class="{'active-tag': queryForm.orderType == 'popularity'}"
|
|
|
|
@click="changeOrder('popularity')"
|
|
|
|
>人气排名</view>
|
|
|
|
<view class="brand-filter" :class="{ active: selectedBrand !== null }" @click="showBrandFilter">
|
|
|
|
<text>筛选品牌</text>
|
|
|
|
<image :src="'/static/icons/filter.svg'" mode="aspectFit" class="filter-icon"></image>
|
2025-03-31 14:29:15 +08:00
|
|
|
</view>
|
2025-03-30 18:00:11 +08:00
|
|
|
</view>
|
2025-04-06 12:46:05 +08:00
|
|
|
</view>
|
2025-03-31 14:29:15 +08:00
|
|
|
|
2025-04-06 12:46:05 +08:00
|
|
|
<!-- 列表内容区域 -->
|
|
|
|
<view class="list-container">
|
|
|
|
<scroll-view
|
|
|
|
scroll-y="true"
|
|
|
|
@scrolltolower="changePage"
|
|
|
|
refresher-enabled="true"
|
|
|
|
:refresher-triggered="isRefreshing"
|
|
|
|
@refresherrefresh="onRefresh"
|
|
|
|
class="scroll-view"
|
|
|
|
>
|
|
|
|
<view class="activity-wrapper">
|
2025-04-05 14:07:39 +08:00
|
|
|
<activity-item
|
2025-04-06 12:46:05 +08:00
|
|
|
v-for="(item, index) in activeList"
|
|
|
|
:key="index"
|
|
|
|
:item="item"
|
|
|
|
@click="toDetail"
|
|
|
|
@review="toReview"
|
|
|
|
/>
|
|
|
|
</view>
|
|
|
|
<view class="cu-load" :class="loading?'loading': activeList.length == total ? 'over' :'more'"></view>
|
|
|
|
</scroll-view>
|
2025-03-30 18:00:11 +08:00
|
|
|
</view>
|
2025-04-06 12:46:05 +08:00
|
|
|
|
|
|
|
<!-- 弹窗组件 -->
|
|
|
|
<login-popup ref="loginRef"></login-popup>
|
|
|
|
<brand-filter ref="brandFilterRef" @confirm="onBrandFilterConfirm"></brand-filter>
|
2025-03-30 18:00:11 +08:00
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import {
|
2025-03-31 14:29:15 +08:00
|
|
|
getActivities
|
2025-03-30 18:00:11 +08:00
|
|
|
} from '@/api/bar.js'
|
2025-04-03 02:20:07 +08:00
|
|
|
import loginPopup from '@/components/loginPopup.vue'
|
|
|
|
import brandFilter from '@/components/brandFilter.vue'
|
2025-04-05 14:07:39 +08:00
|
|
|
import ActivityItem from '@/components/ActivityItem.vue'
|
2025-04-03 02:20:07 +08:00
|
|
|
|
2025-03-30 18:00:11 +08:00
|
|
|
export default {
|
|
|
|
components: {
|
2025-04-03 02:20:07 +08:00
|
|
|
loginPopup,
|
2025-04-05 14:07:39 +08:00
|
|
|
brandFilter,
|
|
|
|
ActivityItem
|
2025-03-30 18:00:11 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
activeList: [], // 活动列表
|
|
|
|
loading: false,
|
2025-04-03 02:20:07 +08:00
|
|
|
isRefreshing: false,
|
2025-03-30 18:00:11 +08:00
|
|
|
queryForm: {
|
|
|
|
pageNum: 1,
|
|
|
|
pageSize: 5,
|
2025-04-03 02:20:07 +08:00
|
|
|
orderType: 'latest',
|
2025-03-30 18:00:11 +08:00
|
|
|
},
|
|
|
|
total: 0,
|
2025-04-03 02:20:07 +08:00
|
|
|
isFilterActive: false,
|
|
|
|
selectedBrand: null, // 选中的品牌ID
|
2025-03-30 18:00:11 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
onLoad() {
|
2025-04-03 20:14:11 +08:00
|
|
|
// 获取活动列表
|
2025-04-03 02:20:07 +08:00
|
|
|
this.getActivitiesFun();
|
2025-03-30 18:00:11 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
// 获取活动列表
|
|
|
|
getActivitiesFun() {
|
2025-03-31 14:29:15 +08:00
|
|
|
this.loading = true;
|
2025-04-03 02:20:07 +08:00
|
|
|
|
|
|
|
const params = {
|
|
|
|
pageNum: this.queryForm.pageNum,
|
2025-04-08 22:59:27 +08:00
|
|
|
pageSize: this.queryForm.pageSize,
|
|
|
|
orderType: this.queryForm.orderType,
|
|
|
|
breweryId: this.selectedBrand
|
2025-04-03 02:20:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
getActivities(params).then(res => {
|
2025-04-08 22:59:27 +08:00
|
|
|
console.log('获取到的数据:', res);
|
2025-03-31 14:29:15 +08:00
|
|
|
this.total = res.total;
|
2025-03-30 18:00:11 +08:00
|
|
|
if(res.rows && res.rows.length > 0) {
|
|
|
|
let arr = res.rows.map(it => {
|
2025-03-31 14:29:15 +08:00
|
|
|
it.remainingDays = this.getRemainingDays(it.endDate);
|
|
|
|
return it;
|
|
|
|
});
|
2025-04-03 02:20:07 +08:00
|
|
|
|
|
|
|
// 更新显示列表
|
2025-03-31 14:29:15 +08:00
|
|
|
if (this.queryForm.pageNum === 1) {
|
2025-04-08 22:59:27 +08:00
|
|
|
this.activeList = arr;
|
2025-03-31 14:29:15 +08:00
|
|
|
} else {
|
2025-04-08 22:59:27 +08:00
|
|
|
this.activeList = [...this.activeList, ...arr];
|
2025-03-31 14:29:15 +08:00
|
|
|
}
|
2025-04-03 02:20:07 +08:00
|
|
|
} else {
|
|
|
|
if (this.queryForm.pageNum === 1) {
|
|
|
|
this.activeList = [];
|
|
|
|
}
|
2025-03-30 18:00:11 +08:00
|
|
|
}
|
2025-03-31 14:29:15 +08:00
|
|
|
this.loading = false;
|
2025-03-30 18:00:11 +08:00
|
|
|
}).catch(err => {
|
2025-04-03 02:20:07 +08:00
|
|
|
console.error('获取活动列表失败:', err);
|
2025-03-31 14:29:15 +08:00
|
|
|
this.loading = false;
|
|
|
|
});
|
2025-03-30 18:00:11 +08:00
|
|
|
},
|
2025-03-31 14:29:15 +08:00
|
|
|
|
2025-03-30 18:00:11 +08:00
|
|
|
// 计算剩余天数
|
|
|
|
getRemainingDays(date) {
|
|
|
|
const targetDate = new Date(date);
|
|
|
|
const currentDate = new Date();
|
|
|
|
const timeDiff = targetDate.getTime() - currentDate.getTime();
|
|
|
|
const remainingDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
|
|
|
|
return remainingDays;
|
|
|
|
},
|
2025-03-31 14:29:15 +08:00
|
|
|
|
2025-04-03 20:14:11 +08:00
|
|
|
// 切换排序
|
|
|
|
changeOrder(type) {
|
|
|
|
// 如果点击当前激活的排序方式,不做处理
|
|
|
|
if (this.queryForm.orderType === type) return;
|
|
|
|
|
|
|
|
// 切换排序方式
|
|
|
|
this.queryForm.orderType = type;
|
|
|
|
|
|
|
|
// 重置分页
|
|
|
|
this.queryForm.pageNum = 1;
|
|
|
|
this.activeList = [];
|
|
|
|
|
|
|
|
// 重新获取数据
|
|
|
|
this.getActivitiesFun();
|
|
|
|
},
|
|
|
|
|
|
|
|
// 分页加载
|
|
|
|
changePage() {
|
|
|
|
if (this.activeList.length < this.total) {
|
|
|
|
this.queryForm.pageNum++;
|
|
|
|
this.getActivitiesFun();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// 跳转详情
|
|
|
|
toDetail(item) {
|
|
|
|
uni.navigateTo({
|
|
|
|
url: "/pagesActivity/activityDetail?id=" + item.id
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
// 跳转酒评
|
|
|
|
toReview(it) {
|
|
|
|
const token = uni.getStorageSync('token')
|
|
|
|
if (!token) {
|
|
|
|
this.$refs.loginRef.show()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
uni.navigateTo({
|
|
|
|
url: "/pages/index/review?beerId=" + it.id
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2025-03-31 14:29:15 +08:00
|
|
|
// 显示品牌筛选
|
|
|
|
showBrandFilter() {
|
2025-04-03 02:20:07 +08:00
|
|
|
// 如果还没有数据,先获取数据
|
2025-04-03 20:14:11 +08:00
|
|
|
if (!this.activeList || this.activeList.length === 0) {
|
2025-04-03 02:20:07 +08:00
|
|
|
this.queryForm.pageNum = 1;
|
|
|
|
this.getActivitiesFun().then(() => {
|
2025-04-03 20:14:11 +08:00
|
|
|
this.$refs.brandFilterRef.extractBrandsFromList(this.activeList);
|
2025-04-03 02:20:07 +08:00
|
|
|
this.$refs.brandFilterRef.open();
|
|
|
|
});
|
|
|
|
} else {
|
2025-04-03 20:14:11 +08:00
|
|
|
this.$refs.brandFilterRef.extractBrandsFromList(this.activeList);
|
2025-04-03 02:20:07 +08:00
|
|
|
this.$refs.brandFilterRef.open();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// 品牌筛选确认
|
|
|
|
onBrandFilterConfirm(result) {
|
|
|
|
this.selectedBrand = result.id;
|
|
|
|
this.queryForm.pageNum = 1;
|
|
|
|
this.activeList = [];
|
|
|
|
this.getActivitiesFun();
|
2025-03-31 14:29:15 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
// 添加下拉刷新方法
|
|
|
|
onRefresh() {
|
|
|
|
this.isRefreshing = true;
|
|
|
|
// 重置分页参数
|
|
|
|
this.queryForm.pageNum = 1;
|
|
|
|
this.activeList = [];
|
|
|
|
|
|
|
|
// 重新获取数据
|
2025-04-03 02:20:07 +08:00
|
|
|
this.getActivitiesFun();
|
2025-03-31 14:29:15 +08:00
|
|
|
}
|
2025-03-30 18:00:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2025-04-06 12:46:05 +08:00
|
|
|
.page {
|
|
|
|
min-height: 100vh;
|
|
|
|
background: #F9F9F9;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
|
|
|
|
.filter-tabs {
|
|
|
|
background: #FFFFFF;
|
|
|
|
padding: 0;
|
|
|
|
position: sticky;
|
|
|
|
top: 0;
|
|
|
|
z-index: 99;
|
2025-03-30 18:00:11 +08:00
|
|
|
|
2025-04-06 12:46:05 +08:00
|
|
|
.tabs-content {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
padding: 20rpx 24rpx;
|
|
|
|
height: 88rpx;
|
|
|
|
|
|
|
|
.tab-item {
|
|
|
|
width: 144rpx;
|
|
|
|
height: 64rpx;
|
|
|
|
line-height: 64rpx;
|
|
|
|
border-radius: 12rpx;
|
|
|
|
background: #F9F9F9;
|
|
|
|
margin-right: 16rpx;
|
|
|
|
font-size: 24rpx;
|
|
|
|
font-weight: 500;
|
|
|
|
text-align: center;
|
2025-03-30 18:00:11 +08:00
|
|
|
|
2025-04-06 12:46:05 +08:00
|
|
|
&.active-tag {
|
|
|
|
color: #FFF;
|
|
|
|
background: #D42E78;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.brand-filter {
|
|
|
|
margin-left: auto;
|
2025-03-31 14:29:15 +08:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2025-04-06 12:46:05 +08:00
|
|
|
justify-content: center;
|
|
|
|
height: 64rpx;
|
|
|
|
min-width: 144rpx;
|
|
|
|
padding: 0 24rpx;
|
|
|
|
border-radius: 12rpx;
|
|
|
|
background: #FFFFFF;
|
|
|
|
border: 1rpx solid #D42E78;
|
|
|
|
|
|
|
|
text {
|
|
|
|
color: #D42E78;
|
2025-03-31 14:29:15 +08:00
|
|
|
font-size: 24rpx;
|
|
|
|
font-weight: 500;
|
2025-04-06 12:46:05 +08:00
|
|
|
margin-right: 8rpx;
|
|
|
|
}
|
2025-03-30 18:00:11 +08:00
|
|
|
|
2025-04-06 12:46:05 +08:00
|
|
|
.filter-icon {
|
|
|
|
width: 32rpx;
|
|
|
|
height: 32rpx;
|
2025-03-31 14:29:15 +08:00
|
|
|
}
|
2025-03-30 18:00:11 +08:00
|
|
|
|
2025-04-06 12:46:05 +08:00
|
|
|
&.active {
|
|
|
|
background: #D42E78;
|
|
|
|
border-color: #D42E78;
|
2025-03-31 14:29:15 +08:00
|
|
|
|
|
|
|
text {
|
2025-04-06 12:46:05 +08:00
|
|
|
color: #FFFFFF;
|
2025-03-31 14:29:15 +08:00
|
|
|
}
|
2025-03-30 18:00:11 +08:00
|
|
|
|
2025-03-31 14:29:15 +08:00
|
|
|
.filter-icon {
|
2025-04-06 12:46:05 +08:00
|
|
|
filter: brightness(0) invert(1);
|
2025-03-31 14:29:15 +08:00
|
|
|
}
|
2025-03-30 18:00:11 +08:00
|
|
|
}
|
2025-03-31 14:29:15 +08:00
|
|
|
}
|
|
|
|
}
|
2025-04-06 12:46:05 +08:00
|
|
|
}
|
2025-03-31 14:29:15 +08:00
|
|
|
|
2025-04-06 12:46:05 +08:00
|
|
|
.list-container {
|
|
|
|
flex: 1;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
.scroll-view {
|
|
|
|
flex: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.activity-wrapper {
|
|
|
|
padding: 24rpx;
|
|
|
|
}
|
|
|
|
|
|
|
|
.cu-load {
|
|
|
|
text-align: center;
|
|
|
|
padding: 24rpx;
|
|
|
|
color: #999999;
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
|
|
|
&.loading::after {
|
|
|
|
content: "加载中...";
|
|
|
|
}
|
|
|
|
|
|
|
|
&.over::after {
|
|
|
|
content: "没有更多了";
|
|
|
|
}
|
|
|
|
|
|
|
|
&.more::after {
|
|
|
|
content: "上拉加载更多";
|
|
|
|
}
|
2025-03-31 14:29:15 +08:00
|
|
|
}
|
2025-04-06 12:46:05 +08:00
|
|
|
}
|
2025-03-30 18:00:11 +08:00
|
|
|
</style>
|