Tang %!s(int64=4) %!d(string=hai) anos
pai
achega
d0cb06b673
Modificáronse 3 ficheiros con 162 adicións e 73 borrados
  1. 3 1
      common/api.js
  2. 27 0
      common/httpList/collect.js
  3. 132 72
      pages2/course/detail.vue

+ 3 - 1
common/api.js

@@ -8,6 +8,7 @@ import face from './httpList/face.js'
 import userInfo from './httpList/userInfo.js'
 import teacher from './httpList/teacher.js'
 import chapter from './httpList/chapter.js'
+import collect from './httpList/collect.js'
 export default {
 	...login,
 	...polyvVideo,
@@ -18,5 +19,6 @@ export default {
 	...face,
 	...userInfo,
 	...teacher,
-	...chapter
+	...chapter,
+	...collect
 }

+ 27 - 0
common/httpList/collect.js

@@ -0,0 +1,27 @@
+import {
+	myRequest
+} from '../request.js'
+export default {
+	//新增收藏课程
+	coursecollect(data) {
+		return myRequest({
+			url: '/collect/course',
+			method: 'post',
+			data: data,
+		})
+	},
+	//删除收藏课程
+	deletecoursecollect(data) {
+		return myRequest({
+			url: '/collect/course/delete/' + data,
+			method: 'post',
+		})
+	},
+	//判断是否收藏课程
+	coursecollectPD(data) {
+		return myRequest({
+			url: '/collect/course/' + data,
+			method: 'get',
+		})
+	},
+}

+ 132 - 72
pages2/course/detail.vue

@@ -19,7 +19,7 @@
 			<view>
 				<u-row>
 					<u-col span="8" offset="1">
-						<view class="video_t1">{{ pageData.courseName }}</view>
+						<view class="video_t1">{{ infoData.name || pageData.courseName }}</view>
 					</u-col>
 					<u-col span="3"><view class="video_t1">共60课时</view></u-col>
 				</u-row>
@@ -50,16 +50,16 @@
 							<view v-for="(item, index) in chapterList" :key="index" style="margin-right: 20rpx;display:inline-block"><view class="r_t2">{{item.name}}</view></view>
 						</scroll-view>
 					</view> -->
+
 					<view class="catalogBox" :class="activeStatus ? 'changeCatalogBox' : ''">
 						<view
 							class="catalogA"
 							v-for="(item, index) in chapterList"
 							:key="index"
-							:class="activeStatusCata === index ? 'activesq' : ''"
+							:class="activeStatusCata === item.chapterId ? 'activesq' : ''"
 							@click="activeList(item, index)"
 						>
 							{{ item.name }}
-							<span style="color: #1677FF;">试看</span>
 						</view>
 					</view>
 				</view>
@@ -149,6 +149,26 @@
 				<view class="buy" @click="jumpBuy">立即购买</view>
 			</view>
 		</view>
+		<u-popup v-model="showBox" mode="bottom" border-radius="14">
+			<view class="content">
+				<scroll-view scroll-y="true" style="height: 300rpx;">
+					<view v-if="boxList.length > 0">
+						<view
+							v-for="(item, index) in boxList"
+							:key="index"
+							style="height: 60rpx;line-height: 60rpx;border-bottom: 1rpx solid #eee;display: flex;align-items: center;justify-content: space-between;"
+							:style="infoData.sectionId === item.sectionId ? 'color:#1677ff;' : ''"
+							@click="getsec(item)"
+						>
+							<view>{{ item.name }}</view>
+							<u-icon v-if="infoData.sectionId === item.sectionId" name="checkbox-mark"></u-icon>
+						</view>
+					</view>
+					<view v-else>暂无内容</view>
+				</scroll-view>
+				<view class="confrim-btn" style="margin-top: 10rpx;"><u-button @click="showBox = false">取消</u-button></view>
+			</view>
+		</u-popup>
 	</view>
 </template>
 
@@ -186,14 +206,20 @@ export default {
 			windowHeight: 0,
 			modules4Bottom: 0,
 			isClick: false,
-			vid: 'd5f6d309fe0b016d3844b194a8b32249_d', // 视频ID
+			// vid: 'd5f6d309fe0b016d3844b194a8b32249_d', // 视频ID
+			vid: '', // 视频ID
 			sign: '',
 			ts: '',
 			startStatus: false,
-			queryData: {},
+			queryData: {}, //页面跳转内容
 			pageData: {},
+			infoData: {},
 			chapterList: [],
-			teacherInfo: {}
+			teacherInfo: {},
+			faceGetState: true, //模拟今天是否人脸识别
+			showBox: false,
+			boxList: [],
+			payStatus: true //是否购买该课程
 		};
 	},
 	onLoad(options) {
@@ -201,6 +227,7 @@ export default {
 		Verify.init();
 		this.queryData = options;
 		this.getCourseInfo();
+		this.getChapter(options.courseId);
 	},
 	onShow() {
 		let that = this;
@@ -269,58 +296,33 @@ export default {
 	},
 	methods: {
 		activeList(item, index) {
-			this.activeStatusCata = index;
-			this.$navTo.togo('/pages2/course/detail', item);
-		},
-		async certification() {
 			var self = this;
-			const faceBiz = await self.$api.facecertificationPicBizToken();
-			self.BizToken = faceBiz.data.data.bizToken;
-			wx.startVerify({
-				data: {
-					token: self.BizToken
-				},
-				success: result => {
-					setTimeout(() => {
-						console.log(999,result)
-						self.$api.facecertificationPicDetectInfo(self.BizToken).then(faceRec => {
-							if(faceRec.data.data === 0){
-								uni.showToast({
-									title: '识别成功',
-									icon: 'none',
-									duration: 2000
-								})  
-								
-							}else{
-								uni.showToast({
-									title: '识别失败',
-									icon: 'none',
-									duration: 2000
-								})
-								console.log('识别失败')
-							}
-						});
-					}, 500);
-				},
-				fail: err => {
-					setTimeout(() => {
-						console.log('识别功能失败')
-						uni.showModal({
-							title: '提示',
-							content: err,
-							showCancel: false
-						});
-					}, 500);
-				}
+			var dataset = {
+				chapterId: item.chapterId
+			};
+			this.$api.coursesectionlist(dataset).then(result => {
+				result.data.rows.forEach((items, indexs) => {
+					items.value = items.sectionId;
+					items.label = items.name;
+				});
+				self.boxList = result.data.rows;
 			});
+			this.showBox = true;
 		},
+		getsec(item) {
+			this.startStatus = false;
+			this.infoData = item;
+			this.vid = this.infoData.vid;
+			this.activeStatusCata = item.chapterId;
+			this.showBox = false;
+		},
+
 		getCourseInfo() {
 			var self = this;
 			this.$api.courseInfo(this.queryData.courseId).then(res => {
 				console.log(res.data.data);
 				if (res.data.code === 200) {
 					self.pageData = res.data.data;
-					self.getChapter(res.data.data.courseId);
 					self.getTeacher(res.data.data.teacherIds);
 				}
 			});
@@ -331,15 +333,14 @@ export default {
 				courseId: v
 			};
 			this.$api.coursechapterlist(data).then(res => {
-				this.chapterList = res.data.rows;
-				res.data.rows.forEach((item, index) => {
-					var dataset = {
-						chapterId: item.chapterId
-					};
-					self.$api.coursesectionlist(dataset).then(result => {
-						console.log(result);
-					});
+				var chaList = res.data.rows;
+				var dataset = {
+					chapterId: res.data.rows[0].chapterId
+				};
+				self.$api.coursesectionlist(dataset).then(result => {
+					self.getsec(result.data.rows[0])
 				});
+				this.chapterList = chaList;
 			});
 		},
 		getTeacher(v) {
@@ -351,26 +352,82 @@ export default {
 			});
 		},
 		startVideo() {
-			uni.getStorageSync('union_id');
-			if (!uni.getStorageSync('union_id')) {
+			if (!uni.getStorageSync('union_id') && this.$store.state.token === '') {
 				uni.navigateTo({
 					url: '/pages/login/login'
 				});
 			} else {
-				this.certification();
-				// this.$api
-				// 	.polyvVideoSign(this.vid)
-				// 	.then(res => {
-				// 		console.log(res);
-				// 		this.startStatus = true;
-				// 		// this.sign = res.data.data.sign;
-				// 		// this.ts = res.data.data.ts;
-				// 	})
-				// 	.catch(err => {
-				// 		console.log('报错');
-				// 	});
+				//模拟今天是否人脸识别
+				if (!this.faceGetState) {
+					this.certification();
+					return;
+				}
+				if (!this.payStatus) {
+					uni.showToast({
+						title: '暂未购买该课程',
+						icon: 'none',
+						duration: 2000
+					});
+					return;
+				}
+				if (this.vid === null) {
+					uni.showToast({
+						title: '视频加载失败',
+						icon: 'none',
+						duration: 2000
+					});
+					return;
+				}
+				this.$api
+					.polyvVideoSign(this.vid)
+					.then(res => {
+						this.startStatus = true;
+					})
+					.catch(err => {
+						console.log('报错');
+					});
 			}
 		},
+		async certification() {
+			var self = this;
+			const faceBiz = await self.$api.facecertificationPicBizToken();
+			self.BizToken = faceBiz.data.data.bizToken;
+			wx.startVerify({
+				data: {
+					token: self.BizToken
+				},
+				success: result => {
+					setTimeout(() => {
+						self.$api.facecertificationPicDetectInfo(self.BizToken).then(faceRec => {
+							if (faceRec.data.data === 0) {
+								uni.showToast({
+									title: '识别成功',
+									icon: 'none',
+									duration: 2000
+								});
+							} else {
+								uni.showToast({
+									title: '识别失败',
+									icon: 'none',
+									duration: 2000
+								});
+								console.log('识别失败');
+							}
+						});
+					}, 500);
+				},
+				fail: err => {
+					setTimeout(() => {
+						console.log('识别功能失败');
+						uni.showModal({
+							title: '提示',
+							content: err,
+							showCancel: false
+						});
+					}, 500);
+				}
+			});
+		},
 		touchMove(e) {
 			this.isClick = false;
 		},
@@ -415,7 +472,6 @@ export default {
 				key: 'union_id',
 				success: function(res) {
 					// 继续操作
-					
 				},
 				fail: function(err) {
 					//重新登入
@@ -434,6 +490,10 @@ export default {
 }
 </style>
 <style scope>
+.content {
+	padding: 24rpx;
+	text-align: left;
+}
 .catalogBox {
 	display: flex;
 	align-items: center;