vaccines.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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" :note="item.note" :ellipsis="1" :title="item.title" 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/cms.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.getList();
  26. },
  27. methods: {
  28. listItemBtn(e) {
  29. uni.navigateTo({ url: `/pages/details/cmsinfo?id=${e.id}` });
  30. },
  31. // 查询列表函数
  32. async getList() {
  33. this.page += 1;
  34. this.more = 'loading';
  35. const res = await request.getArticleList({ pageNum: this.page, pageSize: this.size, typeName: 'jzdcx' });
  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. this.getList();
  46. }
  47. }
  48. }
  49. </script>
  50. <style>
  51. </style>