<template>
	<view>
		<view class="navbox">
			<uni-nav-bar color="#ffffff" left-icon="left" title="就餐预订" :background-color="backgroundColor"
				:border="false" statusBar='true' fixed="true" @clickLeft='getBack'>
			</uni-nav-bar>
		</view>
		<image :src="navbg" class="navbg"></image>
		<view class="zxmain" :style="'margin-top:-'+marTop+'rpx;'">
			<view class="ytbox">
				<uni-forms ref="form" class="ytforms"  :modelValue="datainfo">
					<view class="ytsbox">
						<view class="yttit">预订信息</view>
						<view class="pt5">
							<uni-forms-item label="就餐日期" name="appointmentSite">
								<picker mode="date" class="pickbox" range-key='dictLabel'  :value="adridx"
									 @change="bindTimeChangea">
									<view class="flexc flex1">
										<view class="flex1 " :class="day?'co16 fw5 f14':'coa f14'">
											{{day||'请选择'}}</view>
											<image :src="hupimg" class="hupimg"></image>
									</view>
								</picker>
								
							</uni-forms-item>
							<uni-forms-item label="就餐类型"  name="appointmentSite">
								<picker  class="pickbox" range-key='dictLabel' :value="adridx"
									:range="adrlist" @change="bindTimeChangea">
									<view class="flexc flex1">
										<view class="flex1 " :class="jclx?'co16 fw5 f14':'coa f14'">
											{{jclx||'请选择'}}</view>
											<image :src="hupimg" class="hupimg"></image>
									</view>
								</picker>
							</uni-forms-item>
							<uni-forms-item label="姓名" class="disable"  name="visitName">
								<view class="intit">刘安宁</view>
								<!-- <uni-easyinput :inputBorder="false" disabled v-model="datainfo.visitName" placeholder="请输入姓名">
								</uni-easyinput> -->
							</uni-forms-item>
							<uni-forms-item label="部 门" class="disable"  name="visitPhone">
								<view class="intit">人力行政部</view>
								<!-- <uni-easyinput :inputBorder="false" disabled type="number" v-model="datainfo.visitPhone"
									placeholder="请输入手机号码">
								</uni-easyinput> -->
							</uni-forms-item>
						</view>
						<view class="ybtn flexcc" @click="getSubmit">确认提交</view>
						<view class="tips">* 为响应国家号召，请您视真实情况填写，珍惜粮食，适量定 餐，避免剩餐，减少浪费。</view>
					</view>
					
				</uni-forms>

				
			</view>
		</view>
	</view>
</template>

<script>
	import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
	import {getCameraList,getCameraVideo} from "@/api/mine/order.js"
	import {getDictionaryFn} from "@/api/mine/register.js"
	export default {
		components: {},
		data() {
			return {
				hupimg:require("@/static/images/order/hup.png"),
				navbg:require("@/static/images/navbg.png"),
				backgroundColor: "transparent",
				datainfo:{},
				nvaHeight: 44,
				marTop: 0, //距离顶部的距离
				stubarHeight: 0, //
				day:'',
				jclx:'',
				adridx:'',
				adrlist:[],
			}
		},
		onPageScroll(e) {
			var scrollTop = Number(e.scrollTop);
			if (scrollTop > 0) {
				this.backgroundColor = '#0491FD'
			} else {
				this.backgroundColor = 'transparent'
			}
		},
		onLoad: function() {
			this.init()
			// this.getDataFn()
			uni.getSystemInfo({
				success: (e) => {
					this.stubarHeight = Number(e.statusBarHeight);
					this.nvaHeight = Number(e.statusBarHeight) + 44;
					this.tabscheight = Number(this.nvaHeight) * 2 + 100;
				}
			})
			// 3c8cadac11af4f1298a2882addc8788d
		},
		onUnload() {
			uni.$off('refreshdatalist')
		},

		onShow() {},
		mounted() {
			this.getHeightFn()
		},
		// 上拉触底加载更多触发事件
		onReachBottom() {
			if (this.reachflag) {
				this.pageNum++
				this.getDataFn()
			}
		},
		methods: {
			checkPermi,
			checkRole,
			getBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			bindTimeChangea(e){
				var val=e.detail.value;
				this.day=val
			},
			getHeightFn() {
				let query = uni.createSelectorQuery().in(this);
				//需要给黄色区域设置一个id标识，在这里是demo
				query.select('.navbox').boundingClientRect(data => {
					var top = data.top < 0 ? -data.top : data.top;
					var stubarHeight = Number(this.stubarHeight);
					this.marTop = stubarHeight > 0 ? 692 - Number(data.height) * 2 : 692 - Number(data.height) *
						2 + 40 //赋值，待会要用
					if (top <= this.nvaHeight) {
						const opacity = top / 100 // 计算透明度值
						const color = `rgba(4, 145, 253, ${opacity})`
						this.backgroundColor = color // 更新盒子背景颜色
					} else {
						this.backgroundColor = '#00A9F0'
					}
				}).exec();
			},
			init() {
				// 门卫
				// getDictionaryFn('is_read').then(res=>{
				// 	if(res.code==200){
				// 		this.ydztlist = res.data.map(v => {
				// 			return {
				// 				label: v.dictLabel,
				// 				value: v.dictValue
				// 			}
				// 		})
				// 	}
				// })
			},
			getDataFn() {
				var params = {
					pageSize: this.pageSize,
					pageNo: this.pageNum,
					// visitType:3
				}
				getCameraList(params).then(res => {
					if (res.code == 200) {
						if (res.rows.length < this.pageSize) {
							this.reachflag = false
							this.wtdt = '到底了~';
						} else {
							var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum -
								1)
							if (num < res.total) {
								this.reachflag = true
								this.wtdt = '上拉加载更多'
							} else {
								this.reachflag = false
								this.wtdt = '到底了~';
							}
						}
						if (this.pageNum == 1) {
							this.list = res.rows;
						} else {
							this.list = this.list.concat(res.rows)
						}
					} else {
						this.$toast(res.msg)
					}
				})

			},
		},

	}
