国外MOSE官网
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.

195 lines
4.5 KiB

4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
  1. <template>
  2. <view class="volunteer-header">
  3. <view class="swiper-container" @click="goToDetail">
  4. <uv-swiper :list="bannerList" indicator indicatorMode="dot" height="270rpx" circular></uv-swiper>
  5. <!-- <view class="header-title">
  6. <text class="title-text">国际志愿者日</text>
  7. <text class="date-text">12/05</text>
  8. </view> -->
  9. <!-- <image class="dove-icon" src="/static/路径 6665@2x.png" mode="aspectFit"></image> -->
  10. </view>
  11. <view class="notice-bar" @click="goToAnnouncement">
  12. <image class="horn-icon" src="/static/首页_小喇叭.png" mode="aspectFit"></image>
  13. <view class="notice-scroll-container">
  14. <view class="notice-scroll" :animation="animationData">
  15. <text class="notice-text" v-for="(notice, index) in noticeList" :key="index">
  16. {{ notice.title }}
  17. </text>
  18. </view>
  19. </view>
  20. <uv-icon name="arrow-right" color="#999" size="14"></uv-icon>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. name: 'VolunteerHeader',
  27. data() {
  28. return {
  29. bannerList: [
  30. '/static/bannerImage.png',
  31. '/static/bannerImage.png',
  32. '/static/bannerImage.png',
  33. ],
  34. noticeList: [
  35. { id: 1, title: '【重要通知】志愿者服务活动报名开始啦,欢迎大家踊跃参与!' },
  36. { id: 2, title: '【活动预告】本周六将举办环保志愿活动,期待您的参与' },
  37. { id: 3, title: '【表彰通知】优秀志愿者表彰大会将于下周举行' },
  38. { id: 4, title: '【温馨提醒】请各位志愿者及时更新个人信息' }
  39. ],
  40. animationData: {},
  41. currentIndex: 0,
  42. scrollTimer: null
  43. }
  44. },
  45. methods: {
  46. goToAnnouncement() {
  47. // 跳转到公告页面
  48. uni.navigateTo({
  49. url: '/subPages/index/announcement'
  50. })
  51. },
  52. goToDetail() {
  53. // 跳转到详情页面
  54. uni.navigateTo({
  55. url: '/subPages/index/activityDetail'
  56. })
  57. },
  58. async queryBannerList() {
  59. const res = await this.$api.home.queryBannerList()
  60. this.bannerList = res.result.records.map(item => item.image)
  61. },
  62. // 获取公告列表
  63. async queryNoticeList() {
  64. const res = await this.$api.home.queryNoticeList({
  65. pageNo: 1,
  66. pageSize: 4,
  67. })
  68. this.noticeList = res.result.records
  69. },
  70. // 开始滚动动画
  71. startScroll() {
  72. this.scrollTimer = setInterval(() => {
  73. this.currentIndex = (this.currentIndex + 1) % this.noticeList.length
  74. const animation = uni.createAnimation({
  75. duration: 500,
  76. timingFunction: 'ease-in-out'
  77. })
  78. animation.translateY(-this.currentIndex * 30).step()
  79. this.animationData = animation.export()
  80. }, 2000)
  81. },
  82. // 停止滚动动画
  83. stopScroll() {
  84. if (this.scrollTimer) {
  85. clearInterval(this.scrollTimer)
  86. this.scrollTimer = null
  87. }
  88. }
  89. },
  90. async mounted() {
  91. console.log('出发喽');
  92. await this.queryBannerList()
  93. await this.queryNoticeList()
  94. // 启动公告滚动
  95. this.startScroll()
  96. },
  97. beforeDestroy() {
  98. // 清理定时器
  99. this.stopScroll()
  100. },
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .volunteer-header {
  105. width: 100%;
  106. .swiper-container {
  107. position: relative;
  108. margin: 20rpx;
  109. border-radius: 20rpx;
  110. overflow: hidden;
  111. .header-title {
  112. position: absolute;
  113. bottom: 20rpx;
  114. left: 20rpx;
  115. z-index: 10;
  116. display: flex;
  117. flex-direction: column;
  118. background-color: rgba(0,0,0,0.4);
  119. padding: 10rpx 20rpx;
  120. border-radius: 10rpx;
  121. .title-text {
  122. font-size: 36rpx;
  123. font-weight: bold;
  124. color: #fff;
  125. }
  126. .date-text {
  127. font-size: 28rpx;
  128. color: #2c5e2e;
  129. margin-top: 6rpx;
  130. }
  131. }
  132. .dove-icon {
  133. position: absolute;
  134. right: 20rpx;
  135. bottom: 20rpx;
  136. z-index: 10;
  137. width: 70rpx;
  138. height: 70rpx;
  139. background-color: #fff;
  140. border-radius: 50%;
  141. padding: 10rpx;
  142. }
  143. }
  144. .notice-bar {
  145. display: flex;
  146. align-items: center;
  147. background-color: #fff;
  148. padding: 20rpx;
  149. margin: 0 20rpx 20rpx;
  150. border-radius: 12rpx;
  151. // 如何只显示底部阴影
  152. box-shadow: 0rpx 1rpx 0rpx 0rpx #3a94e1; ;
  153. // border-bottom: 1rpx solid #3A94E1;
  154. .horn-icon {
  155. width: 40rpx;
  156. height: 40rpx;
  157. margin-right: 10rpx;
  158. }
  159. .notice-scroll-container {
  160. flex: 1;
  161. height: 60rpx;
  162. overflow: hidden;
  163. position: relative;
  164. }
  165. .notice-scroll {
  166. position: absolute;
  167. top: 0;
  168. left: 0;
  169. width: 100%;
  170. }
  171. .notice-text {
  172. display: block;
  173. height: 60rpx;
  174. line-height: 60rpx;
  175. font-size: 28rpx;
  176. color: $uni-text-color;
  177. white-space: nowrap;
  178. overflow: hidden;
  179. text-overflow: ellipsis;
  180. }
  181. }
  182. }
  183. </style>