Explorar el Código

feat: 双师制

xuqiaoying hace 3 años
padre
commit
9929c3bb9c
Se han modificado 4 ficheros con 332 adiciones y 39 borrados
  1. 9 0
      common/httpList/goods.js
  2. 119 8
      pages3/course/detail.vue
  3. 18 1
      pages3/polyv/css/detail.scss
  4. 186 30
      pages3/polyv/detail.vue

+ 9 - 0
common/httpList/goods.js

@@ -64,6 +64,15 @@ export default {
 			noToken: true
 		})
 	},
+	// 获取双师制
+	getGoodsCourseTeacher(data) {
+		return myRequest({
+			url: '/app/common/course/teacher/list',
+			method: 'get',
+			data: data,
+			noToken: true
+		})
+	},
 	collectQuestion(data) {
 		return myRequest({
 			url: '/collect/question',

+ 119 - 8
pages3/course/detail.vue

@@ -30,15 +30,12 @@
 					</view>
 					<view style="display: flex;justify-content: space-between;margin-top: 13rpx;">
 						<view class="prices">
-							<!-- <text class="price_sym">¥</text> -->
-							<!-- <text class="price_word">¥ {{ detail.standPrice }}</text> -->
 							<text v-if="detail.standPrice" class="price_word">¥ {{ detail.standPrice }}</text>
 							<text v-else class="price_word free">免费</text>
 							<text v-if="detail.linePrice" class="sale"> ¥ </text>
 							<text v-if="detail.linePrice" class="price_line"> {{detail.linePrice }}</text>
 						</view>
 						<view class="noteTag">
-							<!-- <image src="/static/icon/wk_icon1.png" class="wk_icon"></image> -->
 							共 <text class="blackFont">{{courseList.length}} 课程 {{detail.classHours || '-'}}</text> 学时
 						</view>
 					</view>
@@ -62,8 +59,10 @@
 				</view>
 			</view>
 			<view style="padding: 20rpx;padding-bottom: 100rpx;position: relative;" v-show="current==1">
-					<view v-for="(item,index) in courseList" :key="index" >
-						<view class="courseItemBox" >
+				<!-- <view v-for="(item, index) in courseItem.courseList" :key="index" > -->
+				<view v-for="(courseItem, gTindex) in goodsTeacher" :key="gTindex">
+					<view v-for="(item, index) in courseItem.courseList" :key="index">
+						<view class="courseItemBox"  v-if="item.show && item.show == 1">
 							<view class="courseItem" @click="openCourse(item)">
 								<view class="courseName">{{item.courseName}}</view>
 								<view>
@@ -71,6 +70,11 @@
 									<image src="/static/icon/down.png" class="icon_up" v-if="!item.down"></image>
 								</view>
 							</view>
+							<view v-if="courseItem.teaList && courseItem.teaList.length > 0" class='teacher_names'>
+								<view v-for="(tea, tindex) in courseItem.teaList" :key="tindex" class="names" :class="{nactive: teaIndex == tindex}" @click.stop="switchTeacher(tea, tindex)">
+									<view>{{ tea.aliasName }}</view>
+								</view>
+							</view>
 							<view v-show="!item.down">
 								<view v-for="(itemM,indexM) in item.menuList"  :key="indexM">
 									<courseModule :courseId="itemM.courseId" :needOpen="(isFirstEnter && menuIndex[0] === index && menuIndex[1] === indexM) ? true : false" v-if="itemM.type==1" :menuItem="itemM"></courseModule>
@@ -80,9 +84,11 @@
 									
 								</view>
 							</view>
+							
 						</view>
-						
 					</view>
+				</view>
+				
 			</view>
 			<view style="padding: 20rpx;padding-bottom: 100rpx;position: relative;" v-show="current==2">
 				<!-- <view > -->
@@ -100,8 +106,6 @@
 
 		
 		<view class="bottomBox" v-if="!hideBuyState">
-			<!-- <view class="priceTag">¥ {{toFixed(detail.standPrice)}}</view> -->
-            <!-- <view class="priceTag">分享</view> -->
 			<view class="icons">
 				<view class="icon_item ones">
 					<image src="/static/index/share.png" class="share"></image>
@@ -171,10 +175,13 @@ export default {
 			startTime:0,
 			bugCourseModel: false, // 弹窗
 			hadBuyCourse: {}, // 已购买课程信息
+			goodsTeacher: [],
+			teaIndex: 0,
 		};
 	},
 	computed: { ...mapGetters(['userInfo','goodsAuditionConfigIdList','playSectionId','hideBuyState']) },
 	onLoad(option) {
+		// this.id => goodsId
 		this.id = option.id;
 		this.getDetail()
 		this.goodsCourseList()
@@ -357,6 +364,7 @@ export default {
 					}
 					this.courseList = res.data.rows;
 					this.getFirstCourse();
+					this.getCourseTeacher(res.data.rows)
 				}
 			});
 		},
