<template>
	<view class="container">
		<view class="carousel">
			<swiper indicator-dots :circular="true" duration="400">
				<swiper-item class="swiper-item" v-for="(item, index) in good.slider_image" :key="index">
					<view class="image-wrapper">
						<image :src="item" class="loaded" mode="scaleToFill"></image>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<view class="introduce-section">
			<view class="price-box">
				<text class="price-tip">¥</text>
				<text class="price">{{ good.hanging_price }}</text>
			</view>
			<text class="title">{{ good.name }}</text>
		</view>
		<view class="detail-desc">
			<view class="d-header"><text>商品详情</text></view>
			<rich-text class="detail-centent" :nodes="good.description"></rich-text>
			</view>
		</view>
	</view>
</template>

<script>
	// import share from '@/components/share';
	import uniNumberBox from '@/components/uni-number-box.vue';
	import uniCountdown from '@/components/uni-countdown/uni-countdown.vue';
	import { product } from '@/api/index.js'
	import {
		goodsDetail,
		cartAdd,
		collectAdd,
		collectDel,
		seckillGoods,
		groupGoods
	} from '@/api/product.js';
	// #ifdef H5
	import {
		weixindata,
		shareLoad
	} from '@/utils/wxAuthorized';
	import {
		mapState
	} from 'vuex';
	import weixinObj from "@/plugin/jweixin-module/index.js";
	// #endif
	export default {
		components: {
			uniNumberBox,
			uniCountdown
		},
		filters: {
			address(val) {
				let str = '';
				if (val) {
					str = val[0] + ' ' + val[1];
				}
				return str;
			}
		},
		data() {
			return {
				goodId: '',
				good: {}
			};
		},
		async onLoad(opt) {
			let obj = this;
			obj.goodId = opt.id
			this.getproduct()
			
		},
		computed: {
			// #ifdef H5
			...mapState(['weichatObj', 'baseURL', 'urlFile']),
			...mapState('user', ['userInfo'])
			// #endif
		},
		methods: {
			getproduct() {
				let obj =this
				product({
					id: obj.goodId
				}).then(res => {
					console.log(res)
					obj.good = res.data
				})
			},
		}
	};
</script>

