<template name="goods">
	<view class="goods-template">
		<!-- 商品列表 -->
		<view class="goods-list">
			<view v-for="(item, index) in list" :key="index" class="goods-item clearfix">
				<view class="shoptitle">
					<view class="title-text" v-if="information.secondHandOrderFlag == 1"
						>{{ item.shopName }}
					</view>
					<view class="title-text" v-else @click="goShophome(item)">
						{{ item.shopName }} <label class="iconfont icon-jinrudianpu"></label>
					</view>
				</view>
				<view class="productlist" v-for="(pros, idx) in item.orderProductList" :key="idx">
					<view class="goods-pros-t " @click="details(pros)">
						<view class="pros-left">
							<view class="pros-img">
								<image :src="pros.image" alt="" />
							</view>
						</view>
						<view class="pros-product">
							<view class="producttitle">{{ pros.name }}</view>
							<view class="productspec product-view" v-if="pros.productCategory != 2"
								>规格：{{ pros.productUnit ? pros.productUnit : '' }}</view
							>
							<view class="product-view">
								<view class="view-num red">￥{{ pros.price | NumFormat }}</view>
								<view class="view-num right">x {{ pros.num }}</view>
							</view>
						</view>
					</view>
					<!-- <view class=" product-info clearfix"> 
						<view class="product-view" v-if="pros.returnedNum > 0 || pros.actualCancelNum > 0">
							<view class="view-num">已退货/已取消：<text class="text">{{ pros.returnedNum }}/{{ pros.actualCancelNum }}</text></view>
						</view>
						<view class="product-view" v-if="pros.svipPriceType != 1">
							<view class="view-num">折扣：<text class="text">{{ pros.discount == null ? '0' : pros.discount }}%</text></view>
						</view>
						<view class="product-view">
							<view class="view-num">税率：<text class="text">{{ pros.taxRate }}%</text></view>
						</view>
						<view class="product-view">
							<view class="view-num">折后单价：<text class="text">￥{{ pros.discountPrice | NumFormat }}</text></view>
						</view>
						<view class="product-view allPrice">
							<view class="view-num">合计：<text class="text">￥{{ pros.totalFee | NumFormat }}</text></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 clearfix" v-if="information.onlinePayFlag == 0">
					<view class="pros-price-view" v-if="item.isHandelShow">
						<view class="price-view-le">商品总额：</view>
						<view class="price-view-ri">￥{{ item.totalAmount | NumFormat }}</view>
					</view>
					<view class="pros-price-view" v-if="item.isHandelShow">
						<view class="price-view-le">优惠：</view>
						<view class="price-view-ri">￥{{ item.eachDiscount | NumFormat }}</view>
					</view>
					<view class="pros-price-view" v-if="item.isHandelShow">
						<view class="price-view-le">应付金额：</view>
						<view class="price-view-ri">￥{{ item.realPay | NumFormat }}</view>
					</view>
					<view class="pros-price-view" v-if="item.isHandelShow">
						<view class="price-view-le">已付金额：</view>
						<view class="price-view-ri">￥{{ item.receiptAmount | NumFormat }}</view>
					</view>
					<view class="pros-price-view">
						<view class="price-view-le">待付金额：</view>
						<view class="price-view-ri red">￥{{ item.obligation | NumFormat }}</view>
					</view>
					<view class="pros-price-btn">
						<view class="btn" @click="handelShowDetails(item)">
							{{ item.isHandelShow ? '收起' : '查看更多' }}
							<text class="iconfont" :class="item.isHandelShow ? 'icon-xiangshangjiantou' : 'icon-xiangxiajiantou'"></text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'goods',
	props: {
		shopOrderData: {
			type: Array
		},
		information: {
			type: Object
		}
	},
	data() {
		return {
			list: [],
			vipFlag: 0,
		}
	},
	created() {
		this.initGetStotage(this.shopOrderData)
	},
	filters: {
		NumFormat(value) {
			//处理金额
			return Number(value).toFixed(2)
		},
		formatIncludedTax(value) {
			if (value === '1') {
				return '不含税 '
			} else if (value === '2') {
				return '含税'
			} else {
				return ''
			}
		}
	},
	computed: {},
	methods: {
		async initGetStotage(data) {
			const userInfo = await this.$api.getStorage()
			this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
			this.list = data.map((el,index)=>{
				el.isHandelShow = false
				return el
			})
		},
		handelShowDetails(item){
			item.isHandelShow = !item.isHandelShow
		},
		goShophome(shop) {
			if(shop.shopType === 2){
				return
			}
			this.$api.navigateTo(`/pages/supplier/user/my-shop?shopId=${shop.shopId}`)
		},
		details(pros) {
			if (pros.validFlag == 9) {
				return
			} else {
				this.$api.navigateTo(`/pages/goods/product?id=${pros.productId}`)
			}
		},
		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;
            .floor-item-act{
                height: 56rpx;
                text-align: center;
                box-sizing: border-box;
                float: left;
                padding: 10rpx 0;
                margin-right: 12rpx;
                .floor-tags{
                    height: 28rpx;
                    border-radius: 6rpx;
                    background-color: #FFFFFF;
                    line-height: 28rpx;
                    color: $color-system;
                    text-align: center;
                    display: inline-block;
                    padding:0 6rpx;
                    font-size: $font-size-20;
                    border: 1px solid #FF5B00;
                    float: left;
                }
            }
			.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;
				.iconfont {
					color: #999999;
					font-size: 28rpx;
					margin-left: 10rpx;
				}
				.paymenttext {
					color: #f9a94b;
					font-size: $font-size-22;
					margin-left: 20rpx;
				}
			}
		}
		.productlist {
			width: 100%;
			height: auto;
			padding: 0;
			box-sizing: border-box;
		}
		.goods-pros-t {
			display: flex;
			width: 100%;
			height: auto;
			margin: 20rpx 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;
				}
			}
		}
		.product-info {
			padding: 10rpx 0;
			.product-view {
				font-size: $font-size-24;
				color: #999999;
				overflow: hidden;
				height: 44rpx;
				line-height: 44rpx;
				float: left;
				width: 50%;
				.view-num {
					float: left;
					.text{
						color: #333333;
					}
				}
			}
		}
		.pros-product {
			width: 468rpx;
			height: 100%;
			line-height: 36rpx;
			font-size: $font-size-26;
			position: relative;
			.product-view {
				&.allPrice {
					width: 100%;
				}
				.view-num {
					flex: 1;
					text-align: left;
					font-size: $font-size-26;
					color: #999999;
					line-height: 44rpx;
					float: left;
					&.right {
						float: right;
					}
					&.red {
						color: #ff2000;
						font-weight: bold;
						&.none {
							text-decoration: line-through;
							color: #999999;
						}
					}
				}
			}
			.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: #999999;
				line-height: 44rpx;
				text-overflow: ellipsis;
				display: -webkit-box;
				word-break: break-all;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 1;
				overflow: hidden;
			}
			.productprice {
				height: 48rpx;
				position: absolute;
				width: 100%;
				bottom: 0;
				.price {
					line-height: 48rpx;
					font-size: $font-size-28;
					width: 48%;
					color: #ff2a2a;
					float: left;
					.price {
						line-height: 48rpx;
						font-size: $font-size-28;
						width: 48%;
						color: #ff2a2a;
						float: left;
						font-weight: bold;
					}
				}
				.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-item-act {
				height: 56rpx;
				text-align: center;
				box-sizing: border-box;
				float: left;
				padding: 10rpx 0;
				margin-right: 12rpx;
			}
		}
		.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%;
			padding-top: 12rpx;
			float: left;
			.pros-price-view{
				width: 100%;
				height: 44rpx;
				font-size: 24rpx;
				line-height: 44rpx;
				.price-view-le{
					float: left;
					color: #999999;
					text-align: left;
				}
				.price-view-ri{
					float: right;
					color: #333333;
					text-align: right;
					&.red{
						color: #F94B4B;
					}
				}
			}
			.pros-price-btn{
				width: 100%;
				height: 48rpx;
				.btn{
					width: 168rpx;
					height: 48rpx;
					line-height: 46rpx;
					box-sizing: border-box;
					border: 2rpx solid #e1e1e1;
					border-radius: 8rpx;
					text-align: center;
					color: #b2b2b2;
					margin: 0 auto;
					font-size: $font-size-24;
					.iconfont {
						
					}
				}
			}
		}
	}
}
</style>
