<template>
	<view class="page-prebook-list">
		<visitor-list @prebookEvent="getBookData" ref="visitors"></visitor-list>
		<pre-book-list class="preg-books" :dataList="bookList"></pre-book-list>
	</view>
</template>

<script>
	import preBookList from '@/components/preBookList.vue'
	import visitorList from '@/components/visitorList.vue'
	export default {
		data() {
			return {
				bookList:[]
			}
		},
		components:{
			preBookList,
			visitorList
		},
		onShow() {
			setTimeout(function(){
				this.pageInit()
			}.bind(this))
		},
		methods: {
			getBookData(visitor_id) {
				var param = new Object()
				param.page = 1
				param.limit = 10000
				if(visitor_id >= 0){
					param.visitor_id = visitor_id
				}else{
					param.visitor_id = '0'
				}
				uni.showLoading({
					title:'加载中',
					mask:true
				})
				var timerobj = setTimeout(function(){
					uni.hideLoading()
				}, 3000)
				this.$http.req('user/get_appoints', param, 'POST', true).then(data=>{
					clearTimeout(timerobj)
					uni.hideLoading()
					if(data == -1) return
					this.bookList = data;
					// if(this.userSelectIndex === 0){
						// this.vistors = JSON.parse(JSON.stringify(data))
					// }
				});
			},
			pageInit() {
				this.$refs.visitors.getVisitors()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page-prebook-list{
		width: 100%;
		height: 100vh;
		box-sizing: border-box;
		overflow-y: auto;
		background: #F8F8F8;
		.preg-books{
			width: 714rpx;
			margin: 0 auto;
		}
	}
</style>
