<template>
	<view>
		<statusBar :item="navBarData"></statusBar>

		<view class="collectBox">
			<view class="collect_length">
				<text>共{{ classList.length }}条收藏</text>
			</view>
			<!-- <view class="classBox" @click="gotoWeb(index)" v-for="(item,index) in classList" :key="index"> -->
			<view class="classBox" v-for="(item,index) in classList" :key="index" @click="gotoDetail" :data-all="item">
				<view class="classTitle">
					<text>{{ item.acName }}</text>
					<image src="https://teacherapi.cocorobo.cn/teaching-file/static/mine/Collect_yellow.png"
						mode="aspectFill" @click.stop="coll" :data-e="item"></image>
					<!-- <image :src="collArr.includes(item.acId) ? pic2 : '' " style="width: 28rpx; height: 26rpx" mode="aspectFill"  @click="coll" :data-e="item"></image> -->

				</view>
				<view class="classContent">
					<view class="contentLeft">
						<view class="constDate">
							<text class="manage">类型</text>
							<text>|</text>
							<text class="c_data">{{item.dtime}}</text>
							<!-- <text class="c_time">21:07</text> -->
						</view>
						<view class="classIntro">
							<text>{{ item.brief }}</text>
						</view>
					</view>
					<view class="contentRight">
						<image :src="item.pic" mode="aspectFill"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				navBarData: {
					title: '我的收藏',
					btn: 1
				},
				collArr: [], 
				classList: [],
				
				
			};
		},
		methods: {
			getData() {
				
				let data = {
					oid: this.$store.state.user.openid, //用户id
					type: 0
				}
				this.$request('/selectOperator', 'POST', data).then(res => {
					console.log('获取收藏', res);
					
					this.classList = res[0]
				})
			},
			
			// 这里获取的活动肯定是已收藏的，就不用判断直接删除就可以了
			coll(event) {
				
				let aId = event.currentTarget.dataset.e.acId
				
				let data = {
					acid: aId,
					oid: this.$store.state.user.openid, //用户id
					ty: 0
				}
				
				this.$request('/deleteOperator', 'POST', data).then(res => {
					console.log(res);
					this.getData()
				})
			},
			// 跳转到详情页
			gotoDetail(e) {
				let data=e.currentTarget.dataset.all
				
				if(data.type<=1){
					uni.navigateTo({
						url: `/pages/activityDetail/activityDetail?acId=${data.acId}`,
					});
				}else{
					uni.navigateTo({
						url: `/pages/teachingDetail/teachingDetail?acId=${data.acId}`
					});
				}
			},
		},
		onShow() {
			this.getData()
		}
	}
</script>

<style lang="scss">
	.collectBox {
		margin: 0 30rpx;
		// margin-bottom: 30rpx;
		padding-bottom: 50rpx;

		.collect_length {
			width: 100%;
			height: 40rpx;
			font-size: 24rpx;
			font-weight: 400;
			color: #00000099;
			display: flex;
			align-items: center;
			margin-top: 6px;
			margin-bottom: 6px;
		}

		.classBox {
			width: 100%;
			height: 248rpx;
			background-color: #fff;
			border-radius: 20rpx;
			padding: 0 16rpx;
			margin-bottom: 20rpx;

			.classTitle {
				display: flex;
				padding-top: 15px;
				justify-content: space-between;
				margin-bottom: 6px;

				text {
					font-size: 32rpx;
					font-weight: 500;
					display: -webkit-box;
					word-break: break-all;
					text-overflow: ellipsis;
					overflow: hidden;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 1;
				}

				image {
					flex-shrink: 0;
					width: 32rpx;
					height: 32rpx;
				}
			}

			.classContent {
				width: 100%;
				display: flex;
				justify-content: space-between;

				.contentLeft {
					display: flex;
					flex-direction: column;

					.constDate {
						display: flex;
						margin-bottom: 6px;

						text {
							color: #00000066;
							font-size: 24rpx;
							font-weight: 400;

							&.manage {
								border: 1px #00B2B6 solid;
								font-size: 10px;
								display: flex;
								white-space: nowrap;
								justify-content: center;
								align-items: center;
								padding: 1px 6px;
								border-radius: 3px;
								margin-right: 10rpx;
								color: #00B2B6;
								font-weight: 600;
							}

							&:nth-child(2) {
								color: #E7E7E7;
								;
								margin-left: 4px;
							}

							&:nth-child(3) {
								margin-left: 6px;
							}

							&:nth-child(4) {
								margin-left: 6px;
							}
						}
					}

					.classIntro {
						width: 93%;

						text {
							color: #00000099;
							font-size: 28rpx;
							display: -webkit-box;
							word-break: break-all;
							text-overflow: ellipsis;
							overflow: hidden;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2;
							/*设置 需要显示的行数*/
							line-height: 23px;
						}
					}
				}

				.contentRight {
					image {
						width: 182rpx;
						height: 132rpx;
						border-radius: 8rpx;
					}
				}
			}

		}
	}
</style>