<template>
	<view class="index-content">
		<u-navbar back-icon-color='#fff' back-icon-name=''
			:background="{ background: 'rgba(64, 158,255,'+bgOpacity+')'}" back-text="" title-color='#fff'
			:immersive='true' :border-bottom='false' title="首页">
			<!-- <template v-slot:right>
				<u-icon name="bell" color="#fff" size="36" style="padding-right: 30rpx;"
					@click="open('/pages/notaic/index')"></u-icon>
			</template> -->
		</u-navbar>
		<view class="top">
			<image src="../static/images/mobile_bg.png" class="bg" mode=""></image>
			<view class="top-box">
				<view class="number">
					<view class="number-item">
						<view>32</view>
						<view>设备总数</view>
					</view>
					<view class="number-item">
						<view>32</view>
						<view>故障中设备</view>
					</view>
					<view class="number-item">
						<view>32</view>
						<view>已报修设备</view>
					</view>
				</view>
				<view class="status">
					<view class="status-item">
						<view>32</view>
						<view>待接单</view>
					</view>
					<view class="status-item">
						<view>32</view>
						<view>待验证</view>
					</view>
					<view class="status-item">
						<view>32</view>
						<view>待审核</view>
					</view>
				</view>
			</view>
		</view>
		<view class="box">
			<view class="title">设备维护</view>
			<u-row gutter="16" style="padding:0px 20rpx ;">
				<u-col span="3">
					<view class="icon-item" @click="open('/pages/deviceReport/index?type=DEVICE')">
						<image src="../static/images/icon4.svg" mode=""></image>
						<view>设备报修</view>
					</view>
				</u-col>
				<u-col span="3">
					<view class="icon-item" @click="open('/pages/repairOrder/index?type=DEVICE')">
						<image src="../static/images/icon5.svg" mode=""></image>
						<view>维修工单</view>
					</view>
				</u-col>
				<u-col span="3">
					<view class="icon-item" @click="open('/pages/workOrderList/index?type=3')">
						<image src="../static/images/icon3.svg" mode=""></image>
						<view>检修工单</view>
					</view>
				</u-col>
				<u-col span="3">
					<view class="icon-item" @click="open('/pages/workOrderList/index?type=4')">
						<image src="../static/images/icon2.svg" mode=""></image>
						<view>点检工单</view>
					</view>
				</u-col>
				<u-col span="3">
					<view class="icon-item" @click="open('/pages/workOrderList/index?type=5')">
						<image src="../static/images/icon1.svg" mode=""></image>
						<view>保养工单</view>
					</view>
				</u-col>
			</u-row>
			<view class="title">模具维护</view>
			<u-row gutter="16">
				<u-col span="3">
					<view class="icon-item" @click="open('/pages/deviceReport/index?type=MOLD')">
						<image src="../static/images/icon4.svg" mode=""></image>
						<view>设备报修</view>
					</view>
				</u-col>
				<u-col span="3">
					<view class="icon-item" @click="open('/pages/serviceWorkOrderList/index')">
						<image src="../static/images/icon5.svg" mode=""></image>
						<view>维修工单</view>
					</view>
				</u-col>
				<u-col span="3">
					<view class="icon-item" @click="open('/pages/overhaulWorkOrderList/index')">
						<image src="../static/images/icon2.svg" mode=""></image>
						<view>检修工单</view>
					</view>
				</u-col>
				<u-col span="3">
					<view class="icon-item" @click="open('/pages/maintenWorkOrderList/index')">
						<image src="../static/images/icon1.svg" mode=""></image>
						<view>保养工单</view>
					</view>
				</u-col>
			</u-row>
			<view class="title">备件管理</view>
			<u-row gutter="16">
				<u-col span="3">
					<view class="icon-item" @click="open('/pages/sparePartsApplication/index')">
						<image src="../static/images/icon6.png" mode=""></image>
						<view>领用申请</view>
					</view>
				</u-col>
				<u-col span="3">
					<view class="icon-item" @click="open('/pages/sparePartsServiceWorkOrderList/index')">
						<image src="../static/images/icon5.svg" mode=""></image>
						<view>维修工单</view>
					</view>
				</u-col>
			</u-row>
		</view>

	</view>
</template>

<script>
	import {
		getInfo
	} from '@/api/login'
	import {
		getCounts
	} from '@/api/index'
  import { getAccessToken } from '@/utils/auth'

	export default {
		data() {
			return {
				bgOpacity: 0,
				
			}
		},

		methods: {
			open(url) {
				this.$tab.navigateTo(url)
			},
			getInfo() {
				getInfo().then(res => {
					console.log((res))
				})
			},
			getPermissionInfo() {
				this.$store.dispatch('GetPermissionInfo').then(res => {

				})
			},
			getCounts() {
				getCounts().then(res => {
					console.log((res))
				})
			},
		},
		onLoad: function() {
			if (getAccessToken()) {
			 this.getInfo()
			 this.getPermissionInfo()
			 this.getCounts()
			}

		},
		onPageScroll(e) {
			if (e.scrollTop > 0) {
				this.bgOpacity = e.scrollTop / 200;
			} else {
				this.bgOpacity = 0
			}
		},
	}
</script>

<style scoped lang="scss">
	.index-content {
		background-color: white;
		min-height: 100vh;
	}

	.bg {
		width: 100%;
	}

	.top {
		position: relative;

		image {
			height: calc(var(--status-bar-height) + 410rpx);
		}
	}

	.top-box {
		position: absolute;
		width: 100%;
		bottom: 0px;

		.number {
			padding: 30rpx 80rpx 50rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.number-item {
				text-align: center;

				view {
					&:nth-child(1) {
						color: white;
						font-size: 40rpx;
						font-weight: bold;
					}

					&:nth-child(2) {
						color: rgba(255, 255, 255, 0.7);
						font-size: 28rpx;
						margin-top: 10rpx;
					}
				}
			}
		}

		.status {
			margin: 0px 40rpx;
			padding: 40rpx 0rpx;
			background: white;
			border-radius: 20rpx 20rpx 0px 0px;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.status-item {
				text-align: center;
				position: relative;
				flex: 1;

				view {
					&:nth-child(1) {
						color: black;
						font-size: 40rpx;
						font-weight: bold;
					}

					&:nth-child(2) {
						color: rgba(0, 0, 0, 0.5);
						font-size: 28rpx;
						margin-top: 10rpx;
					}
				}

				&::after {
					content: "";
					border-right: 1px solid #dedede;
					position: absolute;
					height: 60rpx;
					right: 0px;
					top: 50%;
					margin-top: -30rpx;

				}

				&:nth-last-child(1)::after {
					border: none;
				}
			}
		}
	}

	.box {
		.title {
			font-size: 32rpx;
			font-weight: bold;
			padding: 50rpx 50rpx 30rpx;
		}

		.icon-item {
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			margin: 20rpx 0px;

			image {
				width: 80rpx;
				height: 80rpx;
			}

			view {
				margin-top: 20rpx;
				color: #999999;
			}
		}
	}
</style>