Commit 75f36528 authored by 林文清's avatar 林文清

学习-页面调整

parent 741aa0dd
<template> <template>
<view class="study"> <view class="study">
<u-navbar <u-navbar :is-back="false" background="{background: transparent}" :border-bottom="false" :is-fixed="false">
:is-back="false" <text class="title-view">学习</text>
background="{background: transparent}"
:border-bottom="false"
:is-fixed="false"
>
<text class="title-view">学习</text>
</u-navbar> </u-navbar>
<image :src="bannerImage" mode="" class="banner"></image> <image :src="bannerImage" mode="" class="banner"></image>
<!-- <u-tabs :list="tabs" :is-scroll="false" :current="current" @change="change"></u-tabs> --> <!-- <u-tabs :list="tabs" :is-scroll="false" :current="current" @change="change"></u-tabs> -->
<view> <view>
<u-tabs-swiper bg-color="#F4F5F7" inactive-color="#999999" font-size="28" ref="uTabs" :list="tabs" :current="current" @change="tabsChange" :is-scroll="false" swiperWidth="750"></u-tabs-swiper> <u-tabs-swiper bg-color="#F4F5F7" inactive-color="#999999" font-size="28" ref="uTabs" :list="tabs"
:current="current" @change="tabsChange" :is-scroll="false" swiperWidth="750"></u-tabs-swiper>
</view> </view>
<swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" style="height: 755rpx;"> <swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish"
style="height: 755rpx;">
<swiper-item class="swiper-item"> <swiper-item class="swiper-item">
<scroll-view scroll-y style="height:796rpx;width:100%;" @scrolltolower="onreachBottom"> <scroll-view scroll-y style="height:796rpx;width:100%;" @scrolltolower="onreachBottom">
<view class="standard" @click="goToPrint"> <view class="standard" @click="goToPrint">
...@@ -47,15 +44,18 @@ ...@@ -47,15 +44,18 @@
<image class="img" :src=courselist.course.preview_pic mode=""></image> <image class="img" :src=courselist.course.preview_pic mode=""></image>
<view class="right"> <view class="right">
<view class=""> <view class="">
{{courselist.course.name}} {{courselist.course.name}}
</view> </view>
<view class="intro" v-html="courselist.course.intro"> <view class="intro" v-html="courselist.course.intro">
{{courselist.course.intro}} {{courselist.course.intro}}
</view> </view>
<view class="" style="display:flex;justify-content: space-between;"> <view class="" style="display:flex;justify-content: space-between;">
<u-line-progress active-color="#2979ff" :percent=courselist.learnedInfo.learnPercent style="width:54%;"></u-line-progress> <u-line-progress active-color="#2979ff"
<text v-text="(courselist.learnedInfo.isLearned) ?(courselist.learnedInfo.learnPercent==1)?'已完成':'继续':'未观看' "></text> :percent=courselist.learnedInfo.learnPercent style="width:54%;">
</u-line-progress>
<text
v-text="(courselist.learnedInfo.isLearned) ?(courselist.learnedInfo.learnPercent==1)?'已完成':'继续':'未观看' "></text>
</view> </view>
</view> </view>
</view> </view>
...@@ -69,7 +69,8 @@ ...@@ -69,7 +69,8 @@
快速学习,使用APP接单、抢单 快速学习,使用APP接单、抢单
</view> </view>
<view class="" style="display:flex;justify-content: space-between;"> <view class="" style="display:flex;justify-content: space-between;">
<u-line-progress active-color="#2979ff" :percent="30" style="width:54%;"></u-line-progress> <u-line-progress active-color="#2979ff" :percent="30" style="width:54%;">
</u-line-progress>
<text>继续</text> <text>继续</text>
</view> </view>
</view> </view>
...@@ -87,7 +88,8 @@ ...@@ -87,7 +88,8 @@
让你全面了解充电桩市场及服务规范 让你全面了解充电桩市场及服务规范
</view> </view>
<view class="" style="display:flex;justify-content: space-between;"> <view class="" style="display:flex;justify-content: space-between;">
<u-line-progress active-color="#2979ff" :percent="100" style="width:54%;"></u-line-progress> <u-line-progress active-color="#2979ff" :percent="100" style="width:54%;">
</u-line-progress>
<text>完成</text> <text>完成</text>
</view> </view>
</view> </view>
...@@ -162,378 +164,394 @@ ...@@ -162,378 +164,394 @@
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
msg: "赣南吴彦祖", msg: "赣南吴彦祖",
tabs: [ tabs: [{
{ name: "交付规范",
name: "交付规范", },
}, {
{ name: "培训通知",
name: "培训通知", },
}, {
{ name: "在线学习",
name: "在线学习", },
}, {
{ name: "考核认证",
name: "考核认证", },
}, ],
], current: 0,
current: 0, swiperCurrent: 0,
swiperCurrent: 0, params: {
params: { start: 0,
start: 0, },
}, list: [],
list: [], courselist: null,
courselist: null, loadStatus: "loading", //加载样式:loadMore-加载前样式,loading-加载加载中样式,nomore-没有数据样式
loadStatus: "loading", //加载样式:loadMore-加载前样式,loading-加载加载中样式,nomore-没有数据样式 isLoadMore: false, //是否加载中
isLoadMore: false, //是否加载中 course_id: "course_id_=173",
course_id: "course_id_=173", exam: null,
exam: null, };
}; },
}, onLoad() {
onLoad() { // this.getList();
this.getList(); // this.getCourseList();
this.getCourseList(); // this.getUserExamInfo();
this.getUserExamInfo(); },
}, computed: {
computed: { bannerImage() {
bannerImage() { return process.uniEnv.qn_base_url + "banner-xx.png";
return process.uniEnv.qn_base_url + "banner-xx.png"; },
}, },
}, methods: {
methods: { getList() {
getList() { this.$u.api
this.$u.api .getTrainingNoticeList(this.params)
.getTrainingNoticeList(this.params) .then((res) => {
.then((res) => { if (res.code == 200) {
if (res.code == 200) { if (res.data) {
if (res.data) { this.list = this.list.concat(res.data);
this.list = this.list.concat(res.data); if (res.data.length < 5) {
if (res.data.length < 5) { //判断接口返回数据量小于请求数据量,则表示此为最后一页
//判断接口返回数据量小于请求数据量,则表示此为最后一页 this.isLoadMore = true;
this.isLoadMore = true; this.loadStatus = "nomore";
this.loadStatus = "nomore"; } else {
} else { this.isLoadMore = false;
this.isLoadMore = false; }
} } else {
} else { this.isLoadMore = true;
this.isLoadMore = true; this.loadStatus = "nomore";
this.loadStatus = "nomore"; }
} } else {
} else { //接口请求失败的处理
//接口请求失败的处理 uni.showToast({
uni.showToast({ title: res.message,
title: res.message, icon: "none",
icon: "none", });
}); this.isLoadMore = false;
this.isLoadMore = false; if (this.params.start > 0) {
if (this.params.start > 0) { this.page -= 5;
this.page -= 5; }
} }
} })
}) .catch((err) => {
.catch((err) => { uni.showToast({
uni.showToast({ title: err,
title: err, icon: "none",
icon: "none", });
}); this.isLoadMore = false;
this.isLoadMore = false; if (this.params.start > 0) {
if (this.params.start > 0) { this.page -= 5;
this.page -= 5; }
} });
}); },
}, //在线学习通用课程信息
//在线学习通用课程信息 getCourseList() {
getCourseList() { this.$u.api
this.$u.api .CourseList()
.CourseList() .then((res) => {
.then((res) => { if (res.code == 200) {
if (res.code == 200) { if (res.data) {
if (res.data) { this.courselist = res.data;
this.courselist = res.data; console.log("--------");
console.log("--------"); console.log(this.courselist);
console.log(this.courselist); if (res.data.length < 5) {
if (res.data.length < 5) { //判断接口返回数据量小于请求数据量,则表示此为最后一页
//判断接口返回数据量小于请求数据量,则表示此为最后一页 this.isLoadMore = true;
this.isLoadMore = true; this.loadStatus = "nomore";
this.loadStatus = "nomore"; } else {
} else { this.isLoadMore = false;
this.isLoadMore = false; }
} } else {
} else { this.isLoadMore = true;
this.isLoadMore = true; this.loadStatus = "nomore";
this.loadStatus = "nomore"; }
} } else {
} else { //接口请求失败的处理
//接口请求失败的处理 uni.showToast({
uni.showToast({ title: res.message,
title: res.message, icon: "none",
icon: "none", });
}); this.isLoadMore = false;
this.isLoadMore = false; if (this.params.start > 0) {
if (this.params.start > 0) { this.page -= 5;
this.page -= 5; }
} }
} })
}) .catch((err) => {
.catch((err) => { uni.showToast({
uni.showToast({ title: err,
title: err, icon: "none",
icon: "none", });
}); this.isLoadMore = false;
this.isLoadMore = false; if (this.params.start > 0) {
if (this.params.start > 0) { this.page -= 5;
this.page -= 5; }
} });
}); },
}, //tabs通知swiper切换
//tabs通知swiper切换 tabsChange(index) {
tabsChange(index) { this.swiperCurrent = index;
this.swiperCurrent = index; switch (index) {
}, case 1:
//swiper-item左右移动,通知tabs的滑块跟随移动 this.getList();
transition(e) { break;
let dx = e.detail.dx; case 2:
this.$refs.uTabs.setDx(dx); this.getCourseList();
}, console.log('重新加载学习进度');
animationfinish(e) { break;
let current = e.detail.current; case 3:
this.$refs.uTabs.setFinishCurrent(current); this.getUserExamInfo();
this.swiperCurrent = current; break;
this.current = current; }
}, },
//跳转到assessment页面 //swiper-item左右移动,通知tabs的滑块跟随移动
aaa() { transition(e) {
wx.navigateTo({ let dx = e.detail.dx;
url: "./assessment", this.$refs.uTabs.setDx(dx);
}); },
}, animationfinish(e) {
//跳转到课程介绍 let current = e.detail.current;
ccc(id) { this.$refs.uTabs.setFinishCurrent(current);
uni.navigateTo({ this.swiperCurrent = current;
url: "./curriculum?course_id=" + id, this.current = current;
}); },
}, //跳转到assessment页面
//跳转到 aaa() {
bbb(e) { wx.navigateTo({
var news = { url: "./assessment",
body: e.body, });
id: e.id, },
level: e.level, //跳转到课程介绍
title: e.title, ccc(id) {
}; uni.navigateTo({
// console.log(news) url: "./curriculum?course_id=" + id,
});
},
//跳转到
bbb(e) {
var news = {
body: e.body,
id: e.id,
level: e.level,
title: e.title,
};
// console.log(news)
uni.navigateTo({ uni.navigateTo({
url: "./news-details", url: "./news-details",
}); });
setTimeout(() => { setTimeout(() => {
uni.$emit("news", news), console.log("发送数据"); uni.$emit("news", news), console.log("发送数据");
}, 500); }, 500);
console.log("跳转结束11111111"); console.log("跳转结束11111111");
}, },
//scroll-view到底部加载更多 //scroll-view到底部加载更多
onreachBottom() { onreachBottom() {
console.log("上拉触底函数"); console.log("上拉触底函数");
//上拉触底函数 //上拉触底函数
if (!this.isLoadMore) { if (!this.isLoadMore) {
this.isLoadMore = true; this.isLoadMore = true;
this.params.start += 5; this.params.start += 5;
if (this.loadStatus !== "nomore") { if (this.loadStatus !== "nomore") {
this.getList(); this.getList();
} }
} }
}, },
//跳转到拍照小程序首页 //跳转到拍照小程序首页
goToPrint() { goToPrint() {
console.log("111111"); console.log("111111");
uni.navigateToMiniProgram({ uni.navigateToMiniProgram({
appId: "wxd1d6eede324b0465", appId: "wxd1d6eede324b0465",
success(res) { success(res) {
//打开成功 //打开成功
console.log("success", res); console.log("success", res);
}, },
fail(err) { fail(err) {
console.log("err", err); console.log("err", err);
}, },
}); });
}, },
//考核认证,通用认证,考试通过or未通过查询接口请求 //考核认证,通用认证,考试通过or未通过查询接口请求
getUserExamInfo() { getUserExamInfo() {
uni.showLoading({ uni.showLoading({
title: "请稍候", title: "请稍候",
}); });
let that = this; let that = this;
uni.request({ uni.request({
url: url: "http://192.168.1.22" +
"http://192.168.1.22" + "/wxh-worker-rest/rest/exam" +
"/wxh-worker-rest/rest/exam" + "/serviceRule/userExamInfo/" +
"/serviceRule/userExamInfo/" + getApp().globalData.token +
getApp().globalData.token + "?examId=" +
"?examId=" + 2,
2, method: "POST",
method: "POST", data: {
data: { //examId:this.examId,
//examId:this.examId, },
}, header: {
header: { "Content-Type": "application/x-www-form-urlencoded",
"Content-Type": "application/x-www-form-urlencoded", },
}, success: (res) => {
success: (res) => { console.log(res.data);
console.log(res.data); uni.hideLoading();
uni.hideLoading(); if (!res.data) {
if (!res.data) { return;
return; }
} if (res.data.code == 401 || res.data.code == 403) {
if (res.data.code == 401 || res.data.code == 403) { // uni.navigateTo({
// uni.navigateTo({ // url: '/pages/login/wxlogin'
// url: '/pages/login/wxlogin' // })
// }) // return
// return console.log("洪塘张学友");
console.log("洪塘张学友"); }
} if (res.data.code == 200) {
if (res.data.code == 200) { //examStatus 用户考试状态 0考试中 1考试完成 2未参与
//examStatus 用户考试状态 0考试中 1考试完成 2未参与 that.exam = res.data.data;
that.exam = res.data.data; console.log(that.exam);
console.log(that.exam); if (res.data.data.examStatus == 2) {
if (res.data.data.examStatus == 2) { that.applyExam();
that.applyExam(); return;
return; }
} if (res.data.data.examStatus == 1) {
if (res.data.data.examStatus == 1) { console.log("111111111111111111111111111");
console.log("111111111111111111111111111"); that.isComplete = true;
that.isComplete = true; that.examScore = res.data.data.examScore;
that.examScore = res.data.data.examScore; that.postResult();
that.postResult(); return;
return; }
} if (res.data.data.examStatus == 0) {
if (res.data.data.examStatus == 0) { that.userExamId = res.data.data.id;
that.userExamId = res.data.data.id; that.getNext();
that.getNext(); }
} } else {
} else { uni.showToast({
uni.showToast({ icon: "none",
icon: "none", title: res.data.message,
title: res.data.message, });
}); }
} },
}, fail: (e) => {
fail: (e) => { uni.hideLoading();
uni.hideLoading(); uni.showToast({
uni.showToast({ icon: "none",
icon: "none", title: "获取考试信息失败",
title: "获取考试信息失败", });
}); },
}, });
}); },
}, },
}, };
};
</script> </script>
<style> <style>
.study { .study {
height: 100vh; height: 100vh;
background-color: #f4f5f7; background-color: #f4f5f7;
padding: 0rpx 30rpx 0 30rpx; padding: 0rpx 30rpx 0 30rpx;
} }
.title-view {
color: #333333; .title-view {
font-weight: bold; color: #333333;
font-size: 40rpx; font-weight: bold;
} font-size: 40rpx;
}
.banner {
width: 690rpx;
height: 240rpx;
/* margin-left: -15rpx; */
}
/* //交付规范 */
.standard {
width: 656rpx;
display: flex;
justify-content: space-between;
border-bottom: 1rpx solid #82848a;
padding: 0 34rpx;
margin: 72rpx auto;
}
/* //培训通知 */
.notice {
border: #808080 solid 2rpx;
width: 100%;
height: 400rpx;
margin-top: 36rpx;
overflow: hidden;
}
.n-head {
text-align: center;
margin: 32rpx 0;
}
.news {}
/* //在线学习 */
.currency-class {
width: 100%;
background: #ffffff;
padding: 18rpx;
margin-bottom: 11px;
border-radius: 12rpx;
}
.banner { .title {
width: 690rpx; font-size: 32rpx;
height: 240rpx; font-weight: bold;
/* margin-left: -15rpx; */ font-family: PingFang-SC-Bold, PingFang-SC;
} }
/* //交付规范 */ .class1 {
.standard { display: flex;
width: 656rpx; justify-content: space-between;
display: flex; padding-top: 22rpx;
justify-content: space-between; margin-top: 28rpx;
border-bottom: 1rpx solid #82848a; border-top: 1rpx solid #808080;
padding: 0 34rpx; }
margin: 72rpx auto;
}
/* //培训通知 */ .img {
.notice { width: 201rpx;
border: #808080 solid 2rpx; height: 201rpx;
width: 100%; display: block;
height: 400rpx; margin-right: 0rpx;
margin-top: 36rpx; }
overflow: hidden;
}
.n-head { .right {
text-align: center; width: 428rpx;
margin: 32rpx 0; display: flex;
} flex-direction: column;
.news { justify-content: space-between;
} }
/* //在线学习 */
.currency-class {
width: 100%;
background: #ffffff;
padding: 18rpx;
margin-bottom: 11px;
border-radius: 12rpx;
}
.title {
font-size: 32rpx;
font-weight: bold;
font-family: PingFang-SC-Bold, PingFang-SC;
}
.class1 {
display: flex;
justify-content: space-between;
padding-top: 22rpx;
margin-top: 28rpx;
border-top: 1rpx solid #808080;
}
.img { .intro {
width: 201rpx; color: #9999a6;
height: 201rpx; }
display: block;
margin-right: 0rpx;
}
.right { .tab {
width: 428rpx; background: #fff;
display: flex; height: 82rpx;
flex-direction: column; margin: 0 0;
justify-content: space-between; }
}
.intro {
color: #9999a6;
}
.tab {
background: #fff;
height: 82rpx;
margin: 0 0;
}
.text { .text {
margin: 0 40rpx; margin: 0 40rpx;
line-height: 82rpx; line-height: 82rpx;
color: #667eb5; color: #667eb5;
} }
.content { .content {
margin: 5px 0; margin: 5px 0;
height: 485rpx; height: 485rpx;
background: #fff; background: #fff;
} }
swiper { swiper {
height: 691rpx; height: 691rpx;
} }
</style> </style>
<template> <template>
<view class="learn-vedio" v-if="isShowVideo"> <view class="learn-vedio" v-if="isShowVideo">
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<view><video <view><video object-fit="cover" class="course-video" id="courseVideo" :src="courseSrc"
object-fit="cover" :options="playerOptions" :playsinline="true" @play="playCourse" @error="videoErrorCallback"
class="course-video" @ready="playerReadied" @timeupdate="onPlayerTimeupdate($event)" controls></video></view>
id="courseVideo" <view class="title-content">
:src="courseSrc" <view class="item-content">
:options="playerOptions" <view class="item-st">
:playsinline="true" <image style="width: 80rpx; height: 36rpx" :src="kcImage"></image>
@play="playCourse" <text class="item-st-text">{{ courseTitle.split(" ") ? courseTitle.split(" ")[0] : "" }}</text>
@error="videoErrorCallback" </view>
@ready="playerReadied" <view class="item-title">{{ courseTitle.split(" ") ? courseTitle.split(" ")[1] : "" }}</view>
@timeupdate = "onPlayerTimeupdate($event)" </view>
controls <view>接单操作须知有助你快速了解充电桩安装业务,提高接单效率,请认真查看及学习。</view>
></video </view>
></view> <view class="learn-view" v-if="courseId >= 0">
<view class="title-content"> <view class="learn-view-title">视频内容介绍</view>
<view class="item-content"> <!-- <view
<view class="item-st">
<image style="width: 80rpx; height: 36rpx" :src="kcImage"></image>
<text class="item-st-text">{{
courseTitle.split(" ") ? courseTitle.split(" ")[0] : ""
}}</text>
</view>
<view class="item-title">{{
courseTitle.split(" ") ? courseTitle.split(" ")[1] : ""
}}</view>
</view>
<view
>接单操作须知有助你快速了解充电桩安装业务,提高接单效率,请认真查看及学习。</view
>
</view>
<view class="learn-view" v-if="courseId >= 0">
<view class="learn-view-title">视频内容介绍</view>
<!-- <view
class="learn-list" class="learn-list"
v-for="(item, key) in courseOutlines[courseId]" v-for="(item, key) in courseOutlines[courseId]"
:key="key" :key="key"
> --> > -->
<view class="learn-list-item">{{ item }}</view> <!-- <view class="learn-list-item">{{ item }}</view> -->
</view> <view class="u-content">
</view> <u-parse :html="CourseSectionlist.content"></u-parse>
</view> </view>
</view>
</view>
</view>
<view v-else> <view v-else>
<view class="title"> <view class="title">
{{CourseSectionlist.name}} {{CourseSectionlist.name}}
</view> </view>
<view class="content" v-html="CourseSectionlist.content"> <view class="u-content">
{{CourseSectionlist.content}} <u-parse :html="CourseSectionlist.content"></u-parse>
</view> </view>
</view> </view>
</view>
</template> </template>
<script> <script>
let app = getApp(); let app = getApp();
export default { export default {
data() { data() {
return { return {
courseId: "", courseId: "",
courseStatus: 0, courseStatus: 0,
courseSrc: "", courseSrc: "",
courseTitle: "", courseTitle: "",
courseDesc: "", courseDesc: "",
currentIndex: -1, // 第几个视频 currentIndex: -1, // 第几个视频
section_id:0, section_id: 0,
isShowVideo: false, isShowVideo: false,
CourseSectionlist: {},//节信息 CourseSectionlist: {}, //节信息
playerOptions : { playerOptions: {
playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度 playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
autoplay: false, //如果true,浏览器准备好时开始回放。 autoplay: true, //如果true,浏览器准备好时开始回放。
muted: false, // 默认情况下将会消除任何音频。 muted: false, // 默认情况下将会消除任何音频。
loop: false, // 导致视频一结束就重新开始。 loop: false, // 导致视频一结束就重新开始。
preload: 'auto', preload: 'auto',
language: 'zh-CN', language: 'zh-CN',
aspectRatio: '16:9', aspectRatio: '16:9',
fluid: true, fluid: true,
// sources: [{ notSupportedMessage: '此视频暂无法播放,请稍后再试',
// type: "", controlBar: {
// src: "" //url地址 timeDivider: true,
// }], durationDisplay: true,
// poster: "../../static/images/test.jpg", //你的封面地址 remainingTimeDisplay: false,
// width: document.documentElement.clientWidth, fullscreenToggle: 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: {
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
}
this.changeCourseStatus();
},
playerReadied (player) {
console.log('i go to playerReadied gklog:' + this.gklog)
player.currentTime(this.gklog)
},
changeCourseStatus() {
let that = this;
if (that.courseId) {
that.$u.api
.saveCourseRate({
courseId: that.courseId,
})
.then((res) => {
if (res.code !== 200) {
uni.showToast({
icon: "none",
title: "更新课程状态失败",
});
}
});
} else {
uni.showToast({
title: "课程ID为空,请重新选择课程",
});
}
},
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";
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);
this.courseTitle = res.data.name;
this.courseDesc = res.data.content;
this.section_id = res.data.id;
}
} }
} },
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
}) })
.catch((err) => { },
console.log('--------settttt---------'); onReady: function(res) {
console.log(err); // #ifndef MP-ALIPAY
uni.showToast({ this.videoContext = uni.createVideoContext("courseVideo");
title: err, // #endif
icon: "none", },
methods: {
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() {
updateLearnedStatus(nowLength) { const rgb = [];
if(this.gklog != nowLength && nowLength%this.howTimeToUpdateLearnedStatus == 0){ for (let i = 0; i < 3; ++i) {
if(nowLength < this.howLongIsLearned){ let color = Math.floor(Math.random() * 256).toString(16);
this.status = 0; color = color.length == 1 ? "0" + color : color;
}else{ rgb.push(color);
this.status = 1; }
console.log('--已学习--'); return "#" + rgb.join("");
} },
//大于 playCourse: function(e) {
let param = { if (this.courseStatus && (this.courseStatus == "1" || this.courseStatus == 1)) {
section_id: this.section_id, return
video_time: nowLength, }
status: this.status, this.changeCourseStatus();
}; },
this.$u.api.updateLearnCourses(param).then((res) => { playerReadied(player) {
console.log('--'+this.howTimeToUpdateLearnedStatus+'更新一次观看状态--time:' + nowLength); console.log('i go to playerReadied gklog:' + this.gklog)
}); player.currentTime(this.gklog)
} },
} changeCourseStatus() {
}, let that = this;
}; if (that.courseId) {
that.$u.api
.saveCourseRate({
courseId: that.courseId,
})
.then((res) => {
if (res.code !== 200) {
uni.showToast({
icon: "none",
title: "更新课程状态失败",
});
}
});
} else {
uni.showToast({
title: "课程ID为空,请重新选择课程",
});
}
},
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";
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);
this.courseTitle = res.data.name;
this.courseDesc = res.data.content;
this.section_id = res.data.id;
this.section_content = res.data.content;
}
}
}
})
.catch((err) => {
console.log('--------settttt---------');
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);
});
}
}
},
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.learn-vedio { .learn-vedio {
background-color: #f4f5f7; background-color: #f4f5f7;
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
overflow-y:auto; overflow-y: auto;
} }
.course-video {
width: 100%;
}
.course-video { .course-title {
width: 100%; font-size: 36rpx;
} font-weight: 700;
padding: 40rpx 40rpx 10rpx 40rpx;
}
.course-title { .title {
font-size: 36rpx; font-weight: 700;
font-weight: 700; font-family: Medium, Helvetica Neue, Helvetica, Arial, sans-serif;
padding: 80rpx 60rpx 40rpx 60rpx; font-size: 77rpx;
} color: #333;
padding: 80rpx 60rpx 40rpx 60rpx;
}
.content {
padding: 40rpx 30rpx;
margin-bottom: 20rpx;
}
.title { .course-desc {
font-weight: 700; margin-left: 60rpx;
font-family: Medium,Helvetica Neue,Helvetica,Arial,sans-serif; }
font-size: 77rpx;
color: #333;
padding: 80rpx 60rpx 40rpx 60rpx;
}
.content { .title-content {
padding: 40rpx 30rpx; padding: 40rpx 30rpx;
margin-bottom: 20rpx; margin-bottom: 20rpx;
} background-color: #ffffff;
color: #999999;
font-size: 24rpx;
.course-desc { .item-content {
margin-left: 60rpx; display: flex;
} align-items: center;
}
.title-content { .item-st {
padding: 40rpx 30rpx; width: 80rpx;
margin-bottom: 20rpx; height: 36rpx;
background-color: #ffffff; padding-right: 2rpx;
color: #999999; text-align: center;
font-size: 24rpx; margin-right: 20rpx;
line-height: 24rpx;
position: relative;
.item-content { .item-st-text {
display: flex; color: #ffffff;
align-items: center; position: absolute;
} font-size: 16rpx;
left: 20rpx;
top: 8rpx;
line-height: 28rpx;
}
}
.item-st { .item-title {
width: 80rpx; color: #333333;
height: 36rpx; font-size: 44rpx;
padding-right: 2rpx; font-weight: bold;
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-title { .item-content {
color: #333333; display: flex;
font-size: 44rpx; padding-bottom: 30rpx;
font-weight: bold; }
}
}
.item-content { .item-title {
display: flex; color: #333333;
padding-bottom: 30rpx; font-size: 28rpx;
} }
.item-title { .learn-view {
color: #333333; background-color: #ffffff;
font-size: 28rpx; border-radius: 12rpx;
} padding: 38rpx 30rpx 30rpx 30rpx;
margin-bottom: 20rpx;
font-size: 32rpx;
color: #333333;
.learn-view { .learn-view-title {
background-color: #ffffff; font-size: 32rpx;
border-radius: 12rpx; font-weight: bold;
padding: 38rpx 30rpx 30rpx 30rpx; margin-bottom: 10rpx;
margin-bottom: 20rpx; }
font-size: 32rpx;
color: #333333;
.learn-view-title { .learn-list {
font-size: 32rpx; .learn-list-item {
font-weight: bold; font-size: 28rpx;
margin-bottom: 10rpx; margin-top: 30rpx;
} margin-bottom: 30rpx;
.learn-list { color: #333333;
.learn-list-item { }
font-size: 28rpx;
margin-top: 30rpx;
margin-bottom: 30rpx;
color: #333333;
}
.line-view { .line-view {
background-color: #f4f5f7; background-color: #f4f5f7;
height: 2rpx; height: 2rpx;
width: 100%; width: 100%;
} }
} }
} }
.u-content {
// margin-top: 10rpx;
padding: 40rpx 30rpx;
margin-bottom: 20rpx;
}
</style> </style>
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