<template>
	<view class="container all-type-list-wrapper">
		<!-- 商品列表 -->
		<product-list ref="productList" @operationConfim="hanldOperationConfim"></product-list>
		<!-- 选择规格弹窗 -->
		<cm-unit-popup v-if="popupShow1" :popupShow="popupShow1" :product="handleData"></cm-unit-popup>
	</view>
</template>

<script>
import productList from './components/productList'
import cmUnitPopup from '@/components/cm-module/productDetails/cm-unit-popup.vue'
export default {
	components: {
		productList,
		cmUnitPopup
	},
	data() {
		return {
			userId: 0,
			isIphoneX: this.$store.state.isIphoneX,
			popupShow1:false,
			handleData: {},
		}
	},
	onLoad() {
		this.initGetStotage()
	},
	methods: {
		async initGetStotage() {
			const userInfo = await this.$api.getStorage()
			this.userId = userInfo.userId ? userInfo.userId : 0
			this.GetProductListInfo()
			this.ProductCartNumber()
		},
		hanldOperationConfim(data) {
			//显示选择数量确认弹窗
			this.popupShow1 = true
			this.handleData = data
		},
		GetUserCartNumber() {
			this.OrderService.ShoppingCartCount({ userId: this.userId })
				.then(response => {
					this.$refs.productList.cartQuantity = response.data
				})
				.catch(error => {
					console.log('查询用户购物车数量失败')
				})
		}
	},
	onShow() {
	
	}
}
</script>

<style lang="scss">
page {
	background: $sub-bg-color;
	.all-type-list-wrapper {
		display: flex;
		flex-direction: column;
	}
}
/* 加入购物模态层*/
@keyframes showPopup {
	0% {
		opacity: 0;
	}
	100% {
		opacity: 1;
	}
}
@keyframes hidePopup {
	0% {
		opacity: 1;
	}
	100% {
		opacity: 0;
	}
}
@keyframes showLayer {
	0% {
		transform: translateY(0);
	}
	100% {
		transform: translateY(-100%);
	}
}
@keyframes hideLayer {
	0% {
		transform: translateY(-100%);
	}
	100% {
		transform: translateY(0);
	}
}
@keyframes showAmnation {
	0% {
		top: -12rpx;
		opacity: 0;
	}
	50% {
		top: -60rpx;
		opacity: 1;
	}
	100% {
		top: -100rpx;
		opacity: 0;
	}
}
@keyframes hideAmnation {
	0% {
		top: -100rpx;
		opacity: 0;
	}
	100% {
		top: -12rpx;
		opacity: 0;
	}
}
.popup {
	position: fixed;
	top: 0;
	width: 100%;
	height: 100%;
	z-index: 999;
	display: none;
	.mask {
		position: fixed;
		top: 0;
		width: 100%;
		height: 100%;
		z-index: 21;
		background-color: rgba(0, 0, 0, 0.6);
	}
	.layer {
		position: fixed;
		z-index: 22;
		bottom: -294rpx;
		width: 702rpx;
		padding: 24rpx 24rpx 36rpx 24rpx;
		height: 236rpx;
		border-radius: 20rpx 20rpx 0 0;
		background-color: #fff;
		display: flex;
		flex-wrap: wrap;
		align-content: space-between;
		.content {
			width: 100%;
		}
		.btn {
			width: 100%;
			height: 88rpx;
			display: flex;
			.button {
				width: 340rpx;
				height: 88rpx;
				color: #fff;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: $font-size-28;
				border-radius: 44rpx;
				&.buy {
					background: $btn-confirm;
				}
				&.add {
					background: rgba(239, 175, 0, 1);
					margin-left: 20rpx;
				}
			}
		}
	}

	&.show {
		display: block;
		.mask {
			animation: showPopup 0.2s linear both;
		}
		.layer {
			animation: showLayer 0.2s linear both;
		}
	}
	&.hide {
		display: block;
		.mask {
			animation: hidePopup 0.2s linear both;
		}

		.layer {
			animation: hideLayer 0.2s linear both;
		}
	}
	&.none {
		display: none;
	}
	&.service {
		.row {
			margin: 30upx 0;
			.title {
				font-size: 30upx;
				margin: 10upx 0;
			}
			.description {
				font-size: 28upx;
				color: #999;
			}
		}
	}
	.layer-smimg {
		width: 114rpx;
		height: 114rpx;
		float: left;
		border-radius: 10rpx;
		margin-right: 24rpx;
		image {
			width: 114rpx;
			height: 114rpx;
			border-radius: 10rpx;
		}
	}
	.layer-nunbox {
		justify-content: space-between;
		align-items: center;
		width: 536rpx;
		height: 88rpx;
		padding: 13rpx 0 0 0;
		float: left;
		.layer-nunbox-t {
			width: 100%;
			height: 44rpx;
			position: relative;
			display: flex;
			.layer-nunbox-text {
				line-height: 44rpx;
				font-size: $font-size-28;
			}
			.number-box {
				display: flex;
				justify-content: center;
				align-items: center;
				border: 2rpx solid #ffe6dc;
				border-radius: 30rpx;
				height: 48rpx;
				margin-left: 20rpx;
				.iconfont {
					font-size: $font-size-24;
					padding: 0 18rpx;
					color: #999999;
					text-align: center;
					line-height: 48rpx;
					font-weight: bold;
					background: #fef6f3;
					&.icon-jianhao {
						border-radius: 30rpx 0 0 30rpx;
					}
					&.icon-jiahao {
						border-radius: 0 30rpx 30rpx 0;
					}
				}
				.btn-input {
					width: 62rpx;
					height: 48rpx;
					line-height: 48rpx;
					background: #ffffff;
					border-radius: 4rpx;
					text-align: center;
					font-size: $font-size-28;
				}
			}
			.product-step {
				position: absolute;
				left: 45rpx;
				bottom: 0;
				height: 44rpx;
				background: #ffffff;
			}
		}
		.layer-nunbox-b {
			width: 100%;
			height: 44rpx;
			margin-top: 13rpx;
		}
		.text {
			line-height: 44rpx;
			font-size: $font-size-28;
			.p {
				color: #ff2a2a;
			}
			.p:first-child {
				margin-left: 30rpx;
			}
			.p.sm {
				font-size: $font-size-24;
			}
		}
	}
}
</style>
