<template>
	<view class="home">
		<!-- swiper -->
		<view class="home-swiper">
			<uni-swiper-dot :info="infoList" :current="current1" :mode="mode" :dots-styles="dotsStyles">
				<swiper class="swiper-box" @change="change1" circular>
					<swiper-item v-for="(item ,index) in infoList" :key="index">
						<view class="swiper-item">
							<image style="width: 100%;height:416rpx;" :src="item.img" mode="aspectFill"></image>
						</view>
					</swiper-item>
				</swiper>
			</uni-swiper-dot>
		</view>

		<!-- 金刚图 -->
		<view class="home-nav">
			<view class="home-nav-item" v-for="(item,index) in navList" @click="goOther(index)">
				<image style="width: 101.96rpx;height: 103.96rpx;" :src="item.img" mode=""></image>
				<text style="color: #333;font-size: 24rpx;margin-top: 18rpx; ">{{item.name}}</text>
			</view>
		</view>

		<!-- 活动专区 -->
		<view class="home-special-area">
			<view class="home-special-area-left">
				<text>西部活动专区</text>
				<image style="width:16rpx;height: 16rpx;margin-left: 14rpx;" src="/static/icon/symbol.png" mode="">
				</image>
			</view>
			<view @click="goSpecialList" class="home-special-area-right">
				<text>全部</text>
				<image style="width: 12rpx; height: 20rpx;margin-left: 8rpx;" src="/static/icon/right01.png" mode="">
				</image>
			</view>
		</view>

		<!-- 活动图片 -->
		<view class="home-special-img">
			<view class="ListItem" v-for="item in specialList">
				<image style="width: 312rpx;height: 200rpx;" :src="item.img" mode=""></image>
				<view class="kudosicon">
					<image style="width:24rpx;height: 24rpx;" src="/static/icon/Kudos.png" v-if="false"></image>
					<image style="width:24rpx;height: 24rpx;" src="/static/icon/Kudos(1).png"></image>
				</view>
				<text style="color: #333;font-weight: bold;font-size: 28rpx;">{{item.name}}</text>
			</view>
		</view>

		<!-- 广告图 -->
		<view class="home-banner">
			<view class="home-banner-img">
				<image style="width: 100%; height: 576rpx; border-radius: 12rpx;  "
					src="http://t9.9026.com/imgs/swiper01.png" mode=""></image>
				<image class="img-clean" style="width: 20rpx; height: 20rpx; " src="/static/icon/clean.png" mode="">
				</image>
				<view class="img-IHg" @click="goJoin">
					<image style="width: 64rpx; height: 58rpx; " src="/static/icon/vip.png" mode=""></image>
				</view>
			</view>

		</view>

		<!-- 广告的附图 -->
		<view class="home-attach" @click="goH5">
			<image style="width: 690rpx;height: 156rpx;" src="http://t9.9026.com/imgs/banner05.png" mode=""></image>
		</view>

		<!-- 酒店推荐 -->
		<view class="home-hotel home-special-area">
			<view class="home-special-area-left">
				<text>酒店商品推荐</text>
				<image style="width:16rpx;height: 16rpx;margin-left: 14rpx;" src="/static/icon/symbol.png" mode="">
				</image>
			</view>
		</view>

		<!-- 酒店推荐图片 -->
		<view class="home-hotel-img">

			<view class="home-hotel-img-content">
				<view class="home-hotel-img-content-item" v-for="item in goodsList"
					:style="{marginTop:item.marginTop || 0 }">
					<image class="home-hotel-img-content-item-img"
						:class="item.short?'home-hotel-img-content-item-img': 'home-hotel-img-content-item-img-long' "
						:src="item.img" mode=""></image>
					<view class="text">
						<text class="text-top">{{item.text}}</text>
						<text class="text-main">{{item.title}}</text>
					</view>
				</view>
			</view>

			<view class="home-hotel-img-more" @click="goProduceList">
				<text>查看更多商品</text>
			</view>
		</view>

		<!-- 酒店品牌 -->
		<view class="home-brand home-special-area">
			<view class="home-special-area-left">
				<text>洲际酒店集团品牌</text>
				<image style="width:16rpx;height: 16rpx;margin-left: 14rpx;" src="/static/icon/symbol.png" mode="">
				</image>
			</view>
		</view>


		<!-- 酒店品牌图片 -->
		<view class="home-brand-img">
			<uni-swiper-dot :info="info" mode="default" :current="current2" :dots-styles="dotsStylesBand">
				<swiper class="swiper-box" circular @change="change2">
					<swiper-item v-for="(items ,index) in info" :key="index">
						<view v-for="(item ,j) in items" :key="j" class="swiper-item"
							@click="goGoodsDetail(item.pic_url)">
							<image style="width:144rpx;height:142rpx;" :src="item.img" mode="aspectFill"></image>
						</view>
					</swiper-item>
				</swiper>
			</uni-swiper-dot>
		</view>


		<!-- 触底 -->
		<view class="home-bottom">
			<uni-load-more :status="status" color="#CCCCCC" :content-text="contentText" />
		</view>


		<view style="height:168rpx; background-color: #f9f9f9; "></view>
		<tab-bar></tab-bar>
	</view>

