<template>
	<view class="choose-product-item" :style="{width:width + 'px'}">
		 <view>
			 <view class="choose-product-item-img">
				<u-image :src="item.productImage+'?x-oss-process=image/resize,p_50'" height="200rpx" width="100%"></u-image>
				<view class="back-price" v-if="item.promoRuleValue">返<text>{{item.promoRuleValue}}</text>元</view>
				<view class="choose-product-item-left-info-code ellipsis-one">{{item.productCode}}</view>
			 </view>
			 <view class="choose-product-item-info">
				<view class="choose-product-item-left-info-name ellipsis-two">{{item.productName}}</view>
				<view class="choose-product-item-left-info-guige ellipsis-two">{{item.productOrigCode}}</view>
				<view class="choose-product-item-left-info-price">
					<view class="price-txt">￥<text>{{item.cost}}</text></view>
					<view>
						<u-number-box v-model="item.qty" :index="item.id" :input-width="60" :input-height="60" size="mini" :min="1" @change="changeQty"></u-number-box>
					</view>
				</view>
			 </view>
		 </view>
	</view>
</template>

<script>
	export default {
		name: 'chooseProductItem',
		props: {
			item: {
				type: Object,
				default: () => {}
			},
			width: {
				type: Number,
				default: 730
			}
		},
		data() {
			return {
			}
		},
		methods: {
			changeQty(e) {
				this.$emit('changeQty', e)
			}
		}
	}
</script>

<style lang="less">
	.choose-product-item{
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 20rpx 0;
		border-bottom: 1px solid #eee;
		> view{
			 display: flex;
			 align-items: center;
			 justify-content: space-between;
			 flex-grow: 1;
			 width: 100%;
		}
		.choose-product-item-img{
			margin-right: 20rpx;
			width: 35%;
			position: relative;
			overflow: hidden;
			border: 1px solid #eee;
			padding: 10rpx;
			.back-price{
				zoom: calc(0.8);
			}
			.choose-product-item-left-info-code{
				color: #666;
				position: absolute;
				width: 100%;
				left:0;
				bottom:0;
				background: rgba(255,255,255,0.7);
				text-align: center;
			}
		}
		.choose-product-item-info{
			margin-right: 10rpx;
			width: 65%;
			flex-grow: 1;
			.choose-product-item-left-info-price{
				display: flex;
				align-items:center;
				justify-content: space-between;
				>view{
					&:last-child{
						display: flex;
						align-items:center;
					}
				}
			}
			.choose-product-item-left-info-name{
				font-size: 28rpx;
				font-weight: 900;
				color: #666;
			}
			.choose-product-item-left-info-guige{
				color: #2196F3;
				margin: 10rpx 0;
				text{
					margin-right: 10rpx;
				}
			}
		}
	}
</style>