<template>
	<div class="dyn_box">
		<div class="dyn_title">
			<!-- <div class="dyn_item" @click="studentXuan"> -->
			<div class="souew">
				<img src="@/static/icon_lsjl_ss.png" alt="" class="iconfr">
				<input type="text" v-model="nhese" class="injue" placeholder="请输入要查询的查询码">
				<button class="nhye"   @click="seache" >搜索</button>
			</div>
				
				<!-- <van-search
				  :value="value"
				  shape="round"
				  background="#4fc08d"
				  placeholder="请输入搜索关键词"
				/> -->
			<!-- </div> -->
			<!-- <div class="dyn_item" @click="riqu">
				<span>{{titlerid}}</span>
				<img src="@/static/icon_xsdt_sx_xl@2x.png" alt="" class="icon">
			</div> -->
		</div>
		
		<div>
			<scroll-view scroll-y class="scroll-view" upper-threshold="40" lower-threshold="40" @scrolltolower="bot_btn">
			<div class="byes" v-for="(item,index) in list" :key="index" @click="nhje(item)">
				<p>{{item.reportNumber}}</p>
				<p>{{item.createTime}}</p>
			</div>
			<div class="shax" v-show="listShow">
					{{wtdt}}
				</div>
			</scroll-view>
			<div class="zanwu " v-show="!listShow"><span>暂无数据</span></div>
		</div>
		
		
		
		<!-- <table>
			<thead>
				<tr>
					<th style="width: 130upx;text-align: center;">姓名</th>
					<th style="width: 60upx; text-align: center;">性别</th>
					<th  style="width: 100upx; text-align: center;">班级</th>
					<th style="width: 100upx; text-align: center;">扫码时间</th>
					<th style="width: 100upx; text-align: center;">温度(℃)</th>
					<th style="width: 60upx; text-align: center;">详细信息</th>
				</tr>
			</thead>
			<tbody>
				
			</tbody>
		</table> -->
		<!-- //时间选择 -->
		<!-- <van-popup :show="showtime" @close="onClosetime" position="bottom">
		<van-datetime-picker
		  type="date"
		  :value="currentDate"
		  :min-date="minDate"
		  :max-date="maxDate"
		  :formatter="formatter"
		  @input="onInput"
		  @confirm = "timeone"
		  @cancel = "itemcel"
		/>		
		</van-popup> -->
		<!-- //选择学生 -->
		<!-- <van-popup :show="stushow" @close="stuonClose" position="bottom">
			<van-picker :columns="columns" @change="stuonChange"  show-toolbar
            title="信息"   @cancel="stuCancel" @confirm="stuConfirm"/>
		</van-popup> -->
		
	</div>
</template>

