<template>
	<view
	class="product-list"
	>
		<view 
		class="product-item" 
		:style="{width:itemWidth+'px',marginTop:gap+'px'}"
		v-for="(item,index) in list"
	    :key="item.id" 
		 @click="toDetail(item)">
			<view>
				<image mode="aspectFit" :src="item.productImage ? item.productImage.replace('http:','https:')+'?x-oss-process=image/resize,p_30':'/static/def_imgs.png'" style="height: 140px;width: 100%;"></image>
				<view class="back-price xiajia" v-if="item.status==0||!item.status">下架</view>
				<view class="back-price xiajia" v-else-if="item.dealerScopeFlag==0">售罄</view>
				<view class="product-code"><text :max-lines="1" overflow="ellipsis">{{item.productCode}}</text></view>
			</view>
			<view>
				<view class="product-name"><text :max-lines="2" overflow="ellipsis">{{item.productName}}</text></view>
				<view class="product-guige"><text :max-lines="2" overflow="ellipsis">{{item.productOrigCode}}</text></view>
				<view class="product-button">
					<view class="price-txt">
						￥<text>{{item.priceStr[0]}}</text>.{{item.priceStr[1]}}
					</view>
					<view class="flex align_center rebate-tag" v-if="item.promoType=='BUY_PROD_GIVE_VALID'">
						返<text>{{item.resultValue}}</text>元
					</view>
					<view class="flex align_center rebate-tag" v-if="item.promoType=='BUY_PROD_GIVE_PROD'">
						买{{item.conditionValue}}赠{{item.resultValue}}
					</view>
					<view class="flex align_center tejia-tag" v-if="item.promoType=='PROMO_PROD'">
						特价<text>￥{{item.orginPrice}}</text>
					</view>
					<view class="flex align_center tejia-tag" v-if="item.shopProductSubsidy&&item.shopProductSubsidy.subsidyAmount<item.price&&!item.shopPromoProduct&&showBalanceAuth">
						可抵扣<text>￥{{item.shopProductSubsidy.subsidyAmount}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'productItemSkline',
		props: {
			list: {
				type: Array,
				default: () => []
			},
			index:{
				type: [Number,String],
				default: 0
			},
			gap:{
				type: [Number,String],
				default: 10
			},
			itemWidth:{
				type: [Number,String],
				default: 0
			}
		},
		data() {
			return {
				
			}
		},
		computed:{
			// 抵扣余额支付是否可用
			showBalanceAuth(){
				return this.$store.state.vuex_showBalanceAuth
			},
		},
		methods: {
			toDetail(item){
				this.$emit('detail',item)
			}
		},
	}
</script>

<style lang="less">
.product-list{
	display:flex;
	flex-wrap: wrap;
	justify-content: space-between;
	padding: 0 2%;
}
.product-item{
	background: #ffffff;
	border-radius: 10upx;
	box-shadow: 1px 1px 3px #EEEEEE;
	width: 48%;
	margin: 10px 0 0 0;
	display: flex;
	flex-direction: column;
	.price-txt{
		color: red;
		display: flex;
		align-items: baseline;
		font-size: 12px;
		text{
			font-size: 36rpx;
		}
	}
	.back-price{
		zoom: calc(0.8);
		padding: 6rpx 65rpx;
		position: absolute;
		top: 18rpx;
		right: -45rpx;
		z-index: 2;
		font-size: 20rpx;
		text-align: center;
		transform: rotate(40deg);
		display: flex;
		align-items: center;
		text{
			font-size: 28rpx;
			margin: 0 5rpx;
		}
	}
	.xiajia{
		background: #ececec;
		color: #5f5f5f;
	}
	.fantext{
		background: rgba(255 ,87 ,34 , 1);
		color: #fff;
		font-size: 8px;
	}
	> view{
		&:first-child{
			position: relative;
			overflow: hidden;
			.product-code{
				color: #666;
				position: absolute;
				width: 100%;
				left:0;
				bottom:0;
				background: rgba(255,255,255,0.7);
				text-align: center;
			}
		}
		&:last-child{
			position: relative;
			flex-grow: 1;
			padding: 10px 10px 35px;
			.product-name{
				font-size: 28rpx;
				color: #333;
			}
			.product-guige{
				margin: 10rpx 0;
				color: #2196F3;
			}
		}
		.product-button{
			position: absolute;
			left: 5%;
			bottom: 0;
			width: 90%;
			padding: 5px 0 10px;
			display: flex;
			align-items: center;
			.rebate-tag{
				background: #ffe7df;
				color: #E91E63;
				padding: 2px 5px;
				font-size: 10px;
				border-radius: 3px;
				margin-left: 6px;
			}
			.tejia-tag{
				color: #E91E63;
				margin-left: 6px;
				font-size: 12px;
				text{
					font-size: 12px;
					color: #999;
					margin-left: 5px;
					text-decoration: line-through;
				}
			}
		}
	}
	}
</style>