</script>
<style>
/* 	page {
		background: #ffffff;
	} */
</style>
<style lang="scss" scoped>
.ytbox /deep/ .uni-forms .uni-forms-item{padding: 10rpx 26rpx 10rpx;border: 2rpx solid #0391FD;margin-bottom: 24rpx;border-radius: 12rpx;}
.ytbox /deep/ .uni-forms-item__label{flex: 0 0 auto;width: 144rpx !important;font-size: 28rpx;font-weight: bold;position: relative;color: #161616;text-align-last: justify;}
.ytbox /deep/ .uni-forms-item__label text{flex: 1;}
.ytbox /deep/ .uni-forms-item__label .is-required{position: absolute;right: 0;color: #F10C31;margin-top: 16rpx;}
.ytbox /deep/ uni-textarea{flex: 1;width: auto;text-align: right;}
.ytbox /deep/ .uni-textarea-placeholder{font-size: 28rpx;color: #DDDDDD !important;}
.ytbox /deep/ .uni-easyinput__placeholder-class{font-size: 28rpx;color: #DDDDDD;}
.ytbox /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
.ytbox /deep/ .uni-easyinput{flex: 1;text-align: right;}
.ytbox /deep/ .uni-easyinput__content-input{font-size: 28rpx;}
 .ytbox /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
 .disable{background: #EFF0F2;border: none !important;}
 .ytbox{width: 684rpx;margin: 0 auto;padding-top: 24rpx;position: relative;flex: 1;overflow: auto;background-color: #ffffff;padding-bottom: 4rpx;border-radius: 14rpx;}
.ytforms{
	.yttit{font-size: 28rpx;font-weight: bold;margin-bottom: 56rpx;
color: #161616;display: flex;align-items: center;padding: 0rpx 26rpx;box-sizing: border-box;position: relative;
		&::before{content: '';width: 6rpx;height: 34rpx;background: $com-cd3;border-radius: 4rpx;position: absolute;top: 50%;transform: translateY(-50%);left: 0rpx;}
	}
	.ytsbox{background-color: #ffffff;padding: 32rpx 28rpx 0;border-radius: 14rpx;margin-bottom: 24rpx;
		.intit{font-weight: 500;flex: 1;font-size: 26rpx;text-align: right;color: #666666;}
		.pickbox{flex: 1;text-align: right;font-weight: 500;font-size: 28rpx;color: #161616;
			.hupimg{width: 18rpx;height: 14rpx;margin-left: 12rpx;flex: 0 0 auto;}
		}
		
	}
}
// 按钮
	.ybtn{width: 100%;height: 90rpx;background: $com-cd3;border-radius: 14rpx;margin: 100rpx auto 0;font-size: 28rpx;font-weight: 500;color: #FFFFFF;
		&.btn1{background-color: #9a9c9e;}
	}
	.tips{font-weight: bold;margin-top: 28rpx;
font-size: 22rpx;line-height: 34rpx;
color: #FF0000;}

.navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4;	}
.navbg{width: 100%;height: 692rpx;}	
.zxmain{position: relative;padding: 20rpx 32rpx 40rpx;box-sizing: border-box;display: flex;
		min-height: calc(100vh - 44px);		
}

</style>
