<template>
	<view class="work-container">
		
		<!-- 宫格组件 -->
		<!-- <uni-section title="系统管理" type="line"></uni-section> -->
		<view class="grid-body">
			<uni-grid :column="2" :showBorder="false">
				<uni-grid-item>
					<view class="grid-item-box" @click="showMinYong">
						<uni-icons type="person-filled" size="30"></uni-icons>
						<text class="text">民用工程</text>
					</view>
				</uni-grid-item>



				<uni-grid-item>
					<view class="grid-item-box" @click="showGongYe">
						<uni-icons type="staff-filled" size="30"></uni-icons>
						<text class="text">工业工程</text>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="municipalProjectClick">
						<uni-icons type="color" size="30"></uni-icons>
						<text class="text">市政工程</text>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="showDangerous">
						<uni-icons type="settings-filled" size="30"></uni-icons>
						<text class="text">危险作业工程</text>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="showTopPipe">
						<uni-icons type="heart-filled" size="30"></uni-icons>
						<text class="text">顶管工程</text>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="showInfrastructureDialog">
						<uni-icons type="bars" size="30"></uni-icons>
						<text class="text">基建工程</text>
					</view>
				</uni-grid-item>


			</uni-grid>
			<view v-if="showPopup" class="popup">
				<view class="content">
					<view class="line1">
						<view>旧改工程</view>
					</view>
					<view class="line2" v-for="(item, index) in OldProjectList" :key="index">
						<view @click="OldProject(item.dictValue)">{{item.dictLabel}}</view>
						<!-- <view @click="Courtyard(0)">庭院</view>
						<view @click="Overhead(0)">架空</view> -->

					</view>
					<view class="line1">
						<view>新建工程</view>
					</view>
					<view class="line2" v-for="(item, index) in NewProjectList" :key="index">
						<view @click="NewProject(item.dictValue)">{{item.dictLabel}}</view>
						<!-- <view @click="Courtyard(0)">庭院</view>
						<view @click="Overhead(0)">架空</view> -->

					</view>
				</view>

				<view class="btn-group">
					<view class="btn_position">
						<view class="cancel" @click="showMinYong">取消</view>
					</view>
				</view>
			</view>
			<view v-if="showPopup" class="mask" @click="showMinYong"></view>
		</view>


		<view class="share">
			<view :class="{'share-box': shareState}" @click="handleHiddenShare">
			</view>
			<view class="share-item" :class="{'share-show': shareState}">
				<view class="share-to">
					<text>请选择</text>
				</view>
				<scroll-view scroll-y="true" class="scroll-Y">
					<view class="content">
						<view class="block" v-for="(item, index) in typeList" :key="index" @click="showTypeSheet(item)">
							<!-- <image :src="item.image" mode="aspectFill"></image> -->
							<text>{{item.dictLabel}}</text>
						</view>
					</view>
				</scroll-view>
				<view class="cancel" @click.stop="handleHiddenShare">
					<text>取消</text>
				</view>
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	import {
		getDicts
	} from "@/api/system/dict/data";
	export default {

		data() {
			return {
				showPopup: false,
				shareState: false,
				array: [],
				projectType: '', //工程类型
				OldProjectList: '', //旧改工程
				NewProjectList: '', //民用工程
				typeList: '', //二次弹窗数据
				enginType: '',
				enginClassification: '', // 旧改节点 数据字典
				enginClassValue: '', //二次节点  数据字典
				current: 0,
				swiperDotIndex: 0,
			
			}
		},
		methods: {
			// 显示二次弹窗
			handleShowSheet() {
				this.shareState = true;
			},
			// 隐藏二次弹窗
			handleHiddenShare() {
				this.shareState = false;
			},
			clickBannerItem(item) {
				console.info(item)
			},
			changeSwiper(e) {
				this.current = e.detail.current
			},
			changeGrid(e) {
				this.$modal.showToast('模块建设中~')
			},
			showMinYong() {
				this.projectType = 'MinYong';
				getDicts("old_renovation").then(response => {
					this.OldProjectList = response.data;
				});
				getDicts("new_built").then(response => {
					this.NewProjectList = response.data;
				});
				this.showPopup = !this.showPopup;

			},
			//市政工程-首页-点击事件
			municipalProjectClick() {
				let obj = {
					value: '市政工程'
				};
				uni.navigateTo({
					url: '/pages/municipal/municipal?params=' + encodeURIComponent(JSON
						.stringify(obj))

				});
			},

			NewProject(e) {
				this.enginType = 'new_built'; //写死
				this.enginClassification = e;
				this.typeList = ''; //置空
				console.log("新建", e)
				if (e == 'indoor_engin') {
					//新建室内
					getDicts("new_built_indoor_engin").then(response => {

						this.typeList = response.data;
					});

				} else if (e == 'courtyard') {
					//新建庭院
					getDicts("new_built_courtyard").then(response => {
						console.log("庭院", response.data)
						this.typeList = response.data;

					});
				} else if (e == 'overhead') {
					//新建架空
					getDicts("new_built_courtyard").then(response => {
						console.log("架空", response.data)
						this.typeList = response.data;


					});
				}

				this.handleShowSheet();

			},
			OldProject(e) {
				this.enginType = 'old_renovation'; //写死
				this.enginClassification = e;
				console.log("旧改", e)
				this.typeList = ''; //置空
				if (e == 'indoor_engin') {
					//旧改室内
					getDicts("old_renovation_indoor_engin").then(response => {

						this.typeList = response.data;
					});

				} else if (e == 'courtyard') {
					//旧改庭院
					getDicts("old_renovation_courtyard").then(response => {
						console.log("庭院", response.data)
						this.typeList = response.data;

					});
				} else if (e == 'overhead') {
					//旧改架空
					getDicts("old_renovation_overhead").then(response => {
						console.log("架空", response.data)
						this.typeList = response.data;
					});
				}

				this.handleShowSheet();
			},

			//二次弹窗 选择类型
			showTypeSheet(item) {
				if (this.projectType == 'MinYong') {
					this.showPopup = !this.showPopup; //隐藏第一次弹窗
					this.enginClassValue = item.dictValue; //二次节点赋值
					const obj = {
						enginClassValue: this.enginClassValue, //(拆旧管等 字典值)
						enginType: this.enginType, //旧改 还是新建  写死
						enginClassification: this.enginClassification //室内  庭院  架空

					};
					console.log(obj)
					this.handleHiddenShare();
					// 室内
					if (this.enginClassification == 'indoor_engin') {
						uni.navigateTo({
							url: '/pages/oldrenovation/indoor/indoor?params=' + encodeURIComponent(JSON.stringify(
								obj))
						})
					}
					// 庭院
					else if (this.enginClassification == 'courtyard') {
						uni.navigateTo({
							url: '/pages/oldrenovation/courtyard/courtyard?params=' + encodeURIComponent(JSON
								.stringify(
									obj))
						})
					} else if (this.enginClassification == 'overhead') { //架空
						uni.navigateTo({
							url: '/pages/oldrenovation/overhead/overhead?params=' + encodeURIComponent(JSON
								.stringify(
									obj))
						})
					}
				} else if (this.projectType == 'GongYe') {
					console.log("工业", item)
					let obj = {
						value: item.dictValue
					};
					this.handleHiddenShare();
					uni.navigateTo({
						url: '/pages/enginproject/enginproject?params=' + encodeURIComponent(JSON
							.stringify(
								obj))
					})
				} else if (this.projectType == 'JiJian') {
					console.log("基建", item)
					let obj = {
						value: item.dictValue
					};
					this.handleHiddenShare();
					uni.navigateTo({
						url: '/pages/infrastructure/infrastructure?params=' + encodeURIComponent(JSON
							.stringify(
								obj))
					})
				} else if (this.projectType == 'DingGuan') {
					console.log("顶管", item)
					let obj = {
						value: item.dictValue
					};
					this.handleHiddenShare();
					uni.navigateTo({
						url: '/pages/TopPipeWork/TopPipeWork?params=' + encodeURIComponent(JSON
							.stringify(
								obj))
					})

				}

			},
			showGongYe() {
				this.projectType = 'GongYe';
				//工业工程
				getDicts("engin_classification").then(response => {
					console.log("工业工程", response.data)
					this.typeList = response.data;

					console.log("工业工程", response.data)

				});
				this.handleShowSheet();
			},
			showTopPipe() {
				this.projectType = 'DingGuan';
				getDicts("pipe_jack").then(response => {
					console.log("顶管工程", response.data)
					this.typeList = response.data;


				});
				this.handleShowSheet();
			},
			showInfrastructureDialog() {
				this.projectType = 'JiJian';
				//基建工程
				getDicts("engineering_infrastructure").then(response => {
					console.log("基建工程", response.data)
					this.typeList = response.data;

					console.log("基建工程", response.data)

				});
				this.handleShowSheet();
			},
			showDangerous() {
				console.log("危险作业工程")
				uni.navigateTo({
					url: '/pages/dangerous/dangerous'
				})
			},
		}
	}
