<template>
	<view>
		<u-navbar title="幸运数字" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
		<view class="lucky">
			<view class="lucky-number">
				<view class="flex lucky-number-circle">
					<view class="title">幸运数字</view>
					<view class="num" v-if="info.status == 1">?</view>
					<view class="">{{ info.plainLuckyNum }}</view>
				</view>
			</view>
			<view class="lucky-title">
				<view class="txt">{{ info.title }}</view>
				<view class="id">盲票序列号：{{ info.serialNo }}</view>
			</view>
			<view class="flex lucky-btn">
				<view class="pay" @click="pay">支付{{ info.facePrice / 100 }}元 立即查看</view>
			</view>
		</view>
		
		<pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" />
	</view>
</template>

<script>
	import env from '../../config/env.js'
	import $http from '@/utils/request.js'
	import PayPopup from '../../components/pay-popup/pay-popup.vue'
	export default {
		components:{
			PayPopup
		},
		data() {
			return {
				serialNo: '',
				info: '',
				payInfo: {},
				payShow: false
			};
		},

		onLoad(options) {
			this.serialNo = options.id
			this.getDetail()
		},

		methods: {
			getDetail() {
				$http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
					serialNo: 'T2200044-0003-0000021',
					noToken: true
				}).then(res => {
					console.log(res);
					if (res.code == 0) {
						this.info = res.data
					}
				})
			},
			
			close() {
				this.payShow = false
			},
			
			pay(){
				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 => {
					console.log(res);
					if (res.code == 0) {
						let info = {
							... res.data,
							picUrl: env.filePublic + picUrl,
						}
						this.payInfo = info
						this.payShow = true
						console.log(info);
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.lucky {
		width: 100%;
		height: calc(100vh - 50px);
		background: url(https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic3.zhimg.com%2F50%2Fv2-a6f5c8b5b66fe87e4e79c1fc82a61a36_hd.jpg&refer=http%3A%2F%2Fpic3.zhimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1649658373&t=f216ee4825d5b36e62aa3a490516bfb1) center center;

		&-number {
			padding-top: 400rpx;
			&-circle{
				box-sizing: border-box;
				flex-direction: column;
				width: 336rpx;
				height: 336rpx;
				background-color: $uni-bg-color;
				border-radius: 50%;
				margin: auto;
				
				.title{
					margin-bottom: 20rpx;
				}
				
				.num{
					font-size: 100rpx;
				}
			}
		}
		
		&-title{
			margin-top: 40rpx;
			margin-bottom: 70rpx;
			.txt{
				text-align: center;
				font-size: 36rpx;
				font-weight: bold;
				line-height: 50rpx;
				margin-bottom: 8rpx;
			}
			.id{
				line-height: 40rpx;
				text-align: center;
			}
		}
		
		&-btn{
			.pay{
				width: 400rpx;
				height: 60rpx;
				line-height: 60rpx;
				border-radius: 8rpx;
				background-color: rgba(235, 112, 9, 100);
				color: #FFFFFF;
				text-align: center;
			}
		}
	}
</style>
