<template>
	<view class="work-container">
		<!-- 轮播图 -->
		<uni-swiper-dot class="uni-swiper-dot-box" :info="data" :current="current" field="content">
			<swiper class="swiper-box" :current="swiperDotIndex" @change="changeSwiper">
				<swiper-item v-for="(item, index) in data" :key="index">
					<view class="swiper-item" @click="clickBannerItem(item)">
						<image :src="item.image" mode="aspectFill" :draggable="false" />
					</view>
				</swiper-item>
			</swiper>
		</uni-swiper-dot>

		<!-- 宫格组件 -->
		<!-- <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">
						<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">
						<uni-icons type="color" size="30"></uni-icons>
						<text class="text">市政工程</text>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box">
						<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">
						<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">
						<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">
						<view @click="Indoor(0)">室内</view>
						<view @click="Courtyard(0)">庭院</view>
						<view @click="Overhead(0)">架空</view>

					</view>
					<view class="line1">
						<view>新建工程</view>
					</view>
					<view class="line2">
						<view @click="Indoor(1)">室内</view>
						<view @click="Courtyard(1)">庭院</view>
						<view @click="Overhead(1)">架空</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>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				showPopup: false,

				current: 0,
				swiperDotIndex: 0,
				data: [{
						image: '/static/images/banner/banner01.jpg'
					},
					{
						image: '/static/images/banner/banner02.jpg'
					},
					{
						image: '/static/images/banner/banner03.jpg'
					}
				]
			}
		},
		methods: {
			clickBannerItem(item) {
				console.info(item)
			},
			changeSwiper(e) {
				this.current = e.detail.current
			},
			changeGrid(e) {
				this.$modal.showToast('模块建设中~')
			},
			showMinYong() {
				this.showPopup = !this.showPopup;

			},
			//室内
			Indoor(e) {
				if (e == 0) {
					//旧改
					this.showTypeSheet(0);
				} else if (e == 1) {
					//新建
					this.showTypeSheet(1);
				}
			},
			//庭院
			Courtyard(e) {
				if (e === 0) {

					this.showTypeSheet(0);
					//旧改
				} else if (e == 1) {
					//新建
					this.showTypeSheet(1);
				}
			},
			//架空
			Overhead(e) {
				if (e == 0) {
					//旧改
					this.showTypeSheet(0);
				} else if (e == 1) {
					//新建
					this.showTypeSheet(1);
				}

			},
			//二次弹窗 选择类型
			showTypeSheet(e) {
				uni.showActionSheet({
					itemList: ['拆旧管', '立杠', '挂表', '表后管', '阀管'],
					success: (res) => {
						console.log('选择了第' + (res.tapIndex + 1) + '个选项');
						if (e == 0 && res.tapIndex == 0) {
							uni.navigateTo({
								url: '/pages/oldrenovation/indoor/tearOldPipe'
							})
						}
						if (e == 0 && res.tapIndex == 1) {
							uni.navigateTo({
								url: '/pages/oldrenovation/indoor/verticalBar'
							})
						}
						if (e == 0 && res.tapIndex == 2) {
							uni.navigateTo({
								url: '/pages/oldrenovation/indoor/putUpWatch'
							})
						}
						if (e == 0 && res.tapIndex == 3) {
							uni.navigateTo({
								url: '/pages/oldrenovation/indoor/watchAfterPipe'
							})
						}
						if (e == 0 && res.tapIndex == 4) {
							uni.navigateTo({
								url: '/pages/oldrenovation/indoor/valveTube'
							})
						}

					},
					fail: (err) => {
						console.log('弹窗取消');
					}
				});

			}
		}
	}
</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;
			}
		}

	}
</style>