<template>
	<view class="page">
		<u-navbar title="购买记录" :border-bottom="false" :background="bgc" title-color='#000' title-size='36'
			height='45'></u-navbar>
		<scroll-view class="cont" scroll-y="true" :scroll-with-animation="true" @scrolltolower="handleScrollToLower">
			<view class="vip_card" v-for="(item,index) in CouponLists" :key="index">
					<view class="top">
						<image src="https://lxnapi.ccttiot.com/bike/img/static/uac2wTu5kmOGPkonvNcl" mode=""></image>
						{{item.levelName}}
					</view>
					<view class="bot">
						<view class="left">
							<image src=" https://lxnapi.ccttiot.com/bike/img/static/uvGHCob7uexyCsuMCt2c" mode=""></image>
						</view>
						<view class="right">
							<view class="tit">
								购买时长：{{item.levelTime}}天
							</view>
							<view class="data">
								可用店铺：{{item.storeName}}
							</view>
							<view class="data">
								支付时间：{{item.payTime == null ? '--' : item.payTime}}
							</view>
						</view>
					</view>
				</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgc: {
					backgroundColor: '#fff'
				},
				CouponLists:[],
				pagenum:1,
				pagesize:10,
				total:0,
			}
		},
		onShow() {
			this.getlist()
		},
		methods: {
			// 监听滚动到底部
			handleScrollToLower() {
			    if(this.total == this.CouponLists.length){
					uni.showToast({
						title: '没有更多会员记录了',
						icon: 'none',
						duration:2000
					})
				}else{
					this.getlist()
				}
			},
			// 请求订单列表
			getlist() {
				this.$u.get(`/app/vipOrder/list?pageNum=${this.pagenum}&pageSize=${this.pagesize}`).then((res) => {
					if (res.code == 200) {
                        this.total = res.total
                        if(this.pagenum > 1){
                        	this.pagenum++
                        	this.CouponLists = this.CouponLists.concat(res.rows) 
                        }else{
                        	this.pagenum++
                        	this.CouponLists = res.rows
                        }
					}
				})
			},
		}
	}
</script>

<style lang="less">
	page {
		background-color: #fff;
	}
	.page {
		width: 750rpx;
		.cont {
			display: flex;
			justify-content: center;
			flex-wrap: wrap;
            height: 88vh;
			width: 680rpx;
			margin: auto;
			.tit1 {
				font-weight: 500;
				font-size: 32rpx;
				color: #FFFFFF;
			}
			.tit2 {
				margin-top: 10rpx;
				font-weight: 500;
				font-size: 24rpx;
				color: #FFFFFF;
			}
			.vip_card{
				margin-top: 20rpx;
				width: 680rpx;
				padding: 16rpx 24rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 10rpx 64rpx 0rpx rgba(0,0,0,0.08);
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				.top{
					display: flex;
					flex-wrap: nowrap;
					align-items: center;
					font-weight: 900;
					font-size: 40rpx;
					color: #3B3838;
					image{
						margin-right: 24rpx;
						width: 58rpx;
						height: 58rpx;
					}
				}
				.bot{
					margin-top: 20rpx;
					display: flex;
					flex-wrap: nowrap;
					.left{
						margin-right: 24rpx;
						image{
							width: 194rpx;
							height: 194rpx;
						}
					}
					.right{
						.tit{
							width: 100%;
							font-weight: 600;
							font-size: 32rpx;
							color: #2F3240;
						}
						.data{
							margin-top: 16rpx;
							width: 100%;
							font-weight: 400;
							font-size: 28rpx;
							color: #808080;
						}
					}
				}
			}
		
		}
	}
</style>