<template>
	<view>
		<view class="header">
			<image class="header-image" :src="list.main_image"></image>
		</view>

		<view class="main">
			<view class="main-title">活动信息</view>
			<view class="main-card">
				<view class="card-item">
					<view class="item-name">活动标题：</view>
					<view class="item-content" style="color: black;">{{list.title}}</view>
				</view>
				<view class="card-item">
					<view class="item-name">开始时间：</view>
					<view class="item-content">{{list.start_time}}</view>
				</view>
				<view class="card-item">
					<view class="item-name">活动地址：</view>
					<view class="item-content">{{list.address}}</view>
				</view>
				<!-- <view class="card-item">
					<view class="item-name">活动内容：</view>
					<view class="item-content"><u-parse :content="list.content"></u-parse></view>
				</view> -->
				<view class="card-item">
					<view class="item-name">参加人数：</view>
					<view class="item-content">{{list.join_num}}</view>
				</view>
			</view>
		</view>
		
		<view class="actDetail">
			<view class="actDetail-title">活动详情</view>
			<view class="actDetail-content">
				<u-parse :content="list.content"></u-parse>
			</view>
		</view>

		<view class="bottomEmpty"></view>

		<view class="bottomArea">
			<view class="bottomButton" v-if="join_status == false" @tap="submit">立即报名</view>
			<view class="bottomButton-exist" v-if="join_status == true">已报名</view>
		</view>
	</view>


</template>

<script>
	var _this;
	export default {
		data() {
			return {
				actId: 0,
				list: {},
				join_status: false,
				userinfo: null,
			}
		},
		onLoad(option) {
			_this = this;
			_this.actId = option.id || 0;
			_this.userinfo = uni.getStorageSync('userinfo') || false;
			_this.getMore();
		},
		methods: {
			pageRefresh: function() {
				_this.getMore();
			},
			
			submit() {
				_this.$req.ajax({
					path: "activity/joinActivity",
					data: {
						id: _this.actId,
						userid: _this.userinfo.id,
					}
				}).then((data) => {
					_this.pageRefresh();
					console.log("加入", data)
				}).catch((err) => {
					uni.showModal({
						title: '信息提示',
						content: err,
						showCancel: false
					});
				});
			},

			getMore() {
				_this.$req.ajax({
					path: "activity/detailActivity",
					data: {
						id: _this.actId,
						userid: _this.userinfo.id,
					}
				}).then((data) => {
					_this.join_status = data.join_status
					_this.list = data.list;
					console.log("详情数据", data)
				}).catch((err) => {
					uni.showModal({
						title: '信息提示',
						content: err,
						showCancel: false
					});
				});
			}
		}
	}
</script>

<style lang="scss">
	.header {
		margin: 30rpx 20rpx;

		.header-image {
			width: 100%;
			height: 400rpx;
			border-radius: 20rpx;
		}
	}

	.main {
		margin: 0 20rpx 30rpx;

		.main-title {
			font-size: 35rpx;
			font-weight: bold;
			margin-bottom: 30rpx;
		}

		.main-card {
			padding: 0 20rpx;
			border-radius: 20rpx;
			background-color: #FFFFFF;
			box-shadow: 5rpx 5rpx 10rpx 2rpx rgba(149, 149, 149, 0.3);

			.card-item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 30rpx 0;
				border-bottom: 1rpx solid #f1f1f1;

				.item-name {
					width: 25%;
				}

				.item-content {
					flex: 1;
					text-align: right;
					color: #999999;
				}

				// .item-content {
				// 	flex: 1;
				// 	text-align: right;
				// 	overflow: hidden;
				// 	text-overflow: ellipsis;
				// 	-webkit-line-clamp: 1;
				// 	display: -webkit-box;
				// 	-webkit-box-orient: vertical;
				// }
			}
		}
	}
	
	.actDetail {
		margin: 0 20rpx;
		padding: 20rpx 20rpx;
		border-radius: 20rpx;
		background-color: #FFFFFF;
		box-shadow: 5rpx 5rpx 10rpx 2rpx rgba(149, 149, 149, 0.3);
		
		.actDetail-title {
			font-size: 35rpx;
			font-weight: bold;
			margin-bottom: 30rpx;
		}
	}

	.bottomEmpty {
		margin-top: 80rpx;
		height: 130rpx;
	}

	.bottomArea {
		position: fixed;
		bottom: 0;
		z-index: 100;
		width: 100%;
		height: 130rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #FFFFFF;
		box-shadow: -10rpx -12rpx 12rpx 2rpx rgba(52, 85, 73, 0.16);

		.bottomButton {
			margin: 0 28rpx;
			width: 696rpx;
			height: 90rpx;
			line-height: 90rpx;
			background: #CA151C;
			font-size: 33rpx;
			text-align: center;
			color: #FFFFFF;
			border-radius: 10rpx;
		}

		.bottomButton-exist {
			margin: 0 28rpx;
			width: 696rpx;
			height: 90rpx;
			line-height: 90rpx;
			background: #e8e8e8;
			font-size: 33rpx;
			text-align: center;
			border-radius: 10rpx;
		}
	}
</style>