yuanyiming 1 jaar geleden
bovenliggende
commit
21687961ff
4 gewijzigde bestanden met toevoegingen van 161 en 159 verwijderingen
  1. 132 54
      components/listBlock1/listBlock1.vue
  2. 13 79
      pages/index/index.vue
  3. 13 1
      pages/mineCollect/mineCollect.vue
  4. 3 25
      pages/teachingList/teachingList.vue

+ 132 - 54
components/listBlock1/listBlock1.vue

@@ -1,74 +1,140 @@
 <template>
-	<!-- <view class="teaching_case" v-for="(i,index) in classList" :key="index + 'a'" @click="" :data-index="index"> -->
-	<view class="listBlock1">
-		<view class="img cell-img">
-			<!-- 课程图片 -->
-			<slot name="pic"></slot>
-			<!-- <image :src="i.img" v-if="!item.btn" mode="aspectFill"></image> -->
-		</view>
-	
-		<view class="right">
-			<view class="">
-				<view class="title">
-					<view v-if="!item.btn" class="tag bqZ-font">类型</view>
-					
-					<text class="btn-font" v-if="!item.btn" style="">
-						<!-- 课程名称 -->
-						<slot name="tit"></slot>
-					<!-- {{i.className}} -->
-					</text>
-				</view>
-				<view v-if="!item.btn" class="introduce fwb-font">
-					<!-- 简介 -->
-					<slot name="intro"></slot>
-					<!-- {{ i.intro }} -->
-				</view>
-	
+	<view class="" >
+		<view class="listBlock1" v-for="(i,index) in classList" :key="index+'a'">
+			<view class="img cell-img">
+				<image :src="i.pic" mode="aspectFill"></image>
 			</view>
-	
-			<view class="operate">
-				<view class="left">
-					<view class="opr" style="padding-right: 25rpx">
-						<view class="icon">
-							<!-- 收藏按钮 -->
-							<slot name="Sicon"></slot>
-							<!-- <image src="http://43.139.158.220:5007/img/static/yym/Star 1 (Stroke).png"
-								style="width: 28rpx; height: 26rpx" mode="aspectFill"></image> -->
-						</view>
-						<text class="fz-font">收藏</text>
+				
+			<view class="right">
+				<view class="">
+					<view class="title">
+						<view  class="tag bqZ-font">类型</view>
+						
+						<text class="btn-font"  style="">
+							{{i.acName}}
+						</text>
 					</view>
-					<view class="opr">
-						<view class="icon">
-							<!-- 订阅按钮 -->
-							<slot name="Dicon"></slot>
-							<!-- <image src="http://43.139.158.220:5007/img/static/yym/Vector (Stroke).png"
-								style="width: 22rpx; height: 26rpx" mode="aspectFill"></image> -->
-						</view>
-						<text class="fz-font">订阅</text>
+					<view class="introduce fwb-font">
+						{{ i.brief }}
 					</view>
+				
 				</view>
-				<view class="">
-					<!-- 立即参与按钮 -->
-					<slot name="btn"></slot>
-					<!-- <button class="btn sBtn-font" disableEventPropagation="true" @click.stop="join">
-						立即参与
-					</button> -->
+				
+				<view class="operate">
+					<view class="left">
+						<view class="opr" style="padding-right: 25rpx"  @click="coll" :data-e="i">
+							<view class="icon">
+								<image :src="collArr.includes(i.acId) ? pic2 : pic "
+									style="width: 28rpx; height: 26rpx" mode="aspectFill"></image>
+							</view>
+							<text class="fz-font">收藏</text>
+						</view>
+						<view class="opr">
+							<view class="icon">
+								<image src="http://43.139.158.220:5007/img/static/yym/Vector (Stroke).png"
+									style="width: 22rpx; height: 26rpx" mode="aspectFill"></image>
+							</view>
+							<text class="fz-font">订阅</text>
+						</view>
+					</view>
+					<view class="">
+						<button class="btn sBtn-font" @click.stop="join">
+							立即参与
+						</button>
+					</view>
 				</view>
 			</view>
