 <template>
   <view class="page">
 	<u-navbar title="工作台" placeholder bgColor="#00337A" @leftClick="leftClick" leftIconColor="#fff" :titleStyle="{ color: '#FFF', fontSize: '32rpx' }">
 		<view class="u-nav-slot" slot="left">
 			<u-icon name="grid" size="24"  color="#FFF" v-if="type.indexOf('4')>-1"></u-icon> 
 		</view>
 	</u-navbar>
	<view style="width: 100%;height: 84vh;">
		<scroll-view scroll-y="true">
			<view class="view-box">
				<view class="view-item" @click="goContractWitness">
					<view><image class="img1" src="@/static/realName/contract_witness.png" style="width: 60rpx;height: 60rpx;" alt=""></view>
					<view style="font-size: 24rpx;">合同见证</view>
				</view>
				<view class="view-item" @click="goSafeguarding">
					<view><image class="img1" src="@/static/realName/safeguarding.png" style="width: 60rpx;height: 60rpx;" alt=""></view>
					<view style="font-size: 24rpx;">欠薪维权申诉</view>
				</view>
				<view class="view-item" @click="goPersonEnter">
					<view><image class="img1" src="@/static/realName/base_person.png" style="width: 60rpx;height: 60rpx;" alt=""></view>
					<view style="font-size: 24rpx;">人员信息录入</view>
				</view>
				<view class="view-item" @click="goPeopleLibrary">
					<view><image class="img1" src="@/static/realName/base_person.png" style="width: 60rpx;height: 60rpx;" alt=""></view>
					<view style="font-size: 24rpx;">人员库</view>
				</view>
				<view class="view-item" @click="goeleContract">
					<view><image class="img1" src="@/static/realName/contract_sign.png" style="width: 60rpx;height: 60rpx;" alt=""></view>
					<view style="font-size: 24rpx;">电子合同</view>
				</view>
				<view class="view-item" @click="goWageRecord">
					<view><image class="img1" src="@/static/realName/wage_check.png" style="width: 60rpx;height: 60rpx;" alt=""></view>
					<view style="font-size: 24rpx;">工资查看</view>
				</view>
				<view class="view-item" @click="goWageWitness">
					<view><image class="img1" src="@/static/realName/wage_witness.png" style="width: 60rpx;height: 60rpx;" alt=""></view>
					<view style="font-size: 24rpx;">工资卡见证</view>
				</view>
				<view class="view-item" @click="goDayPlan">
					<view><image class="img1" src="@/static/realName/day_plan.png" style="width: 60rpx;height: 60rpx;" alt=""></view>
					<view style="font-size: 24rpx;">准入信息查询</view>
				</view>
				<view class="view-item" @click="goExam">
					<view><image class="img1" src="@/static/realName/exam.png" style="width: 60rpx;height: 60rpx;" alt=""></view>
					<view style="font-size: 24rpx;">安全教育培训</view>
				</view> 
				
			</view>
		</scroll-view>
	</view>
	
	
	<!-- 弹窗 -->
	<u-popup :show="showPopup" mode="center" @close="closePopup">
		<view style="width:500rpx;height: auto%;position: relative;background-color: #fff;">
			<view style="width: 100%;height: 80rpx;margin: 0 auto;display: flex;justify-content: space-between;align-items: center;background-color: #fff;"> 
				<view style="width: 50%;height: 80rpx;line-height: 80rpx;font-weight: bold;margin-left: 40rpx;">选择工程</view>
				<u-icon style="width: 10%;" name="close" color="#000" size="24" @click="closePopup"></u-icon>
			</view>
			<scroll-view style="width: 100%;height: 50vh;background-color: #fff;" scroll-y="true">
				<view v-for="(item,index) in proList" :key="index" style="padding: 20rpx;" v-if="item.isActive==1" @click="chosenPro(item)">{{item.abbreviation}}</view>
			</scroll-view>
		</view>
	</u-popup>
	
	
	
	
	
	
	<m-tabbar fixed fill :current="1" :tabbar="tabbar"></m-tabbar>
   </view>
 </template>
 
 <script>
 import TabbarConfig from '../util/tabbar.js'
 import config from '@/config'
 
 export default {
   data() {
     return {
 		tabbar: TabbarConfig,
		type:uni.getStorageSync('realNameUser').type,
		subId:uni.getStorageSync('realNameUser').subId,
		showPopup:false,
		proList:[]
 		// userName: uni.getStorageSync('userName'),
 		// className: uni.getStorageSync('className'),
 		// facePath: config.fileUrl + uni.getStorageSync('facePath'),
 		// token: uni.getStorageSync('access_token')
     }
   },
   onLoad() {
		if(this.type.indexOf("4")>-1){//监督端
		   this.getPro()
	    }
   },
   	onShow() {
   		if(this.type.indexOf("4")>-1){ //监督端
   		   let hasChosenPro=uni.getStorageSync('hasChosenPro')
   		   if(!hasChosenPro){
   			   this.showPopup=true
   		   }
   		}
   	},
    methods: {
		goPersonEnter(){
			uni.navigateTo({//人员录入
				url: `/pages/realName/workbench/personEnter/index`
			})
		},
		goPeopleLibrary(){//人员库
			uni.navigateTo({
				url: `/pages/realName/workbench/peopleLibrary/index`
			})
		},
		goeleContract(){//电子合同
			uni.navigateTo({
				url: `/pages/realName/workbench/electronicContract/contractVideo`
			})
		},
		goContractWitness(){//合同见证
			uni.navigateTo({
				url: `/pages/realName/workbench/contractWitness/index`
			})
		},
		goSafeguarding(){//欠薪维权申诉
			uni.navigateTo({
				url: `/pages/realName/workbench/safeguarding/index`
			})
		},
		goWageWitness(){//工资卡见证
			uni.navigateTo({
				url: `/pages/realName/workbench/wageWitness/index`
			})
		},
		goWageRecord(){//工资卡见证
			uni.navigateTo({
				url: `/pages/realName/workbench/wageRecord/index`
			})
		},
		goDayPlan(){//准入信息查询
			uni.navigateTo({
				url: `/pages/realName/workbench/dayPlan/index`
			})
		},
		goExam(){//安全教育培训
			uni.navigateTo({
				url: `/pages/realName/workbench/exam/index`
			})
		},
		
		
		
		getPro(){
			let param={
				id:-1,
				subId:this.subId
			}
			console.log(param)
			uni.request({
			  url: config.realAppUrl + '/offLine/getPro',
			  method: 'post',
			  data: param,
			  header: {
				'Content-Type': 'application/x-www-form-urlencoded',
				Authorization: uni.getStorageSync('realNameToken')
			  },
			  success: res => {
				console.log(res)
				res = res.data;
				if(res.code==200){
					this.proList = res.data;
				}
			  },
			  fail: err => {
				console.log(err)
			  }
			})
		},
		leftClick() {
			if(this.type.indexOf("4")>-1){
			   this.showPopup=true;
			}
		},
		chosenPro(item){
			let obj = uni.getStorageSync('realNameUser')
			obj.proId=item.id
			uni.setStorageSync('realNameUser', obj)
			uni.setStorageSync('hasChosenPro', "1")
			this.showPopup=false;
		},
		closePopup() {
			this.showPopup=false;
		},
   }
 }
 </script>
 
 <style lang="scss">
 .page {
   width: 100%;
   height: 100vh;
   
   // box-sizing: border-box;
   // padding: 15vh 8vw;
   .view-box{
	   width: 100%;height: auto;display: flex;flex-wrap: wrap;flex-direction: row;
	   margin-bottom: 100rpx;
   }
   .view-item{
	   width: 33%;height: 200rpx;display: flex;flex-direction:column;align-items: center;justify-content: center;
   }
 }
 </style>
 