</template>

<script>
	import TabBar from '../../components/TabBar/tabbar.vue'
	import SwiperBox from '../../components/SwiperBox/index.vue'
	export default {
		components: {
			TabBar,
			SwiperBox
		},
		data() {
			return {
				goodsList: [{
						img: 'http://t9.9026.com/imgs/goodsimg01.png',
						text: '中秋佳节五仁月饼，惊喜特供，限时抢购',
						title: '环球洲际',
						short: '',
					},
					{
						img: 'http://t9.9026.com/imgs/goodsimg02.png',
						text: '中秋佳节五仁月饼，惊喜特供，限时抢购',
						title: '环球洲际'
					},
					{
						img: 'http://t9.9026.com/imgs/goodsimg02.png',
						text: '中秋佳节五仁月饼，惊喜特供，限时抢购',
						title: '环球洲际'
					},
					{
						img: 'http://t9.9026.com/imgs/goodsimg01.png',
						text: '中秋佳节五仁月饼，惊喜特供，限时抢购',
						title: '环球洲际',
					},
					
				],
				status: 'noMore',
				contentText: {
					contentdown: '查看更多',
					contentrefresh: '加载中',
					contentnomore: '——  已经到底啦  ——'
				},
				infoList: [{
						img: 'http://t9.9026.com/imgs/swiper01.png',
						name: '酒店预订'
					},
					{
						img: 'http://t9.9026.com/imgs/special01.png',
						name: 'IHG最受欢迎酒店'
					},
				],
				//轮播图
				info: [
					[{
							img: 'http://t9.9026.com/imgs/swiper01.png',
							name: '酒店预订'
						},
						{
							img: 'http://t9.9026.com/imgs/swiper01.png',
							name: '酒店预订'
						},
						{
							img: 'http://t9.9026.com/imgs/swiper01.png',
							name: '酒店预订'
						},
						{
							img: 'http://t9.9026.com/imgs/swiper01.png',
							name: '酒店预订'
						}
					],
					[{
							img: 'http://t9.9026.com/imgs/swiper01.png',
							name: '酒店预订'
						},
						{
							img: 'http://t9.9026.com/imgs/swiper01.png',
							name: '酒店预订'
						},
						{
							img: 'http://t9.9026.com/imgs/swiper01.png',
							name: '酒店预订'
						},
						{
							img: 'http://t9.9026.com/imgs/swiper01.png',
							name: '酒店预订'
						}
					],
					[{
							img: 'http://t9.9026.com/imgs/swiper01.png',
							name: '酒店预订'
						},
						{
							img: 'http://t9.9026.com/imgs/swiper01.png',
							name: '酒店预订'
						},
						{
							img: 'http://t9.9026.com/imgs/swiper01.png',
							name: '酒店预订'
						},
						{
							img: 'http://t9.9026.com/imgs/swiper01.png',
							name: '酒店预订'
						}
					],

				],
				dotsStyles: {
					bottom: 24,
					backgroundColor: 'rgba(255, 255, 255, .3)',
					border: '1px rgba(255, 255, 255, .3) solid',
					color: '#fff',
					selectedBackgroundColor: 'rgba(255, 255, 255, 1)',
					selectedBorder: '1px rgba(255, 255, 255, 1) solid'
				},
				dotsStylesBand: {
					backgroundColor: 'rgba(198, 198, 198, 1)',
					border: '1px rgba(0, 0, 0, .3) solid',
					color: '#fff',
					selectedBackgroundColor: 'rgba(151, 151, 151, 1)',
					selectedBorder: '1px rgba(0, 0, 0, .9) solid'
				},
				//指示点显示位置
				current1: 0,
				current2: 0,
				//指示点模式
				mode: 'dot',
				// 金刚图
				navList: [{
						img: require('../../static/icon/nav01.png'),
						name: '酒店预订'
					},
					{
						img: require('../../static/icon/nav02.png'),
						name: '投票活动'
					},
					{
						img: require('../../static/icon/nav03.png'),
						name: 'IHG西区地图'
					},
					{
						img: require('../../static/icon/nav04.png'),
						name: '了解产品'
					},
					{
						img: require('../../static/icon/nav05.png'),
						name: '周边游'
					},
				],

				//活动专区
				specialList: [{
						img: 'http://t9.9026.com/imgs/special01.png',
						name: 'IHG最受欢迎酒店'
					},
					{
						img: 'http://t9.9026.com/imgs/special01.png',
						name: '成都最好玩的地方'
					},
					{
						img: 'http://t9.9026.com/imgs/special01.png',
						name: 'IHG最受欢迎酒店'
					},
					{
						img: 'http://t9.9026.com/imgs/special01.png',
						name: 'IHG成都最好玩的地方'
					},
					{
						img: 'http://t9.9026.com/imgs/special01.png',
						name: 'IHG最受欢迎酒店'
					},
				]

			}
		},

		onShow() {
			this.shortLong()
			console.log(this)
		},
		methods: {
			shortLong() {
				this.goodsList.forEach((item, index, arr) => {
					if (index % 4 === 0) {
						item.short = true
					}
					if (index % 4 === 1) {
						item.long = true
					}
					if (index % 4 === 2) {
						item.long = true
						item.marginTop = -68 + "rpx"
					}
					if (index % 4 === 3) {
						item.short = true
					}
				})
				console.log(this.goodsList);
			},

			// 金刚图跳转
			goOther(index) {
				switch (index) {
					case 0:
						wx.navigateToMiniProgram({
							appId: 'wx255b58f0992b3c53', //appid
							path: 'pages/booking/booking_home', //path
							extraData: { //参数
								foo: 'bar'
							},
							// envVersion: 'develop', //开发版develop 开发版 trial   体验版 release 正式版 
							success(res) {
								console.log('成功')
								// 打开成功
							},
							fail(e) {
								console.log(e, '失败')
							}
						})
						break;
					case 1:
						uni.navigateTo({
							url: '/pages/index/active-list/index'
						})
						break;
					default:
						console.log(index)
				}

			},
			// 跳转其他小程序
			goJoin() {
				wx.navigateToMiniProgram({
					appId: 'wx255b58f0992b3c53', //appid
					path: 'newUIMain/enrollment/enrollment', //path
					extraData: { //参数
						foo: 'bar'
					},
					// envVersion: 'develop', //开发版develop 开发版 trial   体验版 release 正式版 
					success(res) {
						console.log('成功')
						// 打开成功
					},
					fail(e) {
						console.log(e, '失败')
					}
				})
			},
			// 跳转到h5页面
			goH5() {
				const url = 'https://m.sichuanair.com/touch-webapp/user/register'; // 跳转的外链
				const navtitle = 'H5'; // 这个标题是你自己可以设置的
				uni.navigateTo({
					// 跳转到webview页面
					url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
					success: () => {
						console.log('成功')
					},
					fail: (e) => {
						console.log(e, "失败")
					}
				});
			},

			//产品列表
			goProduceList() {
				uni.navigateTo({
					url: '/pages/goods/goods'
				})
			},

			//活动列表
			goSpecialList() {
				uni.navigateTo({
					url: '/pages/index/active-list/index'
				})
			},
			// 切换轮播图指示点
			change1(e) {
				this.current1 = e.detail.current;
			},
			change2(e){
				this.current2 = e.detail.current;
			}

		}
	}
