index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view class="container">
  3. <uni-list border class="list">
  4. <uni-list-item v-for="(item, index) in dataList" :key="index" :ellipsis="2" :title="item.title" link clickable @click="listItemBtn(item)" ></uni-list-item>
  5. </uni-list>
  6. <uni-load-more :status="more" />
  7. </view>
  8. </template>
  9. <script>
  10. import request from '../../api/cms.js';
  11. export default {
  12. data() {
  13. return {
  14. page: 0,
  15. size: 12,
  16. // more = 加载前, loading = 加载中, noMore = 没有更多
  17. more: 'more',
  18. dataList: []
  19. }
  20. },
  21. onShow: function() {},
  22. async mounted() {
  23. this.getPolicyList({ typeName: 'questionnaire' });
  24. },
  25. methods: {
  26. // 列表点击函数
  27. listItemBtn(e) {
  28. uni.navigateTo({ url: `/pages/questionnaire/details?id=${e.id}` })
  29. },
  30. // 搜索函数
  31. async getPolicyList(e) {
  32. this.page += 1;
  33. this.more = 'loading';
  34. const res = await request.getArticleList({ pageNum: this.page, pageSize: this.size, ...e });
  35. this.dataList.push(...res.rows)
  36. // 根据总数 算页数 如果当前页 = 总页数就是没有数据 否则就是上拉加载
  37. this.more = this.page >= Math.ceil(res.total / this.size) ? 'noMore' : 'more';
  38. },
  39. reset() {
  40. this.page = 0;
  41. this.dataList = [];
  42. }
  43. },
  44. // 页面生命周期中onReachBottom(页面滚动到底部的事件)
  45. onReachBottom() {
  46. if(this.more != 'noMore') {
  47. this.more = 'more';
  48. this.getPolicyList();
  49. }
  50. }
  51. }
  52. </script>
  53. <style>
  54. .container {
  55. width: 100%;
  56. background-color: #fff;
  57. }
  58. .top {
  59. width: 100%;
  60. z-index: 999;
  61. background-color: #fff;
  62. }
  63. .tabsBox {
  64. width: 100%;
  65. border-bottom: 1px solid #d3d3d3;
  66. display: flex;
  67. }
  68. .tab {
  69. width: 25%;
  70. }
  71. .text {
  72. display: block;
  73. width: 80%;
  74. margin: 0 auto;
  75. text-align: center;
  76. }
  77. .current {
  78. color: #ff9302;
  79. border-bottom: 1px solid #ff9302;
  80. }
  81. .search {
  82. width: 90%;
  83. height: 2em;
  84. border: 1px solid #f3f3f3;
  85. background-color: #fff !important;
  86. border-radius: 12px;
  87. display: flex;
  88. margin: 20px auto;
  89. }
  90. .uni-easyinput {
  91. width: 70%;
  92. margin-left: 5%;
  93. height: 100%;
  94. font-size: 14px;
  95. }
  96. .uni-easyinput .uni-easyinput__content {
  97. border: none !important;
  98. height: 100%;
  99. line-height: 2em;
  100. }
  101. .searchBtn {
  102. width: 20%;
  103. background-color: #ff9302 !important;
  104. border: none;
  105. color: #fff !important;
  106. height: 2em;
  107. margin-top: 0.2em;
  108. margin-left: 4%;
  109. border-radius: 12px;
  110. }
  111. .list {
  112. display: block;
  113. }
  114. </style>