<template>
	<view id="page">
		<view style="
		position: sticky;
		top: 0;
		z-index: 999;">
			<view class="header Box">
				<view class="title">道路交通安全隐患</view>
				<view class="title">排查助手</view>
				<view class="desc">洞察隐患 智能守护 科技之眼照亮安全之路</view>
				<view class="total Flex Flex_C_S-B PositionR">
					<view class="left Flex">
						<view class="info" @click="jump(1)">
							<view class="name">待办</view>
							<view class="number">{{ totalData.UnderInvestigation }}</view>
						</view>
						<image style="width: 160rpx" mode="widthFix" :src="$.imgSrc + '/need.png'" class="need"></image>
						<view class="bottom PositionA Flex Flex_C_S-A TextCenter blur">
							<view class="item Flex_C_S-Center">
								<text>超期</text>
								<text style="margin-left: 10rpx;color: #CC2936;">{{ totalData.Delay }}</text>
							</view>
							<view class="item Flex_C_S-Center">
								<text>临期</text>
								<text style="margin-left: 10rpx;color: #E68A0B;">{{ totalData.Dying }}</text>
							</view>
						</view>
					</view>
					<view class="right">
						<view class="current_mouth Flex Flex_C_S-B blur" @click="jump(2,'2')">
							<image style="width: 80rpx" mode="widthFix" :src="$.imgSrc + '/mouth.png'" class="video">
							</image>
							<text class="name">个人上报</text>
							<text class="number">{{ totalData.MonthReport }}</text>
						</view>
						<view class="finish Flex Flex_C_S-B blur" @click="jump(2,'1')">
							<image style="width: 80rpx" mode="widthFix" :src="$.imgSrc + '/finish.png'" class="video">
							</image>
							<text class="name">已完成</text>
							<text class="number">{{ totalData.InGovernance }}</text>
						</view>
					</view>
				</view>
			</view>
			<view class="con" @click="konw">
				<image class="bg" src="/static/know.png" />
				<view class="con-box">
					<text
						style="font-family: Source Han Sans CN, Source Han Sans CN;color: #363F4D;font-weight: 500;">交通隐患排查知识库</text>
					<view class="icon">
						<uni-icons type="right" size="18" color="#fff" />
					</view>
				</view>
			</view>
		</view>
		<view class="Width100 Box BorderBox">
			<view class="list_title">待办任务</view>
			<view class="Content MarginAuto BorderBox">
				<no-data v-if="isEmpty" />
				<view v-else class="List Width100 BorderBox">
					<view class="Unit FontBold BorderBox Width100 MarginT_30rpx BG_FFFFFF" v-for="item in list"
						:key='item.id' @click='handleClick(item)'>
						<image class="imgleft" :src="item.imgurl || '/static/logo.png'" mode="widthFix"></image>
						<view class="right">
							<view class="title">{{ item.name }}</view>
							<view class="type">
								<text>排查</text>
								<text>{{ item.deadlineStatus || '--' }}</text>
							</view>
						</view>
						<view class="trapezoidal" v-if="item.deadlineType == 1">
							超期
						</view>
						<view class="trapezoidal lin" v-if="item.deadlineType == 2">
							临期
						</view>
					</view>
				</view>
				<u-loadmore :status="loadmorestatus" v-show="!isEmpty" />
			</view>
		</view>
		<Tabbar name="首页" v-if="tabbarShow"></Tabbar>
	</view>
</template>

