<template>
	<view :style="'padding-top:'+nvaHeight+'px;'">
		<view class="navbox">
			<uni-nav-bar title="今日巡更" left-icon="left" @clickLeft="getBackFn"  color="#161616" :background-color="backgroundColor" :border="false" statusBar='true' fixed="true">	
			</uni-nav-bar>
			<view class="pfbox" :style="'background-color:'+backgroundColor">
				<view class="patop">
					<view class="tit" @click="getRecordFn">巡更记录</view>
					<view class="txt" @click="getSetFn">巡更点设置</view>
				</view>
				<view class="patabs flexc">
					<view class="patab cof7" @click="tabval=0">
						<view class="pattit">25</view>
						<view class="pattxt">巡更点</view>
						<image :src="linea" class="line" v-if="tabval==0"></image>
					</view>
					<view class="patab co02" @click="tabval=1">
						<view class="pattit">25</view>
						<view class="pattxt">已巡更</view>
						<image :src="lineb" class="line" v-if="tabval==1"></image>
					</view>
					<view class="patab cof6" @click="tabval=2">
						<view class="pattit">25</view>
						<view class="pattxt">未巡更</view>
						<image :src="linec" class="line" v-if="tabval==2"></image>
					</view>
				</view>
			</view>
		</view>
		<image :src="pbg" class="navbg"></image>
		<view class="wymain">
			<view class="pfbox" style="opacity: 0;">
				<view class="patop">
					<view class="tit">巡更记录</view>
					<view class="txt">巡更点设置</view>
				</view>
				<view class="patabs flexc">
					<view class="patab cof7" @click="tabval=0">
						<view class="pattit">25</view>
						<view class="pattxt">巡更点</view>
						<image :src="linea" class="line" v-if="tabval==0"></image>
					</view>
					<view class="patab co02" @click="tabval=1">
						<view class="pattit">25</view>
						<view class="pattxt">已巡更</view>
						<image :src="lineb" class="line" v-if="tabval==1"></image>
					</view>
					<view class="patab cof6" @click="tabval=2">
						<view class="pattit">25</view>
						<view class="pattxt">未巡更</view>
						<image :src="linec" class="line" v-if="tabval==2"></image>
					</view>
				</view>
			</view>
			<!-- 列表 -->
			<view class="carlists">
				<car-list :datainfo="list" :wtdt="wtdt" type='patrol' @getDetail="getDetail" @getAddFn="getAddFn"></car-list>
			</view>
		</view>
		<loading></loading>
	</view>
</template>

<script>
	import config from '@/config'
	const baseUrl = config.baseUrl
	import carList from "@/work/components/car/list.vue"
	import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
	export default{
		components:{carList},
		data(){
			return{
				backgroundColor: "transparent",
				pbg:require("@/work/static/service/pbg.png"),
				plbg:require("@/work/static/service/plbg.png"),
				linea:require("@/work/static/service/linea.png"),
				lineb:require("@/work/static/service/lineb.png"),
				linec:require("@/work/static/service/linec.png"),
				list:[{tit:'皖A IC520',type:1},{tit:'晋E KD783',type:2},],
				pageSize: 10,
				pageNum: 1,
				reachflag: true,
				wtdt:'',
				nvaHeight:44,
				tabval:0,
			}
		},
		onPageScroll(e) {
			var scrollTop = Number(e.scrollTop);
			if (scrollTop > 0) {
				this.backgroundColor = '#CDDEFF'
			} else {
				this.backgroundColor = 'transparent'
			}
		},
		// 上拉触底加载更多触发事件
		onReachBottom() {
			if (this.reachflag) {
				this.pageNum++
				this.getDataFn()
			}
		},
		onLoad: function() {
			uni.getSystemInfo({
				success: (e) => {
					this.nvaHeight = Number(e.statusBarHeight)+44;
				}
			})
		},
		methods:{
			checkPermi, checkRole,
			getDetail(){
				this.$tab.navigateTo("/work/pages/service/patroldetail")
			},
			getRecordFn(){
				this.$tab.navigateTo("/work/pages/service/patrolrecord")
			},
			getSetFn(){
				this.$tab.navigateTo("/work/pages/service/patrolset")
			},
			getAddFn(){
				this.$tab.navigateTo("/work/pages/service/patroladd")
			},
			getBackFn(){
				uni.navigateBack({
					delta:1
				})
			},
			getDataFn(){
				return
				var params={
					pageSize:this.pageSize,
					pageNum: this.pageNum,
				}
				params.noticeType=this.tabidx
				getNoticeList(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: #F3F3F0;}
</style>
<style lang="scss" scoped>
.navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4;	}
.navbg{width: 100%;height: 578rpx;z-index: 0;}
.wymain{z-index: 2;position: relative;}
.carlists{padding: 0 18rpx;}
.patop{display: flex;justify-content: space-between;padding-top: 20rpx;margin-bottom: 28rpx;
	.tit{font-weight: 500;font-size: 26rpx;color: #304367;width: 152rpx;height: 58rpx;border-radius: 0 29rpx 29rpx 0;background-color: #AEC3EB;line-height: 58rpx;padding-left: 22rpx;
	}
	.txt{font-weight: 500;font-size: 26rpx;color: #304367;padding-right: 20rpx;}	
}
.patabs{
	padding: 0 26rpx;margin-bottom:40rpx;
	.patab{margin: 0 16rpx;width: 200rpx;height: 124rpx;background: #FFFFFF;border-radius: 20rpx;padding-top: 16rpx;text-align: center;position: relative;
		.pattit{font-size: 40rpx;font-weight: bold;margin-bottom: 6rpx;}
		.line{position: absolute;bottom: -12rpx;left: 4rpx;width: 192rpx;height: 20rpx;}
		
		.pattxt{font-weight: 500;font-size: 22rpx;}
	}
}
</style>