<template>
	<view>
		<swiper class="head" :current="banner_current" >
			<swiper-item @click="clickBanner">
				<image src="https://picsum.photos/375/360" class="swipe-img"></image>
			</swiper-item>
			<swiper-item @click="clickBanner">
				<image src="https://picsum.photos/375/360" class="swipe-img"></image>
			</swiper-item>
		</swiper>
		<view class="content">
			<!-- 消息模块 -->
			<view class="lf-row-between lf-m-b-34 message-box">
				<view class="lf-flex">
					<text class="lf-iconfont lf-icon-tongzhi lf-text-vertical"></text>
					<view class="lf-m-l-12 lf-line-1" style="max-width: 510rpx;">国庆优惠大促，快来看看吧！</view>
				</view>
				<view class="message-btn" hover-class="lf-opacity" @click="$url('/pages/notice/article')">详情</view>
			</view>
			<!-- 频道 -->
			<view class="lf-row-between lf-m-b-10">
				<view class="lf-font-36 lf-font-bold lf-color-333">添加频道</view>
				<view class="lf-flex lf-color-555" @click="$url('/pages/channel/index')">
					<view class="lf-m-r-10">编辑</view>
					<view class="lf-iconfont lf-icon-xiangyou lf-text-vertical"></view>
				</view>
			</view>
			<view class="lf-flex-wrap">
				<view class="channel-item" v-for="(item, index) in 7" @click="$url('/pages/goodsList/index')">
					<image src="../../static/logo.png" class="channel-mask" mode="aspectFill"></image>
					<view class="lf-row-center channe-text lf-font-bold">冲浪</view>
					<!-- <view>
						<u-icon name="lock-fill lf-text-vertical"></u-icon>
					</view> -->
				</view>
			</view>
			<!-- 中间广告模块 -->
			<swiper class="lf-m-t-40 ad" :current="banner_current" >
				<swiper-item @click="clickAD">
					<image src="https://picsum.photos/375/230" class="lf-w-100 lf-h-100"></image>
				</swiper-item>
			</swiper>
			<!-- 人气爆款 -->
			<view class="lf-row-between lf-m-t-40">
				<view class="lf-font-36 lf-font-bold lf-color-333">人气爆款</view>
				<view class="lf-flex lf-color-555" @click="$url('/pages/activityList/index')">
					<view class="lf-m-r-10">更多</view>
					<view class="lf-iconfont lf-icon-xiangyou lf-text-vertical"></view>
				</view>
			</view>
			<view class="recomm lf-m-t-20 lf-m-b-30">
				<view class="lf-row-between">
					<view class="max-recomm-img" @click="$url('/pages/activityList/index')">
						<image src="../../static/logo.png" class="lf-w-100 lf-h-100"></image>
						<view class="recomm-title">
							<view class="lf-line-2 lf-m-b-10">土耳其双人游飞机往返酒店五星级各大热门景点豪华双人游纯江湖救急</view>
							<lf-price price="3999.00"></lf-price>
							<!-- <view class="lf-font-42 lf-font-bold lf-m-t-10" style="color: #FF0000;">￥3999.00</view> -->
						</view>
					</view>
					<view>
						<view class="recomm-img" @click="$url('/pages/activityList/index')">
							<image src="../../static/logo.png" class="lf-w-100 lf-h-100"></image>
						</view>
						<view class="recomm-img lf-m-t-10" @click="$url('/pages/activityList/index')">
							<image src="../../static/logo.png" class="lf-w-100 lf-h-100"></image>
						</view>
					</view>
				</view>
				<view class="lf-row-between lf-m-t-10">
					<view class="recomm-img" @click="$url('/pages/activityList/index')">
						<image src="../../static/logo.png" class="lf-w-100 lf-h-100"></image>
					</view>
					<view class="recomm-img" @click="$url('/pages/activityList/index')">
						<image src="../../static/logo.png" class="lf-w-100 lf-h-100"></image>
					</view>
					<view class="recomm-img" @click="$url('/pages/activityList/index')">
						<image src="../../static/logo.png" class="lf-w-100 lf-h-100"></image>
					</view>
				</view>
			</view>
			<!-- tab标签 -->
			<!-- <view class="lf-m-t-40">
				<u-tabs :list="tab_list" :is-scroll="true" :current="current" @change="tabChange"></u-tabs>
			</view> -->
			<!-- 推荐 -->
			<!-- <view class="lf-row-between lf-m-t-40 lf-m-b-10">
				<view class="lf-font-36 lf-font-bold lf-color-333">推荐</view>
				<view class="lf-flex lf-color-555">
					<view class="lf-m-r-10">更多</view>
					<u-icon name="lock-fill lf-text-vertical"></u-icon>
				</view>
			</view> -->
		</view>
		<!-- 猜你喜欢 -->
		<lf-title-line></lf-title-line>
		<!-- 商品列表-瀑布流 -->
		<view style="padding: 0 20rpx;">
			<lf-waterfall :list="recomm_list"></lf-waterfall>
			<!-- <u-loadmore v-if="recomm_list.length" status="已加载全部数据~" @loadmore="addRandomData"></u-loadmore> -->
			<view class="loading-more">
				<text :class="{'loading-more-text': loading_class}" v-if="recomm_list.length">{{ loading_text }}</text>
				<lf-nocontent v-else></lf-nocontent>
			</view>
		</view>
		<!-- 回到顶部 -->
		<u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top>
	</view>
</template>

