<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" @click="handleTest(item)">
				<view class="infoBody">
					<view>
						<view style="border-bottom: 1px #b8b8b8 solid;">
							<uni-row class="demo-uni-row">
								<uni-col :span="20">
									<view class="demo-uni-col dark"
										style="font-size: 36rpx;margin: -20rpx 0 0 0;font-weight: bold;letter-spacing:5rpx;">
										{{item.title}}
									</view>
								</uni-col>
							</uni-row>
						</view>
						<uni-row class="demo-uni-row">
							<uni-col>
								<view class="demo-uni-col light" style="padding: 26rpx;color: #b1b1b1;">
									{{item.reason}}
								</view>
							</uni-col>
						</uni-row>
						<uni-row class="demo-uni-row">
							<uni-col :span="5">
								<view class="demo-uni-col light" style="color: #727272;">
									申请人：
								</view>
							</uni-col>
							<uni-col :span="7">
								<view class="demo-uni-col light" style="color: #727272;">
									{{item.applyUserName}}
								</view>
							</uni-col>
							<uni-col :span="13">
								<view class="demo-uni-col light" style="color: #727272;">
									{{item.createTime}}
								</view>
							</uni-col>
						</uni-row>
					</view>
					<view></view>
				</view>
			</view>
		</scroll-list>
	</view>
</template>
<style lang="scss" scoped>
	// page {
	// 	background-color: #f3f3f3;
	// }

	.page-wrap {}

	.infoBody {
		background-color: #ffffff;
		padding: 40rpx;
		border-radius: 20rpx;
		margin: 20rpx;
		box-shadow: 0px 2px 10px #cccccc;
	}
</style>
<script>
	export default {
		data() {
			return {
				option: {
					page: 1,
					size: 5,
					auto: true
				},
				page: 1,
				list: [],
				total: 0
			}
		},
		onLoad() {},
		onShow() {
			this.refresh({
				page: 1,
				size: 5
			})
		},
		methods: {
			handleTest(item) {
				item.pageType = 4
				uni.setStorageSync("approval", item)
				this.$goto('../ge/geApproval')
			},
			async taskList(paging) {
				// 发送请求
				const {
					data: res
				} = await this.$httpRequest({
					url: '/app/leaveList?pageNum=' + paging.page + '&pageSize=' + paging.size,
					method: 'get'
				});
				if (res.code === 200) {
					setTimeout(() => {
						if (paging.page === 1) {
							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.list.push(res.rows[i])
							}
							this.$refs.list.loadSuccess({
								list: this.list,
								total: this.total
							});
						}
					}, 300)
				}
			},
			// 刷新刷剧
			refresh(paging) {
				this.taskList(paging)
			},
			scrolltolower(e) {
				console.log(e)
			},
			load(paging) {
				console.log(2, paging)
				this.taskList(paging)
			},
			loadSuccess(list) {
				console.log(3, list)
				this.list = list
			}
		}
	}
</script>
