<template>

		
	<view class="detail">
		<!-- <view class="nav-bar-back">
		    <image class="nav-bar-back-icon" src="/static/discover/back.png" @click="goBack"></image>
		    <view class="nav-bar-title">{{title}}</view>
		</view> -->
		<view v-if="from==1">
			<view class="top">
					<image  @click="goBack" class="back" src="/static/discover/back.png"></image>
					<view class="title">活动详情</view>
					<image @click="delPost" class="empty1" src="/static/discover/delete.png"></span>
			</view>
		</view>
		<view v-if="from!=1">
		<view class="top">
				<image  @click="goBack" class="back" src="/static/discover/back.png"></image>
				<view class="title">活动详情</view>
				<span class="empty"></span>
		</view>
		</view>
		<view class="school-activity-icon-wrapper"><image class="school-activity-icon" :src="this.picture"></image></view>
		<view class="activity-production">
			<image class="activity-production-icon" src="/static/discover/production.png"></image>
			<text class="activity-title">活动介绍:</text>
			<view class="production-detail">{{production}}</view>
		</view>
		<view class="activity-object">
			<image class="activity-production-icon" src="/static/discover/object.png"></image>
			<text class="activity-title">活动对象:</text>
			<view class="production-detail">{{object}}</view>
		</view>
		<view class="activity-time">
			<image class="activity-production-icon" src="/static/discover/time.png"></image>
			<text class="activity-title">活动时间:</text>
			<view class="production-detail">{{time}}</view>
		</view>
		<view class="activity-place">
			<image class="activity-production-icon" src="/static/discover/place.png"></image>
			<text class="activity-title">活动地点:</text>
			<view class="production-detail">{{place}}</view>
		</view>
		<view class="activity-contact">
			<image class="activity-production-icon" src="/static/discover/contact.png"></image>
			<text class="activity-title">联系方式:</text>
			<view class="production-detail">{{contact}}</view>
		</view>
		<!-- 是否删除 -->
				<uni-popup ref="alertDialog" type="dialog">
					<uni-popup-dialog  cancelText="取消" confirmText="确定" title="警告" content="确定删除该活动吗？"
						@confirm="dialogConfirm"></uni-popup-dialog>
				</uni-popup>
		<!-- <image @click="getData" class="activity-production-icon" src="/static/discover/place.png"></image> -->
		
	</view>
</template>

<script>
	export default {
	    data() {
	      return {
			id:'1',
	        title: '',
			production:'',
			object:'',
			time:'',
			place:'',
			contact:'',
			activityId: '',
			picture:'',
			from:''//判断页面来源
	      }
	    },
	    methods: {
	      goBack() {
	        uni.navigateBack({
	          delta: 1
	        })
	      },
		  deleteActivity() {
		    uniCloud.callFunction({
		    		name: 'fe-find-deleteActivity',
		    		data: { activityId:this.activityId
		    		}
		    	})
		    	.then(res => {
					console.log(res);
		    	});
				uni.showToast({
				title: '删除成功',
				duration: 1000,
				success: () => {
				     setTimeout(() => {
				  uni.navigateBack()
				     }, 1000)
				}
				    })
		  },
		  getData() {
			  uniCloud.callFunction({
			  		name: 'fe-find-activityDetail',
			  		data: { activityId:this.activityId
			  		}
			  	})
			  	.then(res => {
					console.log(res);
					this.title = res.result.data.title,
					this.production=res.result.data.content,
					this.picture=res.result.data.picture,
					this.object=res.result.data.invitee,
					this.time=res.result.data.startDate+'——'+res.result.data.endDate,
					this.place=res.result.data.place,
					this.contact=res.result.data.contact
			  	});
		  },delPost() {
				this.$refs.alertDialog.open();
			},
			dialogConfirm() {
				console.log('点击确认')
				this.$refs.alertDialog.close();
				this.deleteActivity();
			},
			dialogClose() {
				console.log('点击关闭')
				this.$refsalertDialog.close();
			}
	    },
		onLoad(e) {
			this.from=e.from;
			this.activityId=e.activityId;
			this.getData();
		}
		// mounted() {
			
		// 	this.activityId = this.$route.query.activityId
		// }
	  }
</script>

<style>
		.top {
			width: 100%;
			height: 50px;
			background-color: #EDEEF0;
			text-align: center;
		}
		
		.back {
			width: 40px;
			height: 30px;
			margin-top: 10px;
			margin-bottom: 10px;
			float: left;
			margin-left: 10px;
		}
		
		.empty{
			width: 40px;
			height: 30px;
			margin-top: 10px;
			margin-bottom: 10px;
			float: right;
			margin-right: 10px;
		}
		.empty1{
			width: 40px;
			height: 30px;
			margin-top: 12px;
			margin-bottom: 10px;
			float: right;
			margin-right: 10px;
		}
		.title {
				margin-top: 15px;
				display: inline-block;
			}
	  /* .nav-bar-back {
	    display: flex;
	    align-items: center;
	    justify-content: center;
	    width: 100%;
	    height: 60px;
		background-color: #EDEEF0;
	  }
	  .nav-bar-back-icon {
	    width: 40px;
	    height: 30px;
	  }
	  .nav-bar-title {
	    flex: 1;
	    text-align: center;
	    font-size: 24px;
	    font-weight: bold;
	    color: #F1992D;
	  } */
	  .school-activity-icon-wrapper{
			margin-top: 10px;
			display: flex;
			justify-content: center;
			align-items: center;
	  }
	  
	  .school-activity-icon {
	    width: 89%;
	    height: 200px;
	    margin: 0px;
		padding: 0px;
		border-radius: 15px;
	  }
	  .activity-production{
	  		  margin-top: 10px;
	  }
	  .activity-title {
	    font-size: 20px; /* 调整字体大小为24像素 */
	  }

	  .activity-object{
	  	  margin-top: 10px;
	  }
	  .activity-time{
	  	  margin-top: 10px;
	  }
	  .activity-place{
	  	  margin-top: 10px;
	  }
	  .activity-contact{
	  	  margin-top: 10px;
	  }
	  .activity-production-icon{
		  width: 40px;
		  height: 35px;
		  margin-left: 30px;
		  margin-top:8px;
		  margin-bottom: -5px;
	  }
	  .production-detail{
	      width: 85%;
	      background-color: rgb(245 154 35 / 30%);
	      border-radius: 5px;
		  margin-left: 20px;
		  margin-top: 5px;
		  /* 文字换行处理 */
	      word-wrap:break-word;
	      word-break:break-all;
		  padding-left: 7px;
		  padding-right: 7px;
		  padding-top:5px;
	  }

</style>