<script>
	import tabFun from '@/libs/function/tabbar.js'
	import NoData from "../../components/no-data.vue";
	import Tabbar from "../../components/tabbar.vue";
	export default {
		// 组件
		components: {
			NoData,
			Tabbar
		},
		data() {
			return {
				$: this.$,
				// 公用的js
				bgUrl1: '', // 登录信息背景图
				list: [],
				isEmpty: false,
				isMore: true,
				page: 1,
				tab: 1,
				totalData: {
					UnderInvestigation: 0,
					InGovernance: 0,
					Finished: 0,
					MonthReport: 0,
					Dying: 0,
					Delay: 0,
				},
				loadmorestatus: 'loading',
				tabbarShow: true
			}
		},
		// 页面加载
		onLoad(e) {
			// this.getData()
			// this.getList()
		},
		onShow(e) {
			uni.hideTabBar() //隐藏官方的tabBar
			this.getData()
			this.isMore = true
			this.list = []
			this.page = 1
			this.getList()
			// tabFun.tabbar()
			// this.tabbarShow = false
			// this.$nextTick(() => {
			// 	this.tabbarShow = true
			// })
		},
		// 计算属性
		computed: {},
		// 方法
		methods: {
			getData() {
				const data = this.$.getData('token')
				this.$request.globalRequest('/hiddenDanger/highDanger/getHighDangerStatusNum', {
					nuserid: data
				}, 'GET').then(res => {
					if (res.code === 200) {
						res.result.forEach(item => {
							this.totalData[item.status] = item.count
						})
					} else {
						this.$.toast(res.message)
					}
				})
			},
			getList() {
				let datas = {
					nuserid: this.$.getData('token'),
					status: '10',
				}
				this.loadmorestatus = 'loading'
				this.$request.globalRequest(
						`/hiddenDanger/highDanger/getHigDangerDealt?pageNum=${this.page}&pageSize=${10}`, datas, 'POST')
					.then(res => {
						this.loadmorestatus = 'loadmore'
						if (res.code === 200) {
							if (res.result.total === 0) {
								this.isEmpty = true;
								return false
							}
							this.list.push(...res.result.list)
							if (this.list.length >= res.result.total) {
								this.isMore = false
								this.loadmorestatus = 'nomore'
							}
						} else {
							this.$.toast(res.message)
						}
					}).catch((err) => {
						this.loadmorestatus = 'nomore'
					})
			},
			handleClick(row) {
				if (row.pcType == 2) {
					this.$.open("/pages/investigation/task" + "?id=" + row.businessId + '&sectionId=' + row.sectionCode +
						'&operator=' + row.operator + '&deptId=' + row.handleDept + '&taskName=' + row.name +
						'&pcType' + row.pcType + '&sectionName=' + row.sectionName + '&sectionCode=' + row.sectionCode);
				} else {
					this.$.open('/pages/map/index?businessId=' + row.businessId + '&sectionId=' + row.sectionCode +
						'&operator=' + row.operator + '&deptId=' + row.handleDept + '&taskName=' + row.name +
						'&pcType' + row.pcType + '&sectionName=' + row.sectionName + '&sectionCode=' + row.sectionCode)
				}
			},
			konw() {
				this.$.open('/pages/knowledge/index')
			},
			// 跳转页面
			skipPage(even) {
				// this.$.open(even)
			},
			jump(v, type) {
				if (v == 1) {
					this.$.setData('pageStatus', 1)
					this.$.setData('pageType', 1)
				}
				if (v == 2) {
					this.$.setData('pageStatus', 3)
					this.$.setData('pageType', type)
				}

				this.$.openTab('/pages/investigation/index')
			}
		},
		onReady() {
			// this.$tabFun.tabbar()
		},
		mounted() {

		},
		// 页面卸载
		onUnload() {

		},
		// 触发下拉刷新
		onPullDownRefresh() {
			// 延迟关闭刷新动画
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 1500);
		},
		// 页面上拉触底事件的处理函数
		onReachBottom() {
			if (this.isMore) {
				this.page++
				this.getList()
			}
		}
	}
</script>

