<template name="goods">
	<view class="goods-template">
		 <!-- 商品列表 -->
		<view class="goods-list">
			<view class="goods-list-title">商品信息</view>
		 	<view v-for="(item, index) in initData.orderItemList" :key="index" class="goods-item">
		 		<view class="productlist">
		 			<view class="goods-pros-t">
		 				<view class="pros-img"><image :src="item.productPic" alt="" mode="scaleToFill"/></view>
		 				<view class="pros-product">
		 					<view class="producttitle">{{item.productName}}</view>
		 					<view class="productspec" v-for="(attr,idx) in JSON.parse(item.productAttr)" :key="idx">
		 						<text>{{attr.key}}：</text>
		 						<text>{{attr.value}}</text>
		 					</view>
		 					<view class="productprice">
								<view class="count">
									<text class="small">x</text>{{item.productQuantity}}
								</view>
		 						<view class="price">
		 							<text><text class="small">￥</text>{{ item.productPrice | NumFormat }}</text>
		 						</view>
		 					</view>
		 				</view>	
		 			</view>
		 		</view>	
		 	</view>
		</view>
		<view class="information-content">
			<view class="information-view">
				<view class="view-num time">
					<view class="view-num-label">商品合计：</view>
					<view class="view-num-text">
						￥{{ initData.totalAmount | NumFormat }}
					</view>
				</view>	
				<view class="view-num time">
					<view class="view-num-label">运费(快递)：</view>
					<view class="view-num-text">
						￥{{ initData.freightAmount | NumFormat }}
					</view>
				</view>
			</view>
			<view class="information-view">
				<view class="view-num time">
					<view class="view-num-label">优惠券：</view>
					<view class="view-num-text">
						￥{{ initData.couponAmount | NumFormat }}
					</view>
				</view>
				<view class="view-num time">
					<view class="view-num-label">积分抵扣：</view>
					<view class="view-num-text">
						￥{{ initData.integrationAmount | NumFormat }}
					</view>
				</view>
			</view>
			<view class="information-view">
				<view class="view-num time">
					<view class="view-num-label">活动优惠：</view>
					<view class="view-num-text">
						￥{{ initData.promotionAmount | NumFormat }}
					</view>
				</view>
				<view class="view-num time">
					<view class="view-num-label">折扣金额：</view>
					<view class="view-num-text">
						￥{{ initData.discountAmount | NumFormat }}
					</view>
				</view>
			</view>
			<view class="information-view">
				<view class="view-num time">
					<view class="view-num-label">订单总金额：</view>
					<view class="view-num-text">
						￥{{ (initData.totalAmount + initData.freightAmount) | NumFormat }}
					</view>
				</view>
				<view class="view-num time">
					<view class="view-num-label">应付款金额：</view>
					<view class="view-num-text">
						￥{{ (initData.payAmount + initData.freightAmount - initData.discountAmount) | NumFormat }}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		name:"goods",
		props:{
			orderInfo:{
				type:Object
			}
		},
		data() {
			return{
				initData:{}
			}
		},
		filters: {
			NumFormat:function(text) {//处理金额
				return Number(text).toFixed(2);
			},
		},
		created(){
			this.initData = this.orderInfo
		},
		computed: {

		},
		methods:{
			toFixedFn(text){//处理小数点后两位数
				return Number(text).toFixed(2);
			},
		}
	}
</script>

<style lang="scss">
	.goods-template{
		width: 100%;
		height: auto;
		background: #FFFFFF;
		float: left;
		margin-top: 16rpx;
		.goods-list{
			width: 100%;
			height: auto;	
			background:#F7F7F7;
			border-bottom: 1px solid #EBEBEB;
			.goods-list-title{
				background-color: #FFFFFF;
				font-size: $font-size-28;
				color: $text-color;
				line-height: 60rpx;
				width: 100%;
				padding: 0 20rpx;
				font-weight: bold;
			}
			.goods-item{
				width: 100%;
				padding:10rpx 20rpx;
				background: #FFFFFF;
				margin-bottom: 16rpx;
				&:last-child{
					margin-bottom: 0;
				}
			}
			.shoptitle{
				display: flex;
				align-items: center;
				height: 80rpx;
				line-height: 80rpx;
				.title-logo{
					width: 48rpx;
					height: 48rpx;
					float: left;
					image{
						width: 48rpx;
						height: 48rpx;
					}
				}
				.title-text{
					float: left;
					margin-left: 16rpx;
					font-size: $font-size-28;
					color: $text-color;
					text-align: left;
					line-height: 56rpx;
					font-weight: bold;
				}
			}
			.productlist{
				width: 100%;
				height: auto;
			}	
			.goods-pros-t{
				display: flex;
				align-items: center;
				width: 100%;
				height: auto;
				.pros-img{
					width: 100rpx;
					height: 100rpx;
					border-radius: 10rpx;
					margin:0 26rpx 0 0;
					border:1px solid #f3f3f3;
					image{
						width: 100%;
						height: 100%;
						border-radius: 10rpx;
					}
				}
			}
			.pros-product{
				width: 600rpx;
				height: 100%;
				line-height: 36rpx;
				font-size: $font-size-26;	
				position: relative;
				padding: 6rpx 0;
				box-sizing: border-box;
				.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: 36rpx;
					color: #999999;
				}
				.productprice{
					height: 48rpx;
					width: 100%;
					.price{
						line-height: 48rpx;
						font-size: $font-size-28;
						width: 48%;
						color: #FF5000;
						float: right;
						text-align: right;
						.small{
							font-size: $font-size-22;
						}
					}
					.count{
						height: 100%;
						float: left;
						position: relative;
						.small{
							color: #666666;
						}
					}
				}
			}
			.goods-pros-m{
				height: 76rpx;
				line-height: 76rpx;
				font-size: $font-size-26;
				color: $text-color;
				margin-top: 12rpx;
				.m-text{
					width: 90rpx;
					float: left;
					padding-right: 20rpx;
				}
				.m-input{
					position: relative;
					float: left;
					width: 620rpx;
					height: 70rpx;
					padding: 20rpx 40rpx;
					background: #F7F7F7;
					border-radius: 50rpx;
					input{
						width: 100%;
						height: 100%;
						background: #F7F7F7;
						font-size: $font-size-26;
						line-height: 36rpx;
						color: #333333;
						min-height: 36rpx;
					}
				}
			}
			.goods-pros-b{
				width:100%;
				height: auto;
				.sum{
					font-size: $font-size-28;
					line-height: 60rpx;
					color: $text-color;
					display: flex;
					justify-content: flex-end;
					.money{
						color: #FF2A2A;
						font-size: $font-size-28;
					}
				}
			}
		}
		.information-content{
			width: 100%;
			box-sizing: border-box;
			padding: 20rpx;
			.information-view{
				height: 50rpx;
				line-height: 50rpx;
				font-size: $font-size-24;
				color: $text-color;
				margin: 4rpx 0;
				display: flex;
				.view-num{
					flex: 1;
					color: $text-color;
					.view-num-label{
						text-align: left;
						float: left;
						color: $text-color;
					}
					.view-num-text{
						float: left;
						text-align: left;
						color: #999999;
					}
				}
				.red{
					color: #FF2A2A;
				}
				.view-type{
					float: right;
					text-align: right;
					color: #FF2A2A;
					flex: 2;
				}
			}
		}
	}
</style>
