<template>
	<view class="content">
		<image v-if="detail.pics" :src="detail.pics.split(',')[1]" mode="widthFix" class="top-img"></image>
		<view class="add-if">
			<view class="jj" v-if="!detail.partake">
				<view class="if-tit">
					购买7万元宏根蒂品牌红酒成为
				</view>
				<view class="if-level">
					品牌经纪人
				</view>
				<view class="if-status">
					{{userInfo.level > 0 ?'您已满足参与条件': '您未满足参与条件'}}
				</view>
				<view class="add-btn" :class="{'cant': userInfo.level == 0}" @click="add()">
					立即参与
				</view>
			</view>
			<view v-else>
				<view class="flex">
					<image class="action_icon" src="../../static/img/action_left_icon.png" mode="widthFix"></image>
					<view class="text-white action_title">
						参与进度
					</view>
					<image class="action_icon" src="../../static/img/action_right_icon.png" mode="widthFix"></image>
				</view>
				<view class="jj margin-t-20">
					<view class="dqyj">
						当前业绩量: {{detail.partake.money}}
					</view>
					<view class="show-jdt">
						<image src="../../static/img/action_bg.png" mode="" style="width: 601rpx;"></image>
						<view class="jdt">
							<view class="jdt-wrap">
								<view class="jdt-wc" :style="{'width': detail.partake.money == 0? '0%':(detail.partake.money*1 >= detail.number*1 ? '100%': (((detail.partake.money*1)/(detail.number*1)*100).toFixed(2) + '%')) }">
									
								</view>
							</view>
						</view>
						<view class="jdt-tit">
							业绩量达到{{detail.number}}
						</view>
					</view>
					
				</view>
			</view>

		</view>
		<view class="add-recoed flex">
			<view class="add-left">
				<image src="../../static/icon/time.png" mode="widthFix"></image>参与记录
			</view>
			<view class="add-left add-right" @click="goDetail()">
				查看详情<image src="../../static/icon/write-go.png" mode="widthFix"></image>
			</view>
		</view>
		<view class="jj-wrap">
			<view class="jj-tit">
				活动说明
			</view>
			<view class="jj" v-html="detail.content"></view>
		</view>
		<view class="" style="height: 60rpx;">

		</view>
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import empty from '@/components/empty';
	import {
		getActionDetail,
		addAction
	} from '@/api/index.js'
	import {
		getUser
	} from '@/api/user.js'
	export default {
		components: {
			uniLoadMore,
			empty
		},
		data() {
			return {
				userInfo: {

				},
				detail: {}
			}
		},
		onLoad(opt) {
			this.id = opt.id
			this.getUser()
		},
		onShow() {

		},
		onReachBottom() {

		},
		onReady() {

		},
		onBackPress() {
			uni.switchTab({
				url: '/pages/index/index'
			})
			return true;
		},
		methods: {
			goDetail() {
				uni.navigateTo({
					url: '/pages/index/addList'
				})
			},
			getUser() {
				getUser().then(res => {
					this.userInfo = res.data
					this.getActionDetail()
				})
			},
			getActionDetail() {
				let that = this
				getActionDetail({

				}, that.id).then(res => {

					console.log(res);
					that.detail = res.data
				})
			},
			add() {
				uni.showLoading({
					title: '报名中',
					mask: true
				});
				addAction({
					out_id: this.id
				}).then(res => {
					uni.hideLoading()
				}).catch(() => {
					uni.hideLoading()
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		height: auto;
		min-height: 100%;
		background-color: #fdd717;
	}

	.add-if {
		width: 693rpx;
		margin: 20rpx auto;
		border: 3rpx solid #FED888;
		background: linear-gradient(0deg, #FF9805, #FFB606);
		border-radius: 20rpx;
		padding: 20rpx;

		.action_title {
			font-size: 44rpx;
		}

		.action_icon {
			height: 22rpx;
			width: 46rpx;
		}

		.if-tit {
			font-size: 43rpx;
			font-weight: bold;
			text-align: center;
			color: #6B4216;
		}

		.if-level {
			width: 274rpx;
			height: 76rpx;
			border: 2rpx solid #6B4216;
			border-radius: 14rpx;
			text-align: center;
			line-height: 76rpx;
			font-size: 37rpx;
			font-weight: bold;
			color: #6B4216;
			margin: 40rpx auto 30rpx;
		}

		.if-status {
			font-size: 26rpx;
			font-weight: 500;
			color: #666666;
			text-align: center;
		}

		.add-btn {
			width: 366rpx;
			height: 80rpx;
			background: linear-gradient(0deg, #FFB605, #FFD778);
			border-radius: 40rpx;
			line-height: 80rpx;
			font-size: 36rpx;
			font-weight: 500;
			color: #6B4216;
			text-align: center;
			margin: 30rpx auto 20rpx;

			&.bg-gray {
				color: #FFFFFF;
			}
		}
	}

	.add-recoed {
		width: 693rpx;
		height: 104rpx;
		border: 3rpx solid #FED888;
		background: linear-gradient(0deg, #FF9805, #FFB606);
		border-radius: 35rpx;
		margin: 20rpx auto;
		padding: 0 32rpx;

		.add-left {
			display: flex;
			align-items: center;

			image {
				width: 38rpx;
				margin: 0 15rpx 0 0;
			}

			font-size: 36rpx;
			font-weight: bold;
			color: #FFFFFF;
		}

		.add-right {
			font-size: 30rpx;
			font-weight: 500;
			color: #FFFFFF;

			image {
				width: 15rpx;
				margin: 0 0 0 15rpx;
			}
		}
	}

	.action-wrap {
		width: 704rpx;
		height: 330rpx;
		margin: 20rpx auto;

		image {

			width: 704rpx;
			height: 330rpx;
			border-radius: 20rpx;
		}
	}

	.jj-wrap {
		width: 693rpx;
		// height: 100rpx;
		padding: 49rpx 0 29rpx;
		border: 3rpx solid #FED888;
		background: linear-gradient(0deg, #FF9805, #FFB606);
		border-radius: 35rpx;
		margin: auto;

		.jj-tit {
			margin-bottom: 20rpx;
			font-size: 44rpx;
			font-weight: bold;
			color: #FFFFFF;
			text-align: center;
			position: relative;

			&::before {
				content: '';
				position: absolute;
				bottom: 0;
				left: 0;
				right: 0;
				margin: auto;
				width: 418rpx;
				height: 13rpx;
				background: linear-gradient(0deg, #FFCA4E, #F3F4AB);
				border-radius: 6rpx;
			}
		}

	}

	.jj {
		background-color: #fff;
		width: 653rpx;
		margin: auto;
		border-radius: 20rpx;
		border: 3px solid #FCE791;
		padding: 20rpx;
	}

	.top-img {
		width: 750rpx;
	}

	.cant {
		background: #D3D3D3 !important;
		color: #fff !important;
	}
	.dqyj {
		font-size: 32rpx;
		font-weight: bold;
		color: #6B4216;
		padding: 35rpx 0;
		text-align: center;
	}
	.show-jdt {
		position: relative;
		height: 120rpx;
		image {
			height: 120rpx;
		}
		.jdt-tit {
			font-size: 17rpx;
			font-weight: bold;
			color: #B3703D;
			text-align: right;
			padding-right: 20rpx;
			position: absolute;
			bottom: 10rpx;
			right: 0;
		}
		.jdt {
			position: absolute;
			bottom: 47rpx;
			left: 0;
			right: 0;
			margin: auto;
			
			width: 577rpx;
			height: 28rpx;
			background: #B3703D;
			border: 2rpx solid #FFFFFF;
			box-shadow: 4rpx 9rpx 5rpx 0px rgba(0,0,0,0.32);
			border-radius: 14rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			
			.jdt-wrap {
				width: 555rpx;
				height: 10rpx;
				border-radius: 5rpx;
				background: #bbb;
				position: relative;
				
				.jdt-wc {
					height: 10rpx;
					background: linear-gradient(0deg, #ECCF97, #FFF7E0, #EBCD93);
					border-radius: 5rpx;
				}
				
			}
			
		}
	}
	
</style>
