Commit 80cdc868 authored by 林文清's avatar 林文清

学习视频详情,少了个view标签

parent b062d88b
<template>
<view class="learn-vedio" v-if="isShowVideo">
<view class="uni-padding-wrap uni-common-mt">
<view><video object-fit="cover" class="course-video" id="courseVideo" :src="courseSrc"
:options="playerOptions" :playsinline="true" @play="playCourse" @error="videoErrorCallback"
@ready="playerReadied" @timeupdate="onPlayerTimeupdate($event)" controls></video></view>
<view class="title-content">
<view class="item-content">
<view class="item-st">
<image style="width: 80rpx; height: 36rpx" :src="kcImage"></image>
<text class="item-st-text">5课时</text>
</view>
<view class="item-title">服务规范</view>
</view>
<view>接单操作须知有助你快速了解充电桩安装业务,提高接单效率,请认真查看及学习。</view>
</view>
<view class="learn-view" v-if="courseId >= 0">
<view class="learn-view-title">课程讲师</view>
<view class="" style="padding-top: 30rpx;display: flex;padding-left: 30rpx;">
<u-avatar :style="{'width':'100rpx', 'height':'100rpx'}" :src="teacher.avatar" mode="circle"></u-avatar>
<view style="height:120rpx;font-size: 30rpx;padding-left:30rpx;">
<view class="" style="display: flex;font-size: 32rpx;">
<view class="" style="font-size: 32rpx;font-weight: bold;">{{ teacher.name }}</view>
<view class="" style="font-size: 24rpx;margin-left: 30rpx;margin-top: 6rpx;">课程讲师</view>
<view class="">
<view class="learn-vedio" v-if="isShowVideo">
<view class="uni-padding-wrap uni-common-mt">
<view><video object-fit="cover" class="course-video" id="courseVideo" :src="courseSrc"
:options="playerOptions" :playsinline="true" @play="playCourse" @error="videoErrorCallback"
@ready="playerReadied" @timeupdate="onPlayerTimeupdate($event)" controls></video></view>
<view class="title-content">
<view class="item-content">
<view class="item-st">
<image style="width: 80rpx; height: 36rpx" :src="kcImage"></image>
<text class="item-st-text">5课时</text>
</view>
<view class="" style="font-size: 24rpx;margin-top: 30rpx;">反正这里就是放老师的简介,只是写啥我也不知道,反正就是写很厉害的简介啦</view>
<view class="item-title">服务规范</view>
</view>
<view>接单操作须知有助你快速了解充电桩安装业务,提高接单效率,请认真查看及学习。</view>
</view>
<view class="learn-view-title">目录</view>
<view class="" style="display: flex;overflow: auto;padding-top: 30rpx;padding-bottom: 30rpx;">
<view v-for="(item, index) in list" :key="index">
<view @click="goNext(item.id)" class="list-cell list-default" :class="{'list-default-active': item.isActive}" style="width:280rpx;height:150rpx;margin-left: 20rpx;padding: 20rpx;border-radius: 12rpx;">
<view class="" style="font-size: 24rpx;">{{ item.title }}</view>
<view class="" style="font-size: 26rpx;margin-top: 16rpx;">
{{ item.intro }}
<view class="learn-view" v-if="courseId >= 0">
<view class="learn-view-title">课程讲师</view>
<view class="" style="padding-top: 30rpx;display: flex;padding-left: 30rpx;">
<u-avatar :style="{'width':'100rpx', 'height':'100rpx'}" :src="teacher.avatar" mode="circle"></u-avatar>
<view style="height:120rpx;font-size: 30rpx;padding-left:30rpx;">
<view class="" style="display: flex;font-size: 32rpx;">
<view class="" style="font-size: 32rpx;font-weight: bold;">{{ teacher.name }}</view>
<view class="" style="font-size: 24rpx;margin-left: 30rpx;margin-top: 6rpx;">课程讲师</view>
</view>
<view class="" style="font-size: 24rpx;margin-top: 30rpx;">反正这里就是放老师的简介,只是写啥我也不知道,反正就是写很厉害的简介啦</view>
</view>
</view>
<view class="learn-view-title">目录</view>
<view class="" style="display: flex;overflow: auto;padding-top: 30rpx;padding-bottom: 30rpx;">
<view v-for="(item, index) in list" :key="index">
<view @click="goNext(item.id)" class="list-cell list-default" :class="{'list-default-active': item.isActive}" style="width:280rpx;height:150rpx;margin-left: 20rpx;padding: 20rpx;border-radius: 12rpx;">
<view class="" style="font-size: 24rpx;">{{ item.title }}</view>
<view class="" style="font-size: 26rpx;margin-top: 16rpx;">
{{ item.intro }}
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<view v-else>
<view class="title">
{{CourseSectionlist.name}}
</view>
<view class="u-content">
<u-parse :html="CourseSectionlist.content"></u-parse>
</view>
</view>
<view v-else>
<view class="title">
{{CourseSectionlist.name}}
</view>
<view class="u-content">
<u-parse :html="CourseSectionlist.content"></u-parse>
</view>
</view>
</view>
</template>
<script>
let app = getApp();
export default {
data() {
return {
courseId: "",
courseStatus: 0,
courseSrc: "",
courseTitle: "",
courseDesc: "",
currentIndex: -1, // 第几个视频
section_id: 0,
isShowVideo: false,
CourseSectionlist: {name: '', content: ''}, //节信息
let app = getApp();
export default {
data() {
return {
courseId: "",
courseStatus: 0,
courseSrc: "",
courseTitle: "",
courseDesc: "",
currentIndex: -1, // 第几个视频
section_id: 0,
isShowVideo: false,
CourseSectionlist: {name: '', content: ''}, //节信息
list: [
{'title': '第一节', 'intro': '考核规则1:接单及 时率', 'isActive': true},
{'title': '第二节', 'intro': '考核规则1:接单及 时率', 'isActive': false},
{'title': '第三节', 'intro': '考核规则1:接单及 时率', 'isActive': false},
{'title': '第四节', 'intro': '考核规则1:接单及 时率', 'isActive': false},
{'title': '第五节', 'intro': '考核规则1:接单及 时率', 'isActive':false},
{'title': '第一节', 'intro': '考核规则1:接单及 时率', 'isActive': true, "id": 288},
{'title': '第二节', 'intro': '考核规则1:接单及 时率', 'isActive': false, "id": 288},
{'title': '第三节', 'intro': '考核规则1:接单及 时率', 'isActive': false, "id": 288},
{'title': '第四节', 'intro': '考核规则1:接单及 时率', 'isActive': false, "id": 288},
{'title': '第五节', 'intro': '考核规则1:接单及 时率', 'isActive':false, "id": 288},
],
teacher: {
name: "",
avatar: ""
},
playerOptions: {
playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
autoplay: true, //如果true,浏览器准备好时开始回放。
muted: false, // 默认情况下将会消除任何音频。
loop: false, // 导致视频一结束就重新开始。
preload: 'auto',
language: 'zh-CN',
aspectRatio: '16:9',
fluid: true,
notSupportedMessage: '此视频暂无法播放,请稍后再试',
controlBar: {
timeDivider: true,
durationDisplay: true,
remainingTimeDisplay: false,
fullscreenToggle: true //全屏按钮
}
},
gklog: '',
videoTotalTime: 0,
howTimeToUpdateLearnedStatus: 5, //设置几秒提交一次状态
status: 1, //是否已学习默认1已学习
howLongIsLearned: this.videoTotalTime / 2, //默认设置观看1/2就是已学
};
},
computed: {
courseOutlines() {
// 视频内容介绍
return {
1: [
"1、考核规则:接单及时率",
"2、考核规则:上门及时率",
"3、考核规则:安装完工率",
"4、考核规则:资料提交及时率",
"5、考核规则:安装完工率",
"6、考核规则:客户满意度",
],
2: ["1、必备材料4大类", "2、施工工具准备"],
3: [
"1、接线安装工艺标准",
"2、PVC、镀锌管电缆管明敷",
"3、电缆敷设的防火要求",
"4、电源点标识",
"5、配电箱接线及安装",
"6、管线敷设接头处理",
"7、充电桩内部接线",
"8、配电箱安装",
],
4: ["1、勘测环节录单要求", "2、安装环节录单要求"],
};
},
kcImage() {
return process.uniEnv.qn_base_url + "kc.png";
},
},
onLoad(e) {
this.getCourseSection({
section_id: e.section_id
})
},
onReady: function(res) {
// #ifndef MP-ALIPAY
this.videoContext = uni.createVideoContext("courseVideo");
// #endif
},
methods: {
playerOptions: {
playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
autoplay: true, //如果true,浏览器准备好时开始回放。
muted: false, // 默认情况下将会消除任何音频。
loop: false, // 导致视频一结束就重新开始。
preload: 'auto',
language: 'zh-CN',
aspectRatio: '16:9',
fluid: true,
notSupportedMessage: '此视频暂无法播放,请稍后再试',
controlBar: {
timeDivider: true,
durationDisplay: true,
remainingTimeDisplay: false,
fullscreenToggle: true //全屏按钮
}
},
params:{
course_id:0,
},
gklog: '',
videoTotalTime: 0,
howTimeToUpdateLearnedStatus: 5, //设置几秒提交一次状态
status: 1, //是否已学习默认1已学习
howLongIsLearned: this.videoTotalTime / 2, //默认设置观看1/2就是已学
};
},
computed: {
courseOutlines() {
// 视频内容介绍
return {
1: [
"1、考核规则:接单及时率",
"2、考核规则:上门及时率",
"3、考核规则:安装完工率",
"4、考核规则:资料提交及时率",
"5、考核规则:安装完工率",
"6、考核规则:客户满意度",
],
2: ["1、必备材料4大类", "2、施工工具准备"],
3: [
"1、接线安装工艺标准",
"2、PVC、镀锌管电缆管明敷",
"3、电缆敷设的防火要求",
"4、电源点标识",
"5、配电箱接线及安装",
"6、管线敷设接头处理",
"7、充电桩内部接线",
"8、配电箱安装",
],
4: ["1、勘测环节录单要求", "2、安装环节录单要求"],
};
},
kcImage() {
return process.uniEnv.qn_base_url + "kc.png";
},
},
onLoad(e) {
this.getCourseSection({
section_id: e.section_id
})
this.getCapterDetails();
},
onReady: function(res) {
// #ifndef MP-ALIPAY
this.videoContext = uni.createVideoContext("courseVideo");
// #endif
},
methods: {
goNext(id){
uni.navigateTo({
url: "./section?section_id=" + id,
});
},
onPlayerTimeupdate(player) {
console.log('-----onplay----');
console.log(player);
let intCurrentTime = parseInt(player.detail.currentTime);
this.updateLearnedStatus(intCurrentTime);
this.gklog = intCurrentTime;
console.log(' onPlayerTimeupdate!', this.gklog)
},
videoErrorCallback: function(e) {
uni.showModal({
content: e.target.errMsg,
showCancel: false,
});
},
getRandomColor: function() {
const rgb = [];
for (let i = 0; i < 3; ++i) {
let color = Math.floor(Math.random() * 256).toString(16);
color = color.length == 1 ? "0" + color : color;
rgb.push(color);
}
return "#" + rgb.join("");
},
playCourse: function(e) {
if (this.courseStatus && (this.courseStatus == "1" || this.courseStatus == 1)) {
return
}
},
playerReadied(player) {
console.log('i go to playerReadied gklog:' + this.gklog)
player.currentTime(this.gklog)
},
getCourseSection(param) {
this.$u.api
.CourseSection(param)
.then((res) => {
if (res.code == 200) {
if (res.data) {
this.CourseSectionlist = res.data;
console.log("--------")
console.log(this.CourseSectionlist)
let wareVal = this.CourseSectionlist.ware;
this.isShowVideo = wareVal == "0";
this.courseTitle = res.data.name;
this.courseDesc = res.data.content;
this.section_id = res.data.id;
this.section_content = res.data.content;
this.teacher.name = res.data.teachers[0].name;
this.teacher.avatar = res.data.teachers[0].avatar;
if (this.isShowVideo) {
let coureWareList = res.data.courseware;
this.courseSrc = coureWareList[0].src;
this.videoTotalTime = parseInt(JSON.parse(coureWareList[0].info).time);
console.log('视频时长信息:' + this.videoTotalTime);
}else{
this.updateLearnedStatusForText();
}
}
}
})
.catch((err) => {
console.log('--------settttt---------');
console.log(err);
uni.showToast({
title: err,
icon: "none",
});
});
},
updateLearnedStatusForText() {
if (this.isShowVideo) {
return false;
}
let param = {
section_id: this.section_id,
video_time: 0,
status: 1,
};
this.$u.api.updateLearnCourses(param).then((res) => {
// console.log('--' + this.howTimeToUpdateLearnedStatus + '更新一次观看状态--time:' + nowTime);
}).catch((err) => {
console.log('--------updateLearnedStatusForText---------');
console.log(err);
uni.showToast({
title: err,
icon: "none",
});
});
},
updateLearnedStatus(nowTime) {
if (this.gklog != nowTime && nowTime % this.howTimeToUpdateLearnedStatus == 0) {
if (nowTime < this.howLongIsLearned) {
this.status = 0;
} else {
this.status = 1;
console.log('--大于规定时间标记为已学习--');
}
onPlayerTimeupdate(player) {
console.log('-----onplay----');
console.log(player);
let intCurrentTime = parseInt(player.detail.currentTime);
this.updateLearnedStatus(intCurrentTime);
this.gklog = intCurrentTime;
console.log(' onPlayerTimeupdate!', this.gklog)
},
videoErrorCallback: function(e) {
uni.showModal({
content: e.target.errMsg,
showCancel: false,
});
},
getRandomColor: function() {
const rgb = [];
for (let i = 0; i < 3; ++i) {
let color = Math.floor(Math.random() * 256).toString(16);
color = color.length == 1 ? "0" + color : color;
rgb.push(color);
}
return "#" + rgb.join("");
},
playCourse: function(e) {
if (this.courseStatus && (this.courseStatus == "1" || this.courseStatus == 1)) {
return
}
},
playerReadied(player) {
console.log('i go to playerReadied gklog:' + this.gklog)
player.currentTime(this.gklog)
},
getCourseSection(param) {
this.$u.api
.CourseSection(param)
.then((res) => {
if (res.code == 200) {
if (res.data) {
this.CourseSectionlist = res.data;
console.log("--------")
console.log(this.CourseSectionlist)
let wareVal = this.CourseSectionlist.ware;
this.isShowVideo = wareVal == "0";
this.courseTitle = res.data.name;
this.courseDesc = res.data.content;
this.section_id = res.data.id;
this.section_content = res.data.content;
this.teacher.name = res.data.teachers[0].name;
this.teacher.avatar = res.data.teachers[0].avatar;
this.param.course_id = res.data.course_id;
if (this.isShowVideo) {
let coureWareList = res.data.courseware;
this.courseSrc = coureWareList[0].src;
this.videoTotalTime = parseInt(JSON.parse(coureWareList[0].info).time);
console.log('视频时长信息:' + this.videoTotalTime);
}else{
this.updateLearnedStatusForText();
}
}
}
})
.catch((err) => {
console.log('--------settttt---------');
console.log(err);
uni.showToast({
title: err,
icon: "none",
});
});
},
updateLearnedStatusForText() {
if (this.isShowVideo) {
return false;
}
let param = {
section_id: this.section_id,
video_time: 0,
status: 1,
};
this.$u.api.updateLearnCourses(param).then((res) => {
// console.log('--' + this.howTimeToUpdateLearnedStatus + '更新一次观看状态--time:' + nowTime);
}).catch((err) => {
console.log('--------updateLearnedStatusForText---------');
console.log(err);
uni.showToast({
title: err,
icon: "none",
});
});
},
updateLearnedStatus(nowTime) {
if (this.gklog != nowTime && nowTime % this.howTimeToUpdateLearnedStatus == 0) {
if (nowTime < this.howLongIsLearned) {
this.status = 0;
} else {
this.status = 1;
console.log('--大于规定时间标记为已学习--');
}
let param = {
section_id: this.section_id,
video_time: nowTime,
status: this.status,
};
this.$u.api.updateLearnCourses(param).then((res) => {
console.log('--' + this.howTimeToUpdateLearnedStatus + '更新一次观看状态--time:' + nowTime);
}).catch((err) => {
console.log('--------updateLearnedStatus---------');
console.log(err);
uni.showToast({
title: err,
icon: "none",
});
});
}
}
},
};
let param = {
section_id: this.section_id,
video_time: nowTime,
status: this.status,
};
this.$u.api.updateLearnCourses(param).then((res) => {
console.log('--' + this.howTimeToUpdateLearnedStatus + '更新一次观看状态--time:' + nowTime);
}).catch((err) => {
console.log('--------updateLearnedStatus---------');
console.log(err);
uni.showToast({
title: err,
icon: "none",
});
});
}
},
//获取章节详情
getCapterDetails() {
console.log('获取章节详情')
this.$u.api
.ChapterDetails(this.params)
.then((res) => {
if (res.code == 200) {
if (res.data) {
debugger
this.list = this.list.concat(res.data);
console.log(this.list)
}
} else {
//接口请求失败的处理
uni.showToast({
title: res.message,
icon: "none"
});
}
})
.catch((err) => {
uni.showToast({
title: err,
icon: "none",
});
this.isLoadMore = false;
if (this.params.start > 0) {
this.page -= 5;
}
});
},
},
};
</script>
<style lang="scss" scoped>
.learn-vedio {
background-color: #f4f5f7;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
overflow-y: auto;
}
.learn-vedio {
background-color: #f4f5f7;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
overflow-y: auto;
}
.course-video {
width: 100%;
}
.course-video {
width: 100%;
}
.course-title {
font-size: 36rpx;
font-weight: 700;
padding: 40rpx 40rpx 10rpx 40rpx;
}
.course-title {
font-size: 36rpx;
font-weight: 700;
padding: 40rpx 40rpx 10rpx 40rpx;
}
.title {
font-weight: 700;
font-family: Medium, Helvetica Neue, Helvetica, Arial, sans-serif;
font-size: 77rpx;
color: #333;
padding: 80rpx 60rpx 40rpx 60rpx;
}
.title {
font-weight: 700;
font-family: Medium, Helvetica Neue, Helvetica, Arial, sans-serif;
font-size: 77rpx;
color: #333;
padding: 80rpx 60rpx 40rpx 60rpx;
}
.content {
padding: 40rpx 30rpx;
margin-bottom: 20rpx;
}
.content {
padding: 40rpx 30rpx;
margin-bottom: 20rpx;
}
.course-desc {
margin-left: 60rpx;
}
.course-desc {
margin-left: 60rpx;
}
.title-content {
padding: 40rpx 30rpx;
margin-bottom: 20rpx;
background-color: #ffffff;
color: #999999;
font-size: 24rpx;
.title-content {
padding: 40rpx 30rpx;
margin-bottom: 20rpx;
background-color: #ffffff;
color: #999999;
font-size: 24rpx;
.item-content {
display: flex;
align-items: center;
}
.item-content {
display: flex;
align-items: center;
}
.item-st {
width: 80rpx;
height: 36rpx;
padding-right: 2rpx;
text-align: center;
margin-right: 20rpx;
line-height: 24rpx;
position: relative;
.item-st {
width: 80rpx;
height: 36rpx;
padding-right: 2rpx;
text-align: center;
margin-right: 20rpx;
line-height: 24rpx;
position: relative;
.item-st-text {
color: #ffffff;
position: absolute;
font-size: 16rpx;
left: 20rpx;
top: 8rpx;
line-height: 28rpx;
}
}
.item-st-text {
color: #ffffff;
position: absolute;
font-size: 16rpx;
left: 20rpx;
top: 8rpx;
line-height: 28rpx;
}
}
.item-title {
color: #333333;
font-size: 44rpx;
font-weight: bold;
}
}
.item-title {
color: #333333;
font-size: 44rpx;
font-weight: bold;
}
}
.item-content {
display: flex;
padding-bottom: 30rpx;
}
.item-content {
display: flex;
padding-bottom: 30rpx;
}
.item-title {
color: #333333;
font-size: 28rpx;
}
.item-title {
color: #333333;
font-size: 28rpx;
}
.learn-view {
background-color: #ffffff;
border-radius: 12rpx;
// padding: 38rpx 30rpx 30rpx 30rpx;
// margin-bottom: 20rpx;
font-size: 32rpx;
color: #333333;
.learn-view {
background-color: #ffffff;
border-radius: 12rpx;
// padding: 38rpx 30rpx 30rpx 30rpx;
// margin-bottom: 20rpx;
font-size: 32rpx;
color: #333333;
.learn-view-title {
font-size: 32rpx;
font-weight: bold;
margin-bottom: 10rpx;
.learn-view-title {
font-size: 32rpx;
font-weight: bold;
margin-bottom: 10rpx;
padding-top: 30rpx;
margin-left: 30rpx;
}
}
.learn-list {
.learn-list-item {
font-size: 28rpx;
margin-top: 30rpx;
margin-bottom: 30rpx;
color: #333333;
}
.learn-list {
.learn-list-item {
font-size: 28rpx;
margin-top: 30rpx;
margin-bottom: 30rpx;
color: #333333;
}
.line-view {
background-color: #f4f5f7;
height: 2rpx;
width: 100%;
}
}
}
.line-view {
background-color: #f4f5f7;
height: 2rpx;
width: 100%;
}
}
}
.u-content {
// margin-top: 10rpx;
padding: 40rpx 30rpx;
margin-bottom: 20rpx;
}
.u-content {
// margin-top: 10rpx;
padding: 40rpx 30rpx;
margin-bottom: 20rpx;
}
.list-default {
background-color: #F4F5F7;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment