提交 4db36ee6 authored 作者: 王鹏飞's avatar 王鹏飞

merge...

const util = require('../utils/util.js') const util = require('../utils/util.js')
/** /**
* 本API中全部用于 消息 相关接口 * 本API中全部用于 消息 相关接口
*/ */
/* 获取我的消息信息 */ /* 获取我的消息信息 */
...@@ -8,7 +8,8 @@ const getMyMsg = (callback) => { ...@@ -8,7 +8,8 @@ const getMyMsg = (callback) => {
util.requestApi({ util.requestApi({
url: util.config.URL_PATH1 + '/v2/education/message/my', url: util.config.URL_PATH1 + '/v2/education/message/my',
callback: function (res) { callback: function (res) {
let json = res.data.map(function (_, i) { let list = Array.isArray(res.data) ? res.data : res.data.list || []
let json = list.map(function (_, i) {
return { return {
isRead: false, isRead: false,
id: _.id, id: _.id,
...@@ -23,4 +24,4 @@ const getMyMsg = (callback) => { ...@@ -23,4 +24,4 @@ const getMyMsg = (callback) => {
} }
module.exports = { module.exports = {
getMyMsg: getMyMsg getMyMsg: getMyMsg
} }
\ No newline at end of file
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
"color": "#313131", "color": "#313131",
"backgroundColor": "#ffffff", "backgroundColor": "#ffffff",
"selectedColor": "#b49441", "selectedColor": "#b49441",
"aniamtion": "true",
"list": [ "list": [
{ {
"pagePath": "pages/learnSystem/home/home", "pagePath": "pages/learnSystem/home/home",
......
...@@ -13,7 +13,13 @@ Page({ ...@@ -13,7 +13,13 @@ Page({
hasUserInfo: false, hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'), canIUse: wx.canIUse('button.open-type.getUserInfo'),
// 绑定手机号 相关 // 绑定手机号 相关
bindphone: { isShow: '', getCode: true, countDown: 60, phone: '', code: '' }, bindphone: {
isShow: '',
getCode: true,
countDown: 60,
phone: '',
code: ''
},
// 绑定账号 相关 // 绑定账号 相关
bindaccount: { isShow: '', account: '', pwd: '' }, bindaccount: { isShow: '', account: '', pwd: '' },
// 是否 可以使用登录 // 是否 可以使用登录
...@@ -42,16 +48,21 @@ Page({ ...@@ -42,16 +48,21 @@ Page({
/* 判别 是否显示 账号登录 */ /* 判别 是否显示 账号登录 */
wx.request({ wx.request({
url: util.config.URL_PATH1 + '/switch/lock', url: util.config.URL_PATH1 + '/switch/lock',
data: {}, method: 'GET', header: { tenant: 'survey', apikey: 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N' }, success: res => { data: {},
this.setData({ 'isUseAccountLogin': res.data.switch }) method: 'GET',
header: { tenant: 'survey', apikey: 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N' },
success: (res) => {
this.setData({ isUseAccountLogin: res.data.switch })
wx.setStorageSync('isUseAccountLogin', res.data.switch) wx.setStorageSync('isUseAccountLogin', res.data.switch)
} }
}) })
wx.hideLoading(); wx.hideLoading()
}, },
// e.detail.userInfo, // e.detail.userInfo,
/* 按键授权,微信新版 - 获取用户信息 - 授权方式 */ /* 按键授权,微信新版 - 获取用户信息 - 授权方式 */
getUserInfo: function (e) { this.getInfo() }, getUserInfo: function (e) {
this.getInfo()
},
/* 获取用户信息 并 判别是否跟紫荆账号绑定 */ /* 获取用户信息 并 判别是否跟紫荆账号绑定 */
getInfo: function () { getInfo: function () {
wx.showLoading({ title: '信息获取中...', mask: true }) wx.showLoading({ title: '信息获取中...', mask: true })
...@@ -63,29 +74,46 @@ Page({ ...@@ -63,29 +74,46 @@ Page({
wx.setStorageSync('userInfo', {}) wx.setStorageSync('userInfo', {})
if (loginRes.data && loginRes.data.code == 80120) { if (loginRes.data && loginRes.data.code == 80120) {
/* 判别 是否绑定过 紫荆账号 */ /* 判别 是否绑定过 紫荆账号 */
this.popupShow(res); wx.hideLoading(); return; this.popupShow(res)
} else if (loginRes.data && loginRes.data.status && loginRes.data.status != 200) { wx.hideLoading()
wx.hideLoading(); wx.showToast({ title: loginRes.data.message, icon: 'none' }); return; return
} else if (
loginRes.data &&
loginRes.data.status &&
loginRes.data.status != 200
) {
wx.hideLoading()
wx.showToast({ title: loginRes.data.message, icon: 'none' })
return
} else if (loginRes.statusCode != 200) { } else if (loginRes.statusCode != 200) {
wx.hideLoading(); wx.showToast({ title: loginRes.data.message, icon: 'none' }); return; wx.hideLoading()
wx.showToast({ title: loginRes.data.message, icon: 'none' })
return
} else { } else {
let _userInfo = { let _userInfo = {
avatarUrl: loginRes.data.avatar || res.userInfo.avatarUrl || '无', avatarUrl: loginRes.data.avatar || res.userInfo.avatarUrl || '无',
nickName: loginRes.data.nickname || res.userInfo.nickName || '无' nickName: loginRes.data.nickname || res.userInfo.nickName || '无'
} }
wx.setStorageSync('userInfo', _userInfo); wx.setStorageSync('userInfo', _userInfo)
this.setData({ userInfo: _userInfo, hasUserInfo: true }) this.setData({ userInfo: _userInfo, hasUserInfo: true })
wx.hideLoading(); this.goOutSite(); return; wx.hideLoading()
this.goOutSite()
return
} }
// if (res.data.errorCode == 40029) return _that.animteHint("code错误"); // if (res.data.errorCode == 40029) return _that.animteHint("code错误");
} else { } else {
this.setData({ userInfo: wx.getStorageSync('userInfo'), hasUserInfo: true }) this.setData({
wx.hideLoading(); this.goOutSite(); return; userInfo: wx.getStorageSync('userInfo'),
hasUserInfo: true
})
wx.hideLoading()
this.goOutSite()
return
} }
}) })
}, },
guestLogin: function () { guestLogin: function () {
this.accountConfirms(); this.accountConfirms()
// return; // return;
// wx.showModal({ // wx.showModal({
// title: '提示', content: '本账户只适用于“体验学习”,正式学习请点击“登录”按钮', // title: '提示', content: '本账户只适用于“体验学习”,正式学习请点击“登录”按钮',
...@@ -100,54 +128,69 @@ Page({ ...@@ -100,54 +128,69 @@ Page({
}, },
//游客登录 //游客登录
accountConfirms: function (e) { accountConfirms: function (e) {
const _that = this; const _that = this
/* 调用接口 - 使用账号登录 */ /* 调用接口 - 使用账号登录 */
wx.request({ wx.request({
url: util.config.URL_PATH2 + '/user_center/login', url: util.config.URL_PATH2 + '/user_center/login',
data: { data: {
login_name:'18519690645@163.com', login_name: '18519690645@163.com',
password: md5('uokoaduw' + '123456'.split('').reverse().join('') + 'auhgniq'), password: md5(
'uokoaduw' + '123456'.split('').reverse().join('') + 'auhgniq'
),
service: 'applet.ezijing.com' service: 'applet.ezijing.com'
}, method: 'POST', header: { },
'tenant': util.config.tenant, method: 'POST',
header: {
tenant: util.config.tenant,
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
'version': util.config.version, version: util.config.version,
'apikey': 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N' apikey: 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N'
}, },
success: function (res) { success: function (res) {
if (res.statusCode && res.statusCode != 200) { wx.showToast({ title: res.data.message, icon: 'none' }); return; } if (res.statusCode && res.statusCode != 200) {
wx.hideToast(); wx.showToast({ title: res.data.message, icon: 'none' })
wx.setStorageSync('userSession', { sessionKey: res.data.ticket }); return
}
wx.hideToast()
wx.setStorageSync('userSession', { sessionKey: res.data.ticket })
let _token = wx.getStorageSync('userSession').sessionKey let _token = wx.getStorageSync('userSession').sessionKey
if (!_token) { if (!_token) {
wx.reLaunch({ url: '/pages/index/index' }) wx.reLaunch({ url: '/pages/index/index' })
return; return
} }
/* 获取用户信息 */ /* 获取用户信息 */
wx.request({ wx.request({
url: util.config.URL_PATH1 + '/user/check-access', url: util.config.URL_PATH1 + '/user/check-access',
data: {}, method: 'GET', header: { data: {},
method: 'GET',
header: {
token: _token, token: _token,
tenant: util.config.tenant, tenant: util.config.tenant,
'apikey': 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N', apikey: 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N',
'version': util.config.version, version: util.config.version,
unionid: wx.getStorageSync('union_id') unionid: wx.getStorageSync('union_id')
}, },
success: res => { success: (res) => {
if (res.statusCode != 200 && res.statusCode != 401) { wx.showToast({ title: res.data.message, icon: 'none' }); return; } if (res.statusCode != 200 && res.statusCode != 401) {
wx.showToast({ title: res.data.message, icon: 'none' })
return
}
let _userInfo = { let _userInfo = {
avatarUrl: res.data.avatar || '无', avatarUrl: res.data.avatar || '无',
nickName: res.data.nickname || '游客登录' nickName: res.data.nickname || '游客登录'
} }
wx.setStorageSync('userInfo', _userInfo); wx.setStorageSync('userInfo', _userInfo)
_that.setData({ userInfo: _userInfo, hasUserInfo: true }) _that.setData({ userInfo: _userInfo, hasUserInfo: true })
_that.popupClose() _that.popupClose()
_that.goOutSite() _that.goOutSite()
} }
}) })
}, },
fail: function (res) { wx.hideToast(); wx.showToast({ title: res, icon: 'none' }); } fail: function (res) {
wx.hideToast()
wx.showToast({ title: res, icon: 'none' })
}
}) })
}, },
/* 手机号绑定 方法 */ /* 手机号绑定 方法 */
......
...@@ -7,13 +7,13 @@ Page({ ...@@ -7,13 +7,13 @@ Page({
*/ */
data: { data: {
msgList: [ msgList: [
// { // {
// isRead: false, // isRead: false,
// id: '1', // id: '1',
// text: '2017年春季班三期班第三学期课程已经正式开始,作业截止提交时间为2018年1月10日,请三期班同学们合理安排学习时间。2017年春季班三期班第三学期课程已经正式开始,作业截止提交时间为2018年1月10日,请三期班同学们合理安排学习时间。', // text: '2017年春季班三期班第三学期课程已经正式开始,作业截止提交时间为2018年1月10日,请三期班同学们合理安排学习时间。2017年春季班三期班第三学期课程已经正式开始,作业截止提交时间为2018年1月10日,请三期班同学们合理安排学习时间。',
// time: '2015-05-22 15:51', // time: '2015-05-22 15:51',
// isShow: false // 该字段用来做 每条信息的打开、关闭 // isShow: false // 该字段用来做 每条信息的打开、关闭
// } // }
] ]
}, },
/** /**
...@@ -22,7 +22,7 @@ Page({ ...@@ -22,7 +22,7 @@ Page({
onLoad: function (options) { onLoad: function (options) {
wx.showLoading({ title: '页面加载中...', mask: true }) wx.showLoading({ title: '页面加载中...', mask: true })
MsgApi.getMyMsg((json) => { MsgApi.getMyMsg((json) => {
this.setData({ 'msgList': json }) this.setData({ msgList: json })
wx.hideLoading() wx.hideLoading()
}) })
}, },
...@@ -47,15 +47,15 @@ Page({ ...@@ -47,15 +47,15 @@ Page({
*/ */
onPullDownRefresh: function () { onPullDownRefresh: function () {
// 显示顶部刷新图标 // 显示顶部刷新图标
wx.showNavigationBarLoading(); wx.showNavigationBarLoading()
wx.showLoading({ title: '更新中...', mask: true }) wx.showLoading({ title: '更新中...', mask: true })
MsgApi.getMyMsg((json) => { MsgApi.getMyMsg((json) => {
this.setData({ 'msgList': json }) this.setData({ msgList: json.list })
wx.hideLoading() wx.hideLoading()
// 隐藏导航栏加载框 // 隐藏导航栏加载框
wx.hideNavigationBarLoading(); wx.hideNavigationBarLoading()
// 停止下拉动作 // 停止下拉动作
wx.stopPullDownRefresh(); wx.stopPullDownRefresh()
}) })
}, },
/** /**
...@@ -81,11 +81,11 @@ Page({ ...@@ -81,11 +81,11 @@ Page({
* 滚动到底部,加载更多数据 * 滚动到底部,加载更多数据
*/ */
loadmore: function () { loadmore: function () {
let _that = this; let _that = this
wx.showLoading({ title: '数据加载中...', mask: true }) wx.showLoading({ title: '数据加载中...', mask: true })
setTimeout(function () { setTimeout(function () {
wx.showToast({ title: '没有更多了', icon: 'none' }) wx.showToast({ title: '没有更多了', icon: 'none' })
wx.hideLoading() wx.hideLoading()
}, 2000) }, 2000)
} }
}) })
\ No newline at end of file
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
*/ */
var Audio = function (src, _that) { var Audio = function (src, _that) {
if (!(this instanceof Audio)) { if (!(this instanceof Audio)) {
return new Audio(src, _that); return new Audio(src, _that)
} else { } else {
this._audio = this.init(src, _that); this._audio = this.init(src, _that)
this.currentTime = 0; // 当前时间 this.currentTime = 0 // 当前时间
this.totalTime = 0; // 总时间 this.totalTime = 0 // 总时间
this.rateIndex = 2; // 取值为 RATE中的 下标 0,1,2,3,4 this.rateIndex = 2 // 取值为 RATE中的 下标 0,1,2,3,4
} }
} }
/** /**
...@@ -21,44 +21,54 @@ var Audio = function (src, _that) { ...@@ -21,44 +21,54 @@ var Audio = function (src, _that) {
* stop - 视频停止 * stop - 视频停止
* seek - 视频跳到某个位置再播放 * seek - 视频跳到某个位置再播放
* rate - 视频播放速率调整 * rate - 视频播放速率调整
* *
*/ */
Audio.prototype = { Audio.prototype = {
constructor: Audio, constructor: Audio,
RATE: ['0.5', '0.8', '1.0', '1.25', '1.5'], RATE: ['0.5', '0.8', '1.0', '1.25', '1.5'],
init: function (src, _that) { init: function (src, _that) {
let _auCtx = wx.createInnerAudioContext(); let _auCtx = wx.createInnerAudioContext()
_auCtx.autoplay = false; wx.setInnerAudioOption({ obeyMuteSwitch: false })
_auCtx.src = src; _auCtx.autoplay = false
_auCtx.src = src
/* 使用绑定事件,代替wxml中的事件绑定 */ /* 使用绑定事件,代替wxml中的事件绑定 */
_auCtx.onTimeUpdate(() => { let e = { detail: { currentTime: _auCtx.currentTime, duration: _auCtx.duration } }; _that.timeUpdate(e) }) _auCtx.onTimeUpdate(() => {
_auCtx.onPlay(() => { _that.beginPlayVA() }) let e = {
_auCtx.onError((e) => { _that.playError(e) }) detail: { currentTime: _auCtx.currentTime, duration: _auCtx.duration }
_auCtx.onEnded(() => { _that.playEnded }) }
return _auCtx; _that.timeUpdate(e)
})
_auCtx.onPlay(() => {
_that.beginPlayVA()
})
_auCtx.onError((e) => {
_that.playError(e)
})
_auCtx.onEnded(() => {
_that.playEnded
})
return _auCtx
}, },
play: function () { play: function () {
this._audio.play(); this._audio.play()
}, },
pause: function () { pause: function () {
this._audio.pause(); this._audio.pause()
}, },
stop: function () { stop: function () {
this._audio.stop(); this._audio.stop()
}, },
seek: function (time) { seek: function (time) {
this._audio.seek(time); this._audio.seek(time)
}, },
fastSlow15: function (timeStr) { fastSlow15: function (timeStr) {
this._audio.seek(this.currentTime + parseInt(timeStr)); this._audio.seek(this.currentTime + parseInt(timeStr))
}, },
rate: function () { rate: function () {
this.rateIndex++; this.rateIndex++
if (this.rateIndex > 4) this.rateIndex = 0; if (this.rateIndex > 4) this.rateIndex = 0
this._audio.playbackRate(parseFloat(this.RATE[this.rateIndex])); this._audio.playbackRate(parseFloat(this.RATE[this.rateIndex]))
} }
} }
module.exports = { module.exports = {
Audio: Audio Audio: Audio
......
<template name='contentAudio'> <template name='contentAudio'>
<view class='content-audio' <view class='content-audio' wx:if="{{status.isAudio}}">
style='{{status.isSet && status.isAudio ? "display: none;" : "" }} {{status.isImages && status.isAudio ? "display: none;" : "" }} {{status.isVideo ? "display: none;" : "" }}'
>
<image src='./contentAudio/icons/loading_small.gif' class='loading-image {{status.imagesLoaded && "none"}}' mode='aspectFit'/> <image src='./contentAudio/icons/loading_small.gif' class='loading-image {{status.imagesLoaded && "none"}}' mode='aspectFit'/>
<image wx:if='{{image.imgUrls[image.current]}}' src='{{image.imgUrls[image.current]}}' class='slide-image' mode='aspectFill' bindload='imagesLoaded'/> <image wx:if='{{image.imgUrls[image.current]}}' src='{{image.imgUrls[image.current]}}' class='slide-image' mode='aspectFill' bindload='imagesLoaded'/>
<view wx:if='{{!image.imgUrls[image.current]}}' class='slide-image'>本课程暂无PPT</view> <view wx:if='{{!image.imgUrls[image.current]}}' class='slide-image'>本课程暂无PPT</view>
......
<template name='contentVideo'> <template name='contentVideo'>
<!-- 这里加 这么多判断原因,video组件在真机上测试,一定在最上层,其他任何元素都挡不住,只能先隐藏,需要时再显示 --> <!-- 这里加 这么多判断原因,video组件在真机上测试,一定在最上层,其他任何元素都挡不住,只能先隐藏,需要时再显示 -->
<view class='content-video' <view class='content-video' wx:if="{{status.isVideo}}">
style='{{status.isSet && status.isVideo ? "display: none;" : "" }} {{status.isImages && status.isVideo ? "display: none;" : "" }} {{status.isAudio ? "display: none;" : "" }} {{chapterList.isShow && status.isVideo ? "display: none;" : "" }} {{ status.isLoading ? "display: none": "" }}'
>
<video id='my-video' class='my-video' src='{{video.src}}' show-center-play-btn='{{false}}' controls='{{false}}' bindtimeupdate='timeUpdate' bindfullscreenchange='beginAndOutFullScreen' bindpause='beginPauseVA' bindplay='beginPlayVA' binderror='playError' bindended='playEnded' autoplay='{{true}}'></video> <video id='my-video' class='my-video' src='{{video.src}}' show-center-play-btn='{{false}}' controls='{{false}}' bindtimeupdate='timeUpdate' bindfullscreenchange='beginAndOutFullScreen' bindpause='beginPauseVA' bindplay='beginPlayVA' binderror='playError' bindended='playEnded' autoplay='{{true}}'></video>
</view> </view>
</template> </template>
\ No newline at end of file
...@@ -26,7 +26,7 @@ Page({ ...@@ -26,7 +26,7 @@ Page({
isAudio: false, // 是否播放音频 isAudio: false, // 是否播放音频
isImages: false, // 是否播放图片 isImages: false, // 是否播放图片
isVideo: false, // 是否播放视频,独立存在,永远存在,只用isVideo属性控制 isVideo: false, // 是否播放视频,独立存在,永远存在,只用isVideo属性控制
imagesLoaded: false, // 图片是否加载完 imagesLoaded: false // 图片是否加载完
}, },
/* 视频地址 */ /* 视频地址 */
video: { video: {
...@@ -65,21 +65,28 @@ Page({ ...@@ -65,21 +65,28 @@ Page({
chapterList: { chapterList: {
isShow: false, // 是否显示列表 isShow: false, // 是否显示列表
currentChapterId: '11', // 当前章节id currentChapterId: '11', // 当前章节id
course: [{ course: [
title: '第一章:重要概念', {
chapters: [ title: '第一章:重要概念',
{ id: '11', time: '28:18', name: '1.1 现值(PV)和终值(FV)' }, chapters: [
{ id: '12', time: '19:09', name: '1.2 净现值(NPV)及实际收益率' } { id: '11', time: '28:18', name: '1.1 现值(PV)和终值(FV)' },
] { id: '12', time: '19:09', name: '1.2 净现值(NPV)及实际收益率' }
}, { ]
title: '第二章:证券估值', },
chapters: [ {
{ id: '21', time: '27:49', name: '2.1 债券和股票的现金流贴现估值方法' }, title: '第二章:证券估值',
{ id: '22', time: '16:04', name: '2.2 债券评级及债券协议' }, chapters: [
{ id: '23', time: '', name: '公司金融第二周测验' }, {
{ id: '24', time: '', name: '公司金融第二周作业' } id: '21',
] time: '27:49',
}], name: '2.1 债券和股票的现金流贴现估值方法'
},
{ id: '22', time: '16:04', name: '2.2 债券评级及债券协议' },
{ id: '23', time: '', name: '公司金融第二周测验' },
{ id: '24', time: '', name: '公司金融第二周作业' }
]
}
],
nextVideo: {}, // 下一章 音视频对象 nextVideo: {}, // 下一章 音视频对象
prevVideo: {} // 上一章音视频对象 prevVideo: {} // 上一章音视频对象
}, },
...@@ -110,9 +117,18 @@ Page({ ...@@ -110,9 +117,18 @@ Page({
initPage: function (res, vid) { initPage: function (res, vid) {
/* 默认先 显示视频 */ /* 默认先 显示视频 */
this.setData({ 'status.isVideo': true }) this.setData({ 'status.isVideo': true })
this._cache = { isPlay: false, initial_time: 0, currentTime: '00:00', totalTime: '00:00', progress: '0%', curRate: '1.0X', jumpFlag: false, vid: vid } this._cache = {
isPlay: false,
initial_time: 0,
currentTime: '00:00',
totalTime: '00:00',
progress: '0%',
curRate: '1.0X',
jumpFlag: false,
vid: vid
}
/* 加载中时,重置控制内容 全部为 0 */ /* 加载中时,重置控制内容 全部为 0 */
this.setData({ 'ctrlBar': this._cache }) this.setData({ ctrlBar: this._cache })
/* 一定会 存在值 */ /* 一定会 存在值 */
if (res) { if (res) {
let tempVid = wx.getStorageSync('videoCacheCtrlBar').vid let tempVid = wx.getStorageSync('videoCacheCtrlBar').vid
...@@ -123,36 +139,45 @@ Page({ ...@@ -123,36 +139,45 @@ Page({
this._cache.initial_time = res.cpt this._cache.initial_time = res.cpt
this.realTimeProgress = res this.realTimeProgress = res
} }
wx.setStorageSync('videoCacheCtrlBar', this._cache); wx.setStorageSync('videoCacheCtrlBar', this._cache)
wx.setStorageSync('audioCacheCtrlBar', this._cache); wx.setStorageSync('audioCacheCtrlBar', this._cache)
/* 将旧的对象全部抛弃掉 */ /* 将旧的对象全部抛弃掉 */
(!this._video && (this._video = objV.Video('my-video'))); !this._video && (this._video = objV.Video('my-video'))
this._audio = objA.Audio(this.data.audio.src, this); this._audio = objA.Audio(this.data.audio.src, this)
/* setData、视频设置等 异步,需要时间,所以加个延时,为true时播放按钮不可用 */ /* setData、视频设置等 异步,需要时间,所以加个延时,为true时播放按钮不可用 */
this.setData({ 'initVAFlag': true }) this.setData({ initVAFlag: true })
this.setData({ 'ctrlBar.isPlay': true }) this.setData({ 'ctrlBar.isPlay': true })
setTimeout(() => { setTimeout(() => {
/* android 手机有时候 播放失效,追加 autoPlay 自动播放 */ /* android 手机有时候 播放失效,追加 autoPlay 自动播放 */
this.playVA() this.playVA()
this.setData({ 'status.isLoading': false }) this.setData({ 'status.isLoading': false })
/* 这里 设置倍速还有点问题 */ /* 这里 设置倍速还有点问题 */
let _vObj = this._video; for (let i = 0; i < _vObj.RATE.length; i++) { let _ = _vObj.RATE[i]; if (this.data.ctrlBar.curRate.replace(/X/, '') == _) { _vObj.rateIndex = i - 1; this.setRate(); }; } let _vObj = this._video
}, 200); for (let i = 0; i < _vObj.RATE.length; i++) {
let _ = _vObj.RATE[i]
if (this.data.ctrlBar.curRate.replace(/X/, '') == _) {
_vObj.rateIndex = i - 1
this.setRate()
}
}
}, 200)
}, },
/* 页面初始入口,会 先走 AJAX 读取 章节列表数据、音视频和PPT数据、进度数据 */ /* 页面初始入口,会 先走 AJAX 读取 章节列表数据、音视频和PPT数据、进度数据 */
ajaxInitGetInfo: function (vid,videoType) { ajaxInitGetInfo: function (vid, videoType) {
let cid = this.data.options.cid, sid = this.data.options.sid, did = 'jjhz92fn0.le2a6c06c9g0.thhg7ekb1f8'; let cid = this.data.options.cid,
sid = this.data.options.sid,
did = 'jjhz92fn0.le2a6c06c9g0.thhg7ekb1f8'
ChapterApi.getChapterList(cid, sid, vid, (json) => { ChapterApi.getChapterList(cid, sid, vid, (json) => {
this.setData({ 'chapterList': json }) this.setData({ chapterList: json })
}) })
// CC视频走这个接口 // CC视频走这个接口
ChapterApi.getCurrentChapterDetail(vid,videoType, (json) => { ChapterApi.getCurrentChapterDetail(vid, videoType, (json) => {
// 播放的视频数据 // 播放的视频数据
this.setData({ 'video': json.video }) this.setData({ video: json.video })
this.setData({ 'audio': json.audio }) this.setData({ audio: json.audio })
this.setData({ 'image': json.image }) this.setData({ image: json.image })
ChapterApi.getProgress(vid, did, sid, (res) => { ChapterApi.getProgress(vid, did, sid, (res) => {
res.did = did res.did = did
res.vid = vid res.vid = vid
...@@ -163,79 +188,113 @@ Page({ ...@@ -163,79 +188,113 @@ Page({
}) })
}, },
onLoad: function (options) { onLoad: function (options) {
if(!options.vid){ if (!options.vid) {
wx.showToast({ wx.showToast({
title: '获取视频失败', title: '获取视频失败',
icon: 'loading', icon: 'loading',
duration: 3000, duration: 3000,
success:function(){ success: function () {
setTimeout(function(){ setTimeout(function () {
wx.navigateBack({ wx.navigateBack({
delta: 1 delta: 1
}) })
},2000) }, 2000)
} }
}) })
} }
this.data.options = options; this.data.options = options
},
onHide: function () {
this.isBackend = true
this.pauseVA()
clearInterval(this.heartbeat)
},
onUnload: function () {
this.pauseVA()
}, },
onHide: function () { this.isBackend = true; this.pauseVA(); clearInterval(this.heartbeat); },
onUnload: function () { this.pauseVA(); },
onShow: function () { onShow: function () {
/* 兼容 android 这里发现 android 打开预览大图,然后关闭 自动播放视频,而且关不掉, 兼容android强制关闭视频 */ /* 兼容 android 这里发现 android 打开预览大图,然后关闭 自动播放视频,而且关不掉, 兼容android强制关闭视频 */
/* 这里没有 预览大图 关闭监听,所以 isBigPicShow 状态永远为 true */ /* 这里没有 预览大图 关闭监听,所以 isBigPicShow 状态永远为 true */
if (this.isBigPicShow) { this.playVA(); this.isBigPicShow = false; this.isBackend = false; return; } if (this.isBigPicShow) {
this.playVA()
this.isBigPicShow = false
this.isBackend = false
return
}
if (this.isBackend) { if (this.isBackend) {
// this.setData({ 'initVAFlag': true }); // this.setData({ 'initVAFlag': true });
this.playVA(); this.playVA()
/* 这里调用,跟初始化调用时保持一致,其主要也是为了解决android从后台进入前台时出现的问题 */ /* 这里调用,跟初始化调用时保持一致,其主要也是为了解决android从后台进入前台时出现的问题 */
this.isBackend = false; this.isBackend = false
} }
}, },
/* 生命周期函数--监听页面初次渲染完成 */ /* 生命周期函数--监听页面初次渲染完成 */
onReady: function () { this.ajaxInitGetInfo(this.data.options.vid,this.data.options.type); }, onReady: function () {
this.ajaxInitGetInfo(this.data.options.vid, this.data.options.type)
},
/* controlBar页面 - 切换音频页面 - bindTap事件 */ /* controlBar页面 - 切换音频页面 - bindTap事件 */
showContentAudio: function () { showContentAudio: function () {
if (!this.data.audio.src) { wx.showToast({ title: '暂无音频文件', icon: 'none' }); return; } if (!this.data.audio.src) {
this.changeVideoAndAudio({ content: '当前视频将暂停播放,请确认?', setStorage: 'videoCacheCtrlBar', getStorage: 'audioCacheCtrlBar', isAudio: true, isVideo: false }); wx.showToast({ title: '暂无音频文件', icon: 'none' })
return
}
this.changeVideoAndAudio({
content: '当前视频将暂停播放,请确认?',
setStorage: 'videoCacheCtrlBar',
getStorage: 'audioCacheCtrlBar',
isAudio: true,
isVideo: false
})
}, },
/* controlBar页面 - 切换视频页面 - bindTap事件 */ /* controlBar页面 - 切换视频页面 - bindTap事件 */
showContentVideo: function () { showContentVideo: function () {
this.changeVideoAndAudio({ content: '当前音频将暂停播放,请确认?', setStorage: 'audioCacheCtrlBar', getStorage: 'videoCacheCtrlBar', isAudio: false, isVideo: true }); this.changeVideoAndAudio({
content: '当前音频将暂停播放,请确认?',
setStorage: 'audioCacheCtrlBar',
getStorage: 'videoCacheCtrlBar',
isAudio: false,
isVideo: true
})
}, },
/* controlBar页面 - 切换音视频页面:辅助方法 - 1. 关闭音频或视频;2. 需要提示;3. 初始化视频记录或音频记录 */ /* controlBar页面 - 切换音视频页面:辅助方法 - 1. 关闭音频或视频;2. 需要提示;3. 初始化视频记录或音频记录 */
changeVideoAndAudio: function (obj) { changeVideoAndAudio: function (obj) {
this.pauseVA(); this.pauseVA()
wx.showModal({ wx.showModal({
title: '提示', content: obj.content, title: '提示',
content: obj.content,
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
wx.setStorageSync(obj.setStorage, obj.getStorage); // wx.setStorageSync(obj.setStorage, obj.getStorage)
let cache = wx.getStorageSync(obj.getStorage); let cache = wx.getStorageSync(obj.getStorage)
this.setData({ 'ctrlBar': cache }); this.setData(
this.setData({ 'status.isAudio': obj.isAudio }); {
this.setData({ 'status.isVideo': obj.isVideo }); ctrlBar: cache,
'status.isAudio': obj.isAudio,
/* 这里调用,解决VA视频初始化 */ 'status.isVideo': obj.isVideo,
this.setData({ 'initVAFlag': true }); initVAFlag: true
setTimeout(() => { },
this.seekVA(cache.initial_time); function () {
this.playVA(); this.seekVA(cache.initial_time)
}, 200) this.playVA()
}
)
} else {
this.playVA()
} }
} }
}); })
}, },
/* controlBar页面 和 selectChapterList页面 - 切换章节列表 - bindTap事件 */ /* controlBar页面 和 selectChapterList页面 - 切换章节列表 - bindTap事件 */
jumpToOtherVA: function (e) { jumpToOtherVA: function (e) {
/* 跳转时,清空当前播放状态 */ /* 跳转时,清空当前播放状态 */
this.heartbeat && clearInterval(this.heartbeat) this.heartbeat && clearInterval(this.heartbeat)
let _data = e.target.dataset; let _data = e.target.dataset
if (!_data.hasva) { if (!_data.hasva) {
/* 如果存在 - 课后习题类型, type:3、work_type:1 */ /* 如果存在 - 课后习题类型, type:3、work_type:1 */
let i1 = _data.index, i2 = _data.index1 let i1 = _data.index,
i2 = _data.index1
let _course = this.data.chapterList.course[i1] let _course = this.data.chapterList.course[i1]
if (_course && _course.chapters[i2] && _course.chapters[i2].homework) { if (_course && _course.chapters[i2] && _course.chapters[i2].homework) {
let _hw = _course.chapters[i2].homework let _hw = _course.chapters[i2].homework
...@@ -243,91 +302,176 @@ Page({ ...@@ -243,91 +302,176 @@ Page({
wx.navigateTo({ wx.navigateTo({
url: '/pages/learnSystem/courseContent/examDetail/examDetail' url: '/pages/learnSystem/courseContent/examDetail/examDetail'
}) })
return; return
} }
wx.showToast({ title: '请在PC上使用该功能', icon: 'none' }); return; wx.showToast({ title: '请在PC上使用该功能', icon: 'none' })
return
} }
this.isFirstInitAndSwitchVideo = true; this.isFirstInitAndSwitchVideo = true
this.statusClear(_data.name, _data.id); this.statusClear(_data.name, _data.id)
this.ajaxInitGetInfo(_data.id,_data.type); this.ajaxInitGetInfo(_data.id, _data.type)
}, },
/* controlBar页面 和 selectChapterList页面 - 切换章节列表: 辅助方法 - 1. 暂停视频;2. 关闭章节选择列表;3. 状态清理(status、videoCacheCtrlBar、audioCacheCtrlBar);4. 设置微信导航头 */ /* controlBar页面 和 selectChapterList页面 - 切换章节列表: 辅助方法 - 1. 暂停视频;2. 关闭章节选择列表;3. 状态清理(status、videoCacheCtrlBar、audioCacheCtrlBar);4. 设置微信导航头 */
statusClear: function (name, id) { statusClear: function (name, id) {
this.pauseVA(); this.pauseVA()
this.closeSelectChapterList(); this.closeSelectChapterList()
let initStatus = { isLoading: true, isSupport: true, isSet: false, isAudio: false, isImages: false, isVideo: false, imagesLoaded: false }; let initStatus = {
this.setData({ 'status': initStatus }); isLoading: true,
let initCtrlBar = { isPlay: false, initial_time: 0, currentTime: '00:00', totalTime: '00:00', progress: '0%', curRate: '1.0X', jumpFlag: false, vid: id }; isSupport: true,
wx.setStorageSync('videoCacheCtrlBar', initCtrlBar); isSet: false,
wx.setStorageSync('audioCacheCtrlBar', initCtrlBar); isAudio: false,
wx.setNavigationBarTitle({ title: name || '音视频' }); isImages: false,
isVideo: false,
imagesLoaded: false
}
this.setData({ status: initStatus })
let initCtrlBar = {
isPlay: false,
initial_time: 0,
currentTime: '00:00',
totalTime: '00:00',
progress: '0%',
curRate: '1.0X',
jumpFlag: false,
vid: id
}
wx.setStorageSync('videoCacheCtrlBar', initCtrlBar)
wx.setStorageSync('audioCacheCtrlBar', initCtrlBar)
wx.setNavigationBarTitle({ title: name || '音视频' })
}, },
/* controlBar页面 - 上一章 - bindTap事件 */ /* controlBar页面 - 上一章 - bindTap事件 */
prevChapter: function (e) { if (!e.target.dataset.id) { wx.showToast({ title: '已经是第一章了.', icon: 'none' }); return; }; this.jumpToOtherVA(e); }, prevChapter: function (e) {
if (!e.target.dataset.id) {
wx.showToast({ title: '已经是第一章了.', icon: 'none' })
return
}
this.jumpToOtherVA(e)
},
/* controlBar页面 - 下一章 - bindTap事件 */ /* controlBar页面 - 下一章 - bindTap事件 */
nextChapter: function (e) { if (!e.target.dataset.id) { wx.showToast({ title: '已经是最后一章了.', icon: 'none' }); return; }; this.jumpToOtherVA(e); }, nextChapter: function (e) {
if (!e.target.dataset.id) {
wx.showToast({ title: '已经是最后一章了.', icon: 'none' })
return
}
this.jumpToOtherVA(e)
},
/* controlBar页面 - 打开切换章节列表 - bindTap事件 */ /* controlBar页面 - 打开切换章节列表 - bindTap事件 */
openSelectChapterList: function () { this.setData({ 'chapterList.isShow': true }); }, openSelectChapterList: function () {
this.setData({ 'chapterList.isShow': true })
},
/* controlBar页面 - 关闭切换章节列表 - bindTap事件和内部调用 */ /* controlBar页面 - 关闭切换章节列表 - bindTap事件和内部调用 */
closeSelectChapterList: function () { this.setData({ 'chapterList.isShow': false }); }, closeSelectChapterList: function () {
this.setData({ 'chapterList.isShow': false })
},
/* controlBar页面 - 打开图片轮播页面 - bindTap事件 */ /* controlBar页面 - 打开图片轮播页面 - bindTap事件 */
openContentImages: function () { this.setData({ 'status.isImages': true }); }, openContentImages: function () {
this.pauseVA()
this.setData({ 'status.isImages': true })
},
/* controlBar页面 - 关闭图片轮播页面 - bindTap事件 */ /* controlBar页面 - 关闭图片轮播页面 - bindTap事件 */
closeContentImages: function () { closeContentImages: function () {
this.setData({ 'status.isImages': false }); this.playVA()
this.setData({ 'status.isImages': false })
/* 兼容 android 发现打开previewImage后,从swiper 切换回 视频播放页,视频会自动暂停 */ /* 兼容 android 发现打开previewImage后,从swiper 切换回 视频播放页,视频会自动暂停 */
// this.data.status.isVideo && this.pauseVA(); // this.data.status.isVideo && this.pauseVA();
// wx.getStorageSync('videoCacheCtrlBar').isPlay && this.playVA(); // wx.getStorageSync('videoCacheCtrlBar').isPlay && this.playVA();
}, },
/* controlBar页面 - 打开设置面板 - bindTap事件 */ /* controlBar页面 - 打开设置面板 - bindTap事件 */
openSetContent: function () { this.setData({ 'status.isSet': true }); }, openSetContent: function () {
this.data.status.isSet ? this.playVA() : this.pauseVA()
this.setData({ 'status.isSet': !this.data.status.isSet })
},
/* controlBar页面 - 关闭设置面板 - bindTap事件 */ /* controlBar页面 - 关闭设置面板 - bindTap事件 */
closeSetContent: function () { this.setData({ 'status.isSet': false }); }, closeSetContent: function () {
this.setData({ 'status.isSet': false }, function () {
this.playVA()
})
},
/* contentImages页面 - 点击放大图 - bindTap事件 */ /* contentImages页面 - 点击放大图 - bindTap事件 */
showBigImage: function () { showBigImage: function () {
let _obj = this.data.image let _obj = this.data.image
/* 兼容 android 暂停后 回退回来,视频未暂停还在继续播放,但进度条失去作用,所以需要 onShow中 重新调用 暂停方法 */ /* 兼容 android 暂停后 回退回来,视频未暂停还在继续播放,但进度条失去作用,所以需要 onShow中 重新调用 暂停方法 */
this.isBigPicShow = true this.isBigPicShow = true
wx.previewImage({ current: _obj.imgUrls[_obj.selectIndex], urls: _obj.imgUrls }) wx.previewImage({
current: _obj.imgUrls[_obj.selectIndex],
urls: _obj.imgUrls
})
}, },
/* Swiper标签 - 轮播图切换时 - bindchange事件 */ /* Swiper标签 - 轮播图切换时 - bindchange事件 */
imageSelectIndexUpdate: function (e) { this.setData({ 'image.selectIndex': e.detail.current }); }, imageSelectIndexUpdate: function (e) {
this.setData({ 'image.selectIndex': e.detail.current })
},
/* VideoOrAudio image标签 - 图片开始加载 注意:图片过大时,有个加载状态 */ /* VideoOrAudio image标签 - 图片开始加载 注意:图片过大时,有个加载状态 */
imagesLoadBegin: function () { this.setData({ 'status.imagesLoaded': false }) }, imagesLoadBegin: function () {
this.setData({ 'status.imagesLoaded': false })
},
/* contentAudio页面 - 图片加载完成 - bindload事件 */ /* contentAudio页面 - 图片加载完成 - bindload事件 */
imagesLoaded: function () { this.setData({ 'status.imagesLoaded': true }) }, imagesLoaded: function () {
this.setData({ 'status.imagesLoaded': true })
},
/* controlBar页面 - 播放音视频 - bindTap事件和内部调用 */ /* controlBar页面 - 播放音视频 - bindTap事件和内部调用 */
playVA: function () { playVA: function () {
let _data = this.data, _status = _data.status let _data = this.data,
_status = _data.status
this.setData({ 'ctrlBar.isPlay': true }) this.setData({ 'ctrlBar.isPlay': true })
_status.isVideo && this._video.play(); _status.isVideo && this._video.play()
_status.isAudio && this._audio.play(); _status.isAudio && this._audio.play()
this.setHeartbeat() this.setHeartbeat()
}, },
/* controlBar页面 - 暂停音视频 - bindTap事件和内部调用 */ /* controlBar页面 - 暂停音视频 - bindTap事件和内部调用 */
pauseVA: function () { pauseVA: function () {
let _data = this.data, _status = _data.status let _data = this.data,
_status = _data.status
this.setData({ 'ctrlBar.isPlay': false }) this.setData({ 'ctrlBar.isPlay': false })
_status.isVideo && this._video.pause() _status.isVideo && this._video.pause()
_status.isAudio && this._audio.pause() _status.isAudio && this._audio.pause()
clearInterval(this.heartbeat) clearInterval(this.heartbeat)
}, },
/* controlBar页面 - 点击进度条跳到某个位置播放 - bindtouchstart事件 */ /* controlBar页面 - 点击进度条跳到某个位置播放 - bindtouchstart事件 */
tapToSeek: function (e) { let pLine = wx.getSystemInfoSync().windowWidth - e.currentTarget.offsetLeft * 2, pos = e.touches[0].pageX, _data = this.data, _status = _data.status, _obj = _status.isVideo ? this._video : this._audio; this.seekVA(parseInt(pos / pLine * _obj.totalTime)); }, tapToSeek: function (e) {
let pLine =
wx.getSystemInfoSync().windowWidth - e.currentTarget.offsetLeft * 2,
pos = e.touches[0].pageX,
_data = this.data,
_status = _data.status,
_obj = _status.isVideo ? this._video : this._audio
this.seekVA(parseInt((pos / pLine) * _obj.totalTime))
},
/* VideoOrAudio - 跳到某个点开始播放 */ /* VideoOrAudio - 跳到某个点开始播放 */
seekVA: function (time) { let _data = this.data, _status = _data.status; _status.isVideo && this._video.seek(time); _status.isAudio && this._audio.seek(time); }, seekVA: function (time) {
let _data = this.data,
_status = _data.status
_status.isVideo && this._video.seek(time)
_status.isAudio && this._audio.seek(time)
},
/* setContent页面 - 跳过片头 - bindTap事件 */ /* setContent页面 - 跳过片头 - bindTap事件 */
jumpHead: function () { this.setData({ 'ctrlBar.jumpFlag': !this.data.ctrlBar.jumpFlag }); }, jumpHead: function () {
this.setData({ 'ctrlBar.jumpFlag': !this.data.ctrlBar.jumpFlag })
},
/* setContent页面 - 后退15s音视频 - bindTap事件 */ /* setContent页面 - 后退15s音视频 - bindTap事件 */
slow15s: function () { let _data = this.data, _status = _data.status; _status.isVideo && this._video.fastSlow15('-15'); _status.isAudio && this._audio.fastSlow15('-15'); }, slow15s: function () {
let _data = this.data,
_status = _data.status
_status.isVideo && this._video.fastSlow15('-15')
_status.isAudio && this._audio.fastSlow15('-15')
},
/* setContent页面 - 快进15s音视频 - bindTap事件 */ /* setContent页面 - 快进15s音视频 - bindTap事件 */
fast15s: function () { let _data = this.data, _status = _data.status; _status.isVideo && this._video.fastSlow15('15'); _status.isAudio && this._audio.fastSlow15('15'); }, fast15s: function () {
let _data = this.data,
_status = _data.status
_status.isVideo && this._video.fastSlow15('15')
_status.isAudio && this._audio.fastSlow15('15')
},
/* setContent页面 - 改变播放倍率 注意:音频不支持倍速 - bindTap事件 */ /* setContent页面 - 改变播放倍率 注意:音频不支持倍速 - bindTap事件 */
setRate: function () { setRate: function () {
let _data = this.data, _status = _data.status let _data = this.data,
if (_status.isAudio) { wx.showToast({ title: '音频暂不支持倍速', icon: 'none' }); return; } _status = _data.status
if (_status.isAudio) {
wx.showToast({ title: '音频暂不支持倍速', icon: 'none' })
return
}
let _obj = this._video let _obj = this._video
_obj.rate() _obj.rate()
this.setData({ 'ctrlBar.curRate': _obj.RATE[_obj.rateIndex] + 'X' }) this.setData({ 'ctrlBar.curRate': _obj.RATE[_obj.rateIndex] + 'X' })
...@@ -336,37 +480,51 @@ Page({ ...@@ -336,37 +480,51 @@ Page({
beginAndOutFullScreen: function (e) {}, beginAndOutFullScreen: function (e) {},
/* VideoOrAudio标签 - 开始/继续播放时触发play事件时,触发 - bindplay事件 */ /* VideoOrAudio标签 - 开始/继续播放时触发play事件时,触发 - bindplay事件 */
beginPlayVA: function () { beginPlayVA: function () {
if(this.data.initVAFlag){ if (this.data.initVAFlag) {
this.setData({ 'initVAFlag': false }) this.setData({ initVAFlag: false })
this.setHeartbeat() //安卓手机播放之后才会上送进度 this.setHeartbeat() //安卓手机播放之后才会上送进度
} }
/* iphone6 8.4.1 首次初始化时,不能直接 设置进度并播放 */ /* iphone6 8.4.1 首次初始化时,不能直接 设置进度并播放 */
if (this.isFirstInitAndSwitchVideo) { if (this.isFirstInitAndSwitchVideo) {
if (!this._cache) this._cache = wx.getStorageSync('videoCacheCtrlBar') || {} if (!this._cache)
this.seekVA(this._cache.initial_time); this._cache = wx.getStorageSync('videoCacheCtrlBar') || {}
this.isFirstInitAndSwitchVideo = false; this.seekVA(this._cache.initial_time)
this.isFirstInitAndSwitchVideo = false
} }
}, },
/* VideoOrAudio标签 - 暂停播放时触发pause事件时,触发 - bindpause事件 */ /* VideoOrAudio标签 - 暂停播放时触发pause事件时,触发 - bindpause事件 */
beginPauseVA: function () { beginPauseVA: function () {},
},
/* VideoOrAudio标签 - 当播放到末尾时,触发 - bindended事件 */ /* VideoOrAudio标签 - 当播放到末尾时,触发 - bindended事件 */
playEnded: function () { wx.showToast({ title: '当前音/视频播放完毕。', icon: 'none' }); this.pauseVA(); }, playEnded: function () {
wx.showToast({ title: '当前音/视频播放完毕。', icon: 'none' })
this.pauseVA()
},
/* VideoOrAudio标签 - 视频播放错误时,触发 - binderror事件 */ /* VideoOrAudio标签 - 视频播放错误时,触发 - binderror事件 */
playError: function (e) { }, playError: function (e) {},
/* VideoOrAudio标签 - 视频播放发生变化时 - bindtimeupdate事件 */ /* VideoOrAudio标签 - 视频播放发生变化时 - bindtimeupdate事件 */
timeUpdate: function (e) { timeUpdate: function (e) {
let _data = this.data, _status = _data.status, _detail = e.detail, _obj = _status.isVideo ? this._video : this._audio let _data = this.data,
_status = _data.status,
_detail = e.detail,
_obj = _status.isVideo ? this._video : this._audio
_obj.currentTime = parseInt(_detail.currentTime) _obj.currentTime = parseInt(_detail.currentTime)
_obj.totalTime = parseInt(_detail.duration) _obj.totalTime = parseInt(_detail.duration)
this.setData({ 'ctrlBar.progress': _obj.currentTime / _obj.totalTime * 100 + '%' }); this.setData({
this.setData({ 'ctrlBar.currentTime': util.durationToTimeString(_obj.currentTime) }); 'ctrlBar.progress': (_obj.currentTime / _obj.totalTime) * 100 + '%'
this.setData({ 'ctrlBar.totalTime': util.durationToTimeString(_obj.totalTime) }) })
this.setData({
'ctrlBar.currentTime': util.durationToTimeString(_obj.currentTime)
})
this.setData({
'ctrlBar.totalTime': util.durationToTimeString(_obj.totalTime)
})
/* 实时改变 当前的PPT当前页 */ /* 实时改变 当前的PPT当前页 */
let arr = this.data.image.timeArr let arr = this.data.image.timeArr
for (let i = 0; i < arr.length; i++) { for (let i = 0; i < arr.length; i++) {
if (_obj.currentTime >= arr[i] && (i + 1 < arr.length ? _obj.currentTime < arr[i + 1] : 1)) { if (
_obj.currentTime >= arr[i] &&
(i + 1 < arr.length ? _obj.currentTime < arr[i + 1] : 1)
) {
this.setData({ 'image.current': i }) this.setData({ 'image.current': i })
break break
} }
...@@ -381,17 +539,18 @@ Page({ ...@@ -381,17 +539,18 @@ Page({
this.heartbeat = setInterval(() => { this.heartbeat = setInterval(() => {
/* 如果是初始加载状态,就不计算时间状态 和 提交进度了 */ /* 如果是初始加载状态,就不计算时间状态 和 提交进度了 */
if (this.data.initVAFlag) return; if (this.data.initVAFlag) return
let arr = _data.ctrlBar.currentTime.split(':'), tempTime = parseInt(arr[0] * 60) + parseInt(arr[1]); let arr = _data.ctrlBar.currentTime.split(':'),
tempTime = parseInt(arr[0] * 60) + parseInt(arr[1])
this.setData({ 'ctrlBar.initial_time': tempTime }) this.setData({ 'ctrlBar.initial_time': tempTime })
/* 这里改成异步的,试一下 */ /* 这里改成异步的,试一下 */
wx.setStorage({ wx.setStorage({
'key': 'videoCacheCtrlBar', key: 'videoCacheCtrlBar',
'data': _data.ctrlBar data: _data.ctrlBar
}) })
wx.setStorage({ wx.setStorage({
'key': 'audioCacheCtrlBar', key: 'audioCacheCtrlBar',
'data': _data.ctrlBar data: _data.ctrlBar
}) })
/* 由于 音视频相同,所以 设置方式设置成一致就可以了 */ /* 由于 音视频相同,所以 设置方式设置成一致就可以了 */
/* 提交进度请求, 进度进行中,才计算上进度时间 */ /* 提交进度请求, 进度进行中,才计算上进度时间 */
...@@ -404,4 +563,4 @@ Page({ ...@@ -404,4 +563,4 @@ Page({
} }
}, 10000) }, 10000)
} }
}) })
\ No newline at end of file
...@@ -13,14 +13,16 @@ ...@@ -13,14 +13,16 @@
<template is='pageLoading'></template> <template is='pageLoading'></template>
</block> </block>
<block wx:if='{{status.isSupport}}'> <block wx:if='{{status.isSupport}}'>
<template is='contentAudio' data='{{status, audio, image, ctrlBar}}'></template>
<template is='contentVideo' data='{{status, video, chapterList, ctrlBar}}'></template>
<block wx:if='{{status.isSet}}'> <block wx:if='{{status.isSet}}'>
<template is='setContent' data='{{ctrlBar}}'></template> <template is='setContent' data='{{ctrlBar}}'></template>
</block><block wx:elif='{{status.isImages}}'> </block>
<block wx:elif='{{status.isImages}}'>
<template is='contentImages' data='{{status, image}}'></template> <template is='contentImages' data='{{status, image}}'></template>
</block> </block>
<template is='contentAudio' data='{{status, audio, image, ctrlBar}}'></template> </block>
<template is='contentVideo' data='{{status, video, chapterList, ctrlBar}}'></template> <block wx:else>
</block><block wx:else>
<template is='noSupport'></template> <template is='noSupport'></template>
</block> </block>
<template is='controlBar' data='{{status, video, ctrlBar, chapterList, initVAFlag}}'></template> <template is='controlBar' data='{{status, video, ctrlBar, chapterList, initVAFlag}}'></template>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论