</script>

<style lang="scss">
	/* #ifndef APP-NVUE */
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #fff;
		min-height: 100%;
		height: auto;
	}

	view {
		font-size: 14px;
		line-height: inherit;
	}

	/* #endif */

	.text {
		text-align: center;
		font-size: 26rpx;
		margin-top: 10rpx;
	}

	.grid-item-box {
		flex: 1;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 15px 0;
	}

	.uni-margin-wrap {
		width: 690rpx;
		width: 100%;
		;
	}

	.swiper {
		height: 300rpx;
	}

	.swiper-box {
		height: 150px;
	}

	.swiper-item {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
		color: #fff;
		height: 300rpx;
		line-height: 300rpx;
	}

	@media screen and (min-width: 500px) {
		.uni-swiper-dot-box {
			width: 400px;
			/* #ifndef APP-NVUE */
			margin: 0 auto;
			/* #endif */
			margin-top: 8px;
		}

		.image {
			width: 100%;
		}
	}

	// 弹窗效果
	.popup {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		background-color: #fff;
		// padding: 20rpx;
		box-sizing: border-box;
		z-index: 999;
	}

	// 遮罩层
	.mask {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.5);
		z-index: 888;
	}

	// 弹窗内容
	.content {
		.line1 {
			background-color: #6ea8e7;
			text-align: center;
			padding: 20rpx;
		}

		.line2 {
			padding: 20rpx;
			// border-bottom: 1px solid black;

			view {
				margin-bottom: 10rpx;
			}
		}
	}

	// 按钮样式
	.btn-group {
		box-shadow: 0px -2px 6px rgba(0, 0, 0, 0.5);

		/* 示例阴影参数，根据需要进行调整 */
		.btn_position {
			display: flex;
			width: 100%;

			.cancel {
				width: 50%;
				text-align: center;
				padding: 20rpx 0;
				color: #519fe7;
			}

			.submit {
				width: 50%;
				background-color: #519fe7;
				text-align: center;
				padding: 20rpx 0;
				color: #fff;
			}
		}

	}

	.share {
		width: 100%;
		height: 100%;
	}

	.share-box {
		width: 100%;
		height: 100%;
		position: fixed;
		top: 0rpx;
		left: 0rpx;
		bottom: 0rpx;
		right: 0rpx;
		background-color: rgba(0, 0, 0, 0.4);
		transition: .3s;
		z-index: 999;
	}

	// 进入分享动画
	.share-show {
		transition: all 0.3s ease;
		transform: translateY(0%) !important;
	}
	.scroll-Y {
		height: 350rpx;
	}

	// 离开分享动画
	.share-item {
		position: fixed;
		left: 0;
		bottom: 0;
		width: 100%;
		height: auto;
		background-color: #FFFFFF;
		transition: all 0.3s ease;
		transform: translateY(100%);
		z-index: 1999;

		.share-to {
			width: 100%;
			height: 3rem;
			display: flex;
			justify-content: center;
			align-items: center;

			&::after {
				content: '';
				width: 240rpx;
				height: 0rpx;
				border-top: 1px solid #E4E7ED;
				-webkit-transform: scaleY(0.5);
				transform: scaleY(0.5);
				margin-left: 30rpx;
			}

			&::before {
				content: '';
				width: 240rpx;
				height: 0rpx;
				border-top: 1px solid #E4E7ED;
				-webkit-transform: scaleY(0.5);
				transform: scaleY(0.5);
				margin-right: 30rpx;
			}
		}

		.content {
			width: 100%;
			height: 50%;
			display: flex;
			flex-wrap: wrap;

			.block {
				width: 100%;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				height: 80rpx;



				text {
					margin-top: 16rpx;
					font-size: 28rpx;
					color: #606266;
				}
			}
		}

		.cancel {
			width: 100%;
			height: 3rem;
			display: flex;
			justify-content: center;
			align-items: center;
			border-top: 1rpx solid #E4E7ED;
		}
	}
</style>