<style lang="scss">
	page {
		background: $page-color-base;
	}

	//秒杀底部高度
	.seckillBottom {
		height: 110rpx;
	}

	// 文章页底部高度撑开
	.contentBottomHeight {
		height: 110rpx;
	}

	//默认商品底部高度
	.goodsBottom {
		height: 160rpx;
	}

	.iconenter {
		font-size: $font-base + 2rpx;
		color: #888;
	}

	.carousel {
		/* #ifdef APP-PLUS */
		// padding-top: var(--status-bar-height);
		/* #endif */
		height: 722rpx;
		position: relative;

		swiper {
			height: 100%;
		}

		.image-wrapper {
			width: 100%;
			height: 100%;
		}

		.swiper-item {
			display: flex;
			justify-content: center;
			align-content: center;
			// height: 750rpx;
			height: 710rpx;
			overflow: hidden;

			image {
				width: 100%;
				height: 100%;
			}
		}
	}

	// 秒杀
	.seckill-box-title {
		background: linear-gradient(90deg, rgba(239, 78, 81, 1) 0%, rgba(244, 113, 59, 1) 100%) !important;

		.price,
		.price-tip,
		.timeStop,
		.m-price {
			color: #ffffff !important;
		}

		.price-tip {
			font-size: $font-base;
		}

		.price {
			font-size: 45rpx !important;
			font-weight: bold;
		}

		.timeStop {}
	}

	// 底部拼团、秒杀支付按钮
	.goods-pay-box {
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 95;
		width: 750rpx;
		height: 100rpx;
		line-height: 1;
		color: #ffffff;
		text-align: center;
		font-size: $font-lg;

		.bgLine {
			background: linear-gradient(90deg, rgba(239, 78, 81, 1) 0%, rgba(244, 113, 59, 1) 100%);
		}

		// 拼团支付按钮
		.goods-pay {
			display: flex;
			align-content: center;
			flex-wrap: wrap;
			justify-content: center;

			.goods-buttom,
			.goods-buttom-money {
				width: 100%;
			}

			.goods-buttom-money {
				font-size: $font-base;
			}
		}

		.goods-pay-stop,
		.goods-pay {
			padding: 15rpx 0;
			height: 100%;
			width: 100%;
		}

		.goods-pay-stop {
			background: $color-gray;
			line-height: 70rpx;
		}
	}

	/* 标题简介 */
	.introduce-section {
		background: #fff;
		padding: 20rpx 30rpx;

		.title {
			font-size: 32rpx;
			color: $font-color-dark;
			height: 50rpx;
			line-height: 50rpx;
		}

		.price-box {
			display: flex;
			align-items: baseline;
			height: 64rpx;
			padding: 10rpx 0;
			font-size: 26rpx;
			color: #FD3B39;
		}

		.price {
			font-size: $font-lg + 2rpx;
		}

		.m-price {
			margin: 0 12rpx;
			color: $font-color-light;
			text-decoration: line-through;
		}

		.coupon-tip {
			align-items: center;
			padding: 4rpx 10rpx;
			background: $uni-color-primary;
			font-size: $font-sm;
			color: #fff;
			border-radius: 6rpx;
			line-height: 1;
			transform: translateY(-4rpx);
		}

		.bot-row {
			display: flex;
			align-items: center;
			height: 50rpx;
			font-size: $font-sm;
			color: $font-color-light;

			text {
				flex: 1;
			}
		}
	}

	/* 分享 */
	.share-section {
		display: flex;
		align-items: center;
		color: $font-color-base;
		background: linear-gradient(left, #fdf5f6, #fbebf6);
		padding: 12rpx 30rpx;

		.share-icon {
			display: flex;
			align-items: center;
			width: 70rpx;
			height: 30rpx;
			line-height: 1;
			border: 1px solid $uni-color-primary;
			border-radius: 4rpx;
			position: relative;
			overflow: hidden;
			font-size: 22rpx;
			color: $uni-color-primary;

			&:after {
				content: '';
				width: 50rpx;
				height: 50rpx;
				border-radius: 50%;
				left: -20rpx;
				top: -12rpx;
				position: absolute;
				background: $uni-color-primary;
			}
		}

		.iconfavorfill {
			position: relative;
			z-index: 1;
			font-size: 24rpx;
			margin-left: 2rpx;
			margin-right: 10rpx;
			color: #fff;
			line-height: 1;
		}

		.tit {
			font-size: $font-base;
			margin-left: 10rpx;
		}

		.iconprompt {
			padding: 10rpx;
			font-size: 30rpx;
			line-height: 1;
		}

		.share-btn {
			flex: 1;
			text-align: right;
			font-size: $font-sm;
			color: $uni-color-primary;
		}

		.iconenter {
			font-size: $font-sm;
			margin-left: 4rpx;
			color: $uni-color-primary;
		}
	}

	.c-list {
		margin-top: 20rpx;
		font-size: $font-sm + 2rpx;
		color: $font-color-base;
		background: #fff;

		.c-row {
			display: flex;
			align-items: center;
			padding: 20rpx 30rpx;
			position: relative;
		}

		.tit {
			width: 140rpx;
		}

		.con {
			flex: 1;
			color: $font-color-dark;

			.selected-text {
				margin-right: 10rpx;

				.num {
					color: #FD3B39;
				}
			}
		}

		.bz-list {
			height: 40rpx;
			font-size: $font-sm + 2rpx;
			color: $font-color-dark;

			text {
				display: inline-block;
				margin-right: 30rpx;
			}
		}

		.con-list {
			flex: 1;
			display: flex;
			flex-direction: column;
			color: $font-color-dark;
			line-height: 40rpx;
		}

		.red {
			color: $uni-color-primary;
		}
	}

	/* 评价 */
	.eva-section {
		display: flex;
		flex-direction: column;
		padding: 20rpx 30rpx;
		background: #fff;
		margin-top: 16rpx;

		.e-header {
			display: flex;
			align-items: center;
			height: 70rpx;
			font-size: $font-sm + 2rpx;
			color: $font-color-light;

			.tit {
				font-size: $font-base + 2rpx;
				color: $font-color-dark;
				margin-right: 4rpx;
			}

			.tip {
				flex: 1;
				text-align: right;
			}

			.iconenter {
				margin-left: 10rpx;
			}
		}
	}

	.eva-box {
		display: flex;
		padding: 20rpx 0;

		.portrait {
			flex-shrink: 0;
			width: 80rpx;
			height: 80rpx;
			border-radius: 100px;
		}

		.right {
			flex: 1;
			display: flex;
			flex-direction: column;
			font-size: $font-base;
			color: $font-color-base;
			padding-left: 26rpx;

			.con {
				font-size: $font-base;
				color: $font-color-dark;
				padding: 20rpx 0;
			}

			.bot {
				display: flex;
				justify-content: space-between;
				font-size: $font-sm;
				color: $font-color-light;
			}
		}
	}

	.eva-boxs {
		width: 100%;
		overflow: hidden;
		padding: 10px 28rpx;
		background: #f4f4f4;
		border-radius: 12rpx;
		font-size: $font-sm + 2rpx;
		color: #333;

		.portrait {
			flex-shrink: 0;
			width: 80rpx;
			height: 80rpx;
			border-radius: 100px;
		}

		.right {
			flex: 1;
			display: flex;
			flex-direction: column;
			font-size: $font-base;
			color: $font-color-base;

			.con {
				font-size: $font-base;
				color: $font-color-dark;
			}

			.bot {
				display: flex;
				justify-content: space-between;
				font-size: $font-sm;
				color: $font-color-light;
			}
		}
	}

	/*  详情 */
	.detail-desc {
		background: #fff;
		margin-top: 16rpx;

		/deep/ img {
			max-width: 100% !important;
			display: inline !important;
		}

		/deep/ div {
			max-width: 100% !important;
		}

		.d-header {
			display: flex;
			justify-content: center;
			align-items: center;
			height: 80rpx;
			font-size: $font-base + 2rpx;
			color: $font-color-dark;
			position: relative;

			text {
				padding: 0 20rpx;
				background: #fff;
				position: relative;
				z-index: 1;
			}

			&:after {
				position: absolute;
				left: 50%;
				top: 50%;
				transform: translateX(-50%);
				width: 300rpx;
				height: 0;
				content: '';
				border-bottom: 1px solid #ccc;
			}
		}
	}

	/* 规格选择弹窗 */
	.attr-content {
		padding: 10rpx 0 0;

		.a-t {
			padding: 0 30rpx;
			display: flex;

			image {
				width: 170rpx;
				height: 170rpx;
				flex-shrink: 0;
				border-radius: 8rpx;
			}

			.right {
				display: flex;
				flex-direction: column;
				padding-left: 24rpx;
				font-size: $font-sm + 2rpx;
				color: $font-color-base;
				line-height: 42rpx;

				.good-name {
					padding-top: 20rpx;
					max-width: 320rpx;
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #1d2023;
					line-height: 42rpx;
					margin-bottom: 15rpx;
				}

				.price {
					font-size: 60rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #ff6f0f;
					// font-size: $font-lg;
					// color: $uni-color-primary;
					// margin-bottom: 10rpx;
				}

				.selected-text {
					margin-right: 10rpx;
				}
			}
		}

		.attr-list {
			display: flex;
			flex-direction: column;
			font-size: $font-base + 2rpx;
			color: $font-color-base;
			padding-top: 30rpx;
			padding-left: 40rpx;
			padding-right: 30rpx;
		}

		.item-list {
			padding: 20rpx 0 0;
			display: flex;
			flex-wrap: wrap;

			.tit {
				display: flex;
				align-items: center;
				justify-content: center;
				background: #eee;
				// margin-left: 10rpx;
				margin-right: 20rpx;
				margin-bottom: 20rpx;
				border-radius: 100rpx;
				min-width: 60rpx;
				height: 60rpx;
				padding: 0 20rpx;
				font-size: $font-base;
				color: $font-color-dark;
			}

			.selected {
				background: #fbebee;
				color: $uni-color-primary;
			}
		}
	}

	/*  弹出层 */
	.popup {
		position: fixed;
		left: 0;
		top: 0;
		right: 0;
		bottom: 0;
		z-index: 99;

		&.show {
			display: block;

			.mask {
				animation: showPopup 0.2s linear both;
			}

			.layer {
				animation: showLayer 0.2s linear both;
			}
		}

		&.hide {
			.mask {
				animation: hidePopup 0.2s linear both;
			}

			.layer {
				animation: hideLayer 0.2s linear both;
			}
		}

		&.none {
			display: none;
		}

		.mask {
			position: fixed;
			top: 0;
			width: 100%;
			height: 100%;
			z-index: 1;
			background-color: rgba(0, 0, 0, 0.4);
		}

		.layer {
			position: fixed;
			z-index: 99;
			bottom: 0;
			width: 100%;
			min-height: 30vh;
			border-radius: 10rpx 10rpx 0 0;
			background-color: #fff;

			.btn {
				position: absolute;
				bottom: 0;
				width: 750rpx;
				height: 98rpx;
				background: #FE5B38;
				line-height: 98rpx;
				// background: $uni-color-primary;
				font-size: $font-base + 2rpx;
				color: #fff;
			}
		}

		@keyframes showPopup {
			0% {
				opacity: 0;
			}

			100% {
				opacity: 1;
			}
		}

		@keyframes hidePopup {
			0% {
				opacity: 1;
			}

			100% {
				opacity: 0;
			}
		}

		@keyframes showLayer {
			0% {
				transform: translateY(120%);
			}

			100% {
				transform: translateY(0%);
			}
		}

		@keyframes hideLayer {
			0% {
				transform: translateY(0);
			}

			100% {
				transform: translateY(120%);
			}
		}
	}

	/* 底部操作菜单 */
	.page-bottom {
		position: fixed;
		left: 0rpx;
		bottom: 0rpx;
		z-index: 95;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 750rpx;
		height: 98rpx;
		background: rgba(255, 255, 255, 0.9);
		box-shadow: 0 0 20rpx 0 rgba(0, 0, 0, 0.5);

		// border-radius: 16rpx;
		.p-b-btn {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			font-size: $font-sm;
			color: $font-color-base;
			width: 100rpx;
			height: 98rpx;

			.iconfont {
				font-size: 40rpx;
				line-height: 48rpx;
				color: $font-color-light;
			}

			&.active,
			&.active .iconfont {
				color: $uni-color-primary;
			}

			.icon-fenxiang2 {
				font-size: 42rpx;
				transform: translateY(-2rpx);
			}

			.iconlikefill {
				font-size: 46rpx;
			}
		}

		.action-btn-group {
			display: flex;
			height: 98rpx;
			// border-radius: 100px;
			overflow: hidden;
			// margin-left: 20rpx;
			position: relative;

			// &:after {
			// 	content: '';
			// 	position: absolute;
			// 	top: 50%;
			// 	right: 50%;
			// 	transform: translateY(-50%);
			// 	height: 28rpx;
			// 	width: 0;
			// 	border-right: 1px solid rgba(255, 255, 255, 0.5);
			// }
			.shoucang {
				width: 170rpx;
				height: 100rpx;
				background: #FFFFFF;
				flex-direction: column;
				justify-content: center;

				image {
					width: 36rpx;
					height: 35rpx;
				}

				// box-shadow: 0px 0px 40px 0px rgba(50, 50, 52, 0.06);
			}

			.action-btn {
				flex-shrink: 0;
				flex-grow: 1;
				display: flex;
				align-items: center;
				justify-content: center;
				width: 580rpx;
				height: 100%;
				font-size: 34rpx;
				padding: 0;
				border-radius: 0;
				// background: transparent;
				background: #ffb238;

				&.buy-now-btn {
					background-color: #ffb238;
				}

				&.add-cart-btn {
					background: #FD3B39;
				}
			}
		}
	}

	// 商店头
	.shop-box {
		background-color: #ffffff;
		margin-top: 20rpx;
		margin-bottom: 10rpx;
		padding: 20rpx;

		.shop-img {
			border-radius: 300rpx;
			height: 80rpx;
			width: 80rpx;
			margin-right: 20rpx;
		}

		.shop-button {
			border-radius: 100rpx;
			padding: 10rpx 20rpx;
			color: $color-red;
			border: 1px solid $color-red;
			font-size: $font-lg;
			line-height: 1;
		}
	}
</style>