-	
 		</view>
+		
 	</view>
 </template>
 
 <script>
 	export default {
 		name:"listBlock1",
+		props: {
+			classList: {
+				type: Array,
+				default () {
+					return [];
+				},
+			}
+		},
+		// props:['classList'],
 		data() {
 			return {
-				
+				collArr:[],
+				// collArr.includes(i.acId) ? 'http://43.139.158.220:5007/img/static/yym/Star 1 (Stroke).png' : 'http://43.139.158.220:5007/img/static/yym/Vector (Stroke).png'
+				pic:'http://43.139.158.220:5007/img/static/yym/Star 1 (Stroke).png',
+				pic2:'https://teacherapi.cocorobo.cn/teaching-file/static//mine/Collect_yellow.png'
 			};
 		},
+		
 		methods:{
+			// 收藏事件
+			coll(event){
+				// console.log(event.currentTarget.dataset.e);
+				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=>{
+					// console.log('获取收藏信息',res);
+					// return console.log('获取收藏信息',res[0][0].coll=='');
+					let res2
+					let colls
+					if(res[0][0].coll!==null && res[0][0].coll !==""){
+						colls=JSON.parse(res[0][0].coll)
+						console.log('获取收藏信息',colls);
+						// 判断收藏表是否包含这个活动
+						res2 = colls.some((e)=>{
+							return e == aId
+						})
+						// console.log(res2);
+					}
+					
+					// return 	console.log('2',res2);
+					// 第一次存储返回值为null,然后存储收藏
+					if(res[0][0].coll==null || res[0][0].coll==""){
+						// 然后进行存储活动到用户coll字段
+						let arr={
+							oid:this.$store.state.user.openid, //用户id
+							acid:JSON.stringify([aId])
+						}
+						this.$request('/updateColl','POST',arr).then(res=>{
+							this.$request('/selectColl','POST',data).then(res=>{
+								this.collArr=JSON.parse(res[0][0].coll)
+							})
+						})
+					// 当数组中没有这个收藏活动时添加收藏
+					}else if(!res2){
+						colls.push(aId)
+						let arr2={
+							oid:this.$store.state.user.openid, //用户id
+							acid:JSON.stringify(colls) 
+						}
+						this.$request('/updateColl','POST',arr2).then(res=>{
+							this.$request('/selectColl','POST',data).then(res=>{
+								this.collArr=JSON.parse(res[0][0].coll)
+							})
+						})
+					// 取消收藏
+					}else if(res2){
+						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.$request('/selectColl','POST',data).then(res=>{
+								this.collArr=JSON.parse(res[0][0].coll)
+							})
+						})
+					}
+				})
+			},
 			join() {
 				const value = this.$store.state.user.openid;
 				if (value == '') {
@@ -93,15 +159,27 @@
 					}
 				}
 			},
