<template>
	<view class="safeIndex">
		<headers class="fixedheader" :themeType="true" :showBack="true">
			<view class="headerName">
				安全管理系统
			</view>
			<div class="header-btn" v-if="COMPANY != 'longguang'">
				<uni-icons type="scan" color="#fff" size="20" @click="qrCode"></uni-icons>
			</div>
		</headers>
		<scroll-view class="smallHeight" :style="{ 'padding-top': statusBarHeight + 45 + 'px' }" scroll-y>
			<view class="safe-statistics">
				<view class="statistics-list flex">
					<view class="statistics-item b-right">
						<text>{{overdueNotCloseNum}}</text>
						超期未销项重大隐患
					</view>
					<view class="statistics-item">
						<text>{{notCloseNum}}</text>
						未销项重大隐患
					</view>
				</view>
			</view>

			<view class="moudle-box">
				<view class="moudle-title">我的待办</view>
				<view class="moudle-list flex">
					<!-- <view class="moudle-item flex" :class="{'m-right': (index+1)%3 != 0}" v-for="(item,index) in 4" :key="index">
						<uni-icons class="moudle-icon" type="image" size="30"></uni-icons>
						<text>隐患排查{{index}}</text>
					</view> -->
					<view class="moudle-item flex m-right" @click="jumpPage(1)">
						<image class="moudle-icon" src="/static/safeMange/danger_examine.png"></image>
						<text>隐患排查</text>
					</view>
					<view class="moudle-item flex m-right" @click="jumpPage(2)">
						<image class="moudle-icon" src="/static/safeMange/danger_library2.png"></image>
						<text>待整改</text>
					</view>
					<view class="moudle-item flex" @click="jumpPage(3)">
						<image class="moudle-icon" src="/static/safeMange/danger_review.png"></image>
						<text>待复核</text>
					</view>
				</view>
			</view>

			<view class="moudle-box moudle-box2">
				<view class="moudle-title">常用模块</view>
				<!-- <view class="moudle-list flex">
					<view class="moudle-item flex" :class="{'m-right': (index+1)%3 != 0}" v-for="(item,index) in 4" :key="index">
						<uni-icons class="moudle-icon" type="image" size="30"></uni-icons>
						<text>隐患排查{{index}}</text>
					</view>
				</view> -->
				<view class="moudle-list flex">
					<!-- <view class="moudle-item flex m-right"> -->
						<!-- <uni-icons class="moudle-icon" type="image" size="30"></uni-icons> -->
						<!-- <image class="moudle-icon" src="../../../static/safeMange/danger_library.png"></image>
						<text>隐患库</text>
					</view> -->
					<view class="moudle-item flex m-right" @click="jumpPage(4)" v-if="COMPANY != 'sanjiang'">
						<image class="moudle-icon" src="/static/safeMange/project_examine.png"></image>
						<text>项目自检</text>
					</view>
					<view class="moudle-item flex m-right" @click="jumpPage(5)">
						<image class="moudle-icon" src="/static/safeMange/danger_list.png"></image>
						<text>检查台账</text>
					</view>
					<view class="moudle-item flex" @click="jumpPage(8)" v-if="COMPANY != 'sanjiang'">
						<image class="moudle-icon" src="/static/safeMange/danger_project.png"></image>
						<text>危大工程</text>
					</view>