</script>

<style lang="scss" scoped>
	page {
		height: 100%;
		background-color: #f9f9f9;
	}

	.home {
		height: 100%;
		background-color: #f9f9f9;
	}

	.home-swiper {
		width: 100%;
		height: 416rpx;

		.swiper-box {
			width: 100%;
			height: 416rpx;

			::v-deep .swiper-item {
				width: 100%;
				height: 416rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
			}

		}
	}

	.home-nav {
		position: relative;
		top: -15rpx;
		padding-top: 60rpx;
		border-radius: 24rpx 24rpx 0px 0px;
		display: flex;
		align-items: center;
		justify-content: space-between;
		background-color: #f9f9f9;

		.home-nav-item {
			width: 20%;
			flex: none;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
		}
	}

	.home-special-area {
		height: 146rpx;
		padding: 0 30rpx;
		// background-color: deeppink;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.home-special-area-left {
			display: flex;
			align-items: center;
			justify-content: flex-start;
			color: #333;
			font-size: 36rpx;
			font-weight: 800;

			&::before {
				content: '';
				display: inline-block;
				width: 6rpx;
				height: 34rpx;
				background: linear-gradient(180deg, #FF6200 0%, #FF4C00 100%);
				border-radius: 3rpx;
				margin-right: 8rpx;
				margin-top: 2rpx;
			}
		}

		.home-special-area-right {
			display: flex;
			align-items: center;
			justify-content: flex-end;
			font-size: 30rpx;
			color: #999;
		}
	}

	.home-special-img {
		height: 260rpx;
		padding: 0 30rpx;
		// background-color: #fff;
		display: flex;
		align-items: center;
		justify-content: space-between;
		overflow-x: scroll;
		overflow-y: hidden;

		.ListItem {
			width: 312rpx;
			position: relative;
			margin-right: 24rpx;

			.kudosicon {
				width: 40rpx;
				height: 40rpx;
				position: absolute;
				right: 28rpx;
				top: 16rpx;
				border-radius: 50%;
				background: #FFFFFF;
				opacity: 0.84;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}

		.ListItem:last-child {
			margin-right: 0;
		}
	}

	.home-banner {
		height: 640rpx;
		padding: 0 30rpx;
		padding-top: 64rpx;

		.home-banner-img {
			position: relative;

			.img-clean {
				position: absolute;
				right: 28rpx;
				top: 30rpx;
			}

			.img-IHg {
				width: 84rpx;
				height: 84rpx;
				background-color: #fff;
				box-shadow: 0px 8rpx 24rpx 0px rgba(220, 222, 229, 0.4);
				border-radius: 50%;
				display: flex;
				align-items: center;
				justify-content: center;
				position: fixed;
				top: 1030rpx;
				right: 30rpx;
				z-index: 99;

			}
		}
	}

	.home-attach {
		background-color: #f9f9f9;
		padding: 40rpx 30rpx 5rpx;
	}

	.home-hotel {
		height: 124rpx;
		background-color: #f9f9f9;
	}

	.home-hotel-img {
		background-color: #F9f9f9;
		padding: 20rpx 30rpx;

		.home-hotel-img-content {
			display: flex;
			align-items: flex-start;
			justify-content: space-between;
			flex-wrap: wrap;

			.home-hotel-img-content-item {
				width: 332rpx;
				background: #FFFFFF;
				box-shadow: 0px 4rpx 8rpx 0px rgba(0, 0, 0, 0.04);
				border-radius: 12rpx;
				margin-bottom: 26rpx;
				// &:nth-child(2n+1){
				// 	// position: relative;
				// 	top: -33px;
				// }
				// &:nth-child(1){
				// 	// position: relative;
				// 	top: 0;
				// }

				.home-hotel-img-content-item-img {
					width: 332rpx;
					height: 332rpx;
					object-fit: cover;
					object-position: center;
				}

				.home-hotel-img-content-item-img-long {
					width: 332rpx;
					height: 400rpx;
					object-fit: cover;
					object-position: center;
				}

				.text {
					display: flex;
					flex-direction: column;
					align-items: flex-start;
					justify-content: center;
					padding: 18rpx 22rpx 32rpx;

					.text-top {
						font-size: 28rpx;
						font-weight: bold;
						color: #333;
					}

					.text-main {
						margin-top: 20rpx;
						font-size: 24rpx;
						color: #999999;
					}
				}
			}
		}


		.home-hotel-img-more {
			height: 70rpx;
			background-color: #fff;
			border-radius: 10rpx;
			border: 2rpx solid #ddd;
			font-size: 28rpx;
			color: #5A5A5A;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}

	.home-brand {
		height: 124rpx;
		background-color: #f9f9f9;
	}

	.home-brand-img {
		padding: 0 30rpx;
		background-color: #f9f9f9;
		::v-deep .uni-swiper__dots-item {
			width: 22rpx !important;
			height: 2rpx !important;
		}
		::v-deep .uni-swiper__dots-bar {
			width: 22rpx !important;
			height: 2rpx !important;
		}
		.swiper-box {
			background-color: #f9f9f9;
			height: 200rpx;

			::v-deep swiper-item {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: space-between;

				view {
					width: 164rpx;
					height: 162rpx;
					background: #FFFFFF;
					box-shadow: 0px 4rpx 8rpx 0rpx rgba(220, 222, 229, 0.4);
					border-radius: 32rpx;
					display: flex;
					align-items: center;
					justify-content: center;

					image {
						border-radius: 32rpx;
					}
				}

			}
		}
	}






	.home-bottom {
		height: 60rpx;
		background-color: #f9f9f9;
	}
</style>
