diff --git a/pages/IndexFreeCourseDetails/IndexFreeCourseDetails.js b/pages/IndexFreeCourseDetails/IndexFreeCourseDetails.js new file mode 100644 index 0000000..1a1d6ae --- /dev/null +++ b/pages/IndexFreeCourseDetails/IndexFreeCourseDetails.js @@ -0,0 +1,131 @@ +// pages/Videodetails/Videodetails.js +const MyApi = require('../../Api/api.js'); +Page({ + + /** + * 页面的初始数据 + */ + data: { + BaseURL:getApp().globalData.BaseURL, + JustChapter:"", + zhangjieTitle:"", + VideoImageURL:"", + VideoTitle:"", + RealeaseTime:"", + shichangTime:"", + playdata:[], + VideoPlayerSrc:null, + coursedata:null, + top:0, + HiddenVideoControl:true, + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { +//只有当登录才有效 + if (wx.getStorageSync('UserInfoCache').IsLogin) { + //获取接收到的视频序号 + var receivedIndex = options.number ?? null; + if (receivedIndex){ + + MyApi.ApiGetFreeCourseData(receivedIndex) + .then(result => { + this.setData({ + VideoTitle:result.PlayData[0].课程名称, + playdata:result.PlayData, + VideoImageURL:this.data.BaseURL+"/Course/"+result.课程id+".png", + coursedata:result, + }); + }) + .catch(err => { + this.setData({ + playdata:[], + }); + console.error("请求失败:"+err); + }); + } else { + wx.switchTab({ + url: '/pages/index/index', + }) + } + + } else { + setTimeout(function() { + wx.switchTab({ + url: '/pages/index/index', + }) + },50); + } + }, + OnTapVideoList(e){ + //只有当登录才有效 + if (wx.getStorageSync('UserInfoCache').IsLogin) { + // 获取当前点击的索引 + + const courseindex = e.currentTarget.dataset.courseindex; + + + this.setData({ + VideoPlayerSrc:this.data.BaseURL+'/'+this.data.coursedata.PlayData[courseindex].视频m3u8, + HiddenVideoControl:false, + top:420, + }); + } else { + setTimeout(function() { + wx.switchTab({ + url: '/pages/index/index', + }) + },50); + } + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + if (!wx.getStorageSync('UserInfoCache').IsLogin) { + setTimeout(function() { + wx.switchTab({ + url: '/pages/index/index', + }) + },50); + } + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + } +}) \ No newline at end of file diff --git a/pages/IndexFreeCourseDetails/IndexFreeCourseDetails.json b/pages/IndexFreeCourseDetails/IndexFreeCourseDetails.json new file mode 100644 index 0000000..6f5247b --- /dev/null +++ b/pages/IndexFreeCourseDetails/IndexFreeCourseDetails.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/IndexFreeCourseDetails/IndexFreeCourseDetails.wxml b/pages/IndexFreeCourseDetails/IndexFreeCourseDetails.wxml new file mode 100644 index 0000000..3f38741 --- /dev/null +++ b/pages/IndexFreeCourseDetails/IndexFreeCourseDetails.wxml @@ -0,0 +1,25 @@ + +