-		}
+			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)
+					console.log('进来就显示',this.collArr);
+				})
+			}
+		},
+		// created () {
+		// 	this.getdata()
+		// }
 	}
 </script>
 
 <style lang="scss">
 	.listBlock1{
-	
 			display: flex;
 			justify-content: space-between;
+			// margin-bottom: 10px;
 			background-color: #ffffff;
 			padding: 20rpx 30rpx;
 			.img {

+ 13 - 79
pages/index/index.vue

@@ -44,31 +44,10 @@
 			</template>
 			<template #teaching>
 				<!-- <teaching-case :classList="classList"></teaching-case> -->
-				<!-- 推荐课程插槽组件 -->
-				<listBlock1 v-for="i in classList">
-					<template #pic>
-						<image :src="i.pic" mode="aspectFill"></image>
-					</template>
-					<template #tit>
-						{{i.acName}}
-					</template>
-					<template #intro>
-						{{ i.brief }}
-					</template>
-					<template #Sicon>
-						<image src="http://43.139.158.220:5007/img/static/yym/Star 1 (Stroke).png"
-							style="width: 28rpx; height: 26rpx" mode="aspectFill"></image>
-					</template>
-					<template #Dicon>
-						<image src="http://43.139.158.220:5007/img/static/yym/Vector (Stroke).png"
-							style="width: 22rpx; height: 26rpx" mode="aspectFill"></image>
-					</template>
-					<template #btn>
-						<button class="list1btn sBtn-font" @click.stop="join">
-							立即参与
-						</button>
-					</template>
-				</listBlock1>
+				<!-- 推荐课程组件 -->
+				<listBlock1 ref="listBlock1" :classList="classList"></listBlock1>
+				<!-- {{classList}} -->
+				<!-- {{activeList}} -->
 			</template>
 		</viewX-Case>
 		<view class="" style="height: 30rpx; width: 100%"> </view>
@@ -84,56 +63,8 @@
 					title: "首页", //导航栏标题
 					btn: 0, //是否显示返回按钮 0不显示  1 显示
 				},
-				activeList: [
-					// {
-					// 	img: "https://teacherapi.cocorobo.cn/teaching-file/static//img/1695656271245-image.png",
-					// 	count: "3842",
-					// 	className: "丽湖职教双创教育国际虚拟教研室启动大会暨双创教育国际论坛圆满举行",
-					// 	intro: "丽湖职教双创教育国际虚拟教研室为立足全国,辐射海外的国际化教研室,围绕创新创业教育的人才培养与课程建设开展深度研究。教研室以贯彻落实立德树人根本任务,通过加强跨专业、跨校、跨地域的教研交流,推动高校协同打造国际化的精品教学资",
-					// },
-					// {
-					// 	img: "https://teacherapi.cocorobo.cn/teaching-file/static//img/img1.png",
-					// 	count: "3842",
-					// 	className: "丽湖职教双创教育国际虚拟教研室2023年常规教研活动安排",
-					// 	intro: "为深入贯彻落实立德树人根本任务,提升教师教学育人能力,增强教师将现代信息技术与教育教学深度融合的能力,加强跨专业、跨校、跨地域的双创教研交流,推动职教创新创业教育改革纵深发展,由深圳职业技术学院创新创业学院、联合国教科文组织...",
-					// },
-					// {
-					// 	img: "https://teacherapi.cocorobo.cn/teaching-file/static//img/img3.png",
-					// 	count: "3842",
-					// 	className: "产教融合情境下的双创通识课程建设 | 丽湖职教双创教育国际虚拟教研室常规教研活动第2期顺利举行",
-					// },
-					// {
-					// 	img: "https://teacherapi.cocorobo.cn/teaching-file/static//yym/83b48be81d4ed9c93908737496f2a54.png",
-					// 	count: "3842",
-					// 	className: "丽湖职教双创教育国际虚拟教研室 • 常规教研活动 第9期",
-					// },
-				],
-				classList: [
-					// {
-					// 	img: "https://teacherapi.cocorobo.cn/teaching-file/static//img/jiaoxueship.jpg",
-					// 	className: "教学视频",
-					// 	intro: "课程简介:丽湖职教双创教育国际虚拟教研室教学视频",
-					// 	url: 'https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1210'
-					// },
-					// {
-					// 	img: "https://teacherapi.cocorobo.cn/teaching-file/static//img/jiaoxuedagang.jpg",
-					// 	className: "教学大纲",
-					// 	intro: "课程简介:丽湖职教双创教育国际虚拟教研室教学大纲",
-					// 	url: 'https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1210'
-					// },
-					// {
-					// 	img: "https://teacherapi.cocorobo.cn/teaching-file/static//img/peiyangfangan.jpg",
-					// 	className: "培养方案",
-					// 	intro: "课程简介:丽湖职教双创教育国际虚拟教研室培养方案",
-					// 	url: 'https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1210'
-					// },
-					// {
-					// 	img: "https://teacherapi.cocorobo.cn/teaching-file/static//img/xitishiti.jpg",
-					// 	className: "习题试题",
-					// 	intro: "课程简介:丽湖职教双创教育国际虚拟教研室习题试题",
-					// 	url: 'https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1210'
-					// },
-				],
+				activeList: [],
+				classList: []
 			};
 		},
 		onLoad() {},
