<template>
	<view id="hazardousWasteRecyclingHome">
		<view class="max-big-button-box" v-if="buttonTypeA" @click="goPage(1)">
			<img class="left-box" :src="imagesUrl('hazardousWasteRecycling/wfhs_hsbb.png')">
			<view class="right-box">
				<view>回收报备</view>
				<view>可在回收日前填写报备单</view>
			</view>
		</view>
		<view class="max-big-button-box" v-if="buttonTypeB" @click="goPage(2)">
			<img class="left-box" :src="imagesUrl('hazardousWasteRecycling/wfhs_czdj.png')">
			<view class="right-box">
				<view>登记称重</view>
				<view>请在回收日等待回收,完成称重登记</view>
			</view>
		</view>
		<view class="max-big-button-box" @click="goPage(3)">
			<img class="left-box" :src="imagesUrl('hazardousWasteRecycling/wfhs_lsjl.png')">
			<view class="right-box">
				<view>历史记录</view>
				<view>查看我的危废回收记录</view>
			</view>
		</view>
		<view class="max-big-button-box" @click="goPage(4)">
			<img class="left-box" :src="imagesUrl('hazardousWasteRecycling/wfhs_qxsq.png')">
			<view class="right-box">
				<view>权限申请</view>
				<view>查看我的申请，提交新申请</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		hwmsAppRegisterApprovalMenuShow,
		hwmsRecycleConfigList,
	} from '@/pages_hazardousWasteRecycling/api/index.js'
	export default {
		data() {
			return {
				buttonTypeA:false,
				buttonTypeB:false,
				switchType:false,
			}
		},
		onLoad(option) {
		},
		onShow() {
			this.hwmsRecycleConfigList();
			this.hwmsAppRegisterApprovalMenuShow();
		},
		mounted() {
			
		},
		methods: {
			async hwmsRecycleConfigList(){
				let self = this;
				const {
					data
				} = await hwmsRecycleConfigList()
				if (data.code == 200) {
					for(let i=0;i<data.data.length;i++){
						if(data.data[i].configKey == 'HWMS_MASTER_SWITCH'){
							self.$set(self,'switchType',data.data[i].configValue == 1?true:false);
						}
					}
				}
			},
			async hwmsAppRegisterApprovalMenuShow(){
				const {
					data
				} = await hwmsAppRegisterApprovalMenuShow()
				if (data.code == 200) {
					if(data.data == 1){
						this.$set(this,'buttonTypeA',true);
						this.$set(this,'buttonTypeB',true);
					}else if(data.data == 2){
						this.$set(this,'buttonTypeA',true);
						this.$set(this,'buttonTypeB',false);
					}else if(data.data == 3){
						this.$set(this,'buttonTypeA',false);
						this.$set(this,'buttonTypeB',true);
					}else if(data.data == 4){
						this.$set(this,'buttonTypeA',false);
						this.$set(this,'buttonTypeB',false);
					}
				}
			},
			goPage(type){
				if(type == 1){
					if(!this.switchType){
						uni.showToast({
							title: '危废回收已关闭 , 如有疑问请联系管理员',
							icon: "none",
							mask: true,
							duration: 2000
						});
						return
					}
					uni.navigateTo({
						url: "/pages_hazardousWasteRecycling/views/recyclingReportRecord/index",
					});
				}else if(type == 2){
					uni.navigateTo({
						url: "/pages_hazardousWasteRecycling/views/weighingRegistration/index",
					});
				}else if(type == 3){
					uni.navigateTo({
						url: "/pages_hazardousWasteRecycling/views/historicalRecords/index",
					});
				}else if(type == 4){
					// uni.navigateTo({
					// 	url: "/pages_hazardousWasteRecycling/views/permissionApply/index",
					// });
					uni.navigateTo({
						url: "/pages_hazardousWasteRecycling/views/permissionApply/listPage",
					});
				}
			},
		},
	}
</script>

<style lang="stylus" scoped>
	#hazardousWasteRecyclingHome {
		height: 100%;
		display flex;
		flex-direction column;
		.max-big-button-box{
			background-color: #fff;
			border-radius:20rpx;
			margin:40rpx 40rpx 0;
			display: flex;
			.left-box{
				margin:40rpx 40rpx 40rpx 60rpx;
				width:160rpx;
				height:160rpx;
				border-radius:20rpx;
			}
			.right-box{
				view:nth-child(1){
					font-size:28rpx;
					color:#333;
					margin-top:70rpx;
				}
				view:nth-child(2){
					font-size:22rpx;
					color:#999;
					margin-top:20rpx;
				}
			}
		}
	}
</style>