notice.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="notice-page">
  3. <scroll-view scroll-y class="notice-scroll" @scrolltolower="loadMore" refresher-enabled
  4. :refresher-triggered="isRefreshing" @refresherrefresh="onRefresh">
  5. <block v-if="noticeList.length > 0">
  6. <!-- 时间分割线 -->
  7. <view class="notice-bar" v-for="(item, index) in noticeList" :key="index">
  8. <view class="time-divider">{{ item.time }}</view>
  9. <!-- 消息列表 -->
  10. <view class="notice-item flex-d">
  11. <!-- 通知图标 -->
  12. <view class="flex-a notice-header">
  13. <image src="../static/notice.png" style="width:44rpx;height:44rpx"></image>
  14. <view class="notice-title">通知</view>
  15. </view>
  16. <!-- 通知内容 -->
  17. <view class="notice-content">
  18. <view class="notice-text">
  19. <text>{{item.content}}</text>
  20. <text>\n您也可以随时在</text>
  21. <text class="notice-link" @click="goToOrder">【我的订单】</text>
  22. <text>中查看订单状态</text>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </block>
  28. <!-- 空状态 -->
  29. <u-empty v-else mode="message" text="暂无消息"></u-empty>
  30. </scroll-view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. noticeList: [{
  38. id: 1,
  39. type: 'notice',
  40. content: '亲,您的订单已经收到,感谢您对我们的支持,我们将尽快为您发出',
  41. time: '2024-10-16 23:32:28'
  42. }],
  43. page: 1,
  44. pageSize: 10,
  45. isRefreshing: false,
  46. hasMore: true
  47. }
  48. },
  49. onLoad() {
  50. this.loadNotices()
  51. },
  52. methods: {
  53. // 加载消息列表
  54. loadNotices() {
  55. // 模拟数据
  56. const mockData = [{
  57. id: 1,
  58. type: 'notice',
  59. content: '亲,您的订单已经收到,感谢您对我们的支持,我们将尽快为您发出',
  60. time: '2024-10-16 23:32:28'
  61. }]
  62. // 实际开发时替换为接口调用
  63. setTimeout(() => {
  64. this.noticeList = [...this.noticeList, ...mockData]
  65. this.hasMore = mockData.length === this.pageSize
  66. this.isRefreshing = false
  67. }, 500)
  68. },
  69. // 下拉刷新
  70. onRefresh() {
  71. this.isRefreshing = true
  72. this.page = 1
  73. this.noticeList = []
  74. this.loadNotices()
  75. },
  76. // 加载更多
  77. loadMore() {
  78. if (!this.hasMore) return
  79. this.page++
  80. this.loadNotices()
  81. },
  82. // 跳转到订单页面
  83. goToOrder() {
  84. uni.navigateTo({
  85. url: '/pages-mine/pages/order-page'
  86. })
  87. }
  88. }
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. .notice-page {
  93. min-height: 100vh;
  94. background-color: #F5F5F5;
  95. padding: 20rpx 0;
  96. .notice-scroll {
  97. height: 100vh;
  98. }
  99. .time-divider {
  100. text-align: center;
  101. font-family: PingFang SC;
  102. font-weight: 500;
  103. font-size: 26rpx;
  104. color: #333333;
  105. padding: 20rpx 0;
  106. }
  107. .notice-item {
  108. margin: 0 20rpx;
  109. padding: 30rpx;
  110. background: #FFFFFF;
  111. border-radius: 12rpx;
  112. .notice-icon {
  113. margin-right: 20rpx;
  114. padding-top: 6rpx;
  115. }
  116. .notice-header {
  117. border-bottom: 1px solid #f8f8f8;
  118. padding-bottom: 14rpx;
  119. }
  120. .notice-title {
  121. font-size: 30rpx;
  122. font-weight: bold;
  123. color: #333333;
  124. padding-left: 10rpx;
  125. font-family: PingFang SC;
  126. }
  127. .notice-content {
  128. padding-top: 14rpx;
  129. flex: 1;
  130. .notice-text {
  131. font-size: 28rpx;
  132. color: #666666;
  133. line-height: 1.6;
  134. .notice-link {
  135. color: #38C148;
  136. padding: 0 4rpx;
  137. }
  138. }
  139. }
  140. }
  141. }
  142. </style>