<!--					<view class="moudle-item flex" @click="jumpPage(7)" v-if="COMPANY != 'sanjiang'">-->
<!--						<image class="moudle-icon" src="/static/safeMange/danger_check.png"></image>-->
<!--						<text>危大验收</text>-->
<!--					</view>-->
					<!-- <view class="moudle-item flex" @click="jumpPage(6)">
						<image class="moudle-icon" src="/static/safeMange/enterprise_examine.png"></image>
						<text>企业检查</text>
					</view> -->
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
import headers from '../../../components/headers/headers.vue'
export default{
	data(){
		return{
			statusBarHeight: 0,
			userId: "",
			overdueNotCloseNum: "",
			notCloseNum: "",
			styleType:'',
		}
	},
	onShow(){
		this.statusBarHeight = uni.getStorageSync('systemInfo').statusBarHeight;
		this.userId = JSON.parse(uni.getStorageSync('userInfo')).userId;
		this.styleType=JSON.parse(uni.getStorageSync('userInfo')).styleType
		this.queryStatisticsNum()
	},
	methods:{
		jumpPage(val){
			if(val == 1){
				if(uni.getStorageSync('dangerData')){
					uni.removeStorageSync('dangerData');
				}
				if(uni.getStorageSync('detailData')){
					uni.removeStorageSync('detailData');
				}
				uni.navigateTo({
					url: "./addExamine?type=1"
				})
			} else if(val == 2){
				uni.navigateTo({
					url: "./dangerList?type=1"
				})
			} else if(val == 3){
				uni.navigateTo({
					url: "./dangerList?type=2"
				})
			} else if(val == 4){
				uni.navigateTo({
					url: "./projectList"
				})
			} else if(val == 5){
				uni.navigateTo({
					url: "./dangerList?type=3"
				})
			} else if(val == 7){
				uni.navigateTo({
					url:'../dangerBigProject/dangerBigCheckList'
				})
			} else if(val == 8){
				uni.navigateTo({
					url:'../dangerBigProject/index'
				})
			}

		},
		queryStatisticsNum(){
			let data = {
				userId: this.userId
			}
			let _this = this
			this.sendRequest({
				url: 'xmgl/hiddenDangerInspectRecord/selectUserInspectRecordCount',
				method: 'post',
				data: data,
				success: (res) => {
					this.overdueNotCloseNum = res.result.overdueNotCloseNum
					this.notCloseNum = res.result.notCloseNum
					console.log(res.result)
				}
			})
		},
		qrCode(){
			console.log(1)
			uni.scanCode({
			    onlyFromCamera: true,
			    success: function (res) {
			        console.log('条码类型：' + res.scanType);
			        console.log('条码内容：' + res.result);
					if(res.result){
						if(JSON.parse(res.result).type == 'wdgc'){
							uni.navigateTo({
								url: '../dangerBigProject/details?id=' + JSON.parse(res.result).id
							})
						}
						console.log(JSON.parse(res.result).id)
					}
			    }
			});
		}
	}
}
</script>

<style lang="scss" scoped>
.safeIndex{
	height: 100%;
	font-size: 28rpx;
	.fixedheader{
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		z-index: 2;
		.headerName{
			z-index: 1;
		}
	}
	.header-btn{
		position: absolute;
		top: 0;
		right: 20rpx;
		font-size: 24rpx;
		line-height: 88rpx;
		z-index: 2;
	}
	.smallHeight{
		// height: calc(100% - 45px);
		height: 100%;
		box-sizing: border-box;
		background: #F6F6F6;
	}
	.flex{
		display: flex;
	}
	.safe-statistics{
		padding: 26rpx;
		.statistics-list{
			background: #fff;
			background: #fff;
			height: 144rpx;
			align-items: center;
			box-shadow: 0 16rpx 20rpx #E3E3E3;
			background: url("../../../static/safeMange/safe_bg.png") no-repeat center;
			background-size: 100% 100%;
			.statistics-item{
				flex: 1;
				text-align: center;
				uni-text{
					display: block;
					color: #E26C0E;
					font-weight: 600;
					margin-bottom: 6rpx;
				}
			}
			.b-right{
				border-right: 1px solid rgba(244,150,0,0.1);
			}
		}
	}
	.moudle-box{
		margin: 0 26rpx;
		margin-bottom: 20rpx;
		border-radius: 12rpx;
		background: #fff;
		padding: 0 20rpx;
		padding-top: 20rpx;
		.moudle-title{
			margin-bottom: 20rpx;
			font-weight: bold;
			display: inline-block;
			position: relative;
		}
		.moudle-title::after{
			content: "";
			width: 100%;
			height: 10rpx;
			background:	rgba(#127FEC, 0.2);
			position: absolute;
			bottom: 0;
			left: 0;
		}
		.moudle-list{
			flex-wrap: wrap;
			.moudle-item{
				width: 30%;
				height: 206rpx;
				background: #fff;
				border-radius: 10rpx;
				margin-bottom: 40rpx;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				// box-shadow: 4rpx 16rpx 20rpx #E9E9E9;
				.moudle-icon{
					width: 100rpx;
					height: 100rpx;
					line-height: 100rpx;
					margin-bottom: 10rpx;
				}
			}
			.m-right{
				margin-right: 30rpx;
			}
		}
	}
	.moudle-box2{
		padding-bottom: 60rpx;
		.moudle-list{
			.moudle-item{
				font-size: 14px;
				margin-bottom: 20rpx;
				.moudle-icon{
					width: 64rpx;
					height: 68rpx;
				}
			}
		}
	}
}
</style>
