<template>
	<view>
		<cu-custom bgColor="bg-gradual-blueness" :isBack="true" :isRingt="true">
			<block slot="backText">返回</block>
			<block slot="content">高危作业</block>
		</cu-custom>

		<view class="apps-box">
			<view class="apps-row">
				<!-- <view class="apps-title">
					<text class="apps-title-line"></text>
					<text>八项作业</text>
				</view> -->
				<view class="apps-warp">
					<navigator v-show="premission.confinedspace" class="apps-item" hover-class="none" url="/pages/application/confinedspace/home">
						<view class="imgs action">
							<image src="../../static/icon-apps/icon-806.png" mode=""></image>
              				<view v-if="confinedspace_count" class="cu-tag badge">{{confinedspace_count}}</view>
						</view>
						<view class="text-semi" style="text-align: center;">
							<view>受限空间</view>
							<view>安全作业</view>
						</view>
					</navigator>
<!--					<navigator class="apps-item" hover-class="none" url="/pages/application/equipment-overhaul/home">-->
<!--						<view class="imgs action">-->
<!--							<image src="../../static/icon-apps/icon-800.png" mode=""></image>-->
<!--						</view>-->
<!--						<view class="text-semi" style="text-align: center;">-->
<!--							<view>设备检修</view>-->
<!--						</view>-->
<!--					</navigator>-->
					<navigator v-show="premission['blind-board']" class="apps-item" hover-class="none" url="/pages/application/blind-board/home">
						<view class="imgs action">
							<image src="../../static/icon-apps/icon-801.png" mode=""></image>
              				<view v-if="blind_board_count" class="cu-tag badge">{{blind_board_count}}</view>
						</view>
						<view class="text-semi" style="text-align: center;">
							<view>盲板抽堵作业</view>
						</view>
					</navigator>
					<navigator v-show="premission['break-ground']" class="apps-item" hover-class="none" url="/pages/application/break-ground/home">
						<view class="imgs action">
							<image src="../../static/icon-apps/icon-802.png" mode=""></image>
              				<view v-if="break_ground_count" class="cu-tag badge">{{break_ground_count}}</view>
						</view>
						<view class="text-semi" style="text-align: center;">
							<view>动土作业</view>
						</view>
					</navigator>
					  <navigator v-show="premission['high-work']" class="apps-item" hover-class="none" url="/pages/application/high-work/home">
						<view class="imgs action">
						  <image src="../../static/icon-apps/icon-803.png" mode=""></image>
						  <view v-if="high_work_count" class="cu-tag badge">{{high_work_count}}</view>
						</view>
						<view class="text-semi" style="text-align: center;">
						  <view>高处作业</view>
						</view>
					  </navigator>
<!--				</view>-->
<!--				<view class="apps-warp">-->
					<navigator v-show="premission.hoisting" class="apps-item" hover-class="none" url="/pages/application/hoisting/home">
						<view class="imgs action">
							<image src="../../static/icon-apps/icon-804.png" mode=""></image>
              				<view v-if="hoisting_count" class="cu-tag badge">{{hoisting_count}}</view>
						</view>
						<view class="text-semi" style="text-align: center;">
							<view>吊装作业</view>
						</view>
					</navigator>
					<navigator v-show="premission.electricity" class="apps-item" hover-class="none" url="/pages/application/electricity/home">
						<view class="imgs action">
							<image src="../../static/icon-apps/icon-805.png" mode=""></image>
              				<view v-if="electricity_count" class="cu-tag badge">{{electricity_count}}</view>
						</view>
						<view class="text-semi" style="text-align: center;">
							<view>临时用电作业</view>
						</view>
					</navigator>
					<navigator v-show="premission.hotwork" class="apps-item" hover-class="none" url="/pages/application/hotwork/home">
						<view class="imgs action">
							<image src="../../static/icon-apps/icon-807.png" mode=""></image>
              				<view v-if="hotwork_count" class="cu-tag badge">{{hotwork_count}}</view>
						</view>
						<view class="text-semi" style="text-align: center;">
							<view>动火作业</view>
						</view>
					</navigator>
          <navigator v-show="premission['open-circuit']" class="apps-item" hover-class="none" url="/pages/application/open-circuit/home">
            <view class="imgs action">
              <image src="../../static/icon-apps/open-circuit.png" mode=""></image>
              <view v-if="open_circuit_count"  class="cu-tag badge">{{open_circuit_count}}</view>
            </view>
            <view class="text-semi" style="text-align: center;">
              <view>断路作业</view>
            </view>
          </navigator>
				</view>
			</view>