<script>
	export default{
		data() {
			return {
				showtime:false, 
				currentDate: 0,
				titlerid:'扫码日期',
				studentseL:'选择学生',
				value:'',
				minDate:0,
				maxDate:0,
				minHour: 10,
				maxHour: 20,
				columns:[],
				stushow:false,
				phone:0,
				listShow: true, //判断是否有数据 true 有
				haveMore: true,
				timeujyu:'',
				wtdt: '上拉加载更多',
				params: { //上拉刷新
					pageSize: 20,
					pageNum: 1,
					// parentPhone: '', //查询
					// // complate: '',
					// // classId:'',
					// reportNumber: undefined
				},
				list:[],
				nhese:''
			}
		},
		onLoad() {
		this.phone = uni.getStorageSync('phone')
		this.params.queryPhone = uni.getStorageSync('phone')
		console.log(uni.getStorageSync('phone'),34)
		// this.params.parentPhone = 15855353281
		let token = uni.getStorageSync('phone')
		if(!token){
			uni.redirectTo({
				url: '/pages/login/login'
			})
			return  false
		}
		// this.bingeList()
		this.lists(this.params)
		},
		onShow() {
		// let iutem = new Date().getFullYear() + 1
		this.maxDate  = new Date(2020,12,1).getTime()
		this.minDate= new Date(2017, 10, 1).getTime()
		// this.currentDate = new Date().getTime()
		// console.log(new Date().getFullYear() + 1 , new Date(2019, 10, 1).getTime() )		
		},
		//下拉刷新
		onPullDownRefresh() {
		
			console.log(234)
			wx.showNavigationBarLoading()
			// uni.showLoading({
			//         title: '刷新中...',
			//       })
			// this.currentTab = 0
			this.params.pageNum = 1
			// this.tehu = '请选择班级'
			this.params = { //上拉刷新
					pageSize: 20,
					pageNum: 1,
					// searchValue: '', //查询
					// // // classId:'',
					// reportNumber:undefined
				}, //查询
				// this.paramstwo = {
				// 	searchValue: '', //查询
				// 	// complate: '',
				// 	// classId:'',
				// 	deptId: ''
				// }
			this.nhese = ''
			this.titlerid = '扫码日期'
			this.studentseL="选择学生"
			// this.params.parentPhone = uni.getStorageSync('phone')
			this.params.queryPhone = uni.getStorageSync('phone')
			this.list = []
			// this.studentnum(this.paramstwo)
			// this.terd = ''
			this.lists(this.params)
			// uni.stopPullDownRefresh()
			// self.getNewList()
			// self.getLun()
		},
		methods:{
			//获取学生信息接口
			bingeList(){
				const _this = this
				this.$http.post("gateway/query/miniProgramQueryLog" + this.phone).then(res => {
					console.log(res)
					if(res.code == 200){
						console.log(res.data.length)
						
						
						this.lkeiLIst =  res.data
						this.lkeiLIst.filter(router => {
							this.columns.push(router.name)
						})
						
						console.log(this.lkeiLIst)
						console.log(this.columns)
						
						
					}else {
						uni.showToast({
							title: res.msg,
							duration: 1000,
							icon: 'none'
						});
					}
					// console.log(this.studenList)
				})
			},
			//查询列表
			lists(params) {
				var str='?pageSize='+params.pageSize+'&pageNum='+params.pageNum+'&queryPhone='+params.queryPhone;
				if(params.reportNumber){
					str=str+"&reportNumber="+params.reportNumber
				}
				this.$http.post("gateway/query/miniProgramQueryLog"+str).then(res => {
					//停止下拉加载
					uni.hideNavigationBarLoading()
					uni.stopPullDownRefresh()
					if (res.code == 200) {
						if (res.rows.length < params.pageSize) {
							this.listShow = false
							this.haveMore = false
						} else {
							var num=parseInt(res.rows.length)+parseInt(params.pageSize)*parseInt(params.pageNum-1)
							if(num<res.total){
								this.listShow = true
								this.haveMore = true
							}else{
								this.listShow = false
								this.haveMore = false
							}	
						}
						if(params.pageSize==1){
							this.list = res.rows
						}else{
							this.list = this.list.concat(res.rows) 
						}
						// this.shoue = true
						// if(res.data.current != res.data.pageNum) {
						// 	if(res.data.pageNum == 0){
						// 		this.list = res.rows
						// 	}
						// 	this.list = this.list.concat(res.rows)
						// 	this.list.filter(route => {
						// 	          console.log(route,98)
						// 			  if(route.sex == 1){
						// 				  route.sex = '女'
						// 			  }else if(route.sex == 0){
						// 				  route.sex = '男'
						// 			  }
						// 			  //采集判断
						// 			  if(route.picture == ''){					  //未采集
						// 			  		this.Collected = true							
						// 			  }else {
						// 			  		this.Collected = false
						// 			  }
			
			
						// 			  // console.log(this.Collected)
			
						// 	    })
						// 	this.params.pageNum +=1
						// 	this.haveMore = true
						// } else {
						// 	if(this.params.pageNum !==1){
						// 		this.list = this.list.concat(res.rows)
						// 	}else {
						// 		this.list = res.rows
						// 	}
			
						// 	this.list.filter(route => {
						// 	          console.log(route,98)
						// 			  if(route.sex == 1){
						// 				  route.sex = '女'
						// 			  }else if(route.sex == 0){
						// 				  route.sex = '男'
						// 			  }
						// 			  //采集判断
						// 			  if(route.picture == ''){
						// 				  //未采集
						// 				  this.Collected = true
			
						// 			  }else {
						// 				    this.Collected = false
						// 			  }
						// 			  // console.log(this.Collected)
			
						// 	    })
						// 	// console.log(111)
						// 	this.haveMore =  false
						// 	this.shoue = true
						// 	this.wtdt = '暂无更多数据'
						// }
					} else {
						uni.showToast({
							title: res.msg,
							duration: 1000,
							icon: 'none'
						});
			
			
					}
			
			
				})
			},
			// 搜索
			seache(){
			 this.params.reportNumber= this.nhese
			 this.params.pageNum = 1
			 this.list = []
			 this.lists(this.params)
			 console.log(this.params.reportNumber , this.nhese)
			},
			// 点击查看详情
			nhje(id){
				// id.reportNumber = 'NO:ASJ(0000)QG —001号'
				const _this = this
				this.$http.posta("gateway/query/queryReportNum" , {reportNumber:id.reportNumber}).then(res => {
					console.log(res)
					if(res.code == 200){
						console.log(res.data.length)
						let hjees = JSON.stringify(res.data)
						wx.navigateTo({
						  url: '/pages/home/recordtwo?code=' + hjees
						})
						
					}else {
						uni.showToast({
							title: res.msg,
							duration: 1000,
							icon: 'none'
						});
					}
					// console.log(this.studenList)
				})
			},
			look_btn(item) {
				console.log(item)
				let liy = JSON.stringify(item) 
				
				uni.navigateTo({
					url: '/pages/parents/par_dynamic_dec?iju=' +liy 
				})
				uni.setStorageSync('item', item)
			},
			riqu(){
				this.showtime = true
				console.log(234)
			},
			onClosetime(){
				this.showtime = false
			},
			stuonClose(){
				this.stushow = false
			},
			onInput(event) {
				// console.log(event)
			    this.currentDate = event.detail
			},
			itemcel(){
				this.showtime = false
			},
			timeone(event){
				console.log(event)
				this.formatDateTime(event.detail,0)
				this.showtime = false
			},
			onChange(event){
				console.log(event.detail)
			},
			//刷新
			bot_btn() {
				if (this.haveMore) {
					this.params.pageNum++
					this.lists(this.params)
				}
			},
			stuonChange(){
				
			},
			studentXuan(){
				this.stushow = true
			},
			stuConfirm(event){
				this.studentseL = event.detail.value
				console.log(event.detail)
				console.log(this.lkeiLIst[event.detail.index].pid)
				this.params.pageNum = 1
				this.params.pid = this.lkeiLIst[event.detail.index].pid
				this.list=[]
				this.lists(this.params)
				this.stushow = false
			},
			stuCancel(){
				this.stushow = false
			},
			formatter(type, value){
				 if (type === 'year') {
				        return `${value}年`;
				      } else if (type === 'month') {
				        return `${value}月`;
				      }
				      return value;
			},
			// 时间格式化
			formatDateTime(inputTime) {
				var date = new Date(inputTime);
				var y = date.getFullYear();
				var m = date.getMonth() + 1;
				m = m < 10 ? ('0' + m) : m;
				var d = date.getDate();
				d = d < 10 ? ('0' + d) : d;
				var h = date.getHours();
				h = h < 10 ? ('0' + h) : h;
				var s = date.getSeconds();
				s = s < 10 ? ('0' + s) : s;
				var minute = date.getMinutes();
				var second = date.getSeconds();
				minute = minute < 10 ? ('0' + minute) : minute;
				second = second < 10 ? ('0' + second) : second;
				console.log(second)
				this.titlerid = y + '-' + m + '-' + d  
				this.timeujyu = y  +'' + m +''  + d
				this.params.dateYYYYMMDD = this.timeujyu
				console.log(this.timeujyu)
				this.params.pageNum = 1
				this.list=[]
				this.lists(this.params)
				// if(this.shougeflei == 0){
				// 	// 收割开始时间
				// 	this.xmGrowersRelationList[this.shougenum].harvestStartTime = y + '-' + m + '-' + d  + ' ' + h + ':' + minute + ':' + '00'
				//     console.log(this.xmGrowersRelationList[this.shougenum].harvestStartTime)
				// }else if(this.shougeflei == 1){
				// 	//收割结束时间
				// 	this.xmGrowersRelationList[this.shougeendnum].harvestEndTime = y + '-' + m + '-' + d  + ' ' + h + ':' + minute + ':' + '00'
				// }else if(this.shougeflei == 2){
				// 	// 施肥开始时间  
				// 	this.xmGrowersFertilizateList[this.ertili].fertilizationTime = y + '-' + m + '-' + d  + ' ' + h + ':' + minute + ':' + '00'
				// }else if(this.shougeflei == 3){
				// 	this.xmGrowersMedicineList[this.lication].medicineTime = y + '-' + m + '-' + d  + ' ' + h + ':' + minute+ ':' + '00'
				// }
				
				// return this.shoutime
			}
		}
	}
