<template>
	<view class="earnings p30">
		<z-paging ref="paging" v-model="dataList" use-page-scroll @query="queryList">
			<view style="margin-bottom: 30rpx" @click="toCrud(item)" class="mt30 wallet_list" v-for="(item, index) in dataList" :key="index">
				<view style="color: #fff">
					<view style="font-weight: bold; font-size: 32rpx; margin-bottom: 18rpx">
						{{ item.name }}
					</view>
					<view style="margin-bottom: 12rpx; font-size: 28rpx; color: #eee">
						卡号：{{ item.cardNo }}
					</view>
					<view style="margin-bottom: 12rpx; font-size: 28rpx; color: #eee">
						电站：{{ item.stationName }}
					</view>
					<view style="font-size: 28rpx; color: #eee">
						商户：{{ item.merchantName }}
					</view>
				</view>
				<view style="display: flex; flex-direction: column; align-items: center; color: #fff; font-weight: bold; font-size: 26rpx">
					<view style="font-size: 55rpx; margin-bottom: 30rpx">{{ item.balance }}</view>
					<view style="font-weight: 500">余额</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script setup>
import { reactive, ref, computed } from 'vue';
import { onPullDownRefresh, onPageScroll, onReachBottom } from '@dcloudio/uni-app';
import { timeFormat } from '@/uni_modules/uview-plus';
import { userCardList } from '@/api/api.js';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { useNav } from '@/hooks/useNav.js';

const changeSele = (e) => {
	paging.value.reload();
};

const { nav, navTo } = useNav();
let getInfo = ref({});
const paging = ref(null);
let dataList = ref([]);

let isPagingRefNotFound = () => {
	return !paging.value;
};

onPullDownRefresh(() => {
	if (isPagingRefNotFound()) return;
	paging.value.reload().catch(() => {});
});

onPageScroll((e) => {
	if (isPagingRefNotFound()) return;
	paging.value.updatePageScrollTop(e.scrollTop);
	e.scrollTop < 10 && paging.value.doChatRecordLoadMore();
});

onReachBottom(() => {
	if (isPagingRefNotFound()) return;
	paging.value.pageReachBottom();
});

const queryList = (pageNo, pageSize) => {
	const params = {
		current: pageNo,
		pageSize: pageSize
	};

	userCardList(params)
		.then((res) => {
			paging.value.complete(res);
		})
		.catch((res) => {
			paging.value.complete(false);
		});
};

let toCrud = ()=>{
	uni.navigateTo({
		url:'./cardList?id=' + e.id
	})
}
</script>

<style scoped lang="scss">
.wallet_list {
	border-radius: 15rpx;
	background-color: #4879e6;
	padding: 35rpx 50rpx 35rpx 30rpx;
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
}
</style>
