Tang 4 年之前
父节点
当前提交
f79893e3fb
共有 2 个文件被更改,包括 73 次插入13 次删除
  1. 10 1
      common/httpList/course.js
  2. 63 12
      pages2/course/detail.vue

+ 10 - 1
common/httpList/course.js

@@ -8,7 +8,7 @@ export default {
 			url: '/app/common/course/list',
 			method: 'get',
 			data: data,
-			noToken:true
+			noToken: true
 		})
 	},
 	//获取课程详细信息
@@ -19,4 +19,13 @@ export default {
 			noToken: true
 		})
 	},
+	//课程推荐列表
+	courseInforecommendList(data) {
+		return myRequest({
+			url: '/app/common/course/recommendList',
+			method: 'get',
+			noToken: true,
+			data: data
+		})
+	},
 }

+ 63 - 12
pages2/course/detail.vue

@@ -2,7 +2,11 @@
 	<view>
 		<view style="position: fixed;width: 100%;z-index: 999;background: #FFFFFF;" id="top">
 			<view class="video_box">
-				<image v-if="!startStatus" src="https://cdn.uviewui.com/uview/swiper/3.jpg" style="width: 100%;height: 460rpx;"></image>
+				<image
+					v-if="!startStatus"
+					:src="infoData.firstImage === null ? 'https://cdn.uviewui.com/uview/swiper/3.jpg' : infoData.firstImage"
+					style="width: 100%;height: 460rpx;"
+				></image>
 				<image v-if="!startStatus" class="video_play" src="/static/play.png" @click="startVideo"></image>
 				<polyv-player
 					v-else
@@ -21,7 +25,9 @@
 					<u-col span="8" offset="1">
 						<view class="video_t1">{{ infoData.name || pageData.courseName }}</view>
 					</u-col>
-					<u-col span="3"><view class="video_t1">共60课时</view></u-col>
+					<u-col span="3">
+						<view class="video_t1">共{{ chapterList.length }}章节</view>
+					</u-col>
 				</u-row>
 			</view>
 			<view><u-tabs :list="list" font-size="24" bar-width="90" :current="current" @change="change" active-color="#32467B"></u-tabs></view>
@@ -40,7 +46,7 @@
 						</u-col>
 						<u-col span="3" text-align="right">
 							<view class="video_t2" @click="activeStatus = !activeStatus">
-								共60节课
+								共{{ chapterList.length }}章节
 								<u-icon name="arrow-right" size="28" style="transition: all 0.2s;margin-left:10rpx" :class="activeStatus ? 'rotoct' : ''"></u-icon>
 							</view>
 						</u-col>
@@ -114,9 +120,9 @@
 					</u-col>
 				</u-row>
 				<view style="margin: 10rpx;">
-					<view class="tj_box" v-for="(item, index) in list" :key="index">
-						<image src="http://192.168.0.222:8080/img/banner1.png" style="width: 320rpx;height: 160rpx;"></image>
-						<view style="font-size: 24rpx;color: #666666;d">2020年二级建造师继续教...</view>
+					<view class="tj_box" v-for="(item, index) in commendList" :key="index">
+						<image :src="$method.splitImgHost(item.coverUrl)" style="width: 320rpx;height: 160rpx;"></image>
+						<view style="font-size: 24rpx;color: #666666;d">{{ item.courseName }}</view>
 						<view>
 							<u-row>
 								<u-col span="6">
@@ -127,7 +133,7 @@
 								</u-col>
 								<u-col span="6" text-align="right">
 									<text style="color: #E91313;font-size: 16rpx;margin-left: 8rpx;">活动价</text>
-									<text style="color: #E91313;font-size: 24rpx;font-weight: bold;">¥499</text>
+									<text style="color: #E91313;font-size: 24rpx;font-weight: bold;">¥{{ item.price }}</text>
 								</u-col>
 							</u-row>
 						</view>
@@ -138,8 +144,8 @@
 		<view class="footer_tab" id="foot">
 			<u-line color="#D6D6DB" />
 			<view style="height: 100%;display: flex;align-items: center;position: relative;">
-				<view style="text-align: center;margin-left: 30rpx;">
-					<image src="/static/sc.png" class="sc"></image>
+				<view style="text-align: center;margin-left: 30rpx;" @click="favorites">
+					<image :src="collecStatus ? '/static/star.png':'/static/sc.png'" class="sc"></image>
 					<view class="sc_t">收藏</view>
 				</view>
 				<view style="text-align: center;margin-left: 30rpx;">
@@ -218,8 +224,10 @@ export default {
 			teacherInfo: {},
 			faceGetState: true, //模拟今天是否人脸识别
 			showBox: false,
-			boxList: [],
-			payStatus: true //是否购买该课程
+			boxList: [], //章节弹窗列表
+			payStatus: true, //是否购买该课程
+			commendList: [], //推荐课程列表
+			collecStatus: false,//收藏状态
 		};
 	},
 	onLoad(options) {
@@ -228,6 +236,8 @@ export default {
 		this.queryData = options;
 		this.getCourseInfo();
 		this.getChapter(options.courseId);
+		this.getcommendList(options.courseId);
+		this.favoritesStatus();
 	},
 	onShow() {
 		let that = this;
@@ -295,6 +305,47 @@ export default {
 		}
 	},
 	methods: {
+		favoritesStatus() {
+			this.$api.coursecollectPD(this.queryData.courseId).then(result => {
+				if (result.data.data === undefined) {
+					this.collecStatus = false;
+				} else {
+					this.collecStatus = true;
+				}
+			});
+		},
+		favorites() {
+			var self = this;
+			if (!uni.getStorageSync('union_id') && this.$store.state.token === '') {
+				uni.navigateTo({
+					url: '/pages/login/login'
+				});
+			} else {
+				if (this.collecStatus) {
+					this.$api.coursecollectPD(this.queryData.courseId).then(results => {
+						self.$api.deletecoursecollect(results.data.data.collectCourseId).then(resz => {
+							self.favoritesStatus();
+						});
+					});
+				}else{
+				var data = {
+					userId: this.$store.state.userInfo.userId,
+					courseId: this.queryData.courseId
+				};
+				this.$api.coursecollect(data).then(res => {
+					self.favoritesStatus()
+				});
+				}
+			}
+		},
+		getcommendList(v) {
+			var data = {
+				courseId: v
+			};
+			this.$api.courseInforecommendList(data).then(res => {
+				this.commendList = res.data.data;
+			});
+		},
 		activeList(item, index) {
 			var self = this;
 			var dataset = {
@@ -338,7 +389,7 @@ export default {
 					chapterId: res.data.rows[0].chapterId
 				};
 				self.$api.coursesectionlist(dataset).then(result => {
-					self.getsec(result.data.rows[0])
+					self.getsec(result.data.rows[0]);
 				});
 				this.chapterList = chaList;
 			});