<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>
		</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 {
		props: {
			apiUrl: {
				type: String,
				default: ''
			}
		},
		data() {
			return {
				option: {
					page: 1,
					size: 5,
					auto: true
				},
				page: 1,
				list: [],
				scrollList: [],
				total: 0
			}
		},
		onLoad() {

		},
		onShow() {
			this.$refs.list.refresh()
		},
		methods: {
			async back(item) {
				const {
					data: res
				} = await this.$httpRequest({
					url: '/app/backEventOrder?id=' + item.id,
					method: 'get',
					urlType: this.$getUrlType()
				});
				if (res.code === 200) {
					this.taskList({
						page: 1,
						size: 5
					})
					this.$showModal("取消成功")
				} else {
					this.$showModal(res.msg)
				}
			},
			handleTest(item) {
				setTimeout(() => {
					this.list = []
				}, 1000)
				uni.setStorageSync("eventId", item.eventId)
				uni.setStorageSync("isUpload", 1)
				uni.navigateTo({
					url: "more"
				})
			},
			async taskList(paging) {
				// 发送请求
				const {
					data: res
				} = await this.$httpRequest({
					url: this.apiUrl + '?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>