@@ -391,6 +399,93 @@ export default {
 			})
 			
 		},
+		getCourseTeacher(rows) {
+			//获取商品双师资模板
+			this.$api.getGoodsCourseTeacher({
+               goodsId: this.id
+            }).then((res1) => {
+            //   console.log(res1,'res1');
+              if(res1.data.data && res1.data.data.length > 0){
+                  //课程老师模板
+                  let teacherTel = res1.data.data;
+                  //商品课程
+                  let courses = rows
+                  teacherTel.forEach((tea) => {
+                    let dataList = []
+                    let teacherList = []
+                      courses.forEach((item) => {
+                        if(tea.courseIds.search(item.courseId) > -1){
+                          dataList.push(item)
+                          teacherList = tea.courseList
+                        }
+                      })
+                      let result = {
+                        teaList:teacherList,
+                        courseList:dataList
+                      }
+                      this.goodsTeacher.push(result)
+                  })
+                  if(this.goodsTeacher && this.goodsTeacher.length > 0){
+                    let courseIds = []
+                    this.goodsTeacher.forEach((item) => {
+                        item.courseList.forEach((course) => {
+                          courseIds.push(course.courseId)
+                        })
+                    })
+                    if(courseIds.length > 0){
+                      courses.forEach((item) => {
+                          if(!courseIds.includes(item.courseId)){
+                              let data = {
+                                teaList:[],
+                                courseList: []
+                              }
+                              data.courseList.push(item)
+                              this.goodsTeacher.push(data)
+                          }
+                      })
+                    }
+                    this.goodsTeacher.forEach((item) => {
+                      if(item.courseList && item.courseList.length > 0){
+                        item.courseList[0].show = 1
+                      }
+                    })
+                  }
+              }else{
+                //没有双师资模板
+                rows.forEach((item) => {
+                  item.show = 1
+                  let data = {
+                      teaList:[],
+                      courseList: []
+                  }
+                  data.courseList.push(item)
+                  this.goodsTeacher.push(data)
+                })
+               
+              }
+            }) 
+			console.log(this.goodsTeacher,'this.goodsTeacher');
+		},
+		//切换老师
+		switchTeacher(data, tindex){
+			// console.log(data,'data');
+			this.teaIndex = tindex
+			this.goodsTeacher.forEach((item,index) => {
+				if(item.teaList && item.teaList.length > 0){
+				let list = item.teaList.filter(x => x.aliasName == data.aliasName)
+				if(list && list.length > 0){
+					item.courseList.forEach((course,courseIndex) => {
+						if(course.courseId == data.courseId){
+							this.$set(this.goodsTeacher[index].courseList[courseIndex],"show",1)
+						}else{
+							this.$set(this.goodsTeacher[index].courseList[courseIndex],"show",0)
+						}
+					})
+				}
+				}
+			})
+			console.log('切换后的this.goodsTeacher, ', this.goodsTeacher)
+		},
 		getMenuList(item) {
 			let self = this
 			this.$api.menuList({courseId:item.courseId}).then(res => {
@@ -818,4 +913,20 @@ export default {
 		padding: 20rpx;
 		margin-bottom: 20rpx;
 	}
+	// 老师名字样式
+.teacher_names {
+	display: flex;
+	margin-bottom: 10rpx;
+	.names {
+		padding: 12rpx 16rpx;
+		font-size: 24rpx;
+		color: #666666;
+		background: #FFFFFF;
+		border-radius: 8px;
+		margin-right: 10rpx;
+		&.nactive {
+			color: #3F8DFD;
+		}
+	}
+}
 </style>

+ 18 - 1
pages3/polyv/css/detail.scss

@@ -163,4 +163,21 @@
         }
       }
     }
