| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 | <template>	<view>		<statusBar :item="navBarData"></statusBar>		<view class="collectBox">			<view class="collect_length">				<span>共{{ collArr.length }}条收藏</span>			</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">				<view class="classTitle">					<span>{{ item.acName }}</span>					<image src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/Collect_yellow.png" mode="aspectFill" @click="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">							<span class="manage">类型</span>							<span>|</span>							<span class="c_data">{{item.Crdate}}</span>							<!-- <span class="c_time">21:07</span> -->						</view>						<view class="classIntro">							<span>{{ item.brief }}</span>						</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				}				this.$request('/selectColl', 'POST', data).then(res => {					this.collArr = JSON.parse(res[0][0].coll)					// let a=this.collArr.join(', ');					// return console.log({a});					let data = {						oid: this.$store.state.user.openid, //用户id						list: this.collArr					}					// return console.log(data);					this.$request('/selectCollList', 'POST', data).then(res => {						console.log(res);						// this.collArr=res[0]						this.classList = res[0]					})				})			},			// 这里获取的活动肯定是已收藏的,就不用判断直接删除就可以了			coll(event){				console.log(this.$store.state.user.openid);				let aId=event.currentTarget.dataset.e.acId				// 先获取用户收藏信息				let data={					oid:this.$store.state.user.openid, //用户id				}								this.$request('/selectColl','POST',data).then(res=>{										let colls=JSON.parse(res[0][0].coll)										// 把未取消收藏的数据提取出来					const newArray = colls.filter(item => item !== aId);					let arr3={						oid:this.$store.state.user.openid, //用户id						acid:JSON.stringify(newArray) 					}					this.$request('/updateColl','POST',arr3).then(res=>{						// 删除后重新获取数据进行渲染						this.getData()					})				})			},					},		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;				span {					font-size: 32rpx;					font-weight: 500;				}				image {					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;						span {							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%;						span {							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>
 |