en-list.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view class="list">
  3. <Blank v-if="list.length<0"></Blank>
  4. <view class="scroll-view" v-else>
  5. <scroll-view class="scroll-list" scroll-y="true" style="height: 100%;" @scrolltolower="onReachScollBottom">
  6. sadasdsakjdjaks
  7. <slot name="listInfo" v-bind:pagingData="list" ></slot>
  8. <!-- <slot name="listInfo" v-for="(item,itemKey) in list"></slot>-->
  9. <view class="toMore" v-show="list.length<this.total">加载更多</view>
  10. </scroll-view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. import Blank from 'components/en-utils/en-blank/en-blank'
  16. export default {
  17. components: {Blank},
  18. data() {
  19. return {
  20. list: [],
  21. page: 1,
  22. total: null,
  23. isAjax: false,
  24. }
  25. },
  26. mounted() {
  27. this.getList()
  28. },
  29. methods: {
  30. onReachScollBottom() {
  31. if (this.isAjax || this.list.length === this.total) {
  32. return
  33. }
  34. this.getList()
  35. },
  36. getList() {
  37. this.isAjax = true
  38. this.$emit('getList',this.page)
  39. },
  40. startList() {
  41. this.list = []
  42. this.page = 1
  43. this.isAjax = false
  44. },
  45. setList(list, total) {
  46. list.forEach((item) => {
  47. console.log(item)
  48. this.list.push(item)
  49. })
  50. this.total = total
  51. this.isAjax = false
  52. ++this.page;
  53. }
  54. },
  55. }
  56. </script>
  57. <style scoped lang="scss">
  58. .list {
  59. height: 100%;
  60. display: flex;
  61. flex-direction: column;
  62. .scroll-view {
  63. flex: 1;
  64. overflow: auto;
  65. .scroll-list {
  66. width: 100%;
  67. max-height: 100vh;
  68. }
  69. }
  70. .toMore {
  71. color: #999;
  72. font-size: 20rpx;
  73. margin: 25rpx 0;
  74. text-align: center;
  75. }
  76. ::-webkit-scrollbar {
  77. display: none;
  78. width: 0;
  79. height: 0;
  80. background-color: transparent;
  81. }
  82. }
  83. </style>