<template>
    <!-- index.wxml -->
    <view class="wrap">
        <view class="loglist">
            <view class="logitem" v-for="(item, index) in dataList" :key="index">
                <view class="item_price">+{{ item.money }}元</view>

                <view class="item_time">{{ item.pay_at }}</view>
            </view>
        </view>
    </view>
</template>

<script>
// index.js
let myPro = require('../../../utils/wxRequest.js');

let util = require('../../../utils/util.js');

export default {
    data() {
        return {
            page: 1,
            size: 10,
            finished: false,
            dataList: []
        };
    },
    onLoad: function (options) {
        // Do some initialize when page load.
        let that = this;
        that.getDataList();
    },
    onShow: function () {
        // Do something when page show.
        let that = this;
    },
    onReady: function () {
        // Do something when page ready.
    },
    onHide: function () {
        // Do something when page hide.
    },
    onUnload: function () {
        // Do something when page close.
    },
    onPullDownRefresh: function () {
        // Do something when pull down.
    },
    onReachBottom: function () {
        // Do something when page reach bottom.
        let that = this;

        if (!that.finished) {
            that.getDataList();
        }
    },
    onPageScroll: function () {
        // Do something when page scroll
    },
    onResize: function () {
        // Do something when page resize
    },
    methods: {
        // 获取充值记录
        getDataList() {
            let that = this;
            let params = {
                page: that.page,
                size: that.size
            };
            myPro
                .wxRequest('user/v2/rechargeorderList', 'GET', params)
                .then((res) => {
                    let list = res.result;

                    if (list.length == 0) {
                        // 无数据
                        uni.showToast({
                            title: '暂无更多数据',
                            icon: 'none'
                        });
                        that.setData({
                            finished: true
                        });
                    } else {
                        that.setData({
                            dataList: that.dataList.concat(list),
                            page: that.page + 1
                        });
                    }
                })
                .catch((err) => {
                    console.log('报错信息', err);
                    uni.showToast({
                        title: err,
                        icon: 'none'
                    });
                });
        }
    }
};
</script>
<style>
/**index.wxss**/
.logitem {
    width: 100%;
    padding: 30rpx;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 30rpx;
    color: #333333;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
/* .logitem .item_l{
	max-width: 500rpx;
} */
.logitem .time {
    font-size: 26rpx;
    padding-top: 10rpx;
    color: rgba(51, 51, 51, 0.54);
}
.logitem .item_price {
    color: #d54c43;
}
</style>
