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

235 lines
5.4 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
  1. <template>
  2. <view class="recommended-activities">
  3. <view class="activities-header">
  4. <view class="header-left">
  5. <image class="header-icon" src="/static/推荐活动.png" mode="aspectFit"></image>
  6. <!-- <text class="header-title">推荐活动</text> -->
  7. </view>
  8. <view class="more" @click="goToMoreActivities">
  9. <text class="more-text">更多</text>
  10. <uv-icon name="arrow-right" color="#999" size="12"></uv-icon>
  11. </view>
  12. </view>
  13. <view class="activity-list">
  14. <view class="activity-item" v-for="(item, index) in activityList" :key="index" @click="viewActivityDetail(item)">
  15. <image class="activity-image" :src="item.image" mode="aspectFill"></image>
  16. <view class="activity-info">
  17. <view class="title-row">
  18. <view class="activity-badge">
  19. <text class="badge-text">{{item.score}}</text>
  20. </view>
  21. <text class="activity-title">{{item.title}}</text>
  22. </view>
  23. <view class="activity-location">
  24. <uv-icon name="map-fill" size="14" color="#999"></uv-icon>
  25. <text class="location-text">{{item.address}}</text>
  26. </view>
  27. <view class="activity-time">
  28. <uv-icon name="calendar" size="14" color="#999"></uv-icon>
  29. <text class="time-text">{{item.activityTime}}</text>
  30. </view>
  31. <view class="activity-participants">
  32. <uv-icon name="account-fill" size="14" color="#999"></uv-icon>
  33. <text class="participants-text">{{item.numActivity}}人已报名</text>
  34. </view>
  35. </view>
  36. <view class="activity-action">
  37. <uv-button type="primary" size="mini" :text="item.isApply ? '已报名' : (item.numActivity >= item.numLimit ? '已满人' : '报名中')" @click.stop="signUpActivity(item)"></uv-button>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. name: 'RecommendedActivities',
  46. data() {
  47. return {
  48. activityList: [
  49. {
  50. id: 1,
  51. title: '关爱自闭儿童活动',
  52. image: '/static/bannerImage.png',
  53. location: '七步沙社区文化中心',
  54. time: '2025-06-12 14:30',
  55. participants: 12
  56. },
  57. {
  58. id: 1,
  59. title: '关爱自闭儿童活动',
  60. image: '/static/bannerImage.png',
  61. location: '七步沙社区文化中心',
  62. time: '2025-06-12 14:30',
  63. participants: 12
  64. },
  65. {
  66. id: 1,
  67. title: '关爱自闭儿童活动',
  68. image: '/static/bannerImage.png',
  69. location: '七步沙社区文化中心',
  70. time: '2025-06-12 14:30',
  71. participants: 12
  72. },
  73. {
  74. id: 1,
  75. title: '关爱自闭儿童活动',
  76. image: '/static/bannerImage.png',
  77. location: '七步沙社区文化中心',
  78. time: '2025-06-12 14:30',
  79. participants: 12
  80. },
  81. ]
  82. }
  83. },
  84. methods: {
  85. goToMoreActivities() {
  86. // 跳转到更多活动页面
  87. uni.switchTab({
  88. url: '/pages/index/activity'
  89. })
  90. },
  91. viewActivityDetail(activity) {
  92. // 查看活动详情
  93. uni.navigateTo({
  94. url: `/subPages/index/activityDetail?id=${activity.id}`
  95. })
  96. },
  97. signUpActivity(activity) {
  98. // 报名活动
  99. uni.navigateTo({
  100. url: `/subPages/index/activityDetail?id=${activity.id}`
  101. })
  102. },
  103. async getActivityList() {
  104. const res = await this.$api.activity.queryActivityList({
  105. pageNo: 1,
  106. pageSize: 5,
  107. isHot: 1
  108. })
  109. this.activityList = res.result.records
  110. },
  111. },
  112. // created() {
  113. // this.getActivityList()
  114. // }
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. .recommended-activities {
  119. margin: 20rpx;
  120. // background-color: #fff;
  121. border-radius: 12rpx;
  122. // padding: 20rpx;
  123. .activities-header {
  124. display: flex;
  125. justify-content: space-between;
  126. align-items: center;
  127. margin-bottom: 10rpx;
  128. padding-left: 20rpx;
  129. .header-left {
  130. display: flex;
  131. align-items: center;
  132. .header-icon {
  133. width: 158rpx;
  134. height: 50rpx;
  135. margin-right: 10rpx;
  136. }
  137. .header-title {
  138. font-size: 30rpx;
  139. font-weight: bold;
  140. color: $uni-text-color;
  141. }
  142. }
  143. .more {
  144. display: flex;
  145. align-items: center;
  146. .more-text {
  147. font-size: 24rpx;
  148. color: $uni-text-color-grey;
  149. margin-right: 4rpx;
  150. }
  151. }
  152. }
  153. .activity-list {
  154. .activity-item {
  155. display: flex;
  156. margin-bottom: 30rpx;
  157. background: #fff;
  158. border-radius: 12rpx;
  159. padding: 20rpx;
  160. .activity-image {
  161. width: 180rpx;
  162. height: 180rpx;
  163. border-radius: 8rpx;
  164. margin-right: 20rpx;
  165. }
  166. .activity-info {
  167. flex: 1;
  168. display: flex;
  169. flex-direction: column;
  170. justify-content: space-between;
  171. .title-row {
  172. display: flex;
  173. align-items: center;
  174. margin-bottom: 10rpx;
  175. .activity-badge {
  176. width: 31px;
  177. height: 20px;
  178. background: #218cdd;
  179. border-radius: 3.5px;
  180. margin-right: 7rpx;
  181. display: flex;
  182. align-items: center;
  183. justify-content: center;
  184. .badge-text {
  185. font-size: 18rpx;
  186. color: #fff;
  187. // font-weight: bold;
  188. }
  189. }
  190. }
  191. }
  192. .activity-title {
  193. font-size: 28rpx;
  194. font-weight: bold;
  195. color: $uni-text-color;
  196. }
  197. .activity-location, .activity-time, .activity-participants {
  198. display: flex;
  199. align-items: center;
  200. margin-bottom: 6rpx;
  201. .location-text, .time-text, .participants-text {
  202. font-size: 24rpx;
  203. color: $uni-text-color-grey;
  204. margin-left: 6rpx;
  205. }
  206. }
  207. }
  208. .activity-action {
  209. display: flex;
  210. align-items: flex-end;
  211. padding-bottom: 10rpx;
  212. }
  213. }
  214. }
  215. </style>