123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- const app = getApp()
- const util = require("../../../utils/util");
- const api = require('../../../api/api.js');
- const user = require('../../../utils/user.js');
- import moment from 'moment'
- var WxParse = require('../../../lib/wxParse/wxParse.js');
- Page({
- data: {
- isFinished:false,
- id:'',
- courseid:'',
- courseHtml:'',
- courseInfo:{
- arrangement:{
- },
- course:{
- contentType:''
- },
- courseSkill:'',
- courseVideoList:[
- ],
- enrolment:{},
- relationCourse:[],
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- console.log(options);
- if(options){
- this.setData({
- id:options.id,
- courseid:options.courseid
- });
- }
- this.getCourseDetail();
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
-
- },
- videoBegin(e){
- console.log(e);
- // wx.showModal({
- // title: 'start',
- // content: JSON.stringify(e),
- // showCancel: false,
- // confirmText: '确定',
- // success: function (res) {
-
- // }
- // })
- },
- videoPlay(e){
- console.log(e);
- },
- videoEnd(e){
- console.log(e);
- let videoid=e.currentTarget.dataset.videoid;
- // wx.showModal({
- // title: 'end',
- // content: JSON.stringify(e),
- // showCancel: false,
- // confirmText: '确定',
- // success: function (res) {
-
- // }
- // });
- let userInfo = wx.getStorageSync('userInfo');
- util.request(api.addStudyLog, {
- courseEmentId:this.data.id,
- courseId:this.data.courseid,
- videoOssId:videoid,
- workerNo: userInfo.workerNo,
- workerName:userInfo.workerName
- }, 'POST').then(res=> {
- if (res.errno === 0) {
- wx.showToast({
- title: '该视频已完成',
- icon:'none'
- });
- this.getCourseDetail();
- }
- });
-
- },
- getCourseDetail(){
- util.request(api.getCourseInfo, {
- enrolmentId:this.data.id,
- courseId:this.data.courseid
- }, 'GET').then(res=> {
- if (res.errno === 0) {
- this.setData({
- courseInfo:res.data,
- isFinished:res.data.enrolment.isCompleted==1?true:false
- });
- if(this.data.courseInfo.course.contentType==1){
- let detail=this.data.courseInfo.course.courseContent;
- WxParse.wxParse('courseHtml', 'html', detail, this);
- }
- let list=this.data.courseInfo.courseVideoList;
- if(list.length>0){
- list.forEach((item,index)=>{
- if(index==0){
- item.isTiled=true;
- }else{
- item.isTiled=false;
- }
- });
- this.setData({
- 'courseInfo.courseVideoList':list
- });
- }
- }
-
- });
- },
- goCourseDetail(e){
-
- let courseid=e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '/pages/upgrade/courseDetail/courseDetail?id='+''+'&courseid='+courseid,
- });
- },
- toggleVideo(e){
- let index=e.currentTarget.dataset.index;
- let istiled=e.currentTarget.dataset.istiled;
- if(!istiled){
- let list=this.data.courseInfo.courseVideoList;
- list.forEach((item,index)=>{
-
- item.isTiled=false;
- });
- this.setData({
- 'courseInfo.courseVideoList':list
- });
- let itemData = "courseInfo.courseVideoList[" + index + "].isTiled";
- this.setData({
- [itemData]:true
- });
- }
-
-
- },
- switchTab(e){
- let tab=e.currentTarget.dataset.tab;
- if(this.data.currentTab!=tab){
- this.setData({
- currentTab:tab
- });
- }
- },
- goHistory(){
- wx.pageScrollTo({
- selector: '.tab-sticky',
- duration: 300
- })
- this.setData({
- currentTab:'history'
- });
-
- },
- goLearn(){
- wx.navigateTo({
- url: '/pages/upgrade/courseDetail/courseDetail',
- })
- },
- submit(){
- util.request(api.complateCourse, {
- enrolmentId:this.data.id,
- }, 'GET').then(res=> {
- if (res.errno === 0) {
- this.setData({
- isFinished:true,
- })
- }else{
- wx.showToast({
- title: res.errmsg,
- icon:'none'
- })
- }
- });
-
- },
- onHide: function () {
- },
- onUnload: function () {
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
-
- })
|