-  }
+  }
+
+// 老师名字样式
+.teacher_names {
+  display: flex;
+  margin-bottom: 10rpx;
+  .names {
+    padding: 12rpx 16rpx;
+    font-size: 24rpx;
+    color: #666666;
+    background: #FFFFFF;
+    border-radius: 8px;
+    margin-right: 10rpx;
+    &.nactive {
+      color: #3F8DFD;
+    }
+  }
+}

+ 186 - 30
pages3/polyv/detail.vue

@@ -103,9 +103,8 @@
       </view>
       <u-line color="#D6D6DB" />
       <view>
-        <view
-          ><u-tabs
-            gutter="0"
+        <view>
+          <u-tabs
             :item-width="itemWidth()"
             :list="list"
             font-size="32"
@@ -113,8 +112,8 @@
             :current="current"
             @change="change"
             active-color="#007AFF"
-          ></u-tabs
-        ></view>
+          ></u-tabs>
+        </view>
       </view>
       <u-line color="#D6D6DB" />
     </view>
@@ -127,6 +126,12 @@
 						<view class="note">正在直播中</view>
 						<view class="title">{{livingItem.sectionName}}</view>
 					</view>
+          <view v-if="teacherList && teacherList.length > 0" class='teacher_names'>
+              <view v-for="(tea, index) in teacherList" :key="index" class="names"
+                :class="{nactive: teacherIndex == index}" @click="activeFunc(tea, index)">
+                {{ tea.aliasName }}
+              </view>
+          </view>
           <view class="menuBox onessss" v-for="(item, index) in menuList" :key="index">
             <!--模块 -->
             <view v-if="item.type == 1"
@@ -559,25 +564,36 @@
               </scroll-view>
             </view>
 				</view>
+        
 				<view class="check_con">
 					<scroll-view scroll-y="true" style="height: 700rpx;">
-						<view class="course_items"  v-for="(item, index) in s_courseList" :key="index">
-                <view class="course_lefts">
-                  <view class="course_title">{{ item.courseName }}</view>
-                  <view class="course_pros">
-                    学习进度
-                    <text> {{ item.stuAllNum + item.recordNum }}/{{ item.secAllNum + item.examNum}}</text>
-                  </view>
-                </view>
-                <view class="course_rights" @click="jump(item, index)">
-                  <view class="cicles">
-                    <u-icon name="arrow-right" color="#498AFE" size="20"></u-icon>
-                  </view>
-                  <view class="intoStudy">进入学习</view>
+            <view v-for="(courseItem, gTindex) in goodsTeacher" :key="gTindex">
+               <view v-for="(item, index) in courseItem.courseList" :key="index" v-show="item.subjectId === newActiveSubjectId || !newActiveSubjectId">
+                    <view class="course_items"  v-if="item.show && item.show == 1">
+                        <view class="course_lefts">
+                          <view class="course_title">
+                            {{ item.courseName }}
+                          </view>
+                          <view v-if="courseItem.teaList && courseItem.teaList.length > 0" class='teacher_names' >
+                              <view v-for="(tea, tindex) in courseItem.teaList" :key="tindex" class="names"
+                               :class="{nactive: teaIndex == tindex}"  @click.stop="switchTeacher(tea, tindex)">{{tea.aliasName}}</view>
+                          </view>
+                          <view class="course_pros">
+                            学习进度
+                            <text> {{ item.stuAllNum + item.recordNum }}/{{ item.secAllNum + item.examNum}}</text>
+                          </view>
+                        </view>
+                        <view class="course_rights" @click="jump(item, index, 'jump')">
+                          <view class="cicles">
+                            <u-icon name="arrow-right" color="#498AFE" size="20"></u-icon>
+                          </view>
+                          <view class="intoStudy">进入学习</view>
+                        </view>
+                    </view>
                 </view>
