<!-- 回收申请 -->
<template>
    <view id="register">
		<view class="register_li">
			<view class="register_li_min" @click="handleClick('examination')">
				<view>资格申请</view>
				<view>{{zgCount}}</view>
				<img src="@/images/icon_04.png">
			</view>
			<view class="register_li_min" @click="handleClick('gas')" style="border: none;">
				<view>用气申请</view>
				<view>{{yqCount}}</view>
				<img src="@/images/icon_04.png">
			</view>
		</view>
		<view v-if="dataList2.length>0" class="small_title" @click="handleClick('gasList')">气瓶信息<img src="@/images/icon_wdwg_gd.png"></view>
		<view v-if="dataList2.length>0" class="register_li2" >
			<viwe class="register_li2_min" @tap="goInfo2(item2)" v-for="(item2,index2) in dataList2" :key="index2">
				<view class="register_li2_t">{{item2.airName}}-{{item2.configName}}</view>
				<view class="register_li2_b">
					<img src="@/images/Version3.0/icon_qpgl_syl.png">
					<view>余量: {{item2.pressure==null?'-':item2.pressure}}Mpa</view>
					<img src="@/images/Version2.2/icon_wtzg_sj.png">
					<view>最近使用时间: {{item2.useTimeApp==null?'-':item2.useTimeApp}}</view>
				</view>
			</viwe>
		</view>
		<view v-if="dataList.length>0" class="small_title" @click="handleClick('useRecord')">使用记录<img src="@/images/icon_wdwg_gd.png"></view>
		<view v-if="dataList.length>0" class="register_li2">
			<viwe class="register_li2_min" @tap="goInfo(item)" v-for="(item,index) in dataList" :key="index">
				<view class="register_li2_t">{{item.airName}}-{{item.configName}}</view>
				<view class="register_li2_b" style="border:none">
					<img src="@/images/Version3.0/icon_qpgl_syl.png">
					<view>使用量: {{item.pressure==null?'-':item.pressure}}Mpa</view>
				</view>
				<view class="register_li2_b2" style="border-bottom: 1rpx solid #f5f5f5;">
					<img src="@/images/Version2.2/icon_wtzg_sj.png">
					<view>使用时间: {{item.useTimeApp==null?'-':item.useTimeApp}} - {{item.backTimeApp==null?'-':item.backTimeApp}}</view>
				</view>
			</viwe>
		</view>
		<view class="btn" v-if="userApplyNumberYq || userApplyNumberZg">
			<view class="btn_l" @click="handleClick('gasApply')">气瓶申请</view>
			<view class="btn_r" @click="handleClick('QRcode')">使用/归还</view>
		</view>
	</view>
</template>

<script>
    import {useRecordList,listuseRecordByUserId,getUserApplyCount,useRegisterDetail } from '@/api/index.js'
	import { config } from '@/api/request/config.js'
    export default {
        data() {
            return {
				form:{
					name:'',
				},
				//列表请求参数
				getData:{
				    pageNum:1,
					pageSize:3,
				},
				dataList:[],
				dataList2:[],
				yqCount:null,
				zgCount:null,
				userApplyNumberYq:null,//大于0显示使用人，等于零显示规格
				userApplyNumberZg:null,//大于0显示使用人，等于零显示规格
				electronicTag:'',
				
            }
        },
        onLoad(option) {
			
        },
        onShow(){	
			
        },
		
        methods: {
			handleClick(doType) {
				let _this=this;
				if(doType=='examination'){//资格申请
					uni.navigateTo({
					    url:'/pages_student/examination/examination'
					});
				}else if(doType=='gas'){//用气申请
					uni.navigateTo({
					    url:'/pages_student/useGasApply/useGasApply'
					});
				}else if(doType=='audit'){//资格审核
					uni.navigateTo({
					    url:'/pages_student/aptitudeAudit/aptitudeAudit'
					});
				}else if(doType=='useRecord'){//使用记录
					uni.navigateTo({
					    url:'/pages_student/useRecord/useRecord'
					});
				}else if(doType=='gasApply'){//气瓶申请
					uni.navigateTo({
					    url:'/pages_student/gasApply/gasApply'
					});
				}else if(doType=='gasList'){//气瓶列表
					uni.navigateTo({
					    url:'/pages_student/gasList/gasList'
					});
				}else if(doType=='QRcode'){//
					uni.scanCode({
						onlyFromCamera: true,
						success: function (res) {
							_this.electronicTag=res.result
							_this.getInfo()
						}
					});
					
				}
				
				
			},
			//使用记录跳转详情
			goInfo(d){
				uni.navigateTo({
				    url:'/pages_student/useRecord/useRecordDetail?item='+encodeURIComponent(JSON.stringify(d))
				});
			},
			//气瓶信息跳转详情
			goInfo2(d){
				uni.navigateTo({
				    url:'/pages_student/gasList/gasListDetail?item='+encodeURIComponent(JSON.stringify(d))
				});
			},
			async getInfo(){
				let _this=this;
				const {data} = await useRegisterDetail({electronicTag:_this.electronicTag});
				if(data.code==200){
					let res = data.data;
					let userId=uni.getStorageSync('userId');
					
					if(res.currentStatus==4 && res.currentUserId==userId){
						uni.navigateTo({
						    url:'/pages_student/useRegister/giveRegister?code='+_this.electronicTag
						});
					}else{
						uni.navigateTo({
						    url:'/pages_student/useRegister/useRegister?code='+_this.electronicTag
						});
					}
				}
			},
			
			//获取使用记录列表
			async getList(){
				let _this = this;
				const {data} = await useRecordList(_this.getData)
				if(data.code==200){
					let res=data.rows
					_this.dataList=res
				}
			},
			//获取气瓶信息列表
			async getList2(){
				let _this = this;
				const {data} = await listuseRecordByUserId(_this.getData)
				if(data.code==200){
					let res=data.rows
					_this.dataList2=res
				}
			},
			//获取数量
			async getCount(){
				let _this = this;
				const {data} = await getUserApplyCount()
				if(data.code==200){
					let res=data.data
					_this.yqCount=res.yqCount;
					_this.zgCount=res.zgCount;
					_this.userApplyNumberYq=res.userApplyNumberYq;
					_this.userApplyNumberZg=res.userApplyNumberZg;
				}
			},
			
        },
		mounted() {
			this.getList();
			this.getList2();
			this.getCount();
		}
    }
