Эх сурвалжийг харах

feat: 首页新增科目。 fix:多课程总数

xuqiaoying 2 жил өмнө
parent
commit
0462cf2809

+ 83 - 19
pages/index/index.vue

@@ -113,6 +113,16 @@
 					</template>
 				</scroll-view>
 			</view>
+			<view class="filters">
+				<scroll-view class="scroll_view_H" scroll-x="true" >
+					<!-- v-if="tabNum == 0" -->
+					<template >
+						<view v-for="(item, index) in subjectList" :key="index" class="filter_item"  @click="changeSub(item.id, index)">
+							<view class="name" :class="{nactive: subIndex == index}">{{ item.subjectName }}</view>
+						</view>
+					</template>
+				</scroll-view>
+			</view>
 			<view class="course-list" v-show="tabCurrent==0">
 				<template v-if="list1.length">
 					<!-- hover-class="none" -->
@@ -286,6 +296,9 @@ export default {
 			bankIndex: 0,
 			courseId: '',
 			bankId: '',
+			subjectList: [],
+			subIndex: 0,
+			courSubjectId: '',
 		};
 	},
 	async onLoad(option) {
@@ -371,28 +384,30 @@ export default {
 		};
 	},
 	async onPullDownRefresh() {
+		console.log('下拉this.courseId:', this.courseId)
 		if (this.tabNum == 0) {
 			this.list1 = []
 			this.paramList[0].pageNum = 1
-			this.list1 = await this.getGoodsList(this.courseId, 0)
+			this.list1 = await this.getGoodsList(this.courseId, 0, this.courSubjectId)
 		} else {
 			this.list2 = []
 			this.paramList[1].pageNum = 1
-			this.list2 = await this.getGoodsList(this.bankId, 1)
+			this.list2 = await this.getGoodsList(this.bankId, 1, this.courSubjectId)
 		}
 	},
 	async onReachBottom() {
+		console.log('加载this.courseId:', this.courseId, this.list1.length, this.paramList[0].total)
 		if (this.tabNum == 0) {
 			if (this.list1.length < this.paramList[0].total) {
 				this.paramList[0].pageNum++
-				let list1 = await this.getGoodsList(this.courseId, 0)
+				let list1 = await this.getGoodsList(this.courseId, 0, this.courSubjectId)
 				this.list1.push(...list1)
 			}
 		} else {
 
 			if (this.list2.length < this.paramList[1].total) {
 				this.paramList[1].pageNum++
-				let list2 = await this.getGoodsList(this.bankId, 1)
+				let list2 = await this.getGoodsList(this.bankId, 1, this.courSubjectId)
 				this.list1.push(...list2)
 			}
 		}
@@ -587,7 +602,7 @@ export default {
 			this.courseId = recommendId
 			this.paramList[0].pageNum = 1
 			this.list1 = []
-			let list1 = await this.getGoodsList(recommendId, 0)
+			let list1 = await this.getGoodsList(recommendId, 0, this.courSubjectId)
 			this.list1.push(...list1)
 		},
 		async changebank(recommendId, index) {
@@ -595,9 +610,25 @@ export default {
 			this.bankId = recommendId
 			this.paramList[1].pageNum = 1
 			this.list2 = []
-			let list2 = await this.getGoodsList(recommendId, 1)
+			let list2 = await this.getGoodsList(recommendId, 1, this.courSubjectId)
 			this.list2.push(...list2)
 		},
+		async changeSub(subjectId, index) {
+			console.log('subjectId, index:', subjectId, index, 'this.courseId:', this.courseId, 'this.bankId:', this.bankId)
+			this.subIndex = index
+			this.courSubjectId = subjectId
+			this.paramList[this.tabNum].pageNum = 1 
+			if (this.tabNum == 0) {
+				this.list1 = []
+				let list1 = await this.getGoodsList(this.courseId, 0, subjectId)
+				this.list1.push(...list1)
+			} else {
+				this.list2 = []
+				let list2 = await this.getGoodsList(this.bankId, 1, subjectId)
+				this.list2.push(...list2)
+			}
+			
+		},
 		//课程
 		 courseLists() {			
 			// var param = this.paramList[0];
@@ -629,32 +660,47 @@ export default {
 						}
 					});
 					if (this.courseName.length) {
-						let courseId = this.courseId ? this.courseId : this.courseName[0].recommendId
-						this.courseId = this.courseName[0].recommendId
-						let list1 = await this.getGoodsList(courseId, 0)
+						let courseId = ''
+						if (this.courseId) {
+							courseId = this.courseId
+						} else {
+							courseId = this.courseName[0].recommendId
+							this.courseId = this.courseName[0].recommendId
+						}
+						console.log('courseId:', courseId)
+						this.getSubjectList(courseId)
+						let list1 = await this.getGoodsList(courseId, 0, '')
 						this.list1.push(...list1)
 					}
 					
 					if (this.bankName.length) {
-						let bankId = this.bankId ? this.bankId : this.bankName[0].recommendId
-						this.bankId = this.bankName[0].recommendId
-						let list2 = await this.getGoodsList(bankId, 1)
+						let bankId = ''
+						if (this.bankId) {
+							bankId = this.bankId
+						} else {
+							bankId = this.bankName[0].recommendId
+							this.bankId = this.bankName[0].recommendId
+						}
+						let list2 = await this.getGoodsList(bankId, 1, '')
 						this.list2.push(...list2)
 					}
 
 				}
 			});
 		},
