<template name="floors">
	<view>
		<view class="floors-content clearfix">
			<view class="tui-block__box tui-mtop__20" v-for="(floor,index) in list" :key="index">
				<view class="tui-group-name" >
					<view>
						<text class="tui-sub__desc tui-color__pink">{{ floor.topic }}</text>
					</view>
					<view class="tui-more__box" @click="handleFloor(floor)">
						<text>更多</text>
						<text class="iconfont icon-xiangyou"></text>
					</view>
				</view>
				<scroll-view scroll-x>
					<view class="tui-goods__list">
						<view class="tui-goods__item" @click="productDetail(pros.productId)" v-for="pros in floor.products">
							<view class="tui-goods__imgbox">
								<image :src="pros.mainImage" mode="" class="tui-goods__img"></image>
							</view>
							<view class="tui-goods__namebox">
								<text>{{ pros.name }}</text>
							</view>
							<view class="tui-pri__box">
								<view class="tui-sale-pri" v-if="hasLogin">
									￥{{ pros.price | NumFormat }}
								</view>
								<view v-else class="tui-no-price">
									<view class="p-stars">
										<!-- <text class="p-no">￥</text> -->
										<uni-grader
											:grade="pros.priceGrade"
											:margin="14"
										></uni-grader>
									</view>
								</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapState, mapMutations } from 'vuex'
	import uniGrader from '@/components/uni-grade/uni-grade.vue'
	export default{
		name:'floors',
		components: {
			uniGrader
		},
		props:{
			list:{
				type:Array
			}
		},
		filters: {
			NumFormat: function(text) {
				//处理金额
				return Number(text).toFixed(2)
			}
		},
		data() {
			return{
			}
		},
		created(){
		},
		computed: {
			...mapState(['hasLogin'])
		},
		methods:{
			handleFloor(floor){
				this.$api.navigateTo(`/pages/goods/good-floor?id=${floor.id}`)
			},
			productDetail(productId) {
				// 跳转商品详情
				this.$api.navigateTo(`/pages/goods/product?id=${productId}`)
			},
		}
	}
</script>

<style lang="scss">
	.floors-content{
		width: 100%;
		height: auto;
		box-sizing: border-box;
		background: #FFFFFF;
		.tui-block__box {
			width: 100%;
			padding: 0 25rpx 25rpx;
			box-sizing: border-box;
			background-color: #ffffff;
			border-radius: 20rpx;
			overflow: hidden;
		}
		.tui-mtop__20 {
			margin-top: 20rpx;
		}
		.tui-group-name {
			width: 100%;
			line-height: 50rpx;
			font-weight: bold;
			text-align: center;
			padding: 24rpx 0 0 0;
			display: flex;
			align-items: center;
			justify-content: space-between;
			color: #333;
		}
		.tui-sub__desc {
			color: #333;
			font-size: 36rpx;
			font-weight: 400;
		}
		.tui-more__box {
			display: flex;
			align-items: center;
			font-weight: 400;
			color: #999;
			line-height: 50rpx;
			.iconfont{
				font-size: 28rpx;
				margin-left: 10rpx;
			}
		}
		.tui-more__box text{
		  font-size: 24rpx;
		}
		.tui-goods__list {
			display: flex;
			align-items: center;
		}
		.tui-goods__item {
			background-color: #fff;
			width: 210rpx;
			height: 390rpx;
			border-radius: 6rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			flex-shrink: 0;
			margin-right: 18rpx;
		}
		.tui-goods__imgbox {
			width: 210rpx;
			height: 210rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			box-sizing: border-box;
			border-radius: 8rpx;
		}
		
		.tui-goods__img {
			width: 210rpx;
			height: 210rpx;
			display: block;
			border-radius: 8rpx;
		}
		
		.tui-goods__namebox{
			width: 210rpx;
			height: 80rpx;
			margin-top: 16rpx;
			line-height: 40rpx;
			text-overflow: ellipsis;
			display: -webkit-box;
			word-break: break-all;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 2;
			overflow: hidden;
			font-size: 26rpx;
			color: #333333;
		}
		
		.tui-pri__box {
			width: 210rpx;
			display: flex;
			justify-content: center;
			align-items: center;
		}
		
		.tui-sale-pri {
			width: 210rpx;
			display: flex;
			align-items: flex-end;
			padding: 10rpx 0 8rpx;
			box-sizing: border-box;
			font-size: 28rpx;
			line-height: 40rpx;
			color: #EE2727;
			white-space: nowrap;
			text-overflow: ellipsis;
			overflow: hidden;
			text-align: left;
		}
		.tui-no-price {
			width: 210rpx;
			height: 40rpx;
			line-height: 40rpx;
			display: flex;
			box-sizing: border-box;
			.p-no {
				line-height: 40rpx;
				font-size: $font-size-28;
				color: $text-color;
				display: inline-block;
				float: left;
			}
			.p-stars {
				float: left;
			}
		}
		.tui-size-sm {
			font-size: 24rpx;
			line-height: 24rpx;
			transform: scale(0.8);
			transform-origin: 0 50%;
		}
		
		.tui-original__pri {
			font-size: 24rpx;
			line-height: 24rpx;
			color: #999999;
			transform-origin: center 10%;
			transform: scale(0.8);
			display: flex;
			align-items: center;
			justify-content: center;
			text-decoration: line-through;
		}
		
	}
</style>
