<template>
	<view class="content">
		<!-- 轮播 -->
		<view class="carousel-section">
			<swiper class="carousel" :autoplay="true" :interval="3000" :duration="1000">
				<swiper-item v-for="item in carouselList" :key="item.id">
					<image :src="item.pic"></image>
				</swiper-item>
			</swiper>
		</view>
		<!-- 上半部分菜单 -->
		<view class="box-top"></view>
		<view class="top-box flex">
			<view class="top-item" v-for="item in navList" @click="navTo(item.path)">
				<view class="item-tit">{{item.tit}}</view>
				<view class="item-content">{{item.content}}</view>
				<image :src="item.bgimg" mode="" class="item-logo" :style="{width:item.bgwidth,height:item.bgheight,top:item.bgtop,left:item.bgleft}"></image>
			</view>
		</view>
		<!-- 下半部分菜单 -->
		<view class="bottom-box flex">
			<view class="btm-left" @click="navTo('/pages/applic/location')">
				<view class="tit">救在身边救护员</view>
				<view class="left-content">实时救护，就在身边</view>
				<image src="../../static/icon/tb-5.png" mode="" class="bglogo"></image>
			</view>
			<view class="btm-right" >
				<view class="b-l-item" @click="navTo('/pages/applic/aid')">
					<view class="tit">救护站</view>
					<view class="left-content">附近的救护站都在这里</view>
					<image src="../../static/icon/tb-6.png" mode="" class="right-logo"></image>
				</view>
				<view class="b-l-item" @click="navTo('/pages/applic/aed')">
					<view class="tit">智能AED</view>
					<view class="left-content">查找附近AED设备</view>
					<image src="../../static/icon/tb-7.png" mode="" class="right-logo right-logo-2"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		loadIndexs,
		bannerlist,
		getListAED,
		getDistance,
		getListMechanism,
		getdis,
		tocall
	} from '@/api/index.js';
	import {
		saveUrl,
		interceptor
	} from '@/utils/loginUtils.js';
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import {
		userinfo
	} from '@/api/user.js';
	import uniPopup from '@/components/uni-popup/uni-popup.vue';
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import {
		getLoca
	} from '@/utils/wxAuthorized.js';
	import {
		getcomAddress
	} from '@/api/index.js';
	import topTitle from '../../components/top-title/top-title.vue';
	export default {
		components: {
			uniPopup,
			uniLoadMore,
			topTitle
		},
		data() {
			return {
				navList: [{
						tit: '我要报名',
						content: '志愿者捐献者报名',
						path: '/pages/applic/applicList',
						bgimg: '../../static/icon/tb-1.png',
						bgwidth: '84rpx',
						bgheight: '111rpx',
						bgtop: '84rpx',
						bgleft: '210rpx'
					}, {
						tit: '红十字事业',
						content: '红十字事业介绍',
						path: '/pages/applic/cause',
						bgimg: '../../static/icon/tb-2.png',
						bgwidth: '128rpx',
						bgheight: '127rpx',
						bgtop: '69rpx',
						bgleft: '181rpx'
					},
					{
						tit: '我要捐赠',
						content: '在线捐款渠道',
						path: '/pages/applic/love',
						bgimg: '../../static/icon/tb-3.png',
						bgwidth: '120rpx',
						bgheight: '120rpx',
						bgtop: '75rpx',
						bgleft: '192rpx'
					},
					{
						tit: '红十字知识',
						content: '急救知识科普',
						path: '/pages/applic/science',
						bgimg: '../../static/icon/tb-4.png',
						bgwidth: '120rpx',
						bgheight: '120rpx',
						bgtop: '75rpx',
						bgleft: '192rpx'
					}
				],
				carouselList: [], //轮播
			};
		},
		onShow() {
			saveUrl();
			// let token = uni.getStorageSync('token');
			console.log(11, this);
			if (!this.userInfo.uid) {
				// 登录拦截
				interceptor();
				// uni.showModal({
				// 	title: '登录',
				// 	content: '您未登录，是否马上登陆?',
				// 	success: e => {
				// 		if (e.confirm) {
				// 			interceptor();
				// 		}
				// 	},
				// 	fail: e => {
				// 		console.log(e);
				// 	}
				// });
			}
			this.loadData();
		},
		onLoad() {
			saveUrl();
		},
		computed: {
			...mapState('user', ['userInfo', 'baseURL', 'hasLogin'])
		},
		// 下拉加载
		onReachBottom() {
			this.loadData();
		},
		methods: {
			...mapMutations('user', ['setUserInfo']),
			//提示
			tishi() {
				uni.showModal({
					title: '提示',
					content: '获取当前位置信息失败,是否刷新页面。',
					success: function(res) {
						if (res.confirm) {
							window.location.reload();
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
			},
			loadData() {
				let obj = this;
				loadIndexs({}).then(({
					data
				}) => {
					obj.carouselList = data.banner; //轮播图
				});
			},
			navTo(url) {
				uni.navigateTo({
					url
				});
			},
		}
	};
</script>

<style lang="scss">
	a {
		text-decoration: none;
		color: #5f5f5f;
	}

	.content {
		// line-height: 1;
		background-color: #ffabab;
		// padding-bottom: 60rpx;
	}

	.popup_row {
		width: 100%;
		height: 500rpx;
		background-color: #ffffff;
		border-radius: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;

		.rows {
			width: 100%;
			padding: 0 24rpx;

			.rows-item {
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				width: 100%;
				font-size: 32rpx;
				color: #303133;
				// border-bottom: 1rpx solid #f0f0f0;
			}

			// .row-1 {
			// 	margin: auto;
			// 	.first_aid {
			// 		width: 300rpx;
			// 		height: 300rpx;
			// 	}
			// }
			// .row-2 {
			// 	font-size: 38rpx;
			// 	margin-top: 20rpx;
			// }
		}
	}

	.content {
		background-color: #f8f8f8;
		height: 100%;

		/* 头部 轮播图 */
		.carousel-section {
			// padding-top: 10px;
			overflow: hidden;
			background-color: #fff;

			.carousel {
				width: 750rpx;
				height: 504rpx;
				margin: 0 auto;
				overflow: hidden;

				.carousel-item {
					width: 100%;
					height: 100%;
					overflow: hidden;
				}

				image {
					width: 100%;
					height: 100%;
				}
			}
		}

		// 分类
		.cate-section {
			justify-content: space-around;
			background-color: #fff;
			padding: 46rpx 0 30rpx;

			.cate-item {
				width: 25%;
				flex-direction: column;
				text-align: center;
				align-items: center;
				justify-content: center;

				.img-wrapper {
					width: 100rpx;
					height: 88rpx;
					background: #eef4ff;
					border-radius: 14rpx;
					position: relative;

					image {
						position: absolute;
						left: 50%;
						top: 50%;
						transform: translate(-50%, -50%);
					}

					.img1 {
						width: 100rpx;
						height: 84rpx;
					}

					.img2 {
						width: 100rpx;
						height: 85rpx;
					}

					.img3 {
						width: 100rpx;
						height: 84rpx;

					}

					.img4 {
						width: 100rpx;
						height: 88rpx;
					}

				}

				.item-title {
					margin-top: 15rpx;
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
				}
			}
		}

		// 红会科普
		.science-section {
			width: 100%;
			background-color: #ffffff;
			margin-top: 18rpx;
			padding-top: 30rpx;

			.science-title {
				display: flex;
				justify-content: center;
				align-items: center;
				padding-bottom: 22rpx;

				.title {
					width: 285rpx;
					height: 64rpx;
					background-color: #ca121e;
					border-radius: 32rpx;
					color: #ffffff;
					font-size: 32rpx;
					line-height: 64rpx;
					text-align: center;
				}

				image {
					width: 68rpx;
					height: 43rpx;
					margin-left: 16rpx;
					margin-right: 16rpx;
				}
			}

			.science-box {
				padding-left: 15rpx;
				padding-right: 15rpx;
				padding-bottom: 20rpx;
				border-bottom: 1rpx solid #f0f0f0;
				white-space: nowrap;
				display: flex;
				width: 100%;

				// .uni-scroll-view-content{
				// 	display: flex;
				// }
				.science-content {
					// width: 100%;

					// display: flex;
					display: -webkit-box;

					.science-item {
						margin-right: 24rpx;
						width: 198rpx;
						display: flex;
						flex-direction: column;
						align-items: center;
						text-align: center;

						image {
							width: 100%;
							height: 145rpx;
						}

						.article-title {
							width: 198rpx;
							color: #333;
							font-size: 25rpx;
							padding-top: 20rpx;
							padding-bottom: 16rpx;
							font-weight: 900;
						}

						.article-content {
							width: 198rpx;
							color: #999999;
							font-size: 18rpx;
							overflow: hidden;
							text-overflow: ellipsis;
							display: -webkit-box;
							word-break: break-all;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2;
						}
					}
				}
			}

			.science-more {
				display: flex;
				justify-content: center;
				align-items: center;
				color: #cb131c;
				font-size: 30rpx;
				padding-top: 18rpx;
				padding-bottom: 18rpx;

				image {
					width: 20rpx;
					height: 27rpx;
				}
			}
		}

		// sos急救中心
		.system {
			width: 100%;
			background-color: #ffffff;
			margin-top: 18rpx;
			padding: 40rpx 30rpx 35rpx 30rpx;
			margin-bottom: 20rpx;

			.system-map {
				margin: 30rpx auto 0;
				width: 689rpx;
				height: 312rpx;
				background-color: #ffffff;
				// padding: 0 30rpx;
				padding-bottom: 45rpx;
				// .map-box {
				// 	width: 100%;
				// 	height: 312rpx;
				// 	// background-color: #fff;

				// }
			}
		}

		// AED
		.list-box {
			padding: 0rpx 25rpx 24rpx;
			// margin-bottom: 84rpx;
			background-color: #fff;

			.system-title {
				display: flex;
				justify-content: flex-start;
				align-items: center;
				height: 130rpx;
				// padding-bottom: 22rpx;
				background-color: #ffffff;

				.title {
					width: 285rpx;
					height: 64rpx;
					background-color: #ca121e;
					border-radius: 32rpx;
					color: #ffffff;
					font-size: 32rpx;
					line-height: 64rpx;
					text-align: center;
				}

				.img {
					width: 68rpx;
					height: 43rpx;
					margin-left: 16rpx;
					margin-right: 16rpx;

					image {
						width: 68rpx;
						height: 43rpx;
					}
				}
			}
		}

		.map-box {
			width: 100%;
			height: 366rpx;
		}

		.list-tpl {
			background-color: #ffffff;
			margin: 25rpx 0rpx;
			padding: 25rpx 25rpx;
			font-size: 28rpx;
			border-radius: 15rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			border-bottom: 1px solid #f1f1f1;

			.list-left {
				display: flex;
				width: 100%;

				.number {
					font-size: 32rpx;
					margin-right: 14rpx;
				}

				.info {
					width: 100%;

					.title {
						font-size: 32rpx;
						color: #222222;
						font-weight: 500;
					}

					.addr {
						width: 400rpx;
						margin-top: 20rpx;
						font-size: 20rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #999999;
					}
				}
			}

			.image {
				width: 10%;
				text-align: center;

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

				.tip {
					color: #7f7f7f;
					font-size: 21rpx;
				}
			}
		}
	}

	// .red-box {
	// 	margin: 20rpx 0;
	// 	height: 521rpx;
	// 	padding: 40rpx 23rpx 35rpx 23rpx;
	// 	background-color: #fff;

	// 	.red-nav {
	// 		justify-content: space-between;
	// 		margin-top: 23rpx;

	// 		.left-nav {
	// 			width: 332rpx;
	// 			height: 392rpx;
	// 			background: #FFF3F5;
	// 			background-image: url(../../static/img/m1.png);
	// 			background-size: 100% 100%;
	// 		}

	// 		.right-nav {
	// 			width: 357rpx;
	// 			height: 392rpx;
	// 			flex-direction: column;
	// 			justify-content: space-between;

	// 			// background: #F6F6FF;
	// 			.right-top-nav {
	// 				width: 357rpx;
	// 				height: 204rpx;
	// 				background: #F6F6FF;
	// 				background-image: url(../../static/img/m2.png);
	// 				background-size: 100% 100%;
	// 			}

	// 			.right-bottom-nav {
	// 				width: 357rpx;
	// 				height: 173rpx;
	// 				justify-content: space-between;

	// 				view {
	// 					width: 171rpx;
	// 					height: 173rpx;
	// 				}

	// 				.left-item {
	// 					background: #F5EFFE;
	// 					background-image: url(../../static/img/m3.png);
	// 					background-size: 100% 100%;
	// 				}

	// 				.right-item {
	// 					background: #EDFEFE;
	// 					background-image: url(../../static/img/m4.png);
	// 					background-size: 100% 100%;
	// 				}
	// 			}
	// 		}
	// 	}
	// }
	.red-box {
		margin: 20rpx 0;
		// height: 393rpx;
		padding: 30rpx 30rpx 40rpx 30rpx;
		background-color: #fff;

		.red-nav {
			padding-top: 25rpx;
			display: flex;
			justify-content: space-between;

			.nav-item {
				width: 330rpx;
				height: 175rpx;
				background: #FFF4F2;
				border-radius: 15rpx;

				image {
					width: 330rpx;
					height: 175rpx;
				}
			}
		}
	}

	.popup_row2 {
		// margin-top: 108rpx;
		height: 440rpx;
		border-radius: 25rpx;
		width: 100%;
		padding: 24rpx;
		background-color: #f8f8f8;
		z-index: 999;

		.title {
			border-bottom: 2rpx solid #F2F2F2;
			color: #E63931;
			font-size: 32rpx;
			padding-left: 4rpx;
			padding-bottom: 16rpx;
			display: flex;
			justify-content: space-between;

			// align-items: center;
			.cancel {
				margin-left: 52rpx;
				width: 36rpx;
				height: 36rpx;

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

		.inpBox {
			margin-top: 52rpx;
			border: 2px solid #f2f2f2;
			padding: 12rpx 24rpx;
			color: #FF9797;
			border-radius: 8rpx;

			.input-placeholder {
				// height: 70rpx;
				font-size: 32rpx;
				color: #FF9797;
			}
		}

		.inpedit {
			margin-top: 24rpx;
			margin-left: 14rpx;
			font-size: 28rpx;
			color: #FF9797;
		}

		.comfirm {
			display: flex;
			justify-content: flex-end;
			margin-top: 54rpx;

			.comfirm1 {
				padding: 12rpx 24rpx;
				border-radius: 12rpx;
				color: #FFFFFF;
				background-color: #E63931;
			}
		}
	}

	.location-item {
		z-index: 1000;
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1rpx solid #E7E8EA;
		padding: 15rpx 0;

		.box-left {
			display: flex;

			.img01 {
				width: 8rpx;
				height: 28rpx;
				margin-right: 18rpx;

				image {
					width: 8rpx;
					height: 28rpx;
				}
			}

			.img02 {
				width: 117rpx;
				height: 117rpx;
				border-radius: 50%;

				image {
					width: 117rpx;
					height: 117rpx;
					border-radius: 50%;
				}
			}

			.info {
				margin-left: 16rpx;

				.info-header {
					display: flex;
					align-items: center;

					.name {
						font-size: 32rpx;
						color: #333333;
					}

					.distance {
						margin-left: 25rpx;
						font-size: 28rpx;
						color: #303133;
					}

					.location-icon {
						margin-left: 10rpx;
						width: 20rpx;
						height: 26rpx;

						image {
							width: 20rpx;
							height: 26rpx;
							display: inline;
						}
					}
				}

				.address {
					font-size: 26rpx;
					color: #333333;
					margin-top: 33rpx;
				}
			}
		}

		.box-right {
			.img {
				height: 107rpx;

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

			.called {
				margin-right: 16rpx;
				height: 107rpx;
				line-height: 107rpx;
				font-size: 28rpx;
				color: #CB131C;
			}
		}
	}

	.box-top {
		height: 36rpx;
		height: 36rpx;
		border-radius: 36rpx 36rpx 0 0;
		// margin: -36rpx auto;
		margin-bottom: -36rpx;
		position: relative;
		top: -36rpx;
		background-color: #fff;
		z-index: 9;
	}

	.top-box {
		background-color: #fff;
		flex-wrap: wrap;
		justify-content: center;
		padding: 14rpx 0 50rpx;
		margin-bottom: 20rpx;
		.top-item {
			margin: 10rpx;
			width: 327rpx;
			height: 210rpx;
			background: linear-gradient(0deg, #FFF0ED, #FFFFFF, #FFF0ED);
			box-shadow: 0px 0px 20rpx 0px rgba(255, 52, 52, 0.06);
			border-radius: 10rpx;
			position: relative;
			padding: 25rpx 20rpx;
			.item-tit {
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
			}
			.item-content {
				font-size: 22rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #C3C3C3;
				padding-top: 10rpx;
			}
			.item-logo {
				position: absolute;
			}
		}
	}
	.bottom-box {
		justify-content: center;
		flex-wrap: wrap;
		background-color: #fff;
		.tit {
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #333333;
		}
		.left-content {
			padding-top: 5rpx;
			font-size: 20rpx;
			font-family: PingFang SC;
			font-weight: 500;
			max-width: 210rpx;
			color: #C3C3C3;
		}
		.btm-left {
			height: 334rpx;
			width: 261rpx;
			// background-color: #009100;
			padding: 30rpx 20rpx;
			position: relative;
			.bglogo {
				position: absolute;
				width: 189rpx;
				height: 194rpx;
				bottom: 23rpx;
				left: 35rpx;
			}
		}
		.btm-right {
			width: 438rpx;
			height: 334rpx;
			// background-color: #03A9F4;
			.b-l-item {
				width: 438rpx;
				height: 167rpx;
				// background-color: red;
				position: relative;
				padding: 50rpx 36rpx;
				.right-logo {
					position: absolute;
					width: 195rpx;
					height: 137rpx;
					top: 6rpx;
					left: 240rpx;
				}
				.right-logo-2 {
					width: 90rpx;
					height: 130rpx;
					top: 13rpx;
					left: 290rpx;
				}
			}
		}
	}
</style>
