<template name="goods">
	<view class="goods-template">
		 <!-- 商品列表 -->
		<view class="goods-list">
			<view v-for="(item, index) in shopOrderData" :key="index" class="goods-item clearfix">
				<view class="shoptitle">
					<view v-if="item.shopPromotion" class="floor-item-act">
						<view class="floor-tags" @click.stop="clickPopupShow(item.shopPromotion)">{{item.shopPromotion.name}}</view>	
					</view>
					<view class="title-text">{{item.shopName}}</view> 
				</view>
				<view class="productlist" v-for="(pros,idx) in item.orderProductList" :key="idx">
					<view class="goods-pros-t ">
						<view class="pros-left">
							<view class="pros-img">
								<image :src="pros.productImage" alt="" />
								<text class="tips" v-if="pros.productType ==2 || pros.productType ==1">赠品</text>
							</view>
						</view>
						<view class="pros-product">
							<view class="producttitle">{{pros.name}}</view>
							<view class="productspec" v-if="pros.productCategory != 2">规格：{{pros.productUnit ? pros.productUnit : ''}}</view>
							<view class="product-view">
								<view class="view-num">单价：￥{{pros.price | NumFormat}}</view>
								<view class="view-num">数量：{{pros.num}}</view>
							</view>
							<view class="product-view" v-if="pros.returnedNum>0 || pros.actualCancelNum>0">
								<view class="view-num">已退货/已取消：{{pros.returnedNum}}/{{pros.actualCancelNum}}</view>
							</view>
							<view class="product-view">
								<view class="view-num">税率：{{pros.taxRate}}%</view>
								<view class="view-num">折扣：{{pros.discount == null ? '0' : pros.discount}}%</view>
							</view>
							<view class="product-view">
								<view class="view-num">折后单价：￥{{pros.discountPrice | NumFormat}}</view>
							</view>
							<view class="floor-item-act" v-if="pros.productPromotion!=null" >
								<view v-if="PromotionsFormat(pros.productPromotion)" class="floor-tags" @click.stop="clickPopupShow(pros.productPromotion)">
									{{pros.productPromotion.name}}
									<text v-if ="pros.productPromotion!=null && pros.productPromotion.type !=3">
										:￥{{ pros.productPromotion == null ? '0.00' : pros.productPromotion.touchPrice | NumFormat}}
									</text>
								</view>
								<view v-else-if="pros.productPromotion.type !=3" class="floor-tags" @click.stop="clickPopupShow(pros.productPromotion)">{{pros.productPromotion.name}}</view>	
							</view>
							<view class="product-view">
								<view class="view-num">合计：￥{{pros.totalFee | NumFormat}}</view>
							</view>
						</view>	
					</view>
				</view>	
				<view class="goods-pros-m" v-if="item.note!=''">
					<view class="m-text">留言:</view>
					<view class="m-input">
						<view class="text">{{item.note ? item.note : ''}}</view>
					</view>	
				</view>
				<view class="goods-pros-b">
					<view class="count">共{{item.itemCount}}件商品</view>
					<view class="sum">
						<view class="sum-none" v-if="item.promotionFullReduction>0">
							<text class="money-sign">￥</text>
							<text class="money">{{ (item.totalAmount+item.promotionFullReduction) | NumFormat }}</text>
							<text class="money-reduced">减<text>￥{{ (item.promotionFullReduction) | NumFormat}}</text></text>
						</view>
						<view class="sum-money" :class="item.promotionFullReduction == 0 ? 'none' : ''">
							商品总额：<text class="money">￥{{item.totalAmount | NumFormat}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>	
	</view>
</template>

<script>
	export default{
		name:"goods",
		props:{
			shopOrderData:{
				type:Array
			}
		},
		data() {
			return{
				initData:[],
			}
		},
		created(){
			this.initData = this.shopOrderData
		},
		filters:{
			NumFormat(value) {//处理金额
				return Number(value).toFixed(2);
			},
		},	
		computed: {
		
		},
		methods:{
			clickPopupShow(pros){
				console.log(pros)
				this.$emit('popupClick',pros)
			},
			PromotionsFormat(promo){//促销活动类型数据处理
				if(promo!=null){
					if(promo.type == 1 && promo.mode == 1){
						return true
					}else{
						return false
					}
				}
				return false
			},
		}
	}
</script>

<style lang="scss">
	.goods-template{
		width: 100%;
		height: auto;
		background: #FFFFFF;
		float: left;
		margin-top: 24rpx;
		.goods-list{
			width: 100%;
			height: auto;
			background: #F7F7F7;
			.goods-item{
				width: 702rpx;
				padding:24rpx;
				height: auto;
				background: #FFFFFF;
				margin-bottom: 24rpx;
				&:last-child{
					margin-bottom: 0;
				}
			}
			.shoptitle{
				width: 100%;
				float: left;
				height: 56rpx;
				line-height: 56rpx;
				margin-bottom: 12rpx;
				.title-text{
					width: 400rpx;
					overflow: hidden;
					text-overflow:ellipsis;
					white-space: nowrap;
					float: left;
					font-size: $font-size-28;
					color: $text-color;
					text-align: left;
					line-height: 56rpx;
					font-weight: bold;
				}
				.floor-item-act{
					height: 56rpx;
					text-align: center;
					box-sizing: border-box;
					float: left;
					padding: 10rpx 0;
					margin-right: 12rpx;
					.floor-tags{
						float: left;
						height: 36rpx;
						border-radius: 4rpx;
						background-color: rgba(225, 86, 22, 0.1);
						line-height: 36rpx;
						color: $color-system;
						text-align: center;
						display: inline-block;
						padding:0 16rpx;
						font-size: $font-size-20;
					}
				}
			}
			.productlist{
				width: 100%;
				height: auto;
			}	
			.goods-pros-t{
				display: flex;
				width: 100%;
				height: auto;
				padding: 12rpx 0;
				.pros-left{
					width: 210rpx;
					height: 100%;
					margin:0 26rpx 0 0;
				}
				.pros-img{
					width: 210rpx;
					height: 210rpx;
					border-radius: 10rpx;
					border:1px solid #f3f3f3;
					position: relative;
					.tips{
						display: inline-block;
						width: 80rpx;
						height: 40rpx;
						background-image: linear-gradient(214deg, #ff4500 0%, #ff5800 53%, #ff4367 100%);
						line-height: 40rpx;
						text-align: center;
						font-size: $font-size-24;
						color: #FFFFFF;
						border-radius:10rpx 0 10rpx 0 ;
						position: absolute;
						top:0;
						left: 0;
					}
					image{
						width: 210rpx;
						height: 210rpx;
						border-radius: 10rpx;
					}
				}
			}
			.pros-product{
				width: 468rpx;
				height: 100%;
				line-height: 36rpx;
				font-size: $font-size-26;	
				position: relative;
				.product-view{
					width: 100%;
					height: auto;
					display: flex;
					.view-num{
						flex: 1;
						text-align: left;
						font-size: $font-size-26;
						color: #666666;
						line-height: 44rpx;
					}
				}
				.producttitle{
					width: 100%;
					display: inline-block;
					height: auto;							
					text-overflow:ellipsis;
					display: -webkit-box;
					word-break: break-all;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					overflow: hidden;
					margin-bottom: 8rpx;
				}
				.productspec{
					height: 44rpx;
					color: #666666;
					line-height: 44rpx;
				}
				.productprice{
					height: 48rpx;
					position: absolute;
					width: 100%;
					bottom: 0;
					.price{
						line-height: 48rpx;
						font-size: $font-size-28;
						width: 48%;
						color: #FF2A2A;
						float: left;
					}
					.count{
						height: 100%;
						float: right;
						position: relative;
						.small{
							color: #666666;
						}
					}
				}
				.floor-item-act{
					width: 100%;
					height: 56rpx;
					text-align: center;
					box-sizing: border-box;
					float: left;
					padding:10rpx 0 0 0;
					.floor-tags{
						float: left;
						height: 36rpx;
						border-radius: 4rpx;
						background-color: rgba(225, 86, 22, 0.1);
						line-height: 36rpx;
						color: $color-system;
						text-align: center;
						display: inline-block;
						padding:0 16rpx;
						font-size: $font-size-20;
					}
				}
			}
			.goods-pros-m{
				width: 100%;
				height: auto;
				line-height: 76rpx;
				font-size: $font-size-26;
				color: $text-color;
				float: left;
				.m-text{
					width: 62rpx;
					float: left;
					padding-right: 20rpx;
					font-weight:bold;
				}
				.m-input{
					display: -webkit-box;
					display: -webkit-flex;
					display: flex;
					-webkit-box-align: center;
					-webkit-align-items: center;
					align-items: center;
					position: relative;
					width: 620rpx;
					height: auto;
					padding: 20rpx 0 10rpx 0;
					background: #FFFFFF;
					.text{
						width: 100%;
						height: 100%;
						font-size: $font-size-26;
						line-height: 36rpx;
						color: #333333;
					}
				}
			}
			.goods-pros-b{
				width:100%;
				height: 80rpx;
				margin-top: 12rpx;
				float: left;
				.count{
					float: left;
					font-size: $font-size-28;
					line-height: 80rpx;
					color: $text-color;
					display: flex;
					justify-content: flex-end;
				}
				.sum{
					width: 530rpx;
					float: right;
					.sum-none{
						width: 100%;
						height: 40rpx;
						line-height: 40rpx;
						color: $text-color;
						float: left;
						text-align: right;
						.money{
							font-size: $font-size-26;
							color: #999999;
							text-decoration: line-through;
						}
						.money-sign{
							font-size: $font-size-26;
							color: #999999;
							text-decoration: line-through;
						}
						.money-reduced{
							margin-left: 10rpx;
							font-size: $font-size-26;
							color: $color-system;
							.iconfont{
								font-size: $font-size-34;
							}
						}
					}
					.sum-money{
						width: 100%;
						height: 40rpx;
						font-size: $font-size-28;
						line-height: 40rpx;
						color: $text-color;
						display: flex;
						justify-content: flex-end;
						&.none{
							height: 80rpx;
							line-height: 80rpx;
						}
						.money{
							color: #FF2A2A;
							font-size: $font-size-28;
						}
					}		
				}
			}
		}
	}
</style>
