en-list.vue 1.5 KB

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