@@ -146,9 +77,9 @@
 					lim: 6 //一次获取多少数据
 				}
 				this.$request('/selectActivity', "POST", data).then(res => {
-					console.log(res[0]);
+					// console.log(res[0]);
 					// this.activeList=[...this.activeList,...res[0]]
-					this.activeList = res[0].slice(0, 6);
+					this.activeList = res[0]
 				})
 			},
 			// 获取推荐课程list 数据
@@ -160,9 +91,11 @@
 					lim: 6 //一次获取多少数据
 				}
 				this.$request('/selectActivity', "POST", data).then(res => {
-					console.log('推荐课程', res[0]);
+					console.log(res[0]);
 					// this.activeList=[...this.activeList,...res[0]]
-					this.classList = res[0]
+					this.classList =res[0]
+					
+					console.log('推荐课程',this.classList);
 				})
 			},
 			// 跳转到推荐课程查看更多
@@ -266,6 +199,7 @@
 		onShow() {
 			this.getData()
 			this.getlistBlock1Data()
+			this.$refs.listBlock1.getdata()
 		}
 	};
 </script>

+ 13 - 1
pages/mineCollect/mineCollect.vue

@@ -4,7 +4,7 @@
 
 		<view class="collectBox">
 			<view class="collect_length">
-				<span>共{{ classList.length }}条收藏</span>
+				<span>共{{ collArr.length }}条收藏</span>
 			</view>
 			<view class="classBox" @click="gotoWeb(index)" v-for="(item,index) in classList" :key="index">
 
@@ -42,6 +42,7 @@
 					title: '我的收藏',
 					btn: 1
 				},
+				collArr:[],
 				classList: [{
 						url: "https://teacherapi.cocorobo.cn/teaching-file/static//img/Cardimg-1.jpg",
 						className: "中国共产党与中华民族伟大复兴",
@@ -66,6 +67,14 @@
 			};
 		},
 		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)
+				})
+			},
 			gotoWeb(index) {
 				const urls = [
 					"https://www.xuetangx.com/course/zysy06011001641?channel=i.area.course_list_all",
@@ -80,6 +89,9 @@
 					});
 				}
 			},
+		},
+		onLoad() {
+			this.getData()
 		}
 	}
 </script>

+ 3 - 25
pages/teachingList/teachingList.vue

@@ -9,30 +9,7 @@
 		<scroll-view class="list" scroll-y="true">
 			<view>
 				<!-- 推荐课程插槽组件 -->
-				<listBlock1 v-for="i in classList">
-					<template #pic>
-						<image :src="i.pic" class="listBlock1PIC" mode="aspectFill"></image>
-					</template>
-					<template #tit>
-						{{i.acName}}
-					</template>
-					<template #intro>
-						{{ i.brief }}
-					</template>
-					<template #Sicon>
-						<image src="http://43.139.158.220:5007/img/static/yym/Star 1 (Stroke).png"
-							style="width: 28rpx; height: 26rpx" mode="aspectFill"></image>
-					</template>
-					<template #Dicon>
-						<image src="http://43.139.158.220:5007/img/static/yym/Vector (Stroke).png"
-							style="width: 22rpx; height: 26rpx" mode="aspectFill"></image>
-					</template>
-					<template #btn>
-						<button class="list1btn sBtn-font" @click.stop="join">
-							立即参与
-						</button>
-					</template>
-				</listBlock1>
+				<listBlock1 ref="listBlock1" :classList='classList'></listBlock1>
 			</view>
 		</scroll-view>
 
@@ -97,9 +74,10 @@
 
 		},
 
-		onLoad() {
+		onShow() {
 			// 一进页面就加载数据
 			this.getData()
+			this.$refs.listBlock1.getdata()
 		}
 	}
 </script>