</script>

<style lang="stylus" scoped>
    #register{
        height:auto;
        width:100%;
        display flex;
        flex-direction column;
		padding-bottom: 220rpx;
		.register_li{
			background #fff;
			border-radius:20rpx;
			margin:20rpx 20rpx 0;
			padding:20rpx 0;
			box-sizing: border-box;
			.register_li_min{
				margin:0 26rpx;
				display flex;
				align-items center;
				border-bottom: 1px solid #F5F5F5;
				view{
					line-height:100rpx;
				}
				view:nth-child(1){
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
					line-height:100rpx;
				}
				view:nth-child(2){
					flex:1;
					color: #0183FA;
					text-align: right;
					margin-right: 38rpx;
				}
				>img{
					width: 12rpx;
					height: 24rpx;
				}
			}	
		}
		.small_title{
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #999999;
			line-height: 100rpx;
			margin: 0 40rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			>img{
				width: 24rpx;
				height: 24rpx;
			}
		}
		
		.register_li2{
			background #fff;
			border-radius:20rpx;
			margin:0 20rpx 0;
			padding:0 20rpx;
			box-sizing: border-box;
			.register_li2_min{
				
				.register_li2_t{
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
					line-height: 28rpx;
					margin-top: 28rpx;
				}
				.register_li2_b{
					display: flex;
					justify-content: flex-start;
					align-items: center;
					margin-top: 42rpx;
					padding-bottom: 28rpx;
					border-bottom: 1rpx solid #f5f5f5;
					>img{
						width: 28rpx;
						height: 28rpx;
						margin-right: 10rpx;
					}
					>view{
						font-size: 24rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #666666;
						line-height: 24rpx;
					}
					>view:nth-of-type(1){
						width: 180rpx;
					}
					>view:nth-child(2){
					}
				}
				.register_li2_b2{
					display: flex;
					justify-content: flex-start;
					align-items: center;
					padding-bottom: 28rpx;
					
					>img{
						width: 28rpx;
						height: 28rpx;
						margin-right: 10rpx;
					}
					>view{
						font-size: 24rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #666666;
						line-height: 26rpx;
					}
					>view:nth-child(1){
						width: 200rpx;
					}
					>view:nth-child(2){
						flex: 1;
					}
				}
			}
			
		}
		/* 按钮 */
		.btn{
			display: flex;
			position: fixed;
			bottom: 0;
			.btn_l{
				width: 250rpx;
				background: #F28E26;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 100rpx;
				text-align: center;
			}
			.btn_r{
				width: 500rpx;
				background: #0183FA;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 100rpx;
				text-align: center;
			}
		}
	}
	/deep/.input-value-border{
		display :none !important;
	}
</style>
