<template>
  <view class="list">
    <Blank v-if="list.length<0"></Blank>
    <view class="scroll-view" v-else>
      <scroll-view class="scroll-list" scroll-y="true" style="height: 100%;" @scrolltolower="onReachScollBottom">
        sadasdsakjdjaks
        <slot name="listInfo" v-bind:pagingData="list"  ></slot>

<!--          <slot name="listInfo" v-for="(item,itemKey) in list"></slot>-->
        <view class="toMore" v-show="list.length<this.total">加载更多</view>
      </scroll-view>
    </view>

  </view>
</template>

<script>
import Blank from 'components/en-utils/en-blank/en-blank'

export default {
  components: {Blank},
  data() {
    return {
      list: [],
      page: 1,
      total: null,
      isAjax: false,
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    onReachScollBottom() {
      if (this.isAjax || this.list.length === this.total) {
        return
      }
      this.getList()
    },
    getList() {
      this.isAjax = true
      this.$emit('getList',this.page)
    },
    startList() {
      this.list = []
      this.page = 1
      this.isAjax = false
    },
    setList(list, total) {
      list.forEach((item) => {
        console.log(item)
        this.list.push(item)
      })
      this.total = total
      this.isAjax = false
      ++this.page;
    }

  },
}
</script>

<style scoped lang="scss">
.list {
  height: 100%;
  display: flex;
  flex-direction: column;

  .scroll-view {
    flex: 1;
    overflow: auto;

    .scroll-list {
      width: 100%;
      max-height: 100vh;
    }
  }

  .toMore {
    color: #999;
    font-size: 20rpx;
    margin: 25rpx 0;
    text-align: center;
  }

  ::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
    background-color: transparent;
  }


}
</style>