<script>
	import lfWaterfall from '@/components/lf-waterfall/lf-waterfall.vue';
	import lfTitleLine from '@/components/lf-title-line/lf-title-line.vue';
	
	export default {
		components: {
			lfWaterfall,
			lfTitleLine
		},
		data() {
			return {
				banner_current: 0,
				recomm_list: [],
				current: 0,
				loading_class: false,
				loading_text: '已加载全部数据~',
				list: [
				 {
				  price: 35,
				  title: '北国风光，千里冰封，万里雪飘',
				  shop: '李白杜甫白居易旗舰店',
				  image: 'http://pic.sc.chinaz.com/Files/pic/pic9/202002/zzpic23327_s.jpg',
				 },
				 {
				  price: 75,
				  title: '望长城内外，惟余莽莽',
				  shop: '李白杜甫白居易旗舰店',
				  image: 'http://pic.sc.chinaz.com/Files/pic/pic9/202002/zzpic23325_s.jpg',
				 },
				 {
				  price: 385,
				  title: '大河上下，顿失滔滔',
				  shop: '李白杜甫白居易旗舰店',
				  image: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg',
				 },
				 {
				  price: 784,
				  title: '欲与天公试比高',
				  shop: '李白杜甫白居易旗舰店',
				  image: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/zzpic23369_s.jpg',
				 },
				 {
				  price: 7891,
				  title: '须晴日，看红装素裹，分外妖娆',
				  shop: '李白杜甫白居易旗舰店',
				  image: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2130_s.jpg',
				 },
				 {
				  price: 2341,
				  shop: '李白杜甫白居易旗舰店',
				  title: '江山如此多娇，引无数英雄竞折腰',
				  image: 'http://pic1.sc.chinaz.com/Files/pic/pic9/202002/zzpic23346_s.jpg',
				 }
				]
			}
		},
		onLoad() {
			this.addRandomData();
		},
		methods: {
			// 瀑布流随机模拟数据
			addRandomData() {
				for(let i = 0; i < 10; i++) {
					let index = this.$u.random(0, this.list.length - 1);
					// 先转成字符串再转成对象，避免数组对象引用导致数据混乱
					let item = JSON.parse(JSON.stringify(this.list[index]))
					item.id = this.$u.guid();
					this.recomm_list.push(item);
				}
			},
			// tabs标签切换时件，现已费弃
			tabChange(current){
				this.current = current;
			},
			// swiper页面被滑动切换
			pageChange(event){
				console.log(event)
				this.current = event.detail.current;
			},
			// banner图被点击
			clickBanner(){
				this.$msg('您点击了banner图')
			},
			// ad被点击
			clickAD(){
				this.$msg('您点击了ad广告')
			}
		},
		onReachBottom() {
			
		},
		onPullDownRefresh(){
			uni.stopPullDownRefresh();
		},
		onShareAppMessage(){
			let shareInfo = {
				title: '欢迎使用海南旅游小程序',
				path: '/pages/route/index?route=home'
			}
			return shareInfo;
		}
	}
</script>

<style>
	page{
		background-color: #F6F6F6;
	}
</style>
<style lang="scss" scoped>
	.head{
		width: 750rpx;
		height: 360rpx;
		.swipe-img{
			width: 100%;
			height: 100%;
		}
	}
	.content{
		width: 750rpx;
		// height: 600rpx;
		height: max-content;
		border-radius: 30rpx 30rpx 0rpx 0rpx;
		position: relative;
		top: -30rpx;
		background-color: #FFFFFF;
		box-sizing: border-box;
		padding: 40rpx 32rpx 10rpx;
		.message-box{
			width: 686rpx;
			height: 53rpx;
			background: #CFE7FD;
			border-radius: 27rpx;
			color: #1998FE;
			box-sizing: border-box;
			padding: 0 20rpx;
			font-size: 24rpx;
			.message-btn{
				width: 80rpx;
				height: 33rpx;
				border-radius: 10rpx;
				border: 1rpx solid #1998FE;
				text-align: center;
				line-height: 31rpx;
			}
		}
	}
	
	.channel-item{
		width: 160rpx;
		height: 160rpx;
		border-radius: 15rpx;
		margin-top: 15rpx;
		margin-right: 15rpx;
		position: relative;
		overflow: hidden;
		&:nth-child(4n){
			margin-right: 0;
		}
		image{
			width: 160rpx;
			height: 160rpx;
			position: absolute;
			z-index: 0;
		}
		// view{
		// 	position: absolute;
		// 	right: 0;
		// 	bottom: 0;
		// 	background-color: rgba(255,255,255,0.5);
		// 	width: 42rpx;
		// 	height: 42rpx;
		// 	color: #FFFFFF;
		// 	display: flex;
		// 	justify-content: center;
		// 	align-items: center;
		// 	border-radius: 10rpx 0rpx 15rpx 0rpx;
		// 	z-index: 2;
		// }
		.channel-mask::after{
			width: 100%;
			height: 100%;
			content: '';
			position: absolute;
			z-index: 1;
			background: rgba(0, 0, 0, 0.5);
			top: 0;
			left: 0;
		}
		.channe-text{
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;
			z-index: 2;
			color: #FFFFFF;
			font-size: 28rpx;
		}
	}
	
	.ad{
		height: 230rpx;
		width: 100%;
	}
	
	.recomm{
		width: 100%;
		height: max-content;
		.recomm-img{
			width: 222rpx;
			height: 222rpx;
			border-radius: 5rpx;
		}
		.max-recomm-img{
			width: 455rpx;
			height: 455rpx;
			position: relative;
			border-radius: 5rpx;
			overflow: hidden;
			.recomm-title{
				// height: 142rpx;
				height: max-content;
				width: 100%;
				background-color: rgba(0,0,0,0.65);
				box-sizing: border-box;
				padding: 15rpx;
				position: absolute;
				bottom: 0;
				color: #FFFFFF;
				border-radius: 0rpx 0rpx 20rpx 20rpx;
			}
		}
	}
	
</style>
