<template>
	<view>
		<statusBar :item="navBarData"></statusBar>
		<view class="activeBox" v-for="(item,index) in activeList" :key="index">
			<view class="teaching_case" @click="gotoActdetail" :data-index="index">
				<view class="img">
					<!-- <image src="https://teacherapi.cocorobo.cn/teaching-file/static//activity/bg2.png" mode="aspectFill"></image> -->
					<image :src="item.pic" mode="aspectFill"></image>

				</view>

				<view class="right">
					<view class="title">
						<view class="tag bqZ-font">类型</view>
						<text class="three-font" style="font-weight: 600;">{{ item.acName }}</text>
					</view>

					<view class="introduce">
						<view class="money fNum-font"><text class="three-font">￥</text> {{ item.cost }}</view>
					</view>

					<view class="operate">
						<view class="left">

							<view class="person">浏览0 · 订阅0 · 收藏0 · 已购0</view>
						</view>

						<view class="Oright">
							<view class="text">查看详情</view>
							<view class="arrow">
								<image src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right-blue.png"
									mode="aspectFill"></image>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="controls">
				<view class="controls_btns">
					<button @click="gotoEdit(index)">编辑</button>
					<button @click="actDelete(index)">删除</button>
				</view>
			</view>
		</view>
		<view class="" style="width: 100%;height: 50rpx;"></view>
		
		<!-- 弹窗 -->
		<view>
			<view class="mask" v-show="showPopup" @click="closePopup"></view>
			<view class="popup-container" v-show="showPopup">
				<view class="popup">
					<view class="header">
						<text>确认删除</text>
					</view>
					<view class="footer">
						<button class="cancel-btn" @click="closePopup">取消</button>
						<button class="confirm-btn" @click="confirm">确认</button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				navBarData: {
					title: '我的发布', //导航栏标题
					btn: 1 //是否显示返回按钮 0不显示  1 显示
				},
				showPopup: false,
				deleteAcId : '',
				activeList: [
					// {
					// 	pic: "https://teacherapi.cocorobo.cn/teaching-file/static//img/1695656271245-image.png",
					// 	count: "3842",
					// 	cost: "299",
					// 	acName: "丽湖职教双创教育国际虚拟教研室启动大会暨双创教育国际论坛圆满举行",
					// 	intro: "丽湖职教双创教育国际虚拟教研室为立足全国，辐射海外的国际化教研室，围绕创新创业教育的人才培养与课程建设开展深度研究。教研室以贯彻落实立德树人根本任务，通过加强跨专业、跨校、跨地域的教研交流，推动高校协同打造国际化的精品教学资",
					// }, 
				],
			};
		},
		methods: {
			getpublish() {
				let data={
					openid:uni.getStorageSync('oId'),
					del: 0
				}
				this.$request('/selectMyPublish', "POST", data).then(res => {
					console.log(res[0]);
					this.activeList = res[0]
					if (this.activeList.length < 1) {
						uni.showToast({
							title: '没有您发布的内容',
							icon: 'none'
						});
						return;
					}
				})
			},
			gotoActdetail(e) {
				let edata = e.currentTarget.dataset['index'];
				const clickedAcId = this.activeList[edata].acId;
				const type = this.activeList[edata].type;
				const isShow = false
				uni.navigateTo({
					url: "/pages/activityDetail/activityDetail?acId=" + clickedAcId + "&ty=" + type + "&isShow=" + isShow,
				});
			},
			gotoEdit(index) {
				const clickedAcId = this.activeList[index].acId;
				const type = this.activeList[index].type;
				// console.log(clickedAcId);
				uni.navigateTo({
					url: "/pages/publish/publish?acId=" + clickedAcId + "&ty=" + type,
				});
			},
			actDelete(index) {
				this.deleteAcId = this.activeList[index].acId;
				this.showPopup = true; //显示弹窗
			},
			confirm() {
				let data={
					id: this.deleteAcId,
				}
				console.log(this.deleteAcId);
				this.$request('/deleteMyPublish', "POST", data).then(res => {
					// console.log(res);
					console.log('删除成功');
					this.getpublish()
				})
				this.closePopup()
			},
			closePopup() {
				// 取消操作
				this.showPopup = false
				this.deleteAcId = null
			},
		},
		onShow() {
			this.getpublish();
		}
	}