-		getGoodsList(recommendId, num) {	
+		getGoodsList(recommendId, num, subjectId) {	
 			return new Promise((resolve, reject) => {
-				 this.$http({
+				let params = {
+					pageNum: this.paramList[num].pageNum,
+					pageSize: this.paramList[num].pageSize,
+					recommendId: recommendId
+				}
+				subjectId && (params.subjectId = subjectId)
+				console.log('params:', params)
+				this.$http({
 					url: `/app/common/activity/recommend/goodsList`,
 					method: 'get',
-					data: {
-						pageNum: this.paramList[num].pageNum,
-						pageSize: this.paramList[num].pageSize,
-						recommendId: recommendId
-					},
+					data: params,
 					noToken: true
 				}).then((res) => {
 					if (res.data.code == 200) {
@@ -665,6 +711,22 @@ export default {
 			})
 			 
 		},
+		getSubjectList(recommendId) {
+			this.$http({
+				url: `/app/common/activity/recommend/subjectList`,
+				method: 'get',
+				data: {
+					recommendId: recommendId
+				},
+				noToken: true
+			}).then((res) => {
+				if (res.data.code == 200) {
+					let data = res.data.data || []
+					this.subjectList = [{ id: '', subjectName: '全部'}, ...data]
+					console.log('this.subjectList:', this.subjectList)
+				}	
+			})
+		},
 		/**
 		 * @param {Object} item 
 		 * 跳转课程详情
@@ -810,6 +872,8 @@ export default {
 		tab(e) {
 			this.tabCurrent = e;
 			this.tabNum = e
+			let recommendId = e == 0 ? this.courseId : this.bankId
+			this.getSubjectList(recommendId)
 		},
 		updateHomePlan() {
 			this.$refs.home.init();

+ 0 - 3
pages2/subject/collectBank.vue

@@ -936,8 +936,6 @@ export default {
      * 收藏
      */
     collect(state, index, bank) {
-      console.log('0000', state, index, bank);
-      // return
       if (!state) {
         this.$api.collectQuestion({
             examId: this.examId || bank.examId,
@@ -979,7 +977,6 @@ export default {
             }
           });
       }
-      return;
     },
     /**
      * @param {Object} e单选点击

+ 4 - 3
pages3/polyv/detail.vue

@@ -93,10 +93,11 @@
             <view class="notice_wrap" v-if="goodsData.buyNote">
               <view class="video_t1_t" @click="studyNotice"> 学员须知 </view>
             </view>
-            <view class="toggle_course" v-if="courseTotal > 1" @click="changeCourses()">
+            <view class="toggle_course" v-if="goodsTeacher.length > 1" @click="changeCourses()">
               <image class="img" src="/pages3/static/imgs/toggle.png" mode="widthFix"></image>
               <view class="toggle_name">切换课程</view>
-              <view class="numbers">共{{ courseTotal }}门</view>
+              <!-- courseTotal -->
+              <view class="numbers">共{{ goodsTeacher.length }}门</view>
             </view>
             
         </view>
@@ -568,7 +569,7 @@
               <view class="grade">切换课程</view>
 					    <u-icon name="close" color="#9C9C9C" size="40" @click="closePop()"></u-icon>
             </view>
-            <view class="coruse_num">共{{ courseTotal }}门</view>
+            <view class="coruse_num">共{{ goodsTeacher.length }}门</view>
             <view class="menuSel">
               <scroll-view class="sub_sliper" scroll-x="true" >
                 <view v-for="(item,index) in subList" :key="index" style="margin-right: 50rpx;display:inline-block">