<template>
	<view class="head">
		<lf-nav :spreadOut="false" :showIcon="true" bgColor="transparent" titleColor="white" title="我的报名"></lf-nav>
		<view class="bg-left"></view>
		<view class="bg-right"></view>
			<view class="register-card">
				<view class="lf-flex lf-p-l-40 register-content">
					<image class="register-head" :src="activity_details.user.avatar" mode="aspectFill"></image>
					<view class="lf-color-black lf-m-l-21 lf-font-32" v-if="activity_details.user.nick_name">
						{{activity_details.user.nick_name}}
					</view>
				</view>
				<view class="lf-p-l-40">
					<view class="lf-font-36 lf-color-black lf-font-bold ">{{activity_details.activity.name}}</view>
					<view class="lf-m-t-30">
						<view class="lf-m-t-20">
							<text class="lf-color-777 lf-font-28">活动时间：</text><text class="lf-font-28 lf-color-black lf-m-l-10">{{activity_details.activity.apply_start}}-{{activity_details.activity.apply_end}}</text>
						</view>
						<view class="lf-m-t-20 lf-flex">
							<text class="lf-color-777 lf-font-28">活动内容：</text>
							<rich-text class="lf-color-black lf-m-l-10" :nodes="activity_details.activity.content" v-if="activity_details.activity.content"></rich-text>
						</view>
						<view class="lf-m-t-20">
							<text class="lf-color-777 lf-font-28">报名时间：</text><text class="lf-font-28 lf-color-black lf-m-l-10">{{activity_details.created_at}}</text>
						</view>
						<view class="lf-m-t-20">
							<text class="lf-color-777 lf-font-28">报名费用：</text>
							<text class="lf-font-28 lf-color-black lf-m-l-10" v-if="activity_details.activity.price == 0">免费</text>
							<text class="lf-font-28 lf-color-black lf-m-l-10" v-else>{{activity_details.activity.price}}</text>
						</view>
						<view style="margin-top: 60rpx;display: flex;justify-content: center;" v-if="$isRight(activity_details)">
							<view class="lf-flex-column">
								<lf-qrcode :options="config.qrc"></lf-qrcode>
								<view class="lf-font-28 lf-row-center" style="color: #15716E;">{{activity_details.state}}</view>
							</view>
						</view>
						<view style="margin-top: 60rpx;">
							<view class="lf-font-32 lf-color-black">
								报名信息
							</view>
							<view class="lf-m-t-30">
								<text class="lf-font-28 lf-color-777">报名人:</text><text class="lf-font-28 lf-color-777 lf-m-l-10">{{activity_details.name}}</text>
							</view>
							<view class="lf-m-t-30">
								<text class="lf-font-28 lf-color-777">手机号码:</text><text class="lf-font-28 lf-color-777 lf-m-l-10">{{activity_details.phone}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
	</view>
</template>

<script>
	import lfQrcode from '@/components/lf-code/lf-qrcode.vue';
	export default {
		data() {
			return {
				config: {
					bar: {
						code: 'E01181016286106',
						color: '#000', // 条形码的颜色
						bgColor: '#FFFFFF', // 背景色
						width: 586, // 宽度
						height: 210 // 高度
					},
					qrc: {
						code: "",
						size: 352, // 二维码大小
						level: 4, //等级 0～4
						bgColor: '#FFFFFF', //二维码背景色 默认白色
						// border: {
						// 	color: ['#8A2387', '#F27121'], //边框颜色支持渐变色
						// 	lineWidth: 3, //边框宽度
						// },
						// img: '/static/logo.png', //图片
						// iconSize: 40, //二维码图标的大小
						color: '#000000', //边框颜色支持渐变色
					}
				},
				activity_id: 0,
				activity_details: ''
			}
		},
		components: {lfQrcode},
		onLoad(e) {
			this.activity_id = e.activity_id;
			this.getMyActivetiDetails();
		},
		methods: {
			getMyActivetiDetails() {
				this.$http
				    .get({
				        api: 'api/activity/my_detail',
						data: {
							id: this.activity_id
						},
						header: {
						    Authorization: this.$cookieStorage.get('user_token')
						},
				    })
				    .then(res => {
				        if (res.data.code == 200) {
				            if (res.data.status) {
				        		this.activity_details = res.data.data;
								
								this.config.qrc.code = JSON.stringify({
									u_id: this.activity_details.user_id,
									a_id: this.activity_details.activity_id
								})
								
								
								
				               console.log('活动详情',this.activity_details);
				            } else {
				                wx.showModal({
				                    content: res.message || '请下拉页面刷新重试',
				                    showCancel: false
				                });
				            }
				        } else {
				            wx.showModal({
				                content: '请下拉页面刷新重试',
				                showCancel: false
				            });
				        }
				        wx.hideLoading();
				    })
				    .catch(() => {
				        wx.hideLoading();
				        wx.showModal({
				            content: '请求失败',
				            showCancel: false
				        });
				    });
			}
		}
	}
</script>

<style>
	page {
		height: 100%;
	}
</style>
<style lang="scss" scoped>
	.register-content {
		margin-top: -42rpx;
		margin-bottom: 50rpx;
	}
	.register-head {
		width: 160rpx;
		height: 160rpx;
		box-shadow: 0px 2rpx 8rpx 1rpx rgba(21, 113, 110, 0.2);
		border: 5rpx solid #FFFFFF;
		border-radius: 50%;
	}
	.register-card {
		width: 686rpx;
		height: max-content;
		margin-top: 240rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		padding-bottom: 40rpx;
	}
	.head {
		width: 750rpx;
		height: max-content;
		background: linear-gradient(270deg, #187B7A 0%, #2FAAA7 100%, #22A2A0 100%);
		position: relative;
		display: flex;
		align-items: flex-end;
		box-sizing: border-box;
		padding: 60rpx 32rpx 110rpx;
		color: #222222 !important;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.bg-left{
		position: absolute;
		width: 196rpx;
		height: 196rpx;
		border-radius: 50%;
		background-color: rgba(255,255,255,0.04);
		left: -92rpx;
		bottom: 60rpx;
	}
	.bg-right{
		position: absolute;
		width: 520rpx;
		height: 520rpx;
		border-radius: 50%;
		background-color: rgba(255,255,255,0.04);
		right: -168rpx;
		top: -142rpx;
	}
</style>
