<template>
	<view class="content">
		<view class="jg" style="height: 20rpx;">
			
		</view>
		<view class="love-item" v-for="item in list" :key="item.id" @click="navto(item)">
			<view class="">
				证书编号：{{item.SN}}
			</view>
			<view class="">
				捐赠时间：{{item.paytime | time}}
			</view>
			<view class="">
				捐赠意向：{{item.order_name}}
			</view>
		</view>
	</view>
</template>

<script>
	import { getMyloveList } from '@/api/user.js'
	export default {
		data() {
			return {
				list: [],
				page: 1,
				limit: 10,
				loaded: false,
				loadingType: 'more'
			}
		},
		filters: {
			time(val) {
				let str = ''
				if (val) {
					var time = new Date(val * 1000);
					var y = time.getFullYear();
					var m = time.getMonth() + 1;
					var d = time.getDate();
					var h = time.getHours();
					var mm = time.getMinutes();
					var s = time.getSeconds();
					str = y + '-' + m + '-' + d + ' ' + h + ":" + mm
					console.log(str)
				}
				return str
			}
		},
		onLoad() {
			this.getMyloveList()
		},
		onReachBottom() {
			this.getMyloveList()
		},
		methods:{
			navto(item) {
				let date = new Date(item.paytime*1000)
				let year = date.getFullYear()
				let month = date.getMonth() >= 9 ? date.getMonth() + 1 : '0' + (date
					.getMonth() + 1)
				let day = date.getDate() >= 10 ? date.getDate() : '0' + date.getDate()
				uni.navigateTo({
					url: '/pages/form/donaSuccess?money=' + item.amount + '&name=' + item.contact + '&time=' + year + '年' + month + '月' + day + '日' 
				})
			},
			getMyloveList() {
				let obj = this
				getMyloveList({
					page: obj.page,
					limit: obj.limit,
					status: 1
				}).then(({data}) => {
					obj.list = obj.list.concat(data.data)
					obj.page++
					if(obj.limit == data.data.length) {
						obj.loadingType = 'more'
					}else {
						obj.loadingType = 'noMore'
					}
					obj.$set(obj,'loaded',true)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.love-item {
		padding: 10rpx;
		margin-bottom: 20rpx;
		width: 700rpx;
		margin: auto;
		border-radius: 20rpx;
		box-shadow: 0px 0px 5rpx rgba($color: #fa7e67, $alpha: 0.6);
	}
</style>
