<template>
	<view class="container home clearfix">
		<!-- top -->
		<view class="container-top"><image src="http://static-b.caimei365.com/app/meibohui/meibo@_05.jpg" mode=""></image></view>
		<view class="container-activ" @click="LookMyCouponDetils"><image src="http://static-b.caimei365.com/app/meibohui/meibo@_03.jpg" mode=""></image></view>
		<!-- VIP品牌线上馆 -->
		<view class="container-page clearfix">
			<view class="tui-group-name">
				<view class="tui-group-title">
					<view class="tui-group-l">VIP品牌线上馆</view>
				</view>
				<view class="tui-sub__desc">VIP品牌线上馆描述词</view>
			</view>
			<view class="tui-group-list">
				<view class="floor-item-vip" v-for="(vips,index) in supplierList1" :key="index" @click="goSupplier(supps.id)">
					<image :src="vips.image" class="floor-item-image" mode=""></image>
				</view>
			</view>
		</view>
		<!-- 参展商 -->
		<view class="container-page clearfix">
			<view class="tui-group-name">
				<view class="tui-group-title">
					<view class="tui-group-l">参展商</view>
					<view class="tui-group-r" @click="NavToDetailPage('/h5/pages/activity/meobohui-supplier')">
						<text>更多</text>
						<text class="iconfont icon-xiayibu"></text>
					</view>
				</view>
				<view class="tui-sub__desc">参展商描述词</view>
			</view>
			<view class="tui-group-list">
				<view class="floor-item-sup" v-for="(supps,index) in supplierList2" :key="index" @click="goSupplier(supps.id)">
					<image :src="supps.image" class="floor-item-image" mode=""></image>
				</view>
			</view>
		</view>
		<!-- 现场直击 -->
		<view class="container-page clearfix">
			<view class="tui-group-name">
				<view class="tui-group-title">
					<view class="tui-group-l">现场直击</view>
				</view>
				<view class="tui-sub__desc">现场直击描述词</view>
			</view>
			<view class="tui-group-scroll clearfix">
				<scroll-view scroll-x>
					<view class="floor-item__list">
						<view class="floor-item__live" v-for="(lives,index) in liveList" :key="index" @click="LiveGoPathPros(lives)">
							<view class="floor-item__image">
								<image :src="lives.image" mode=""></image>
							</view>
							<view class="floor-item__text">{{lives.liveTitle}}</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</view>
		<!-- 展位图 -->
		<view class="container-page clearfix">
			<view class="tui-group-name">
				<view class="tui-group-title">
					<view class="tui-group-l">展位图</view>
					<view class="tui-group-r" @click="NavToDetailPage('/h5/pages/activity/meobohui-booth')">
						<text>更多</text>
						<text class="iconfont icon-xiayibu"></text>
					</view>
				</view>
				<view class="tui-sub__desc">展位图描述词</view>
			</view>
			<view class="tui-group-list">
				<view class="floor-item-booth" v-for="(booths,index) in boothList" :key="index" @click="previewImg(index)">
					<view class="floor-item-booth-image">
						<image :src="booths.image" class="floor-item-image" mode=""></image>
					</view>
					<view class="floor-item-text">
						<view class="floor-item-p one">{{booths.name}}</view>
						<view class="floor-item-p two">展位号：{{booths.num}}</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 供应商商品楼层 -->
		<view class="container-page clearfix" v-for="(floors,index) in flootData" :key="index">
			<view class="tui-group-name">
				<view class="tui-group-title">
					<view class="tui-group-l">{{floors.shopName}}</view>
					<view class="tui-group-r" @click="goSupplier(floors.shopId)">
						<text>更多</text>
						<text class="iconfont icon-xiayibu"></text>
					</view>
				</view>
				<view class="tui-sub__desc">{{ floors.marke }}</view>
			</view>
			<view class="tui-group-good__scroll clearfix">
				<scroll-view scroll-x>
					<view class="floor-good__list">
						<view class="floor-item ad_04 clearfix" v-for="(product, idx) in floors.productSet" :key="idx" @click.stop="RouterDetailPage(product.productID)">
							<image class="item-img tui-skeleton-fillet" :src="product.mainImage" mode="aspectFill"></image>
							<view class="floor-item-content">
								<view class="title tui-skeleton-rect">
									<text class="mclap-tag">美博会</text>
									<text class="mclap">{{product.name}}</text>
								</view>
								<view class="floor-item-price">
									<view class="floor-item-act">
										<template v-if="userIdentity === 3">
											<template v-if="product.actStatus===1">
												<view class="floor-tags" v-if="PromotionsFormat(product.promotions)">
													{{product.promotions.name}}
													<text v-if="hasLogin && product.price1TextFlag != 1 && product.shopID == shopId">:￥{{product.retailPrice | NumFormat}}</text>
												</view>
												<view class="floor-tags" v-else>{{product.promotions.name}}</view>	
											</template>
											<template v-if="product.actStatus ===0  &&  product.ladderPriceFlag===1">
												<view class="floor-tags">阶梯价格</view>	
											</template>
										</template>	
										<template v-else>
											<template v-if="product.actStatus===1">
												<view class="floor-tags" v-if="PromotionsFormat(product.promotions)">
													{{product.promotions.name}}
													<text v-if="hasLogin && product.price1TextFlag != 1">:￥{{product.retailPrice | NumFormat}}</text>
												</view>
												<view class="floor-tags" v-else>{{product.promotions.name}}</view>	
											</template>
											<template v-if="product.actStatus ===0  &&  product.ladderPriceFlag===1">
												<view class="floor-tags">阶梯价格</view>	
											</template>
										</template>
									</view>	
									<view v-if="hasLogin">
										<template v-if="product.productCategory == 1">
											<template v-if="userIdentity == 3">
												<template v-if="product.shopID == shopId">
													<view class="title-none" v-if="product.price1TextFlag === '1'">
														<text class="p big">￥未公开价格</text>
													</view>
													<view class="price tui-skeleton-rect" v-else :class="PromotionsFormat(product.promotions) ? 'none' : ''">
														<text class="p sm">￥</text>
														<text class="p big">{{ (PromotionsFormat(product.promotions) ? product.price1 : product.retailPrice ) | NumFormat}}</text>
													</view>
												</template>	
												<template v-else>
													<view class="no-price">
														<view class="p-stars">
															<text class="p-no">￥</text>
															<uni-grader :grade="Number(product.price1Grade)" :margin="14"></uni-grader>
														</view>
													</view>	
												</template>
											</template>
											<template v-else-if="userIdentity ===4">
												<view class="title-none" v-if="product.price1TextFlag === '1'">
													<text class="p big">￥未公开价格</text>
												</view>
												<view class="title-none"  v-if="product.price1TextFlag === '2'">
													<text class="p big">￥价格仅会员可见</text>
												</view>
												<view class="price tui-skeleton-rect" v-if="product.price1TextFlag === '0'" :class="PromotionsFormat(product.promotions) ? 'none' : ''">
													<text class="p sm">￥</text>
													<text class="p big">{{ (PromotionsFormat(product.promotions) ? product.price1 : product.retailPrice ) | NumFormat}}</text>
												</view>
											</template>
											<template v-else>
												<view class="title-none" v-if="product.price1TextFlag === '1'">
													<text class="p big">￥未公开价格</text>
												</view>
												<view class="price tui-skeleton-rect" v-else :class="PromotionsFormat(product.promotions) ? 'none' : ''">
													<text class="p sm">￥</text>
													<text class="p big">{{ (PromotionsFormat(product.promotions) ? product.price1 : product.retailPrice ) | NumFormat}}</text>
												</view>
											</template>
										</template>	
										<template v-else>
											<view class="price tui-skeleton-rect">
												<text class="p sm">￥</text>
												<text class="p big">{{ product.retailPrice | NumFormat }}</text>
											</view>
										</template>
									</view>
									<view v-else class="no-price">
										<template>
											<view class="p-stars">
												<text class="p-no">￥</text>
												<uni-grader :grade="Number(product.price1Grade)" :margin="14"></uni-grader>
											</view>
										</template>
									</view>	
								</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</view>
		<!-- 侧边 -->
		<scroll-top :isScrollTop="isScrollTop" :bottom="50"></scroll-top>
		<!-- 透明模态层 -->
		<modal-layer v-if='isModallayer'></modal-layer>
	</view>
