| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- <template>
- <view class="activities-page">
- <!-- 自定义导航栏 -->
- <view class="custom-navbar">
- <view class="navbar-left" @click="goBack">
- <text class="back-icon">←</text>
- </view>
- <view class="navbar-title">活动列表</view>
- <view class="navbar-right"></view>
- </view>
- <!-- 活动列表 -->
- <view class="activity-list">
- <view class="activity-card" v-for="(item, index) in activityList" :key="index"
- @click="goToDetail(item.id)">
- <image :src="item.cover_image" class="activity-image" mode="aspectFill"></image>
- <view class="activity-info">
- <view class="activity-name">{{ item.name }}</view>
- <view class="activity-meta">
- <text class="activity-time">⏰ {{ formatTime(item.start_time) }}</text>
- <text class="activity-location">📍 {{ item.location }}</text>
- </view>
- <view class="activity-footer">
- <view class="activity-price">
- <text class="price-symbol">¥</text>
- <text class="price-value">{{ item.price }}</text>
- </view>
- <view class="activity-btn">立即报名</view>
- </view>
- </view>
- <view class="hot-tag" v-if="item.is_hot">HOT</view>
- </view>
- </view>
- <!-- 加载更多 -->
- <view class="load-more" v-if="hasMore">
- <text class="load-text">{{ loading ? '加载中...' : '上拉加载更多' }}</text>
- </view>
- <view class="no-more" v-else>
- <text class="no-more-text">没有更多了</text>
- </view>
- </view>
- </template>
- <script>
- import api from '@/utils/api.js'
- import { formatTime } from '@/utils/util.js'
- import { DEFAULT_IMAGES } from '@/config/index.js'
- export default {
- data() {
- return {
- activityList: [],
- pageNum: 1,
- pageSize: 10,
- hasMore: true,
- loading: false
- }
- },
- onLoad() {
- this.loadActivityList()
- },
- onReachBottom() {
- if (this.hasMore && !this.loading) {
- this.pageNum++
- this.loadActivityList()
- }
- },
- methods: {
- // 加载活动列表
- async loadActivityList() {
- if (this.loading) return
- this.loading = true
- try {
- const data = await api.activity.getList({
- pageNum: this.pageNum,
- pageSize: this.pageSize,
- status: 1
- })
- if (data && data.length > 0) {
- this.activityList = [...this.activityList, ...data]
- this.hasMore = data.length >= this.pageSize
- } else {
- this.hasMore = false
- }
- } catch (error) {
- console.error('加载活动列表失败:', error)
- uni.showToast({
- title: '加载失败',
- icon: 'none'
- })
- } finally {
- this.loading = false
- }
- },
- // 格式化时间
- formatTime,
- // 跳转到详情
- goToDetail(id) {
- uni.navigateTo({
- url: `/pages/activities/detail?id=${id}`
- })
- },
- // 返回
- goBack() {
- uni.navigateBack()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .activities-page {
- min-height: 100vh;
- background-color: #FFF9F9;
- padding-top: 90rpx;
- }
- /* 自定义导航栏 */
- .custom-navbar {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- height: 90rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 20rpx;
- background-color: #E91E63;
- z-index: 999;
- .navbar-left,
- .navbar-right {
- width: 80rpx;
- }
- .back-icon {
- font-size: 40rpx;
- color: #FFFFFF;
- font-weight: bold;
- }
- .navbar-title {
- flex: 1;
- text-align: center;
- font-size: 32rpx;
- font-weight: bold;
- color: #FFFFFF;
- }
- }
- /* 活动列表 */
- .activity-list {
- padding: 20rpx 30rpx;
- .activity-card {
- position: relative;
- display: flex;
- margin-bottom: 20rpx;
- background-color: #FFFFFF;
- border-radius: 20rpx;
- overflow: hidden;
- box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
- .activity-image {
- width: 260rpx;
- height: 260rpx;
- background-color: #F5F5F5;
- }
- .activity-info {
- flex: 1;
- padding: 20rpx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .activity-name {
- font-size: 30rpx;
- font-weight: bold;
- color: #333333;
- margin-bottom: 10rpx;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- }
- .activity-meta {
- display: flex;
- flex-direction: column;
- gap: 8rpx;
- font-size: 24rpx;
- color: #666666;
- .activity-location {
- color: #999999;
- }
- }
- .activity-footer {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 10rpx;
- .activity-price {
- color: #E91E63;
- font-weight: bold;
- .price-symbol {
- font-size: 24rpx;
- }
- .price-value {
- font-size: 36rpx;
- }
- }
- .activity-btn {
- padding: 10rpx 30rpx;
- background-color: #E91E63;
- color: #FFFFFF;
- text-align: center;
- border-radius: 30rpx;
- font-size: 24rpx;
- }
- }
- }
- .hot-tag {
- position: absolute;
- top: 10rpx;
- left: 10rpx;
- padding: 5rpx 15rpx;
- background: linear-gradient(135deg, #FF6B6B 0%, #FF9800 100%);
- color: #FFFFFF;
- font-size: 20rpx;
- font-weight: bold;
- border-radius: 10rpx;
- }
- }
- }
- /* 加载更多 */
- .load-more,
- .no-more {
- padding: 30rpx 0;
- text-align: center;
- .load-text,
- .no-more-text {
- font-size: 24rpx;
- color: #999999;
- }
- }
- </style>
|