noticelist.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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 uLoadMore from '@/uview-ui/components/u-loadmore/u-loadmore.vue'
  18. import uList from '@/uni_modules/uni-list/components/uni-list/uni-list.vue'
  19. import uListItem from '@/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue'
  20. import uNavBar from '@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue'
  21. import uniDataPicker from '@/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.vue'
  22. import uGroup from '@/uni_modules/uni-group/uni-group.vue'
  23. import uniSection from '@/uni_modules/uni-section/uni-section.vue'
  24. import pageNav from '@/components/page-nav/page-nav.vue';
  25. import uniTable from '@/uni_modules/uni-table/components/uni-table/uni-table.vue'
  26. import uniPagination from '@/uni_modules/uni-pagination/components/uni-pagination/uni-pagination.vue'
  27. import uniBreadcrumb from '@/uni_modules/uni-breadcrumb/components/uni-breadcrumb/uni-breadcrumb.vue'
  28. import http from '@/http/api.js';
  29. export default {
  30. components: {
  31. uList,
  32. uListItem,
  33. uNavBar,
  34. uLoadMore,
  35. },
  36. data() {
  37. return {
  38. title: '公告消息',
  39. status: 'more',
  40. pageCurrent: 1,
  41. pageSize: 10,
  42. noticeList: [],
  43. totalCount: 0,
  44. };
  45. },
  46. onLoad() {
  47. this.getNotice();
  48. },
  49. onReady() {
  50. //let that = this;
  51. // uni.getSystemInfo({
  52. // success(e) {
  53. // console.log(e);
  54. // let {
  55. // windowWidth,
  56. // windowHeight,
  57. // safeArea
  58. // } = e;
  59. // const query = uni.createSelectorQuery().in(that);
  60. // query
  61. // .select('#swiperBox')
  62. // .boundingClientRect(data => {
  63. // that.swiperHeight = safeArea.bottom - data.top;
  64. // })
  65. // .exec();
  66. // }
  67. // });
  68. },
  69. onPullDownRefresh() {
  70. // uni.showToast({
  71. // icon: 'none',
  72. // title: "当前状态:" + this.status
  73. // })
  74. // setTimeout(() => {
  75. // uni.stopPullDownRefresh();
  76. // }, 1500);
  77. },
  78. onReachBottom() {
  79. // uni.showToast({
  80. // icon: 'none',
  81. // title: "当前状态:" + this.status
  82. // })
  83. if (this.totalCount > this.noticeList.length) {
  84. this.status = 'loading';
  85. setTimeout(() => {
  86. this.pageCurrent++
  87. this.getNotice(); //执行的方法
  88. }, 1000)
  89. } else { //停止加载
  90. this.status = 'noMore';
  91. }
  92. // 后续将改为与后端联动
  93. // if (this.page >= 3) return;
  94. // this.status = 'loading';
  95. // this.page = ++this.page;
  96. // setTimeout(() => {
  97. // this.list += 10;
  98. // if (this.page >= 3) this.status = 'nomore';
  99. // else this.status = 'loading';
  100. // this.newsList.push(...[{}, {}]);
  101. // }, 2000);
  102. },
  103. methods: {
  104. toBack() {
  105. uni.navigateBack({
  106. delta: 1
  107. })
  108. },
  109. clickLoadMore(e) {
  110. // uni.showToast({
  111. // icon: 'none',
  112. // title: "当前状态:" + e.detail.status
  113. // })
  114. // })
  115. if (this.totalCount > this.noticeList.length) {
  116. this.status = 'loading';
  117. setTimeout(() => {
  118. this.pageCurrent++
  119. this.getNotice(); //执行的方法
  120. }, 1000)
  121. } else { //停止加载
  122. this.status = 'noMore';
  123. }
  124. },
  125. getNotice() {
  126. const that = this;
  127. const current = this.pageCurrent;
  128. const size = this.pageSize;
  129. //const isSubmit = '0';
  130. http.request({
  131. url: '/galaxy-test/notice/list',
  132. method: 'GET',
  133. params: {
  134. current,
  135. size,
  136. },
  137. }).then(res => {
  138. if (res.data.records != null) {
  139. for (var i = 0; i < res.data.records.length; i++) {
  140. that.noticeList.push(res.data.records[i]);
  141. }
  142. }
  143. that.totalCount = res.data.total;
  144. if (that.totalCount > that.noticeList.length) {
  145. this.status = 'more';
  146. }
  147. that.viewNotice();
  148. }).catch(err => {
  149. console.log(err)
  150. })
  151. },
  152. viewNotice() {
  153. http.request({
  154. url: '/galaxy-test/notice/view',
  155. method: 'POST',
  156. }).then(res => {}).catch(err => {
  157. console.log(err)
  158. })
  159. },
  160. onNoticeItemClick(id) {
  161. console.log('执行click事件', id)
  162. uni.navigateTo({
  163. url: '/pages/news/detail?id=' + id
  164. })
  165. },
  166. }
  167. };
  168. </script>
  169. <style lang="scss">
  170. .message-icon {
  171. width: 32rpx;
  172. height: auto;
  173. margin-right: 27rpx;
  174. }
  175. .tab {
  176. margin: 0 0 10rpx;
  177. border-bottom: 1px solid #e4e7ed;
  178. }
  179. .content {
  180. padding: 0 0 150rpx;
  181. .news {
  182. &:not(:last-of-type) {
  183. border-bottom: 2rpx solid #e4e7ed;
  184. }
  185. }
  186. }
  187. .nomore {
  188. padding: 30rpx 20rpx;
  189. }
  190. .news {
  191. margin: 30rpx 30rpx 0;
  192. padding: 0 0 30rpx;
  193. .head {
  194. display: flex;
  195. .avatar {
  196. flex-shrink: 0;
  197. width: 69rpx;
  198. height: 69rpx;
  199. background: #ffffff;
  200. border: 1px solid #14b9c8;
  201. border-radius: 50%;
  202. }
  203. .info {
  204. flex: 1;
  205. margin-left: 14rpx;
  206. .name {
  207. display: flex;
  208. align-items: center;
  209. font-size: 28rpx;
  210. font-family: PingFang SC;
  211. font-weight: bold;
  212. color: #000000;
  213. line-height: 36rpx;
  214. .tag {
  215. margin-left: 15rpx;
  216. display: inline-block;
  217. padding: 8rpx 10rpx;
  218. font-size: 14rpx;
  219. font-family: PingFang SC;
  220. font-weight: 500;
  221. color: #4cbeca;
  222. line-height: 21rpx;
  223. border: 1px solid #0bb9c8;
  224. border-radius: 6px;
  225. }
  226. }
  227. .date {
  228. font-size: 24rpx;
  229. font-family: PingFang SC;
  230. font-weight: 500;
  231. color: #a3a3a3;
  232. line-height: 36rpx;
  233. }
  234. }
  235. }
  236. .des {
  237. margin-top: 40rpx;
  238. font-size: 30rpx;
  239. font-family: PingFang SC;
  240. color: #000000;
  241. line-height: 47rpx;
  242. }
  243. }
  244. .swiper-box {
  245. height: 100vh;
  246. }
  247. </style>