-						</view>
+              </view>
 					</scroll-view>
-				</view>
+        </view>
 			</view>
 		</u-popup>
 		 
@@ -709,6 +725,11 @@ export default {
       s_courseList: [], // 筛选后的
       subList: [],
       subIndex: 0,
+      goodsTeacher: [],
+      teacherList: [],
+      teaIndex: 0,
+      teacherIndex: 0,
+      newActiveSubjectId: "", //当前选中ID
     };
   },
   computed: {
@@ -760,12 +781,14 @@ export default {
     },
     // 点击课程目录
     cMenu(item, index) {
+      console.log('item', item)
       this.subIndex = index
-      if (item.subjectId != 0) {
-        this.s_courseList = this.courseList.filter((e) => e.subjectId == item.subjectId)
-      } else {
-        this.s_courseList = this.courseList
-      }
+      this.newActiveSubjectId = item.subjectId
+      // if (item.subjectId != 0) {
+      //   this.s_courseList = this.courseList.filter((e) => e.subjectId == item.subjectId)
+      // } else {
+      //   this.s_courseList = this.courseList
+      // }
     },
     courseCourseList() {
       // /course/courseList查询商品下的课程列表
@@ -782,7 +805,7 @@ export default {
           this.courseList.push.apply(this.courseList, res.data.rows)
           this.s_courseList = this.courseList
           this.courseTotal = res.data.total || 0
-
+          // 科目
           let allItem = [{ subjectId: 0, subjectName: '所有'}]
           let ids = []
           const newArr = []
@@ -830,6 +853,9 @@ export default {
             console.log('查询用户最后一次看的录播的信息', res.data, this.courseId)
             this.originOnShow()
             this.originMounted()
+
+            //获取商品双师资模板
+            this.getCourseTeacher(this.courseList)
           } else {
             this.toggleCourseShow = true
           }
@@ -837,6 +863,79 @@ export default {
         }
       })
     },