</script>

<style lang="scss">
	.byes{
		border-bottom: 1px solid #D4D4D4;
		padding: 33upx;
		p{
			font-size: 28upx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #1E1E1E;
		}
		p:nth-child(2){
			font-family: PingFang SC;
			font-weight: 400;
			color: #1E1E1E;
			margin: 17upx 0;
		}
		p:nth-child(3){
			font-size: 22upx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #737373;
		}
	}
	.souew{
		display: flex;
		width: 100%;
		position: relative;
		justify-content: space-between;
		margin-top: 20upx;
		.iconfr{
			position: absolute;
			top:50%;
			transform: translateY(-50%);
			left: 30upx;
			width: 33upx;
			height: 33upx;
		}
		.injue{
			width: 75%;
			height: 69upx;
			background-color: #eee;
			border-radius: 69upx;
			padding-left: 70upx;
			box-sizing: border-box;
		}
		.nhye{
			width: 20%;
			background-color: #2C60F1;
			height: 69upx;
			line-height: 69upx;
			color: #fff;
			font-size: 24upx;
		}
		
	}
	
	//暂无数据
	.zanwu {
		text-align: center;
		padding-top: 20upx;
	
		span {
			font-size: 24upx;
		}
	}
	.scroll-view {
		max-height: calc(100vh - 100upx);
	}
	.shax {
		// height: 83upx;
		font-size: 25upx;
		color: #666;
		text-align: center;
	}
	.dyn_box{
		.dyn_title{
			height: 98upx;
			display: flex;
			padding: 0 34upx;
			align-items: center;
			.dyn_item{
				margin-right: 69upx;
				display: flex;
				align-items: center;
				font-size: 25upx;
				color: #666666;
				span{
					margin-right: 15upx;
				}
				img{
					width: 21upx;
					height: 13upx;
				}
			}
		}
		table{
			thead{
				tr{
					background: #fff;
					color: #333333;
					font-weight: bold;
				}
			}
			tr{
				height: 83upx;
				display: flex;
				background: #fff;
			}
			.b{
				background: #fff;
			}
			.l{
				background: #F6F9FC;
			}
			th,td{
				flex: 1;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 21upx;
				&:nth-of-type(4){
					flex: 2;
				}
			}
			tbody{
				td{
					&:nth-of-type(6){
						color: #32B16C;
					}
				}
				
			}
		}
	}
	.two_tr {
		display: flex;
		// padding: 0 50upx;
		box-sizing: border-box;
		justify-content: space-between;
	
		td {
			// flex: 1;
	
			font-size: 24upx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #333333;
			line-height: 83upx;
			height: 83upx;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
	
		}
	
		.tdse {
			color: #E60012 !important;
		}
	
		.coiu {
			color: #32B16C;
		}
	}
	
	.two_trtwo {
		background-color: #F6F9FC !important;
	}
</style>
