he2802 3 лет назад
Родитель
Сommit
6578dc229e

+ 2 - 2
common/httpList/course.js

@@ -12,7 +12,7 @@ export default {
 	},
 	chapterList(data) {
 		return myRequest({
-			url: '/app/common/course/chapterList',
+			url: '/app/common/course/chapterList/'+data,
 			method: 'get',
 			data: data,
 			noToken: true
@@ -20,7 +20,7 @@ export default {
 	},
 	sectionList(data) {
 		return myRequest({
-			url: '/app/common/course/sectionList',
+			url: '/app/common/course/sectionList/'+data,
 			method: 'get',
 			data: data,
 			noToken: true

+ 7 - 4
pages2/components/course/courseChapter.vue → components/course/courseChapter.vue

@@ -7,7 +7,7 @@
 		</view>
 		<view v-if="!down">
 			<view v-for="(itemM,indexM) in list" >
-				<courseSection :menuItem="itemM"></courseSection>
+				<courseSection :isBuy="isBuy" :menuItem="itemM"></courseSection>
 				<u-line v-if="indexM<list.length-1"></u-line>
 			</view>
 		</view>
@@ -16,13 +16,17 @@
 
 <script>
 import { mapGetters } from 'vuex';
-import courseSection from '@/pages2/components/course/courseSection.vue';
+import courseSection from '@/components/course/courseSection.vue';
 export default {
 	name: 'courseChapter',
 	props: {
 		menuItem: {
 			type: Object,
 			default: {}
+		},
+		isBuy: {
+			type: Boolean,
+			default: false
 		}
 	},
 	components: {
@@ -40,7 +44,6 @@ export default {
 		
 	},
 	mounted() {
-		
 	},
 	methods: {
 		openChapter(item){
@@ -51,7 +54,7 @@ export default {
 		},
 		getSectionList(chapterId) {
 			let self = this
-			this.$api.sectionList({chapterId:chapterId}).then(res => {
+			this.$api.sectionList(chapterId).then(res => {
 				if(res.data.code==200){
 					for(let i=0;i<res.data.data.length;i++){
 						let item = res.data.data[i]

+ 7 - 3
pages2/components/course/courseModule.vue → components/course/courseModule.vue

@@ -7,7 +7,7 @@
 		</view>
 		<view v-if="!down">
 			<view v-for="(itemM,indexM) in list" >
-				<courseChapter  :menuItem="itemM"></courseChapter>
+				<courseChapter :isBuy="isBuy"  :menuItem="itemM"></courseChapter>
 				<u-line v-if="indexM<list.length-1"></u-line>
 			</view>
 		</view>
@@ -15,13 +15,17 @@
 </template>
 
 <script>
-import courseChapter from '@/pages2/components/course/courseChapter.vue';
+import courseChapter from '@/components/course/courseChapter.vue';
 export default {
 	name: 'courseModule',
 	props: {
 		menuItem: {
 			type: Object,
 			default: {}
+		},
+		isBuy: {
+			type: Boolean,
+			default: false
 		}
 	},
 	components: {
@@ -49,7 +53,7 @@ export default {
 		},
 		getChapterList(moduleId) {
 			let self = this
-			this.$api.chapterList({moduleId:moduleId}).then(res => {
+			this.$api.chapterList(moduleId).then(res => {
 				if(res.data.code==200){
 					for(let i=0;i<res.data.data.length;i++){
 						let item = res.data.data[i]

+ 46 - 5
pages2/components/course/courseSection.vue → components/course/courseSection.vue

@@ -5,7 +5,9 @@
 			<view class="tag tagColor2" v-if="menuItem.sectionType==2">直播</view>
 			<view class="tag tagColor3" v-if="menuItem.sectionType==3">回放</view>
 			<view class="t_content">
-				<view>{{menuItem.name}}</view>
+			<view v-if="menuItem.sectionType==1" :class="playSectionId==newId?'color1':''">{{menuItem.name}}</view>
+			<view v-if="menuItem.sectionType==2" :class="playSectionId==newId?'color2':''">{{menuItem.name}}</view>
+			<view v-if="menuItem.sectionType==3" :class="playSectionId==newId?'color3':''">{{menuItem.name}}</view>
 				<view style="font-size: 20rpx;color: #FF3B30;" v-if="menuItem.liveStartTime">
 					<view v-if="menuItem.liveStartTime>nowTime">
 						<text>{{$method.timestampToTime(menuItem.liveStartTime)}}</text>-
@@ -20,13 +22,14 @@
 				</view>
 			</view>
 		</view>
-		<view v-if="menuItem.tryListen" class="tryBox">
+		<view v-if="menuItem.tryListen&&!isBuy" class="tryBox">
 			试看
 		</view>
 	</view>
 </template>
 
 <script>
+import { mapGetters } from 'vuex';
 import eventHub from '@/common/eventHub.js'
 export default {
 	name: 'courseSection',
@@ -34,11 +37,16 @@ export default {
 		menuItem: {
 			type: Object,
 			default: {}
+		},
+		isBuy: {
+			type: Boolean,
+			default: false
 		}
 	},
 	data() {
 		return {
-			nowTime:0
+			nowTime:0,
+			newId:0
 		};
 	},
 	onLoad() {},
@@ -47,12 +55,36 @@ export default {
 	},
 	mounted() {
 		this.nowTime = Number(new  Date().getTime()/1000).toFixed(0)
+		this.newId= this.menuItem.sectionId>0?this.menuItem.sectionId:this.menuItem.menuId
 	},
 	methods: {
 		getVideo(){
-			eventHub.$emit('getSection', this.menuItem.recordingUrl)
+			if(!this.isBuy){
+				//非购买
+				if(!this.menuItem.tryListen){
+					//不允许试听
+					return
+				}
+				
+			}
+			if(!this.menuItem.recordingUrl){
+				uni.showToast({
+				    title: '暂无播放数据',
+				    icon: 'error'
+				});
+			}
+			if(this.playSectionId==this.newId){
+				//切换为同一节
+				return
+			}
+			//设置播放的节ID
+			this.$store.commit('setPlaySectionId', {playSectionId  :this.newId});
+	//		return
+			eventHub.$emit('getSection', this.menuItem)
+			
 		}
-	}
+	},
+	computed: { ...mapGetters(['playSectionId']) }
 	
 };
 </script>
@@ -100,6 +132,15 @@ export default {
 		border: 2rpx solid #007AFF;
 		color: #007AFF;
 	}
+	.color3{
+		color: #FF9500;
+	}
+	.color2{
+		color: #FF3B30;
+	}
+	.color1{
+		color: #007AFF;
+	}
 	.tag{
 		border-radius: 8rpx;
 		font-size: 20rpx;

+ 3 - 1
iconfont/iconfont.css

@@ -15,7 +15,9 @@
   -webkit-font-smoothing: antialiased;
   -moz-osx-font-smoothing: grayscale;
 }
-
+.image-wrap {
+	max-width: 100%;
+}
 .iconrenzheng:before {
   content: "\e60b";
 }

+ 6 - 1
pages.json

@@ -170,6 +170,11 @@
 					"app-plus": {
 						"titleNView": false, //禁用原生导航栏 
 						"bounce": "none"
+					},
+					"mp-weixin": {
+						"usingComponents": {
+							"polyv-player": "plugin://polyv-player/player"
+						}
 					}
 				}
 			},
@@ -527,7 +532,7 @@
 		],
 		 "plugins": {
 			"polyv-player": {
-				"version": "0.1.5",
+				"version": "0.3.0",
 				"provider": "wx4a350a258a6f7876"
 			}
 		}

+ 21 - 10
pages2/class/detail.vue

@@ -1,9 +1,9 @@
 <template>
 	<view>
-		<view style="position: fixed;width: 100%;z-index: 999;background: #FFFFFF;" id="top">
+		<view style="position: fixed;width: 100%;z-index: 999;background: #FFFFFF;top: 0;" id="top">
 			<view class="video_box" v-if="!startStatus">
-				<image src="https://cdn.uviewui.com/uview/swiper/3.jpg" style="width: 100%;height: 460rpx;"></image>
-				<image class="video_play" src="/static/play.png" @click="startVideo"></image>
+				<image :src="$method.splitImgHost(detail.coverUrl)" style="width: 100%;height: 460rpx;"></image>
+				<image v-if="false" class="video_play" src="/static/play.png" @click="startVideo"></image>
 			</view>
 			<view v-else class="video_box" style="width: 100%;height: 460rpx;">
 				<polyv-player
@@ -41,11 +41,11 @@
 			<view v-show="current == 0">
 				<view class="menuBox" v-for="(item, index) in menuList">
 					<!--模块 -->
-					<view v-if="item.type == 1"><courseModule :menuItem="item"></courseModule></view>
+					<view v-if="item.type == 1"><courseModule :isBuy="true" :menuItem="item"></courseModule></view>
 					<!--章 -->
-					<view v-if="item.type == 2"><courseChapter :menuItem="item"></courseChapter></view>
+					<view v-if="item.type == 2"><courseChapter :isBuy="true" :menuItem="item"></courseChapter></view>
 					<!--节 -->
-					<view v-if="item.type == 3"><courseSection :menuItem="item"></courseSection></view>
+					<view v-if="item.type == 3"><courseSection :isBuy="true" :menuItem="item"></courseSection></view>
 				</view>
 			</view>
 			<!--笔记 -->
@@ -102,9 +102,9 @@
 
 <script>
 import eventHub from '@/common/eventHub.js';
-import courseModule from '@/pages2/components/course/courseModule.vue';
-import courseChapter from '@/pages2/components/course/courseChapter.vue';
-import courseSection from '@/pages2/components/course/courseSection.vue';
+import courseModule from '@/components/course/courseModule.vue';
+import courseChapter from '@/components/course/courseChapter.vue';
+import courseSection from '@/components/course/courseSection.vue';
 import { mapGetters } from 'vuex';
 export default {
 	components: {
@@ -166,23 +166,34 @@ export default {
 			],
 			current: 0,
 			vid:'',
+			goodsId:0,
+			goodsData:{}
 		};
 	},
 	onUnload() {},
 	computed: { ...mapGetters(['userInfo']) },
 	onLoad(option) {
 		this.courseId = option.id;
+		this.goodsId = uni.getStorageSync('courseGoodsId');
 		this.courseDetail();
 		this.getMenuList();
+		this.getGoodsDetail()
 	},
 	onShow() {},
 	mounted() {
 		eventHub.$on('getSection', item => {
-			this.vid = item
+			this.vid = item.recordingUrl
 			this.startStatus = true
 		});
 	},
 	methods: {
+		getGoodsDetail(){
+			let self = this
+			this.$api.goodsDetail(this.goodsId).then(res => {
+				self.goodsData = res.data.data;
+				 
+			})
+		},
 		startVideo() {
 			this.startStatus = true;
 		},

+ 131 - 13
pages2/course/detail.vue

@@ -2,7 +2,23 @@
 	<view>
 		<view class="videoBox" >
 			<view >
-				<image :src="$method.splitImgHost(detail.coverUrl)" style="height: 460rpx;width: 100%;"></image>
+				<view class="video_box" v-if="!startStatus">
+					<image :src="$method.splitImgHost(detail.coverUrl)" style="width: 100%;height: 460rpx;"></image>
+					<image v-if="false" class="video_play" src="/static/play.png" @click="startVideo"></image>
+				</view>
+				<view v-else class="video_box" style="width: 100%;height: 460rpx;">
+					<polyv-player
+						id="playerVideo"
+						playerId="playerVideo"
+						height="460rpx"
+						:vid="vid"
+						:showSettingBtn="true"
+						:enablePlayGesture="true"
+						:playbackRate="playbackRate"
+						:isAllowSeek="isAllowSeek"
+						:autoplay="autoplay"
+					></polyv-player>
+				</view>
 				<view style="padding:20rpx;height: 120rpx;">
 					<view style="display: flex;">
 						<view class="yearTag">{{detail.year}}</view>
@@ -23,7 +39,7 @@
 		</view>
 		<view style="padding: 20rpx;position: relative;top: 680rpx;" v-show="current==0">
 			<view class="content">
-				<view v-html="detail.mobileDetailHtml"></view>
+				<view v-html="detail.mobileDetailHtml" style="width: 100%;"></view>
 			</view>
 		</view>
 		<view style="padding: 20rpx;padding-bottom: 100rpx;position: relative;top: 680rpx;" v-show="current==1">
@@ -40,8 +56,8 @@
 						<view v-show="!item.down">
 							<view v-for="(itemM,indexM) in menuList" >
 								<courseModule v-if="itemM.type==1" :menuItem="itemM"></courseModule>
-								<courseChapter v-if="itemM.type==2" :menuItem="itemM"></courseChapter>
-								<courseSection v-if="itemM.type==3" :menuItem="itemM"></courseSection>
+								<courseChapter v-if="itemM.type==2" :isBuy="false" :menuItem="itemM"></courseChapter>
+								<courseSection v-if="itemM.type==3" :isBuy="false" :menuItem="itemM"></courseSection>
 								<u-line></u-line>
 							</view>
 						</view>
@@ -61,9 +77,10 @@
 </template>
 
 <script>
-import courseModule from '@/pages2/components/course/courseModule.vue';
-import courseChapter from '@/pages2/components/course/courseChapter.vue';
-import courseSection from '@/pages2/components/course/courseSection.vue';
+import eventHub from '@/common/eventHub.js';
+import courseModule from '@/components/course/courseModule.vue';
+import courseChapter from '@/components/course/courseChapter.vue';
+import courseSection from '@/components/course/courseSection.vue';
 import { mapGetters } from 'vuex';
 export default {
 	components: {
@@ -85,22 +102,81 @@ export default {
 			current:0,
 			detail:{},
 			courseList:[],
-			menuList:[]
+			menuList:[],
+			startStatus:false,
+			playbackRate: [1.0],
+			isAllowSeek:'no',
+			vid:'',
+			autoplay:true,
+			listenConfigList:[],
+			listenSecond:0,
+			timer:null
 		};
 	},
 	onUnload() {
 		
 	},
-	computed: { ...mapGetters(['userInfo','goodsAuditionConfigIdList']) },
+	computed: { ...mapGetters(['userInfo','goodsAuditionConfigIdList','playSectionId']) },
 	onLoad(option) {
 		this.id = option.id;
 		this.getDetail()
 		this.goodsCourseList()
 	},
-	onShow() {
-		
+	mounted() {
+		eventHub.$on('getSection', item => {
+			console.log('播放')
+			//播放试听
+			this.listenSecond = 0
+			for (var itemChild of this.listenConfigList) {
+				if(itemChild.sectionId==this.playSectionId){
+					if(itemChild.auditionMinute>0){
+						this.listenSecond = itemChild.auditionMinute *60 //试听秒数
+					}
+					
+				}
+			}
+			
+			if(this.listenSecond>0){
+				if(this.timer){
+					clearInterval(this.timer);
+				}
+				this.timer = setInterval(this.timeEvent, 2000);//定时器
+				this.vid = item.recordingUrl
+				this.startStatus = true
+			}else{
+				console.log(this.listenSecond,333)
+				this.$u.toast('试听配置错误');
+			}
+			
+		});
 	},
 	methods: {
+		closePlay(){
+			this.vid = ""
+			this.startStatus = false
+		},
+		timeEvent() {
+			let self = this
+		        var polyvPlayerContext = this.selectComponent('#playerVideo');
+				if (polyvPlayerContext != null) {
+					let PlayCurrentTime = polyvPlayerContext.getCurrentTime();
+					if(PlayCurrentTime>=this.listenSecond){
+						polyvPlayerContext.stop();
+						clearInterval(this.timer);
+						this.timer = null
+						uni.showModal({
+							title: '提示',
+							content: '试听结束',
+							showCancel:false,
+							success: function(resst) {
+								self.closePlay()
+							}
+						});
+						
+					}
+					
+				}
+		},
 		openCourse(item){
 			item.down = !item.down
 			if(!item.down&&this.menuList.length==0){
@@ -160,10 +236,14 @@ export default {
 			let sectionIdList = []
 			this.$api.goodsDetail(this.id).then(res => {
 				if(res.data.code==200){
+					if(res.data.data.mobileDetailHtml){
+						res.data.data.mobileDetailHtml = res.data.data.mobileDetailHtml.replace(/<img/gi,'<img style="max-width:100%;"')
+					}
+					
 					self.detail = res.data.data
 					if(self.detail.goodsAuditionConfig){
-						let configList = JSON.parse(self.detail.goodsAuditionConfig)
-						for (var itemChild of configList) {
+						self.listenConfigList = JSON.parse(self.detail.goodsAuditionConfig)
+						for (var itemChild of self.listenConfigList) {
 							sectionIdList.push(itemChild.sectionId)//存储试听节ID
 						}
 						self.$store.commit('setGoodsAuditionConfigIdList', {goodsAuditionConfigIdList:sectionIdList});
@@ -198,6 +278,43 @@ export default {
 	}
 </style>
 <style scope>
+	.video_t2 {
+		font-size: 24rpx;
+		font-family: PingFang SC;
+		font-weight: 500;
+		color: #666666;
+	}
+	.video_t1 {
+		height: 80rpx;
+		color: #333333;
+		line-height: 80rpx;
+		font-size: 30rpx;
+		font-family: PingFang SC;
+		font-weight: bold;
+		color: #333333;
+	}
+	.video_t1_t {
+		display: flex;
+		flex-direction: column;
+		height: 80rpx;
+		color: #333333;
+		text-align: center;
+		align-items: center;
+		border-left: solid 1px #d6d6db;
+	}
+	.video_play {
+		position: absolute;
+		width: 95rpx;
+		height: 95rpx;
+		top: 0;
+		left: 0;
+		right: 0;
+		bottom: 0;
+		margin: auto;
+	}
+	.video_box {
+		position: relative;
+	}
 	.courseName{
 		white-space:nowrap;
 		overflow:hidden;
@@ -235,6 +352,7 @@ export default {
 	}
 	.content{
 		background-color: #FFFFFF;
+		width: 100%;
 	}
 	.btn2{
 		width: 200rpx;

+ 9 - 3
pages2/wd/course.vue

@@ -1,6 +1,6 @@
 <template>
 	<view style="padding: 30rpx;">
-		<navigator :url="'/pages2/class/detail?id='+item.courseId" v-for="(item, index) in courseList" :key="index" style="margin-bottom: 30rpx;">
+		<view @click="jump(item)"  v-for="(item, index) in courseList" :key="index" style="margin-bottom: 30rpx;">
 			<view class="class_item">
 				<image :src="$method.splitImgHost(item.coverUrl, true)" style="height: 316rpx;width: 100%;border-radius: 24rpx;"></image>
 				<view style="color: #333333;font-weight: bold;font-size: 32rpx;">
@@ -23,7 +23,7 @@
 				
 			</view>
 			
-		</navigator>
+		</view>
 	</view>
 </template>
 
@@ -38,12 +38,18 @@
 		},
 		onLoad(option) {
 			this.goodsId = option.id
-			 this.courseCourseList()
+			uni.setStorageSync('courseGoodsId', this.goodsId);
+			this.courseCourseList()
 		},
 		onShow(){
 			
 		},
 		methods: {
+			jump(item){
+				this.$navTo.togo('/pages2/class/detail', {
+					id: item.courseId
+				});
+			},
 			courseCourseList() {
 				let self = this
 				this.$api.courseCourseList({goodsId:this.goodsId}).then(res => {

+ 8 - 1
store/index.js

@@ -12,7 +12,8 @@ const store = new Vuex.Store({
 		dictObj:null,
 		allowLoading:true,
 		goodsAuditionConfigIdList:[], //当前访问页面的试听节ID
-		shoppingCartList:[]  //购物车支付商品
+		shoppingCartList:[],//购物车支付商品
+		playSectionId:0
 	},  
 	 getters: {
 		userInfo: state => {
@@ -34,6 +35,9 @@ const store = new Vuex.Store({
 		},
 		shoppingCartList:state => {
 			return state.shoppingCartList
+		},
+		playSectionId:state => {
+			return state.playSectionId
 		}
 	},
     mutations: { 
@@ -46,6 +50,9 @@ const store = new Vuex.Store({
 		setShoppingCartList(state, provider){
 			state.shoppingCartList = provider.shoppingCartList;  
 		},
+		setPlaySectionId(state, provider){
+			state.playSectionId = provider.playSectionId;  
+		},
     }  
 })  
 async function getUserInfo(state){