|
|
- <template>
- <view class="page">
-
- <!-- 收藏列表 -->
- <view class="content">
- <view v-if="favoritesList.length > 0" class="activity-list">
- <view class="activity-item" v-for="item in favoritesList" :key="item.id" @click="viewActivityDetail(item)">
- <image class="activity-image" :src="item.image" mode="aspectFill"></image>
- <view class="activity-info">
- <view class="title-row">
- <view class="activity-badge">
- <text class="badge-text">{{ item.score }}分</text>
- </view>
- <text class="activity-title">{{ item.title }}</text>
- </view>
- <view class="activity-location">
- <uv-icon name="map-fill" size="14" color="#999"></uv-icon>
- <text class="location-text">{{ item.address || '线上活动' }}</text>
- </view>
- <view class="activity-time">
- <uv-icon name="calendar" size="14" color="#999"></uv-icon>
- <text class="time-text">{{ item.activityTime }}</text>
- </view>
- <view class="activity-participants">
- <uv-icon name="account-fill" size="14" ></uv-icon>
- <text class="participants-text">报名人数:{{ item.numActivity + '/' + item.numLimit }}</text>
- </view>
- </view>
- <view class="activity-action">
- <uv-button type="primary" size="mini" text="查看详情" @click.stop="viewActivityDetail(item)"></uv-button>
- </view>
- </view>
- </view>
- <view v-else class="empty">
- <uv-empty mode="data" text="暂无收藏活动"></uv-empty>
- </view>
- </view>
-
- </view>
- </template>
-
- <script>
- export default {
- data() {
- return {
- favoritesList: [],
- pageNo: 1,
- pageSize: 10
- }
- },
- methods: {
- // 查看活动详情
- viewActivityDetail(item) {
- uni.navigateTo({
- url: `/subPages/index/activityDetail?id=${item.id}`
- })
- },
- async getActivityCollectionList() {
- const res = await this.$api.activity.queryActivityCollectionList({
- pageNo: this.pageNo,
- pageSize: this.pageSize
- })
- if (!res.result.records.length) {
- uni.showToast({
- title: '没有更多数据了',
- icon: 'none'
- })
- return
- }
- this.favoritesList.push(...res.result.records.map(item => item.communityActivity))
- this.pageNo++
- }
- },
- async onShow() {
- await this.getActivityCollectionList()
- },
- onReachBottom() {
- this.getActivityCollectionList()
- },
- async onPullDownRefresh() {
- this.pageNo = 1
- this.favoritesList = []
- await this.getActivityCollectionList()
- uni.stopPullDownRefresh()
- }
- }
- </script>
-
- <style lang="scss" scoped>
- .page {
- background-color: #f5f5f5;
- min-height: 100vh;
- }
-
- .content {
- padding: 20rpx;
- }
-
- .activity-list {
- .activity-item {
- display: flex;
- margin-bottom: 30rpx;
- background: #fff;
- border-radius: 12rpx;
- padding: 20rpx;
-
- .activity-image {
- width: 180rpx;
- height: 180rpx;
- border-radius: 8rpx;
- margin-right: 20rpx;
- }
-
- .activity-info {
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
-
- .title-row {
- display: flex;
- align-items: center;
- margin-bottom: 10rpx;
-
- .activity-badge {
- width: 31px;
- height: 20px;
- background: #218cdd;
- border-radius: 3.5px;
- margin-right: 7rpx;
- display: flex;
- align-items: center;
- justify-content: center;
-
- .badge-text {
- font-size: 18rpx;
- color: #fff;
- }
- }
- }
-
- .activity-title {
- font-size: 28rpx;
- font-weight: bold;
- color: #333;
- }
-
- .activity-location, .activity-time, .activity-participants {
- display: flex;
- align-items: center;
- margin-bottom: 6rpx;
-
- .location-text, .time-text, .participants-text {
- font-size: 24rpx;
- color: #999;
- margin-left: 6rpx;
- }
- }
- }
-
- .activity-action {
- display: flex;
- align-items: flex-end;
- padding-bottom: 10rpx;
- }
- }
- }
-
- .empty {
- margin-top: 200rpx;
- }
- </style>
|