<template>
	<view>
		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="奖品详情"></u-navbar>
		<view class="detail">
			<view class="detail-top">
				<u-swiper :list="picUrlArr" height="375" radius="0" :indicator="true" :circular="true"></u-swiper>
			</view>
			<view class="detail-info">
				<view class="content">零跑C11电动汽车新能源车整车国产中型SUV C11性能版</view>
			</view>
			<view class="detail-title">商品详情</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: [],

				payShow: false,
				payInfo: {}
			};
		},
		onLoad(opthios) {
			this.getDetail(opthios.id)
		},
		methods: {
			getDetail(id) {
				uni.showLoading({
					title: '加载中'
				});
				$http.post('/api/v1/mp/channel/mall/ticket/detail', {
					boxId: id
				}).then(res => {
					uni.hideLoading();
					console.log(res);
					return
					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
					}
				}).catch(() => {
					uni.hideLoading();
				})
			},

			close() {
				this.payShow = false
			},

			exchange() {
				let data = {
					couponIds: [],
					autoCoupon: 1,
					boxId: this.info.boxId,
					ticketId: this.info.ticketId,
					orderNum: 1
				}
				$http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
					if (res.code == 0) {
						let info = {
							...res.data,
							...this.info,
							picUrl: env.filePublic + res.data.picUrl,
						}
						this.payInfo = info
						this.payShow = true
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.detail {
		padding-bottom: 100rpx;
		
		&-info{
			padding: 50rpx 20rpx 50rpx;
			margin-bottom: 10rpx;
			background-color: #fff;
			
			.content{
				font-size: 32rpx;
				font-weight: bold;
			}
		}
		
		&-title{
			height: 88rpx;
			text-align: center;
			line-height: 88rpx;
			font-weight: bold;
			background-color: #FFFFFF;
		}

	}
</style>