+    getCourseTeacher(rows) {
+      //获取商品双师资模板
+      this.$api.courseTeacherList({
+          goodsId: this.goodsId
+      }).then((res1) => {
+        console.log(res1,'res1');
+        if(res1.data.data && res1.data.data.length > 0){
+            //课程老师模板
+            let teacherTel = res1.data.data;
+            //商品课程
+            let courses = rows;
+            teacherTel.forEach((tea) => {
+              let dataList = []
+              let teacherList = []
+                courses.forEach((item) => {
+                  if(tea.courseIds.search(item.courseId) > -1){
+                    dataList.push(item)
+                    teacherList = tea.courseList
+                  }
+                })
+                let result = {
+                  teaList:teacherList,
+                  courseList:dataList
+                }
+                this.goodsTeacher.push(result)
+            })
+            if(this.goodsTeacher && this.goodsTeacher.length > 0){
+              let courseIds = []
+              this.goodsTeacher.forEach((item) => {
+                  item.courseList.forEach((course) => {
+                    courseIds.push(course.courseId)
+                  })
+              })
+              if(courseIds.length > 0){
+                courses.forEach((item) => {
+                    if(!courseIds.includes(item.courseId)){
+                        let data = {
+                          teaList:[],
+                          courseList: []
+                        }
+                        data.courseList.push(item)
+                        this.goodsTeacher.push(data)
+                    }
+                })
+              }
+              this.goodsTeacher.forEach((item) => {
+                if(item.courseList && item.courseList.length > 0){
+                  item.courseList[0].show = 1
+                }
+              })
+            }
+        } else {
+          //没有双师资模板
+          rows.forEach((item) => {
+            item.show = 1
+            let data = {
+                teaList:[],
+                courseList: []
+            }
+            data.courseList.push(item)
+            this.goodsTeacher.push(data)
+          }) 
+        }
+        console.log(this.goodsTeacher,'this.goodsTeacher', this.courseId);
+        this.goodsTeacher.forEach((item) => {
+          if(item.courseList.some(x => x.courseId == this.courseId)){
+            this.teacherList = item.teaList
+          }
+        })
+        console.log(this.teacherList,'this.teacherList');
+      }) 
+    },
+    
     // 原来onshow里面的内容
     originOnShow() {
       console.log('原来onshow里面的originOnShow')
@@ -974,17 +1073,72 @@ export default {
     closePop() {
       this.toggleCourseShow = false
     },
+    //切换老师
+    switchTeacher(data, tindex){
+        console.log(data,'data');
+        this.teaIndex = tindex
+        this.goodsTeacher.forEach((item,index) => {
+            if(item.teaList && item.teaList.length > 0){
+               let list = item.teaList.filter(x => x.aliasName == data.aliasName)
+               if(list && list.length > 0){
+                  item.courseList.forEach((course,courseIndex) => {
+                      if(course.courseId == data.courseId){
+                        console.log(index,'index');
+                         console.log(courseIndex,'courseIndex');
+                        this.$set(this.goodsTeacher[index].courseList[courseIndex],"show",1)
+                      }else{
+                        this.$set(this.goodsTeacher[index].courseList[courseIndex],"show",0)
+                      }
+                  })
+               }
+            }
+        })
+        console.log('切换后的this.goodsTeacher, ', this.goodsTeacher)
+    },
+    async activeFunc(item, index) {
+      console.log('item', item, this.goodsTeacher)
+      this.teacherIndex = index
+      let findResult = ''
+      this.goodsTeacher.forEach((citem,index) => {
+        citem.courseList.forEach((e, e_index) => {
+          if (e.courseId == item.courseId) {
+            findResult = e
+          }
+        })
+      })
+      
+      console.log('findResult:', findResult)
+      this.jump(findResult, 1)
+      // return
+      // this.vid = ''
+      // this.hasStart = true
+      // await this.originUnload()
+      // this.reStart = false
+      // this.courseId = item.courseId
+      // this.gradeId = findResult.gradeId
+      // console.log('切换老师', item.courseId, item.gradeId)
+      // this.originOnShow()
+      // this.originMounted()
+    },
     // 进入学习
-    async jump(item, index) {
-      console.log('item------>', item,'courseId:',item.courseId, 'goodsId:', this.goodsId, 'orderGoodsId:',item.orderGoodsId)
+    async jump(item, index, type) {
+      // console.log('item------>', index,item,'courseId:',item.courseId, 'goodsId:', this.goodsId, 'orderGoodsId:',item.orderGoodsId)
       this.vid = ''
       this.hasStart = true
       await this.originUnload()
-      // return
+
+      if (type) {
+        this.goodsTeacher.forEach((citem) => {
+            if(citem.courseList.some(x => x.courseId == item.courseId)){
+              this.teacherList = citem.teaList
+            }
+        })
+      }
       this.reStart = false
       this.courseId = item.courseId
       this.gradeId = item.gradeId
       this.toggleCourseShow = false
+      this.teacherIndex = type ? this.teaIndex : 0
       
       if (index == 0) {
         if (item.rebuild === 0) {
@@ -1306,7 +1460,6 @@ export default {
                 this.menuList = [];
                 this.$nextTick(() => {
                   this.menuList = res.data.rows;
-                  console.log('nextTick==', this.menuList)
                 });
               }
             });
@@ -1421,7 +1574,10 @@ export default {
 			}).then(res => {
 				let nowTime = Number(new  Date().getTime()/1000).toFixed(0)
 				// this.livingItem = res.data.data[0]
+        console.log('res.data.data---', res.data.data)
+        if (res.data.data) {
 				this.livingItem = res.data.data.find(item => item.liveStartTime<=nowTime&&item.liveEndTime>nowTime);
+        }
 			})
 		},
 		getbaseprofiletplists() {