<template>
	<view>
		<view v-show="pageInfo.total==0">
			<view class='empty cuIcon-info'></view>
			<view class='empty-text text-gray'>暂无数据</view>
		</view>
		<view class='repayment flex justify-between align-center  margin-top margin-bottom'  v-for="(item,index) in pageInfo.repaymentList" :key='index'>
			<view style="padding: 10upx 0;">
				<view class="title"><text class='text-grey margin-right'>单据编号</text><text>{{item.repayNum}}</text></view>
				<view class="title"><text class='text-grey margin-right'>还款日期</text><text>{{item.repayDate}}</text></view>
				<view class="title"><text class='text-grey margin-right'>会员信息</text><text>{{item.memberName}} -  {{item.mobilePhone}}</text></view>
				<view class="title"><text class='text-grey margin-right '>还款实付</text> <text class="text-price text-red">{{item.payMoney}}</text></view>
			</view>
			<navigator :url="'repayment-detail/repayment-detail?item=' + JSON.stringify(item)">
			<button  class="cu-btn round bg-red">明细</button>
			</navigator>
		</view>
		<text class="margin-left">共 {{pageInfo.total}}  条数据</text>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: null,
				pageInfo: {
					total: 0,
					pageNum: 1,
					pageSize: 5,
					repaymentList: []
				}
			}
		},
		methods: {
			repayPage() {
				var page = {memberId:this.userInfo.id,storeId:this.pageInfo.storeId,pageNum:this.pageInfo.pageNum,pageSize:this.pageInfo.pageSize}
				this.$api.repayPage(page).then(res => {
					if (res.code == '000000') {
						res.pageInfo.repaymentList = res.pageInfo.list
						this.pageInfo = res.pageInfo
					} else if(res.code=='510002'||res.code=='502001'){
					}else{
						uni.showModal({
							title: '提示',
							content: '查询还款列表 , ' + res.message,
							showCancel: false,
							success: function(res) {}
						})
					}
				})
			}
		},
		onReachBottom: function() {
			this.pageInfo.pageSize = this.pageInfo.pageSize + 5
			this.repayPage()
		},
		onShow: function() {
			this.userInfo = uni.getStorageSync("userInfo")
			this.repayPage()
		},
		onPullDownRefresh: function() {
			setTimeout(function() {
				uni.redirectTo({
					url: './repayment'
				})
				uni.showToast({
					title: '刷新成功',
					icon: 'success',
					duration: 2000
				});
				uni.stopPullDownRefresh();
			}, 1000);
		}
	}
</script>

<style>

	.repayment {
		width: 96%;
		margin: 20upx 2%;
		padding: 15upx 20upx;
		background: #fff;
		border-radius: 10upx;
		
	}
</style>
