Component({
  props: {
    className: '',
    pageSize: 10,
    height: '100vh',
    emptyTitle: '暂无数据',
    emptyMessage: '前不见古人、后不见来者',
    onRef: () => null,
    onService: () => Promise.reject(new Error('请传入service'))
  },
  data: {
    list: [],
    loadContent: ['正在加载', '没有更多记录']
  },
  methods: {
    saveRef(ref) {
      this.scrollRef = ref;
    },

    /* 分页逻辑 */
    async onFetchData(page, limit) {
      const {
        list: _list
      } = this.data;
      const {
        onService
      } = this.props;
      const {
        list = [],
        pagination = {}
      } = await onService({
        pageIndex: page,
        pageSize: limit
      });
      const newList = page === 1 ? list : [..._list, ...list];
      this.setData({
        list: newList
      });
      const {
        total
      } = pagination;
      return {
        total,
        list
      };
    },

    /* 刷新 */
    async refresh() {
      this.scrollRef.refresh();
    }

  }
});