<style>
</style>
<style lang="scss" scoped>
	page {
		background: #F6F8FA;
	}

	.header {
		background: url("../../static/home_bg.png") no-repeat;
		background-size: cover;
		height: 500rpx;
		color: #FFFFFF;
		padding: calc(var(--status-bar-height) + 40rpx) 20rpx 20rpx;

		.title {
			font-family: Tensentype MeiHeiJ, Tensentype MeiHeiJ;
			font-weight: bold;
			font-size: 24px;
			line-height: 28px;
			letter-spacing: 2px;
			text-shadow: 0px 4px 0px rgba(255, 255, 255, 0.16);
			text-align: left;
			font-style: normal;
			text-transform: none;
		}

		.desc {
			margin-top: 20rpx;
			font-family: Source Han Sans CN, Source Han Sans CN;
		}

		.total {
			margin-top: 40rpx;

			.number {
				font-size: 20px;
				font-weight: bold;
				color: #363F4D;
			}

			.name {
				font-size: 16px;
				color: #363F4D;
				font-weight: bold;
			}

			.left {
				width: 40%;
				height: 100%;
				padding: 20rpx 20rpx 70rpx;
				border-radius: 10rpx;
				background: linear-gradient(180deg, #F0D9B4 0%, #F6F6F6 100%);
				overflow: hidden;

				.info {
					padding-left: 20rpx;
					padding-top: 20rpx;
					flex: 1;

					.number {
						font-size: 20px;
					}

					.name {
						font-size: 18px;
					}
				}

				.bottom {
					bottom: 0;
					border-radius: 0 0 10rpx 10px;
					width: calc(36% + 40rpx);
					left: 0;
					font-size: 16px;
					text-align: center;
					height: 80rpx;
					line-height: 80rpx;
					color: #363F4D;
				}
			}

			.right {
				flex: 1;
				padding: 0 20rpx;
				margin-left: 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;

				.current_mouth {
					margin-bottom: 20rpx;
				}

				.current_mouth,
				.finish {
					flex: 1;
					border-radius: 10rpx;
					padding: 20rpx;
					width: 100%;
				}
			}

		}
	}

	.img {
		width: 40rpx;
		height: 40rpx;
		margin-left: 30rpx;
	}

	.trapezoidal {
		position: relative;
		display: inline-block;
		min-width: 2em;
		text-align: center;
		padding: 3rpx 20rpx 3rpx 18rpx;
	}

	.trapezoidal::before,
	.trapezoidal::after {
		content: '';
		position: absolute;
		top: 0;
		left: 0%;
		width: 100%;
		height: 100%;
		border-radius: 0rpx 0 0 0;
		background: #FF1111;
		z-index: -1;
		transform-origin: bottom;
		transform: skew(18deg);
		border: 0rpx solid #333;
		box-sizing: border-box;
	}

	.trapezoidal::after {
		left: auto;
		right: 0;
		transform: skew(-0deg);
		border-radius: 0 0rpx 0 0;
		background-color: #FF1111;
		border-left: 0 none;
	}

	.lin::before,
	.lin::after {
		background-color: #E68A0B;
	}

	.list_title {
		font-size: 20px;
		// background: linear-gradient(180deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%);
		background: #f8fafb;
		// border-radius: 24px 24px 0px 0px;
		padding: 20rpx 30rpx 0;
		font-family: Source Han Sans CN, Source Han Sans CN;
		position: sticky;
		/* top: 418px; */
		top: calc(var(--status-bar-height) + 798rpx);
		z-index: 99;
		padding-bottom: 30rpx;
	}

	.Box {
		.Content {
			width: calc(100% - 48rpx);
			padding-bottom: 100rpx;
		}

		.Unit {
			padding: 12rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			position: relative;
			box-shadow: 1px 1px 3px #ccc;
			margin-top: 0;
			margin-bottom: 30rpx;

			.trapezoidal {
				position: absolute;
				top: 0px;
				right: 0px;
				color: #ffffff;
				font-size: 22rpx;
				font-weight: normal;
				z-index: 1;
			}

			image {
				width: 200rpx;
			}

			.right {
				flex: 1;
				padding-left: 30rpx;

				.title {
					font-size: 16px;
				}

				.type {
					font-size: 14px;
					color: #666;
					font-weight: normal;

					text {
						margin-right: 20rpx;
					}
				}
			}
		}
	}

	.con {
		width: 100%;
		height: 240rpx;
		padding: 30rpx;
		box-sizing: border-box;
		position: relative;
		z-index: 999;
		background-size: 100% 100%;
		display: flex;
		align-items: center;
		background: #f8fafb;

		.bg {
			position: absolute;
			top: 0;
			right: 0;
			width: 100%;
			height: 100%;
		}

		.con-box {
			width: 100%;
			padding: 0 20rpx;
			box-sizing: border-box;
			height: 80%;
			background: linear-gradient(to right, #8FB4F2 0%, #BCD2F2 100%);
			z-index: -1;
			position: relative;
			border-radius: 8rpx;
			display: flex;
			align-items: center;

			.icon {
				display: flex;
				justify-content: center;
				align-items: center;
				background: rgba(255, 255, 255, 0.3);
				color: #fff;
				border-radius: 10%;
				width: 40rpx;
				height: 40rpx;
				margin-left: 20rpx;
			}
		}
	}
</style>