木邻有你前端代码仓库
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.

173 lines
3.8 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="page">
  3. <!-- 收藏列表 -->
  4. <view class="content">
  5. <view v-if="favoritesList.length > 0" class="activity-list">
  6. <view class="activity-item" v-for="item in favoritesList" :key="item.id" @click="viewActivityDetail(item)">
  7. <image class="activity-image" :src="item.image" mode="aspectFill"></image>
  8. <view class="activity-info">
  9. <view class="title-row">
  10. <view class="activity-badge">
  11. <text class="badge-text">{{ item.score }}</text>
  12. </view>
  13. <text class="activity-title">{{ item.title }}</text>
  14. </view>
  15. <view class="activity-location">
  16. <uv-icon name="map-fill" size="14" color="#999"></uv-icon>
  17. <text class="location-text">{{ item.address || '线上活动' }}</text>
  18. </view>
  19. <view class="activity-time">
  20. <uv-icon name="calendar" size="14" color="#999"></uv-icon>
  21. <text class="time-text">{{ item.activityTime }}</text>
  22. </view>
  23. <view class="activity-participants">
  24. <uv-icon name="account-fill" size="14" ></uv-icon>
  25. <text class="participants-text">报名人数{{ item.numActivity + '/' + item.numLimit }}</text>
  26. </view>
  27. </view>
  28. <view class="activity-action">
  29. <uv-button type="primary" size="mini" text="查看详情" @click.stop="viewActivityDetail(item)"></uv-button>
  30. </view>
  31. </view>
  32. </view>
  33. <view v-else class="empty">
  34. <uv-empty mode="data" text="暂无收藏活动"></uv-empty>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. favoritesList: [],
  44. pageNo: 1,
  45. pageSize: 10
  46. }
  47. },
  48. methods: {
  49. // 查看活动详情
  50. viewActivityDetail(item) {
  51. uni.navigateTo({
  52. url: `/subPages/index/activityDetail?id=${item.id}`
  53. })
  54. },
  55. async getActivityCollectionList() {
  56. const res = await this.$api.activity.queryActivityCollectionList({
  57. pageNo: this.pageNo,
  58. pageSize: this.pageSize
  59. })
  60. if (!res.result.records.length) {
  61. uni.showToast({
  62. title: '没有更多数据了',
  63. icon: 'none'
  64. })
  65. return
  66. }
  67. this.favoritesList.push(...res.result.records.map(item => item.communityActivity))
  68. this.pageNo++
  69. }
  70. },
  71. async onShow() {
  72. this.favoritesList = []
  73. this.pageNo = 1
  74. await this.getActivityCollectionList()
  75. },
  76. onReachBottom() {
  77. this.getActivityCollectionList()
  78. },
  79. async onPullDownRefresh() {
  80. this.pageNo = 1
  81. this.favoritesList = []
  82. await this.getActivityCollectionList()
  83. uni.stopPullDownRefresh()
  84. }
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. .page {
  89. background-color: #f5f5f5;
  90. min-height: 100vh;
  91. }
  92. .content {
  93. padding: 20rpx;
  94. }
  95. .activity-list {
  96. .activity-item {
  97. display: flex;
  98. margin-bottom: 30rpx;
  99. background: #fff;
  100. border-radius: 12rpx;
  101. padding: 20rpx;
  102. .activity-image {
  103. width: 180rpx;
  104. height: 180rpx;
  105. border-radius: 8rpx;
  106. margin-right: 20rpx;
  107. }
  108. .activity-info {
  109. flex: 1;
  110. display: flex;
  111. flex-direction: column;
  112. justify-content: space-between;
  113. .title-row {
  114. display: flex;
  115. align-items: center;
  116. margin-bottom: 10rpx;
  117. .activity-badge {
  118. width: 31px;
  119. height: 20px;
  120. background: #218cdd;
  121. border-radius: 3.5px;
  122. margin-right: 7rpx;
  123. display: flex;
  124. align-items: center;
  125. justify-content: center;
  126. .badge-text {
  127. font-size: 18rpx;
  128. color: #fff;
  129. }
  130. }
  131. }
  132. .activity-title {
  133. font-size: 28rpx;
  134. font-weight: bold;
  135. color: #333;
  136. }
  137. .activity-location, .activity-time, .activity-participants {
  138. display: flex;
  139. align-items: center;
  140. margin-bottom: 6rpx;
  141. .location-text, .time-text, .participants-text {
  142. font-size: 24rpx;
  143. color: #999;
  144. margin-left: 6rpx;
  145. }
  146. }
  147. }
  148. .activity-action {
  149. display: flex;
  150. align-items: flex-end;
  151. padding-bottom: 10rpx;
  152. }
  153. }
  154. }
  155. .empty {
  156. margin-top: 200rpx;
  157. }
  158. </style>