<template>
  <view>
    <nav-shadow></nav-shadow>
    <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption"
      :up="upOption">
    <view class="flex items-center text-center py-30rpx text-lg text-txBase">
      <view class="flex-1">时间</view>
      <view class="flex-1">金额</view>
    </view>
    <view v-for="(item,index) in dataList" :key="index" class="flex items-center text-center pt-base text-lg text-txGray">
      <view class="flex-1">{{item.created_at}}</view>
      <view class="flex-1">{{item.change_balance}}</view>
    </view>
     </mescroll-body>
  </view>
</template>

<script>
   import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  export default {
     mixins: [MescrollMixin], // 使用mixin
    data() {
      return {
          downOption: {
            auto: false,
          },
          upOption: {
            page: {
              size: 20
            },
            noMoreSize: 1
          },
          dataList: [], //获取到的数据
      };
    },
    methods:{
      downCallback() {
        this.mescroll.resetUpScroll();
        this.dataList = []
      },
      async upCallback(page) {
        this.loadData(page);
      },
      loadData(page) {
        this.$api.get(`/v1/wallet/wallet-logs`, {
          params: {
            page: page.num,
            per_page: page.size,
            action:'withdraw-balance'
          }
        }).then(res => {
          this.mescroll.endSuccess(res.data.length)
          if (page.num == 1) this.dataList = [];
          this.dataList = this.dataList.concat(res.data);
        }).catch(err => {
          this.mescroll.endErr()
        })
      },
    }
  }
</script>

<style lang="scss">
  page {
    min-height: 100vh;
    background: #FFFFFF;
  }
</style>
