<template>
	<view class="page">
		<!-- 导航栏 -->
		<navbar title="商品详情" leftClick @leftClick="$utils.navigateBack" />

		<view class="swipe">
			<uv-swiper :list="productDetail.image
			&& productDetail.image.split(',')" indicator height="520rpx"></uv-swiper>
		</view>

		<!-- 商品标题 -->
		<view class="info">
			<view class="title">
				{{ productDetail.title }}
			</view>
		</view>

		<!-- 服务 -->
		<view class="server">
			<view class="setver-main">
				<view class="title">服务</view>
				<view class="descript">
					免费上门退·7天无理由退货·快递发货
				</view>
			</view>

			<view class="server-arraw">
				<uv-icon name="arrow-right"></uv-icon>
			</view>
		</view>

		<!-- 参数 -->
		<view class="params">
			<view class="params-main">
				<view class="title">参数</view>
				<view class="descript">
					品牌；适应人群
				</view>
			</view>

			<view class="server-arraw">
				<uv-icon name="arrow-right"></uv-icon>
			</view>
		</view>

		<!-- 商品详情 -->
		<view class="item-line">
			<view class="before"></view>
			<view class="label">商品详情</view>
		</view>

		<uv-parse :content="productDetail.details"></uv-parse>

		<!-- 分享和购买按钮 -->
		<submit @service="service" @submit="submit" :detail="productDetail" />
	</view>
</template>

<script>
	import submit from '../components/product/submit.vue'
	import submitUnitSelect from '../components/product/submitUnitSelect.vue'
	export default {
		components: {
			submit,
			submitUnitSelect
		},
		data() {
			return {
				productDetail: {
					image: '',
					details: '',
				},
				id: 0,
			}
		},
		onLoad(args) {
			this.id = args.id
		},
		onShow() {
			this.getRiceProductDetail()
		},
		methods: {
			// 分享商品
			share() {

			},
			// 立即下单
			submit() {
				this.$store.commit('setPayOrderProduct', [
					this.productDetail
				])

				this.$utils.navigateTo('/pages_order/order/createOrder')
			},
			// 获取商品
			getRiceProductDetail() {
				this.$api('getRiceProductDetail', {
					id: this.id
				}, res => {
					if (res.code == 200) {
						res.result.num = 1
						this.productDetail = res.result
					}
				})
			},
			// 联系客服
			service() {
				console.log("联系客服")
				// this.$api('service', {
				// 	shopId: this.id,
				// 	num: 1,
				// }, res => {
				// 	if (res.code == 200) {
				// 		uni.showToast({
				// 			title: '加入购物车成功',
				// 			icon: 'none'
				// 		})
				// 	}
				// })
			},
		}
	}
</script>

<style scoped lang="scss">
	.page {
		.swipe {}

		// 商品标题
		.info {
			padding: 20rpx;
			background-color: #fff;

			.title {
				font-size: 36rpx;
				font-weight: 900;
			}
		}

		// 服务 & 参数
		.server,
		.params {
			background: white;
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;
			padding: 30rpx 20rpx;
			box-sizing: border-box;

			.setver-main,
			.params-main {
				display: flex;
				flex-wrap: wrap;
				width: 90%;
				font-size: 32rpx;

				.title {
					color: #7C7C7C;
					margin-right: 20rpx;
				}
			}

			.server-arraw {
				display: flex;
				justify-content: flex-end;
				text-align: right;
			}
		}

		// 商品详情
		.item-line {
			display: flex;
			background: white;
			padding: 0rpx 20rpx;
			box-sizing: border-box;
			font-size: 34rpx;
			padding: 30rpx 20rpx;
		}

		.item-line .before {
			content: "";
			width: 8rpx;
			height: 30rpx;
			background: $uni-color;
			border-radius: 4rpx;
			margin-right: 10rpx;
			margin-top: 15rpx;
		}

		.item-line .label {
			display: flex;
			align-items: center;
			width: 152rpx;
			height: 60rpx;
		}
	}
</style>