<template>
	<view>
		<u-navbar title="兑换详情" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
		<view class="detail">
			<view class="detail-top">
				<u-swiper :list="picUrlArr" height="320" :indicator="true" :circular="true"></u-swiper>
			</view>
			<view class="detail-sku">
				<view class="detail-sku-title">参数</view>
			</view>
		</view>
		<view class="footer-fixed">
			<view class="flex btn">
				<view class="btn-left" @click="toCart">
					<u-icon name="shopping-cart" color="#808080" size="20"></u-icon>
					<view>购物车</view>
				</view>
				<view class="btn-right">
					<text @click="addCart">加入购物车</text>
					<text @click="toSettlement">立即购票</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import env from '../../config/env.js'
	import $http from '@/utils/request.js'
	export default {
		data() {
			return {
				boxId: '',
				picUrlArr: [
					'https://cdn.uviewui.com/uview/swiper/swiper1.png',
					'https://cdn.uviewui.com/uview/swiper/swiper2.png',
					'https://cdn.uviewui.com/uview/swiper/swiper3.png',
				],
				info: {},
				prizeList: [],
			};
		},
		onLoad(opthios) {
			// this.getDetail(opthios.boxId)
		},
		methods: {
			getDetail(id) {
				$http.post('/api/v1/mp/channel/mall/ticket/detail', {
					boxId: id
				}).then(res => {
					if (res.code == 0) {
						this.info = res.data

						let picUrlArr = res.data.picUrl.split(',')
						picUrlArr.forEach(item => {
							this.picUrlArr.push(env.filePublic + item)
						})

						let prizeList = res.data.prizeList

						prizeList.forEach(item => {
							item.picUrl = env.filePublic + item.picUrl
						})

						this.prizeList = prizeList
					}
				})
			},

			addCart(id) {
				let data = {
					boxId: this.info.boxId,
					orderNum: 1
				}
				$http.post(`/api/v1/mp/channel/mall/cart/add`, data).then(res => {
					if (res.code == 0) {
						uni.$u.toast('加入购物车成功');
					}
				})
			},

			toCart() {
				uni.switchTab({
					url: "/pages/index/cart"
				})
			},

			toSettlement() {
				uni.navigateTo({
					url: `/pages/order/settlement?boxId=${ this.info.boxId }`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	
</style>
<style lang="scss" scoped>
	.detail {
		padding-bottom: 100rpx;

		&-top {
			margin-bottom: 20rpx;
		}

		&-info {
			justify-content: space-between;
			box-sizing: border-box;
			padding: 24rpx 16rpx;
			background-color: #fff;
			margin: 10rpx 10rpx 20rpx;
			border-radius: 10rpx;

			&__left {
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				text {
					font-size: 24rpx;
					line-height: 24rpx;
					display: inline-block;
				}

				.title {
					color: rgba(16, 16, 16, 100);
					font-size: 32rpx;
					line-height: 32rpx;
					font-weight: bold;
					margin-bottom: 40rpx;
				}

				.num {
					width: 220rpx;
					height: 34rpx;
					color: $uni-text-color;
					text-align: center;
					line-height: 34rpx;
					border: 1px solid $uni-bg-color;
					border-radius: 6rpx;
				}
			}

			&__right {
				display: flex;
				flex-direction: column;
				align-items: flex-end;
				justify-content: space-between;

				text {
					color: rgba(157, 157, 157, 100);
					font-size: 14px;
				}

				.money {
					font-size: 40rpx;
					font-weight: bold;
					line-height: 40rpx;
					font-weight: bold;
					color: $uni-text-color;
					margin-bottom: 40rpx;
				}
			}
		}

		&-sku {
			background-color: #fff;
			border-radius: 10rpx;
			margin: 10rpx 10rpx 20rpx;

			&-title {
				padding: 24rpx 16rpx 12rpx;
			}

			&-item {
				padding-bottom: 10rpx;

				view {
					padding-left: 50rpx;
					line-height: 50rpx;
				}
			}
		}

		&-goods {
			margin: 10rpx 10rpx 20rpx;

			&-title {
				margin-bottom: 20rpx;
			}

			&-list {
				background-color: #FFFFFF;

				&-item {
					position: relative;
					margin: 16rpx 0;
					border-bottom: 1px solid rgba(236, 236, 236, 100);

					&__value {
						display: flex;
					}

					.image-wrap {
						width: 250rpx;
						height: 250rpx;
						margin-right: 30rpx;

						image {
							width: 180rpx;
							height: 120rpx;
						}
					}

					.name {
						position: absolute;
						line-height: 28rpx;
						padding: 6rpx 20rpx;
						background-color: $uni-bg-color;
					}

					.info {
						display: flex;
						flex-direction: column;
						font-size: 24rpx;

						text {
							margin-bottom: 10rpx;
						}

						text:first-child {
							font-size: 28rpx;
							margin-top: 24rpx;
							margin-bottom: 30rpx;
							font-weight: bold;
						}
					}
				}

				&-item:last-child {
					border: none;
				}
			}
		}
	}

	.footer-fixed {
		position: fixed;
		bottom: var(--window-bottom);
		left: 0;
		right: 0;
		// min-height: 120rpx;
		z-index: 11;
		box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
		background: #fff;
		// margin-bottom: 40rpx;

		// 设置ios刘海屏底部横线安全区域
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);

		.btn {
			justify-content: space-between;
			padding: 10rpx 40rpx;

			&-left {
				display: flex;
				line-height: 28rpx;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				color: #808080;
			}

			&-right {
				display: flex;
				align-items: center;
				justify-content: flex-end;

				text {
					width: 190rpx;
					height: 60rpx;
					line-height: 60rpx;
					border-radius: 8rpx;
					text-align: center;
					margin-left: 40rpx;
				}

				text:first-child {
					background-color: rgba(236, 153, 84, 100);
					color: rgba(255, 255, 255, 100);
				}

				text:last-child {
					background-color: rgba(235, 112, 9, 100);
					color: rgba(255, 255, 255, 100);
				}
			}
		}
	}
</style>
