<template>
	<view class='container'>
		<view class="sv-y">
			<scroll-view scroll-y>
				<view class="flex-column">
					<view style="position: relative;">
						<view style="width: 100%;">
							<u-swiper :list="swiperList" circular :autoplay="true" radius="5" bgColor="#0F0F0F"
								height="460"></u-swiper>
						</view>
						<u-navbar :autoBack="true" :placeholder="false" bgColor="transparent" leftIconColor="#FFFFFF">
						</u-navbar>
						<view class="pt-100 pb-20 plr-24"
							style="width: 100%; color: white;position:absolute;left: 0rpx;bottom: 0rpx;background: linear-gradient( 180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.75) 49%, #000000 100%);">
							<text class="fs-36">{{partyobj.name}}</text>
						</view>
					</view>
					<view class="flex-column pad-24">
						<view class="flex flex-between align-center">
							<text class="fs-28" style="color:#878787;">{{partyobj.startTime}}</text>
							<button open-type="share" style="background-color: transparent; border: none;">
								<image class="wh-52" src="/static/icon_hdxq_fx.png"></image>
							</button>
						</view>
						<text class="fs-42 mt-10" style="color:#FD46B9;">{{partyobj.mdmc}}</text>
					</view>
					<view class="flex-column mlr-24 mt-25 br-10 pad-24 fs-24"
						style="color: #878787;background-color: #171717;">
						<text style="color: white;">主办方</text>
						<text class="fs-28 mt-10">{{partyobj.zbfMes}}</text>
						<text class="mt-36" style="color: white;">场地信息</text>
						<text class="fs-28 mt-10">{{partyobj.address}}</text>
					</view>
					<view class="flex-column mlr-24 mt-25 br-10 pad-24 fs-24"
						style="color: #878787;background-color: #171717;">
						<image class="w-153 h-40" src="/static/icon_hdxq_text.png"></image>
						<u-parse :content="partyContent"></u-parse>
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="h-100 mtb-30 mlr-24">
			<view @click="isEnd()" class="fullscreen-btn" style="background-color: #FE42C2;">
				<text>立即预订</text>
			</view>

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

<script>
	export default {
		data() {
			return {
				swiperList: [],
				partyobj: '',
				partyContent: ""
			};
		},
		onLoad(options) {
			let list = JSON.parse(decodeURIComponent(options.data))
			this.$api.getPartyByDetail(list.id).then(res => {
				this.partyContent = res.data.partyContent.replace('<img', '<img style="margin:auto;width:50%;"');
				this.partyobj = res.data
				this.swiperList = res.data.image.split(',');
			})
		},
		methods: {
			onShareAppMessage() {
				return {
					title: "花海",
					path: "/",
					success: (res) => {
						this.$u.toast({
							title: '转发成功',
							duration: 1000
						})
					},
					fail: () => {

					}
				}
			},
			isEnd() {
				// if (!uni.getStorageSync('token')) {
				// 	this.$wskj.to('/pages/login/wechatlogin');
				// 	return
				// }
				// 输入的年月日时分字符串
				let dateString = this.partyobj.endTime;
				// 将字符串转换为 Date 对象
				let date = new Date(dateString.replace(/-/g, "/")); // 使用斜杠替换破折号以确保兼容性
				// 获取时间戳（单位：毫秒）
				let endTimestamp = date.getTime();
				// 获取当前时间戳（单位：毫秒）
				let timestamp = new Date().getTime();
				if (timestamp > endTimestamp) {
					this.$u.toast('活动已结束')
				} else {
					this.$wskj.to('/pagesMain/pages/ljyd?data=' + encodeURIComponent(JSON.stringify(this.partyobj)))
				}
			}

		},
	};
</script>

<style scoped>
	.container {
		width: 100%;
		height: 100%;
		background: #0F0F0F;
		background-color: ;
		display: flex;
		flex-direction: column;
	}
</style>