noticelist.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view class="container">
  3. <uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
  4. @clickLeft="toBack">
  5. <view style="width: 100%;display: flex;flex-direction: row;justify-content: center;align-items: center;">
  6. <text style="color: white;font-size: 1rem;">{{title}}</text>
  7. </view>
  8. </uni-nav-bar>
  9. <uni-list>
  10. <uni-list-item ellipsis="1" v-for="item in noticeList" :key="item.id" :title="item.title"
  11. :note="item.releaseTime" showArrow clickable @click="onNoticeItemClick(item.id)"></uni-list-item>
  12. </uni-list>
  13. <uni-load-more :status="status" @clickLoadMore="clickLoadMore" />
  14. </view>
  15. </template>
  16. <script>
  17. import http from '@/http/api.js';
  18. export default {
  19. components: {
  20. },
  21. data() {
  22. return {
  23. title: '通知公告消息',
  24. status: 'more',
  25. pageCurrent: 1,
  26. pageSize: 10,
  27. noticeList: [],
  28. totalCount: 0,
  29. };
  30. },
  31. onLoad() {
  32. this.getNotice();
  33. },
  34. onReady() {
  35. },
  36. onPullDownRefresh() {
  37. },
  38. onReachBottom() {
  39. if (this.totalCount > this.noticeList.length) {
  40. this.status = 'loading';
  41. setTimeout(() => {
  42. this.pageCurrent++
  43. this.getNotice(); //执行的方法
  44. }, 1000)
  45. } else { //停止加载
  46. this.status = 'noMore';
  47. }
  48. },
  49. methods: {
  50. toBack() {
  51. uni.navigateBack({
  52. delta: 1
  53. })
  54. },
  55. clickLoadMore(e) {
  56. if (this.totalCount > this.noticeList.length) {
  57. this.status = 'loading';
  58. setTimeout(() => {
  59. this.pageCurrent++
  60. this.getNotice(); //执行的方法
  61. }, 1000)
  62. } else { //停止加载
  63. this.status = 'noMore';
  64. }
  65. },
  66. getNotice() {
  67. let that = this;
  68. let current = this.pageCurrent;
  69. let size = this.pageSize;
  70. http.request({
  71. url: '/galaxy-business/notice/page',
  72. method: 'GET',
  73. params: {
  74. current,
  75. size,
  76. },
  77. }).then(res => {
  78. if (res.data.records != null) {
  79. for (let i = 0; i < res.data.records.length; i++) {
  80. that.noticeList.push(res.data.records[i]);
  81. }
  82. }
  83. that.totalCount = res.data.total;
  84. if (that.totalCount > that.noticeList.length) {
  85. this.status = 'more';
  86. }
  87. that.viewNotice();
  88. }).catch(err => {
  89. console.log(err)
  90. })
  91. },
  92. viewNotice() {
  93. http.request({
  94. url: '/galaxy-business/notice/view',
  95. method: 'POST',
  96. }).then(res => {}).catch(err => {
  97. console.log(err)
  98. })
  99. },
  100. onNoticeItemClick(id) {
  101. console.log('执行click事件', id)
  102. uni.navigateTo({
  103. url: '/pages/news/detail?id=' + id
  104. })
  105. },
  106. }
  107. };
  108. </script>
  109. <style lang="scss">
  110. .message-icon {
  111. width: 32rpx;
  112. height: auto;
  113. margin-right: 27rpx;
  114. }
  115. .tab {
  116. margin: 0 0 10rpx;
  117. border-bottom: 1px solid #e4e7ed;
  118. }
  119. .content {
  120. padding: 0 0 150rpx;
  121. .news {
  122. &:not(:last-of-type) {
  123. border-bottom: 2rpx solid #e4e7ed;
  124. }
  125. }
  126. }
  127. .nomore {
  128. padding: 30rpx 20rpx;
  129. }
  130. .news {
  131. margin: 30rpx 30rpx 0;
  132. padding: 0 0 30rpx;
  133. .head {
  134. display: flex;
  135. .avatar {
  136. flex-shrink: 0;
  137. width: 69rpx;
  138. height: 69rpx;
  139. background: #ffffff;
  140. border: 1px solid #14b9c8;
  141. border-radius: 50%;
  142. }
  143. .info {
  144. flex: 1;
  145. margin-left: 14rpx;
  146. .name {
  147. display: flex;
  148. align-items: center;
  149. font-size: 28rpx;
  150. font-family: PingFang SC;
  151. font-weight: bold;
  152. color: #000000;
  153. line-height: 36rpx;
  154. .tag {
  155. margin-left: 15rpx;
  156. display: inline-block;
  157. padding: 8rpx 10rpx;
  158. font-size: 14rpx;
  159. font-family: PingFang SC;
  160. font-weight: 500;
  161. color: #4cbeca;
  162. line-height: 21rpx;
  163. border: 1px solid #0bb9c8;
  164. border-radius: 6px;
  165. }
  166. }
  167. .date {
  168. font-size: 24rpx;
  169. font-family: PingFang SC;
  170. font-weight: 500;
  171. color: #a3a3a3;
  172. line-height: 36rpx;
  173. }
  174. }
  175. }
  176. .des {
  177. margin-top: 40rpx;
  178. font-size: 30rpx;
  179. font-family: PingFang SC;
  180. color: #000000;
  181. line-height: 47rpx;
  182. }
  183. }
  184. .swiper-box {
  185. height: 100vh;
  186. }
  187. </style>