index.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <view class="container">
  3. <uni-card :title="istitle" class="cardBox">
  4. <uni-list border class="list">
  5. <uni-list-item v-for="(item, index) in dataList" :key="index" :ellipsis="1" :title="item.noticeTitle" link clickable @click="listItemBtn(item)" ></uni-list-item>
  6. </uni-list>
  7. <uni-load-more :status="more" />
  8. </uni-card>
  9. </view>
  10. </template>
  11. <script>
  12. import request from '../../api/system.js';
  13. export default {
  14. onLoad: function (option) {
  15. },
  16. data() {
  17. return {
  18. dataList: [],
  19. more: 'more',
  20. page: 0,
  21. size: 20
  22. }
  23. },
  24. async mounted() {
  25. await this.getServiceList();
  26. },
  27. methods: {
  28. listItemBtn(e) {
  29. uni.navigateTo({ url: `/pages/details/index?noticeId=${e.noticeId}` });
  30. },
  31. // 查询列表函数
  32. async getServiceList() {
  33. this.page += 1;
  34. this.more = 'loading';
  35. const res = await request.getSystemNoticeList({ pageNum: this.page, pageSize: this.size });
  36. this.dataList.push(...res.rows)
  37. // 根据总数 算页数 如果当前页 = 总页数就是没有数据 否则就是上拉加载
  38. this.more = this.page >= Math.ceil(res.total / this.size) ? 'noMore' : 'more';
  39. },
  40. },
  41. // 页面生命周期中onReachBottom(页面滚动到底部的事件)
  42. onReachBottom() {
  43. if(this.more != 'noMore') {
  44. this.more = 'more';
  45. const filter = {};
  46. if(this.searchVal !== '') filter.title = this.searchVal;
  47. if (this.policyItem !== null && this.policyItem !== '') filter.tagName = this.policyItem;
  48. this.getPolicyList({ ...filter });
  49. }
  50. }
  51. }
  52. </script>
  53. <style>
  54. </style>