</script>

<style lang="scss" scoped>
	.activeBox {
		width: 100%;
		background-color: #fff;
		&:first-child{
			padding: 10px 0 0 0;
		}

		.teaching_case {
			display: flex;
			justify-content: space-between;
			padding: 10px 10px;
			border-top: 1px solid #E7E7E7;

			.img {
				width: 160rpx;
				height: 160rpx;

				image {
					width: 160rpx;
					height: 160rpx;
					border-radius: 10rpx;
				}
			}

			.right {
				padding-left: 15px;
				flex: 1;
				display: flex;
				flex-direction: column;
				// align-content: flex-end;
				justify-content: space-between;

				.title {
					display: flex;
					align-items: center;

					margin-bottom: 5px;

					.tag {
						border: 1px #00b2b6 solid;
						// font-size: 20rpx;
						width: 64rpx;
						height: 38rpx;
						display: flex;
						white-space: nowrap;
						justify-content: center;
						align-items: center;
						padding: 1rpx 4rpx;
						border-radius: 3px;
						margin-right: 10rpx;
						color: #00b2b6;
					}

					text {
						width: 190px;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}

				}

				.introduce {
					width: 230px;
					// font-size: 28rpx;
					// color: #a7a7a7;
					// margin-top: 8px;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;

					.money {
						color: #FFA338;
						font-weight: bold;
						font-size: 36rpx;
						line-height: 20px;
					}
				}

				.operate {
					display: flex;
					justify-content: space-between;
					// align-items: flex-end;
					align-items: baseline;
					// margin-top: 15px;

					.left {
						display: flex;
						flex-direction: row;
						justify-content: space-between;
						align-items: baseline;
						width: 330rpx;



						.person {
							color: #00000099;
							font-size: 20rpx;
							// margin-left: 6px;
						}
					}

					.Oright {
						width: 200rpx;
						display: flex;
						justify-content: flex-end;
						align-items: center;
						// flex-direction: row;
						// justify-content: space-around;
						// align-items: flex-end;

						.text {
							font-size: 24rpx;
							color: #3081E8;
						}

						.arrow {
							display: flex;
							justify-content: center;
							margin-top: 5rpx;

							image {
								width: 32rpx;
								height: 32rpx;
							}
						}
					}
				}
			}
		}

		.controls {
			display: flex;
			justify-content: flex-end;
			padding: 0 10px;
			border-top: 1px solid #E7E7E7;
			align-items: center;
			height: 45px;

			.controls_btns {
				display: flex;
				align-items: center;
				width: 115px;
				height: 35px;

				button {
					width: 96rpx;
					height: 48rpx;
					font-size: 24rpx;
					border-radius: 10rpx;
					border: 1px solid #3081E8;
					background-color: white;
					color: #3081E8;
					padding: 0;
					line-height: 23px;
				}

			}
		}
	}
	.mask {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.3);
		z-index: 999;
		// display: none;
	}
	
	.popup-container {
		position: fixed;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		width: 520rpx;
		height: 260rpx;
		z-index: 1000;
		// display: none;
	
		.popup {
			width: 100%;
			height: 100%;
			display: flex;
			flex-direction: column;
			background-color: #fff;
			border-radius: 16rpx;
	
			.header {
				flex: 1;
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;
				margin-top: 24px;
				font-size: 34rpx;
				font-weight: 600;
	
				image {
					width: 150rpx;
					height: 150rpx;
					margin-top: 15px;
					margin-bottom: 15px;
				}
			}
	
			.footer {
				flex: 1;
				display: flex;
				justify-content: space-around;
				align-items: end;
				padding-top: 17px;
	
				.cancel-btn {
					width: 259rpx;
					height: 100rpx;
					background-color: #F7F7F7;
					color: #000;
					font-size: 34rpx;
					text-align: center;
					border-radius: 0;
					border-bottom-left-radius: 16rpx;
					line-height: 50px;
				}
	
				.confirm-btn {
					width: 259rpx;
					height: 100rpx;
					background-color: #0081FE;
					color: #fff;
					font-size: 34rpx;
					text-align: center;
					border-radius: 0;
					border-bottom-right-radius: 16rpx;
					line-height: 50px;
				}
			}
		}
	}
</style>