</template>

<script>
	import authorize from '@/common/config/authorize.js'
	import uniGrader from '@/components/uni-grade/uni-grade.vue'
	import modalLayer from "@/components/modal-layer"
	import { userInfoLogin } from "@/api/use.js"
	import { mapState,mapMutations} from 'vuex';
	var isPreviewImg;
	export default {
		components:{
			uniGrader,
			modalLayer
		},
		data() {
			return {
				userID:0,
				current:0,
				mode:'round',
				isModallayer:false,
				isLogin:false,
				skeletonShow: true,
				userIdentity:'',
				supplierList1:[
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_sup@_01.png',id:23456},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_sup@_02.png',id:23456},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_sup@_03.png',id:23456},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_sup@_03.png',id:23456}
				],
				supplierList2:[
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_logo@_01.png',id:23456},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_logo@_01.png',id:23456},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_logo@_01.png',id:23456},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_logo@_01.png',id:23456},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_logo@_01.png',id:23456},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_logo@_01.png',id:23456},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_logo@_01.png',id:23456},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_logo@_01.png',id:23456}
				],
				liveList:[
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_live@_01.png',liveTitle:'不同阶段的痘重磅上由...',optionTitle:'直播详情'},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_live@_02.png',liveTitle:'不同阶段的痘重磅上由...',optionTitle:'直播详情'},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_live@_01.png',liveTitle:'不同阶段的痘重磅上由...',optionTitle:'直播详情'},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_live@_02.png',liveTitle:'不同阶段的痘重磅上由...',optionTitle:'直播详情'}
				],
				boothList:[
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_img@_01.png',name:'采美信息技术有限公司',num:'21F'},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_img@_02.png',name:'采美信息技术有限公司',num:'21F'},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_img@_03.png',name:'采美信息技术有限公司',num:'21F'},
					{image:'http://static-b.caimei365.com/app/meibohui/meibo_img@_04.png',name:'采美信息技术有限公司',num:'21F'}
				],
				SuppierNoteList:[
					{shopId:1161,marke:'我的描述文件'}
				],
				flootData:[],//楼层
				isScrollTop:false,
				isRequest:false,
				isNavRequest:false,
				isLiveRequest:false,
				productImage:[],
			}
		},
		onLoad() {
			this.modallayer = false
			this.$api.getComStorage('userInfo').then((resolve) =>{
				this.clubStatus = resolve.clubStatus
				this.userID = resolve.userID ? resolve.userID : 0;
				this.shopId = resolve.shopID ? resolve.shopID : 0;
				this.userIdentity = resolve.userIdentity
				this.GetActitityInit()
			}).catch(error =>{
				this.GetActitityInit()
			})
		},
		filters: {
			NumFormat:function(text) {//处理金额
				return Number(text).toFixed(2);
			}
		},
		computed: {
			...mapState(['hasLogin','userInfo','identity','isActivity'])
		},
		methods: {
			...mapMutations(['login','logout']),
			LookMyCouponDetils(){//点击优惠券 跳转处理
				if(this.login){
					if(this.userIdentity == 2 || this.userIdentity == 4){
						this.$api.navigateTo('/pages/user/coupon/coupon')
					}else if(this.userIdentity == 3){
						this.$api.navigateTo('/supplier/pages/index/index')
					}else{
						return;
					}
				}else{
					this.$api.navigateTo('/pages/login/login')
				}
			},
			GetActitityInit(){
				this.ActivityService.GetRepeatActivityFloorData({userId:this.userID}).then(response =>{
					this.flootData = this.ReturnNewFlootData(response.data,this.SuppierNoteList)
					console.log(this.flootData);
					//处理商品图片列表
					this.productImage =[]
					this.boothList.forEach(item =>{
						this.productImage.push(item.image);
					})
				}).catch(error =>{
					this.$util.msg(error.msg,2000)
				})
			},
			ReturnNewFlootData(listA,listB){
				let NewArray = []
				listA.map(item=>{
					for (let i = 0; i < listB.length; i++) {
						if( item.shopId == listB[i].shopId ){
							NewArray.push(Object.assign(item,listB[i])) 
						}
					}
				});
				return NewArray
			},
			NavToDetailPage(path){
				this.$api.navigateTo(path)
			},
			RouterDetailPage(id) {
				this.isModallayer = true;
				this.$api.navigateTo(`/pages/goods/product?id=${id}`);
				this.isModallayer = false;
			},
			goSupplier(value){//跳供应商资料页
				this.$api.navigateTo('/supplier/pages/user/my-shop?shopId='+value)
			},
			LiveGoPathPros(live){
				this.$api.navigateTo(`/h5/pages/article/page-image?title=${live.optionTitle}&image=${live.image}`)
			},
			PromotionsFormat(promo){//促销活动类型数据处理
				if(promo!=null){
					if(promo.type == 1 && promo.mode == 1){
						return true
					}else{
						return false
					}
				}
				return false
			},
			previewImg (index) {//顶部商品图片预览
				// isPreviewImg = true
				let previewUrls = this.productImage
				uni.previewImage({
					current: index, 	//图片索引
					urls: previewUrls, //必须是http图片，本地图片无效
					longPressActions:''
				})
			},
		},
		onPageScroll(e){//实时获取到滚动的值
			if(e.scrollTop>400){
				this.isScrollTop = true
			}else{
				this.isScrollTop = false
			}	
		},
		onPullDownRefresh() {//下拉刷新
			this.GetActitityInit()
			uni.stopPullDownRefresh()
		},
		onShareAppMessage(res){//分享转发
			if (res.from === 'button') {
		      // 来自页面内转发按钮
		    }
			return {
			  title: '生美医美正品采购服务平台',
			  path: '/h5/pages/activity/meobohui',
			  imageUrl:'https://static.caimei365.com/app/img/bg/min-banner.jpg'
			}
		},
		onShow(){
		
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #F7F7F7;
	}
	.container-top{
		width: 100%;
		height: 500rpx;
		float: left;
		image{
			width: 100%;
			height: 100%;
			display: block;
		}
	}
	.container-activ{
		width: 100%;
		height: 240rpx;
		box-sizing: border-box;
		padding: 0 24rpx;
		margin: 24rpx 0;
		float: left;
		image{
			width: 100%;
			height: 240rpx;
			display: block;
		}
	}
	.container-page{
		background-color: #F7F7F7;
		width: 100%;
		height: auto;
		box-sizing: border-box;
		padding: 0 24rpx;
		float: left;
	}
	.tui-group-name {
		width: 100%;
		height: 92rpx;
		padding: 20rpx 0;
	}
	.tui-group-title{
		width: 100%;
		float: left;
		.tui-group-l{
			float: left;
			font-size: 34rpx;
			font-weight: bold;
			text-align: left;
			line-height: 49rpx;
			color: #333;
		}
		.tui-group-r{
			float: right;
			font-size: $font-size-26;
			text-align: right;
			line-height: 49rpx;
			color: #999999;
			.icon-xiayibu{
				font-size: $font-size-30;
				color: #999999;
			}
		}
	}
	.tui-sub__desc {
		width: 100%;
		float: left;
		color: rgba(153,153,153,0.9);
		font-size: $font-size-26;
	}
	.tui-group-list{
		width: 100%;
		height: auto;
		.floor-item-vip{
			width: 339rpx;
			height: 240rpx;
			float: left;
			margin-right: 24rpx;
			margin-bottom: 24rpx;
			&:nth-child(2n){
				margin-right: 0;
			}
			.floor-item-image{
				width: 100%;
				height: 100%;
				display: block;
			}
		}
		.floor-item-sup{
			width: 162rpx;
			height: 162rpx;
			float: left;
			margin-right: 18rpx;
			margin-bottom: 24rpx;
			&:nth-child(4n){
				margin-right: 0;
			}
			.floor-item-image{
				width: 100%;
				height: 100%;
				display: block;
			}
		}
		.floor-item-booth{
			width: 339rpx;
			height: 382rpx;
			float: left;
			margin-right: 24rpx;
			margin-bottom: 24rpx;
			background-color: #FFFFFF;
			border-radius: 16rpx;
			&:nth-child(2n){
				margin-right: 0;
			}
			.floor-item-booth-image{
				width: 100%;
				height: 240rpx;
				.floor-item-image{
					width: 100%;
					height: 100%;
					display: block;
				}
			}
			.floor-item-text{
				width: 100%;
				height: 142rpx;
				box-sizing: border-box;
				padding: 31rpx 16rpx;
				.floor-item-p{
					width: 100%;
					line-height: 40rpx;
					text-align: left;
					font-size: $font-size-24;
					white-space: nowrap;
					text-overflow: ellipsis;
					overflow: hidden;
					&.one{
						color: #333333;
					}
					&.two{
						color: #999999;
					}
				}
			}
		}
		
	}
	.tui-group-scroll{
		width: 100%;
		height:392rpx;
		float: left;
		background-color: #F7F7F7;
		box-sizing: border-box;
		background-color: #F7F7F7;
		overflow: hidden;
		display: flex;
		align-items: center;
		.floor-item__list {
			display: flex;
			align-items: center;
		}
		.floor-item__live {
			background-color: #fff;
			width: 310rpx;
			height: 392rpx;
			border-radius: 16rpx;
			box-sizing: border-box;
			margin-right: 16rpx;
			.floor-item__image{
				width: 310rpx;
				height: 310rpx;
				float: left;
				image{
					width: 100%;
					height: 100%;
					display: block;
				}
			}
			.floor-item__text{
				width: 100%;
				height: 82rpx;
				line-height: 82rpx;
				box-sizing: border-box;
				padding: 0 24rpx;
				text-align: center;
				font-size: $font-size-24;
				color: #333333;
				white-space: nowrap;
				text-overflow: ellipsis;
				overflow: hidden;
			}
		}
	}
	.tui-group-good__scroll{
		.floor-good__list{
			display: flex;
			align-items: center;
		}
		.floor-item{
			width: 310rpx;
			height: 516rpx;
			margin-right: 20rpx;
			font-size: $font-size-24;
			color: $text-color;
			background: #FFFFFF;
			line-height: 36rpx;
			border-radius: 16rpx;
			margin-bottom: 20rpx;
			float: left;
			box-sizing: border-box;
			position: relative;
			.item-img{
				width: 310rpx;
				height: 310rpx;
				border-radius: 16rpx 16rpx 0 0;
				display: block;
				margin-bottom: 8rpx;
			}
			.floor-item_tag{
				width: 100%;
				height: 32rpx;
				float: left;
				margin: 20rpx 0;
				padding: 0 20rpx;
				box-sizing: border-box;
				text{
					display: inline-block;
					padding: 0 8rpx;
					border: 1px solid #e3ebf7;
					border-radius: 8rpx ;
					color: #9aa5b5;
					font-size: $font-size-22;
					line-height: 32rpx;
					text-align: center;
					float: left;
				}
			}
			.floor-item-content{
				width: 100%;
				padding: 0 20rpx;
				box-sizing: border-box;
			}
			.floor-item-act{
				display: block;
				width: 100%;
				height: 32rpx;
				text-align: center;
				box-sizing: border-box;
			}
			.floor-tags{
				height: 28rpx;
				border-radius: 6rpx;
				background-color: #FFFFFF;
				line-height: 28rpx;
				color: $color-system;
				text-align: center;
				display: inline-block;
				padding:0 16rpx;
				font-size: $font-size-20;
				border: 1px solid #E15616;
				float: left;
			}
			.title-none{
				font-size: $font-size-26;
				color: #FF2A2A;
				line-height: 54rpx;
			}
			.title{
				width: 100%;
				height: 70rpx;
				display: flex;
				line-height: 35rpx;
				flex-direction: column;
				margin: 20rpx 0 10rpx 0;
				padding: 0;
				position: relative;
				.mclap{
					width: 100%;
					line-height:35rpx;
					text-overflow:ellipsis;
					display: -webkit-box;
					word-break: break-all;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					overflow: hidden;
					font-size: 26rpx;
					text-indent: 95rpx;
				}
				.mclap-tag{
					display: block;
					width: 84rpx;
					height: 32rpx;
					background-image: linear-gradient(270deg, #f9c023 0%, #f83600 100%);
					border-radius: 4rpx 48rpx 4px 4px;
					line-height: 32rpx;
					font-size: $font-size-22;
					color: #FFFFFF;
					text-align: center;
					position: absolute;
					left: 0;
					top: 0;
				}
			}
			.no-price{
				height: 54rpx;
				line-height: 54rpx;
				display: flex;
				box-sizing: border-box;
				.p-no{
					font-size: $font-size-28;
					color: $text-color;
					display: block;
					float: left;
				}
				.p-stars{
					float: left;
				}
			}
			.price{
				color: #FF2A2A;
				line-height:54rpx;
				&.none{
					text-decoration: line-through;
					color: #999999;
				}
				.sm{
					font-size: $font-size-24;
				}
				.big{
					font-size: $font-size-28;
				}
			}
		}
	}
	.container-section{
		width: 100%;
		height: auto;
		background-color: #F7F7F7;
	}
</style>