<!-- 			<view class="apps-row">
				<view class="apps-title">
					<text class="apps-title-line"></text>
					<text>其他应用</text>
				</view>
				<view class="apps-warp">
					<navigator class="apps-item" hover-class="none" url="/pages/application/other-apps/videos/videos">
						<view class="imgs action">
							<image src="../../static/icon-apps/icon-zl-7.png" mode=""></image>
						</view>
						<view class="text-semi">视频中心</view>
					</navigator>
				</view>
			</view> -->
			<view class="cu-tabbar-height"></view>
		</view>
	</view>
</template>

<script>
  import { decryptAes } from "@/common/aesUtil";
	import {
		basePath,
		loginUserId,
		formatDate,
		loginUser,
		setloginUserId,
		setCorpinfoId,
		setloginUser,
		setDeptId,
    premission,
		isRest
	} from '@/common/tool.js';
	export default {
		data() {
			return {
        premission: {},
				isRest :'',
        confinedspace_count:0,
        blind_board_count:0,
        break_ground_count:0,
        high_work_count:0,
        hoisting_count:0,
        electricity_count:0,
        hotwork_count:0,
        open_circuit_count:0,
			};
		},
		mounted(){
			this.isRest = isRest;
		},
    onShow() {
      this.premission = Object.assign({}, premission)
      console.info( this.premission)
		  this. confinedspace_count = 0
      this.blind_board_count = 0
      this.break_ground_count = 0
      this.high_work_count = 0
      this.hoisting_count = 0
      this.electricity_count = 0
      this.hotwork_count = 0
      this.open_circuit_count = 0
      this.getRedPoint();
    },
		methods: {
			showRest(){

				uni.showModal({
					title: '提示',
					showCancel:false,
					content: '您处于离岗状态，无需检查清单。',
					confirmText: "返回", // 确认按钮文字
					success: (res) => {
					}
				})
			},

      getRedPoint(){
        uni.request({
          url: basePath +'/app/confinedspace/countCheck',
          method: 'POST',
          dataType: 'json',
          header: {
            'Content-type':'application/x-www-form-urlencoded'
          },
          data: {
            tm:new Date().getTime(),
            CORPINFO_ID:loginUser.CORPINFO_ID,
            USER_ID:loginUser.USER_ID,
          },
          success: (res) => {
            res.data = decryptAes(res.data);
            if ("success" == res.data.result) {
              Object.values(res.data.count).forEach(item=>{
                this.confinedspace_count += (item || 0)
              })
            }
          }
        })

        uni.request({
          url: basePath +'/app/blindboard/countCheck',
          method: 'POST',
          dataType: 'json',
          header: {
            'Content-type':'application/x-www-form-urlencoded'
          },
          data: {
            tm:new Date().getTime(),
            CORPINFO_ID:loginUser.CORPINFO_ID,
            USER_ID:loginUser.USER_ID,
          },
          success: (res) => {
            res.data = decryptAes(res.data);
            if ("success" == res.data.result) {
              Object.values(res.data.count).forEach(item=>{
                this.blind_board_count += (item || 0)
              })
            }
          }
        })

        uni.request({
          url: basePath +'/app/breakground/countCheck',
          method: 'POST',
          dataType: 'json',
          header: {
            'Content-type':'application/x-www-form-urlencoded'
          },
          data: {
            tm:new Date().getTime(),
            CORPINFO_ID:loginUser.CORPINFO_ID,
            USER_ID:loginUser.USER_ID,
          },
          success: (res) => {
            res.data = decryptAes(res.data);
            if ("success" == res.data.result) {
              Object.values(res.data.count).forEach(item=>{
                this.break_ground_count += (item || 0)
              })
            }
          }
        })

        uni.request({
          url: basePath +'/app/highwork/countCheck',
          method: 'POST',
          dataType: 'json',
          header: {
            'Content-type':'application/x-www-form-urlencoded'
          },
          data: {
            tm:new Date().getTime(),
            CORPINFO_ID:loginUser.CORPINFO_ID,
            USER_ID:loginUser.USER_ID,
          },
          success: (res) => {
            res.data = decryptAes(res.data);
            if ("success" == res.data.result) {
              Object.values(res.data.count).forEach(item=>{
                this.high_work_count += (item || 0)
              })
            }
          }
        })

        uni.request({
          url: basePath +'/app/hoisting/countCheck',
          method: 'POST',
          dataType: 'json',
          header: {
            'Content-type':'application/x-www-form-urlencoded'
          },
          data: {
            tm:new Date().getTime(),
            CORPINFO_ID:loginUser.CORPINFO_ID,
            USER_ID:loginUser.USER_ID,
          },
          success: (res) => {
            res.data = decryptAes(res.data);
            if ("success" == res.data.result) {
              Object.values(res.data.count).forEach(item=>{
                this.hoisting_count += (item || 0)
              })
            }
          }
        })

        uni.request({
          url: basePath +'/app/electricity/countCheck',
          method: 'POST',
          dataType: 'json',
          header: {
            'Content-type':'application/x-www-form-urlencoded'
          },
          data: {
            tm:new Date().getTime(),
            CORPINFO_ID:loginUser.CORPINFO_ID,
            USER_ID:loginUser.USER_ID,
          },
          success: (res) => {
            res.data = decryptAes(res.data);
            if ("success" == res.data.result) {
              Object.values(res.data.count).forEach(item=>{
                this.electricity_count += (item || 0)
              })
            }
          }
        })

        uni.request({
          url: basePath +'/app/hotwork/countCheck',
          method: 'POST',
          dataType: 'json',
          header: {
            'Content-type':'application/x-www-form-urlencoded'
          },
          data: {
            tm:new Date().getTime(),
            CORPINFO_ID:loginUser.CORPINFO_ID,
            USER_ID:loginUser.USER_ID,
          },
          success: (res) => {
            res.data = decryptAes(res.data);
            if ("success" == res.data.result) {
              Object.values(res.data.count).forEach(item=>{
                this.hotwork_count += (item || 0)
              })
            }
          }
        })

        uni.request({
          url: basePath +'/app/cutroad/countCheck',
          method: 'POST',
          dataType: 'json',
          header: {
            'Content-type':'application/x-www-form-urlencoded'
          },
          data: {
            tm:new Date().getTime(),
            CORPINFO_ID:loginUser.CORPINFO_ID,
            USER_ID:loginUser.USER_ID,
          },
          success: (res) => {
            res.data = decryptAes(res.data);
            if ("success" == res.data.result) {
              Object.values(res.data.count).forEach(item=>{
                this.open_circuit_count += (item || 0)
              })
            }
          }
        })
      }
		}
	}
</script>

<style>
	.app-banner{
		width: 100%;
		height: 380upx;
	}
	.app-banner image{
		width: 100%;
		height: 100%;
	}
.apps-box {}

	.apps-row {
		padding: 20upx 20upx 10upx 20upx;
		background-color: #fff;
		margin-top: 20upx;
	}
	.apps-row:first-child{
		margin-top: 0;
	}

	.apps-title {
		position: relative;
		padding-left: 20upx;
		color: #989898;
		padding-bottom: 20upx;
	}

	.apps-title-line {
		display: inline-block;
		background-color: #37a6ff;
		width: 10upx;
		height: 23upx;
		position: absolute;
		left: 0upx;
		top: 11upx;
	}

	.apps-warp {
		display: flex;
		flex-wrap: wrap;
	}

	.apps-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 25%;
		font-size: 25upx;
		margin-bottom: 20upx;
	}
	.apps-item .text-semi{
		margin-top: 6upx;
	}
	.apps-item .action{
		position: relative;
	}
	.apps-item .action .cu-tag.badge{
		right: -20upx;
	}
	.apps-item .imgs {
		width: 50upx;
		height: 50upx;
	}

	.apps-item .imgs image {
		width: 100%;
		height: 100%;
	}
</style>
