<template>
	<view>
		<scroll-list ref="list" :option="option" @load="load" @refresh="refresh" @loadSuccess="loadSuccess"
			@scrolltolower="scrolltolower">
			<view v-for="(item, index) in list" :key="index">
				<view style="border: 1rpx solid #cecece;color: #747474;padding: 20rpx ;font-size: 50rpx;">
					<uni-row>
						<uni-col :span="20">
							<view @click="handleTest(item)">
								{{item.source}}
							</view>
							<view v-if="item.endTime">
								{{"截止时间："+$dateResult(item.endTime,'datetime')}}
							</view>
						</uni-col>
						<!-- <uni-col :span="4">
							<view class="yyButton" style="margin:20rpx 5rpx 0;border: 1rpx solid rgb(10, 185, 156);
										color: rgb(10, 185, 156);font-size: 22rpx; padding:  5rpx;
										 border-radius: 10rpx;" @click="back(item)">
								取消预约
							</view>
						</uni-col> -->
					</uni-row>
				</view>
			</view>
		</scroll-list>
	</view>
</template>
<style lang="scss" scoped>
	.page-wrap {}

	.yyButton:active {
		background-color: #dedede;
	}

	.infoBody {
		background-color: #ffffff;
		padding: 20rpx 0;
		font-size: 30px;
		margin: 2rpx;
		box-shadow: 0px 2px 5px #e5e5e5;
	}
</style>
<script>
	export default {
		data() {
			return {
				option: {
					page: 1,
					size: 5,
					auto: true
				},
				page: 1,
				list: [],
				scrollList: [],
				total: 0
			}
		},
		onLoad() {

		},
		onShow() {
			this.$refs.list.refresh()
		},
		methods: {
			handleTest(item) {
				uni.setStorageSync("applyInfo", item)
				uni.navigateTo({
					url: "apply"
				})
			},
			async taskList(paging) {
				// 发送请求
				const {
					data: res
				} = await this.$httpRequest({
					url: '/app/welfareOrders?pageNum=' + paging.page + '&pageSize=' + paging.size,
					method: 'get',
					urlType: this.$getUrlType()
				});
				if (res.code === 200) {
					if (paging.page === 1) {
						this.scrollList = res.rows
						this.total = res.total
						this.$refs.list.loadSuccess({
							list: res.rows,
							total: this.total
						});
					} else if (paging.page > 1) {
						for (var i = 0; i < res.rows.length; i++) {
							this.scrollList.push(res.rows[i])
						}
						this.$refs.list.loadSuccess({
							list: this.scrollList,
							total: this.total
						});
					}
				}
			},
			// 刷新刷剧
			refresh(paging) {
				this.taskList(paging)
			},
			scrolltolower(e) {
				console.log(e)
			},
			load(paging) {
				this.taskList(paging)
			},
			loadSuccess(list) {
				this.list = list
			}
		}
	}
</script>