<template>
	<view class="app">
		<view class="content" v-for="item in list">
			<image :src="item.attachment" mode=""></image>
			<view class="servename">
				{{item.prizeName}}
			</view>
			<view class="PointsRecord">
				{{item.score}}
			</view>
			<view class="button" @tap="goexchange">
				兑换
			</view>
		</view>
	</view>
</template>

<script>
	import {
		prizelist
	} from '@/api/pagesB/PointsMall/index.js'
	export default {
		data() {
			return {
				query: {
					identity: '372325195905293621',
					pageNum: 1,
					pageSize: 10,
				},
				list: [],
				total: 0,
			};
		},

		methods: {
			goexchange() {
				uni.navigateTo({
					url: '/pagesB/exchangerecords/exchangerecords'
				});
			},
			info() {
				prizelist(this.query, '2').then(res => {
					this.list = res.rows
					this.total = res.total
				})
			},
		},
		onLoad() {
			this.info();
		},
		onReachBottom() { //下滑加载
			if (this.list.length >= this.total) {} else {
				this.query.pageNum++
				prizelist(this.query, '1').then(res => {
					if (res.rows) {
						res.rows.forEach(e => {
							this.list.push(e)
						})
					}
				})
			}
		},
		onPullDownRefresh() { //下拉刷新
			this.query.pageNum = 1;
			this.info();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
	}
</script>

<style lang="scss">
	.app {
		background-color: #F7F5F5;
		padding-top: 10rpx;
		height: 100vh;
		display: flex;
		width: 100%;
		flex-wrap: wrap;
		justify-content: space-evenly;

		.content {
			height: 514rpx;
			background: #fff;
			width: 48%;
			position: relative;
			border-radius: 5rpx;
			margin: 0 0 20rpx 0;

			.button {
				width: 100rpx;
				height: 44rpx;
				line-height: 44rpx;
				position: absolute;
				text-align: center;
				font-size: 22rpx;
				font-weight: 400;
				color: #fff;
				right: 3%;
				bottom: 5%;
				background: #26A888;
				border-radius: 5rpx;
			}

			.PointsRecord {
				padding-top: 20rpx;
				font-size: 22rpx;
				font-weight: 400;
				color: #26A888;
				padding-left: 3%;
			}

			.servename {
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				font-size: 28rpx;
				font-weight: 400;
				color: #000000;
				padding-left: 3%;
			}

			image {
				width: 100%;
				height: 355rpx;
				border-radius: 5rpx;
			}
		}
	}
</style>