提交 b4d0caf4 authored 作者: GOD_ZYX's avatar GOD_ZYX

update wxchart

上级 40a6fad2
# 小程序 - 开发项目
## 使用与运行
* 打开小程序 “微信开发者工具” 预览、调试、发布、上传都可以。
- `微信开发者工具`<a href="https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html" target="_blank">下载地址</a>
- `微信开发者工具`<a href="https://developers.weixin.qq.com/miniprogram/dev/devtools/devtools.html?t=18090718" target="_blank">使用说明地址</a>
const util = require('../utils/util.js')
/* 获取章节列表信息 */
// 测试 用 cur_course_id:6438232736871219200 cur_video_id:6290435412296990720
const getChapterList = (cur_course_id, cur_video_id, callback) => {
util.requestApi({
url: util.config.URL_PATH + '/tenant/v1/education/courses/' + cur_course_id,
callback: function (res) {
let i = 0, j = 0, nextVideo = {}, prevVideo = {};
/* 计算上一章 和 下一章 */
for (; i<res.data.chapters.length; i++) {
let _ = res.data.chapters[i]
for (j=0; j<_.children.length; j++) {
if (_.children[j].resource_id === cur_video_id) {
wx.setNavigationBarTitle({ title: _.children[j].name || '音视频' });
if (j-1 >= 0) {
prevVideo = {
id: _.children[j-1].resource_id,
time: _.children[j-1].video && util.durationToTimeString(_.children[j-1].video.video_length) || '',
name: _.children[j-1].name
}
} else if (i-1>=0) {
let _temp = res.data.chapters[i - 1]
prevVideo = {
id: _temp.children[_temp.children.length-1].resource_id,
time: _temp.children[_temp.children.length-1].video && util.durationToTimeString(_temp.children[_temp.children.length-1].video.video_length) || '',
name: _temp.children[_temp.children.length-1].name
}
}
if (j+1 < _.children.length) {
nextVideo = {
id: _.children[j + 1].resource_id,
time: _.children[j + 1].video && util.durationToTimeString(_.children[j + 1].video.video_length) || '',
name: _.children[j + 1].name
}
} else if (i + 1 < res.data.chapters.length) {
let _temp = res.data.chapters[i + 1]
nextVideo = {
id: _temp.children[0].resource_id,
time: _temp.children[0].video && util.durationToTimeString(_temp.children[0].video.video_length) || '',
name: _temp.children[0].name
}
}
}
}
}
let json = {
isShow: false,
currentChapterId: cur_video_id,
course: res.data.chapters.map(function (_, i) {
return {
title: _.name,
chapters: _.children.map(function (__, j) {
return {
id: __.resource_id,
time: __.video && util.durationToTimeString(__.video.video_length) || '',
name: __.name
}
})
}
}),
nextVideo: nextVideo,
prevVideo: prevVideo
}
callback(json)
}
})
}
/* 获取对应某个章节的详细信息 */
const getCurrentChapterDetail = (vid, callback) => {
util.requestApi({
url: util.config.URL_PATH + '/tenant/v1/education/video-streaming',
method: 'POST',
data: {
vid: vid
},
callback: function (res) {
let json = {
video: {
src: res.data.video[0].playurl,
spareSrc: 'http://pd4t7ae3m.bkt.clouddn.com/test.mp4' // 正式环境时,需要将 contentVideo 中 spareSrc 改成 src
},
audio: {
src: res.data.audio[0].url,
poster: res.data.ppts[0] && res.data.ppts[0].ppt_url || ''
},
image: {
imgUrls: res.data.ppts.map(function (_, i) { return _.ppt_url }),
current: 0,
selectIndex: 0,
timeArr: res.data.ppts.map(function (_, i) { return _.ppt_point })
}
}
callback(json)
}
})
}
/* 获取进度信息 */
// 测试 用 device_id : jjhz92fn0.le2a6c06c9g0.thhg7ekb1f8
const getProgress = (vid, did, callback) => {
util.requestApi({
url: util.config.URL_PATH + '/tenant/v1/education/video/' + vid + '/device',
data: {
device_id: did
},
callback: function (res) {
callback(res.data)
}
})
}
/* 提交进度信息 */
const updateProgress = (obj) => {
util.requestApi({
url: util.config.URL_PATH + '/tenant/v1/analytics/upload-video',
data: {
d: obj.did,
i: obj.did,
c: obj.cid,
v: obj.vid,
_p: obj.pt, // 累计时间
_m: obj.mpt, // 当前播放最大时间
_c: obj.cpt // 当前播放位置
},
callback: function (res) {}
})
}
module.exports = {
getChapterList: getChapterList,
getCurrentChapterDetail: getCurrentChapterDetail,
getProgress: getProgress,
updateProgress: updateProgress
}
\ No newline at end of file
差异被折叠。
//app.js
App({
onLaunch: function () {}
})
\ No newline at end of file
{
"pages": [
"pages/index/index",
"pages/outSite/outSite",
"pages/videoPlayer/show",
"pages/learnSystem/home/home",
"pages/learnSystem/message/message",
"pages/learnSystem/my/my",
"pages/videoPlayer/AllBugPages/bugPage1/bugPage1",
"pages/videoPlayer/AllBugPages/test"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
},
"tabBar": {
"borderStyle": "#dcdcdc",
"color": "#313131",
"backgroundColor": "#ffffff",
"selectedColor": "#b49441",
"aniamtion": "true",
"list": [
{
"pagePath": "pages/learnSystem/home/home",
"text": "首页",
"iconPath": "/pages/learnSystem/icons/home.png",
"selectedIconPath": "/pages/learnSystem/icons/home-on.png"
},
{
"pagePath": "pages/learnSystem/message/message",
"text": "消息",
"iconPath": "/pages/learnSystem/icons/message.png",
"selectedIconPath": "/pages/learnSystem/icons/message-on.png"
},
{
"pagePath": "pages/learnSystem/my/my",
"text": "我的",
"iconPath": "/pages/learnSystem/icons/my.png",
"selectedIconPath": "/pages/learnSystem/icons/my-on.png"
}
]
}
}
\ No newline at end of file
const util = require('../../../utils/util.js')
/* 手机 验证码 相关内容 */
const BindPhone = {
popupShow: function (res) { this.tempUserInfo = res.userInfo; this.setData({ 'bindphone.isShow': "on" }); },
/* 关闭 绑定 弹窗 */
popupClose: function () {
!(wx.getStorageSync('userInfo') || {}).nickName && wx.setStorageSync('userSession', {});
clearInterval(this.timer); // 关闭定时器
let bindphone = { isShow: '', getCode: true, countDown: 60, phone: '', code: '' }
this.setData({ 'bindphone': bindphone })
},
/* 电话输入 离开 input blur事件监听 */
inputPhone: function (e) { this.setData({ 'bindphone.phone': e.detail.value }); },
/* 验证码输入 离开 input blur事件监听 */
inputCode: function (e) { this.setData({ 'bindphone.code': e.detail.value }); },
/* 点击获取验证码 */
getCode: function () {
const _that = this, _bind = _that.data.bindphone;
if (!_bind.phone || !/^1[3-9][0-9]{9}$/.test(_bind.phone)) { wx.showToast({ title: '请填入正确手机号', icon: 'none', duration: 1500 }); return; }
wx.showToast({ title: '验证码请求中', icon: 'none' })
wx.request({
url: util.config.URL_PATH + '/tenant/user/get-code',
data: { mobile: _bind.phone }, method: 'POST', header: { tenant: 'sofia' },
success: function (res) {
if (res.statusCode != 200) { wx.showToast({ title: res.data.message, icon: 'none' }); return ; }
wx.hideToast()
_that.setData({ 'bindphone.getCode': false })
/* 增加定时器 */
_that.timer = setInterval(() => {
if (_bind.countDown == 0) { clearInterval(_that.timer); _that.setData({ 'bindphone.countDown': 60, 'bindphone.getCode': true }); return; }
_that.setData({ 'bindphone.countDown': _bind.countDown - 1 });
}, 1000)
},
fail: function (res) { wx.hideToast(); wx.showToast({ title: res, icon: 'none' }); }
})
},
/* 点击确定 */
codeConfirm: function (e) {
const _that = this, _bind = _that.data.bindphone
if (!_bind.phone || !/^1[3-9][0-9]{9}$/.test(_bind.phone)) { wx.showToast({ title: '请填入正确手机号', icon: 'none' }); return ; }
if (!_bind.code || !/^\d{4}$/.test(_bind.code)) { wx.showToast({ title: '请填入正确验证码', icon: 'none' }); return ; }
wx.showToast({ title: '验证中', icon: 'none' })
/* 调用接口 - 使用验证码登录 */
wx.request({
url: util.config.URL_PATH + '/tenant/user/code-login',
data: { mobile: _bind.phone, code: _bind.code }, method: 'POST', header: { skey: wx.getStorageSync('userSession').sessionKey, tenant: 'sofia' },
success: function (res) {
if (res.statusCode && res.statusCode != 200) { wx.showToast({ title: res.data.message, icon: 'none' }); return ; }
wx.hideToast()
clearInterval(_that.timer);
/* 获取用户信息 */
wx.request({
url: util.config.URL_PATH + '/tenant/user/getinfo',
data: {}, method: 'GET', header: {
skey: wx.getStorageSync('userSession').sessionKey,
tenant: 'sofia'
},
success: res => {
if (res.statusCode != 200) { wx.showToast({ title: res.data.message, icon: 'none' }); return; }
let _userInfo = {
avatarUrl: res.data.avatar || _that.tempUserInfo.avatarUrl || '无',
nickName: res.data.nickname || _that.tempUserInfo.nickName || '无'
}
wx.setStorageSync('userInfo', _userInfo);
_that.setData({ userInfo: _userInfo, hasUserInfo: true })
_that.popupClose()
_that.goOutSite()
}
})
},
fail: function (res) { wx.hideToast(); wx.showToast({ title: res, icon: 'none' }); }
})
}
}
module.exports = {
BindPhone: BindPhone,
}
\ No newline at end of file
<template name="bindPhone">
<view wx:if="{{bindphone.isShow}}" class="bind-phone {{bindphone.isShow}}">
<view class="box">
<view class="hdr">
<text>绑定手机号</text>
<image src="./icons/user-close.png" bindtap="popupClose"></image>
</view>
<input maxlength="11" type='number' class="input-phone" placeholder="输入手机号" bindinput="inputPhone" bindblur="inputPhone" value="{{bindphone.phone}}" />
<view class="box-verify">
<input maxlength="6" type='number' class="code" placeholder="输入验证码" bindinput="inputCode" bindblur="inputCode" value="{{bindphone.code}}" />
<view wx:if="{{bindphone.getCode}}" class="button" bindtap="getCode">获取验证码</view>
<view wx:else class="countdown">已发送({{bindphone.countDown}}s)</view>
</view>
<view class="confirm" bindtap="codeConfirm">确定</view>
</view>
</view>
</template>
\ No newline at end of file
.bind-phone { opacity: 0; position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: -1; background: rgba(0, 0, 0, 0.6); }
.bind-phone.on { opacity: 1; z-index: 999; }
.bind-phone .box { position: absolute; left: 50%; top: 50%; padding: 40rpx; width: 630rpx; height: 450rpx; background: #fafafc; border-radius: 10rpx; font-size: 28rpx; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); }
.bind-phone .box .hdr { display: block; width: 100%; height: 46rpx; overflow: hidden; margin-bottom: 40rpx; -webkit-box-sizing: border-box; box-sizing: border-box; }
.bind-phone .box .hdr image { float: right; width: 46rpx; height: 46rpx; }
.bind-phone .box .input-phone { display: block; width: 100%; height: 90rpx; border: 1rpx solid #eee; border-radius: 10rpx; padding: 0 20rpx; -webkit-box-sizing: border-box; box-sizing: border-box; }
.bind-phone .box .box-verify { display: block; height: 90rpx; width: 100%; margin: 20rpx 0 40rpx 0; overflow: hidden; }
.bind-phone .box .box-verify .code { float: left; height: 90rpx; width: 370rpx; border: 1rpx solid #eee; padding: 0 20rpx; border-radius: 10rpx; -webkit-box-sizing: border-box; box-sizing: border-box; }
.bind-phone .box .box-verify .button { float: right; width: 220rpx; height: 90rpx; line-height: 90rpx; text-align: center; border: 1rpx solid #4b0; color: #4b0; border-radius: 10rpx; -webkit-box-sizing: border-box; box-sizing: border-box; }
.bind-phone .box .box-verify .countdown { float: right; width: 220rpx; height: 90rpx; line-height: 90rpx; text-align: center; background: #ccc; color: #fff; border-radius: 10rpx; -webkit-box-sizing: border-box; box-sizing: border-box; }
.bind-phone .box .confirm { height: 90rpx; width: 100%; background: #4b0; color: #fff; line-height: 90rpx; text-align: center; border-radius: 10rpx; }
\ No newline at end of file
//index.js
//获取应用实例
const app = getApp()
const util = require('../../utils/util.js')
const BindPhone = require('./bindPhone/bindPhone.js')
Page({
data: {
motto: '点击进入学习系统',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
// 绑定手机号 相关
bindphone: { isShow: '', getCode: true, countDown: 60, phone: '', code: '' }
},
goOutSite: function () {
wx.navigateTo({
url: '/pages/outSite/outSite'
})
// wx.switchTab({
// url: '/pages/learnSystem/home/home'
// })
},
/* 进入页面,先判断是否获取用户信息 */
onReady: function () {},
// e.detail.userInfo,
/* 按键授权,微信新版 - 获取用户信息 - 授权方式 */
getUserInfo: function (e) { this.getInfo(); },
/* 获取用户信息 并 判别是否跟紫荆账号绑定 */
getInfo: function () {
wx.showLoading({ title: '信息获取中...', mask: true })
/* 判别是否登录或者登录过期 */
util.LoginAgainAndJumpPage((loginRes, res) => {
if (loginRes) {
/* 只要调用登录接口,就返回sessionKey, 如果没有绑定 直接 */
wx.setStorageSync('userSession', { sessionKey: loginRes.data.session_key })
wx.setStorageSync('userInfo', {})
if (loginRes.data && loginRes.data.error_code == 40030) {
/* 判别 是否绑定过 紫荆账号 */
this.popupShow(res); wx.hideLoading(); return;
} else if (loginRes.data && loginRes.data.status && loginRes.data.status != 200) {
wx.hideLoading(); wx.showToast({ title: loginRes.data.message, icon: 'none' }); return;
} else {
let _userInfo = {
avatarUrl: loginRes.data.avatar || res.userInfo.avatarUrl || '无',
nickName: loginRes.data.nickname || res.userInfo.nickName || '无'
}
wx.setStorageSync('userInfo', _userInfo);
this.setData({ userInfo: _userInfo, hasUserInfo: true })
wx.hideLoading(); this.goOutSite(); return;
}
// if (res.data.errorCode == 40029) return _that.animteHint("code错误");
} else {
this.setData({ userInfo: wx.getStorageSync('userInfo'), hasUserInfo: true })
wx.hideLoading(); this.goOutSite(); return;
}
})
},
/* 手机号绑定 方法 */
timer: BindPhone.BindPhone.timer,
popupShow: BindPhone.BindPhone.popupShow,
popupClose: BindPhone.BindPhone.popupClose,
inputPhone: BindPhone.BindPhone.inputPhone,
inputCode: BindPhone.BindPhone.inputCode,
getCode: BindPhone.BindPhone.getCode,
codeConfirm: BindPhone.BindPhone.codeConfirm
})
{
"navigationBarTitleText": "MBA学习系统",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#414141",
"disableScroll": true
}
\ No newline at end of file
<!--index.wxml-->
<import src='bindPhone/bindPhone.wxml' />
<view class='container'>
<image class='bg' src='./icons/bg.png' mode='aspectFill'></image>
<image class='logo' src='./icons/hd-logo.png' mode='aspectFit'></image>
<view class='text'>在线学习系统</view>
<button class='btn' open-type='getUserInfo' bindgetuserinfo='getUserInfo'>登录</button>
<view class='userinfo'>
<!-- wx:if='{{!hasUserInfo && canIUse}}' -->
<!-- <block wx:else>
<image bindtap='goOutSite' class='userinfo-avatar' src='{{userInfo.avatarUrl}}' background-size='cover'></image>
<text bindtap='goOutSite' class='userinfo-nickname'>{{userInfo.nickName}}</text>
</block> -->
</view>
<template is='bindPhone' data='{{bindphone}}'></template>
</view>
\ No newline at end of file
/**index.wxss**/
@import "bindPhone/bindPhone.wxss";
.container { position: fixed; top: 0; left: 0; bottom: 0; right: 0; background: #e5e5e5; }
.container .bg { position: absolute; z-index: 0; top: 0; left: 0; width: 100%; height: 100%; }
.container .logo { position: absolute; z-index: 1; top: 233rpx; left: 50%; width: 344rpx; height: 47rpx; -webkit-transform: translateX(-50%); transform: translateX(-50%); }
.container .text { position: absolute; z-index: 1; top: 303rpx; left: 0; width: 100%; color: #fff; font-size: 54rpx; letter-spacing: 14rpx; line-height: 54rpx; text-align: center; font-weight: 300; }
.container .btn { position: absolute; left: 50%; bottom: 253rpx; width: 500rpx; height: 80rpx; line-height: 80rpx; font-size: 30rpx; font-weight: 300; color: #fff; background: #b49441; -webkit-transform: translateX(-50%); transform: translateX(-50%); }
\ No newline at end of file
// pages/learnSystem/home/home.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"navigationBarTitleText": "MBA学习系统"
}
\ No newline at end of file
<!--pages/learnSystem/home/home.wxml-->
<view class='left'>已发布 2018-09-23 至 2019-10-21 已选修</view>
/* pages/learnSystem/home/home.wxss */
.left {margin-left: 270rpx; margin-right: 25rpx; font-size: 18rpx;}
\ No newline at end of file
// pages/learnSystem/message/message.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"navigationBarTitleText": "消息"
}
\ No newline at end of file
<!--pages/learnSystem/message/message.wxml-->
<text>pages/learnSystem/message/message.wxml</text>
/* pages/learnSystem/message/message.wxss */
\ No newline at end of file
// pages/learnSystem/my/my.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"navigationBarTitleText": "我的"
}
\ No newline at end of file
<!--pages/learnSystem/my/my.wxml-->
<text>pages/learnSystem/my/my.wxml</text>
/* pages/learnSystem/my/my.wxss */
\ No newline at end of file
// pages/outSite/outSite.js
const util = require('../../utils/util.js')
Page({
/**
* 页面的初始数据
*/
data: {
outerLink: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
// 这里注意,苹果对于url传参,长度受到限制,不能过长;android不受限
this.setData({ 'outerLink': util.config.outSiteLink + '?skey=' + encodeURIComponent(wx.getStorageSync('userSession').sessionKey) });
wx.showLoading({ title: '加载中' });
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () { wx.hideLoading(); },
/**
* 生命周期函数--监听页面显示
*/
onShow: function () { wx.hideLoading(); },
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () { wx.hideLoading(); },
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () { wx.hideLoading(); },
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"navigationBarBackgroundColor": "#3f3f3f",
"navigationBarTextStyle": "white",
"backgroundColor": "#535353",
"navigationBarTitleText": "学习系统"
}
\ No newline at end of file
<!--pages/outSite/outSite.wxml-->
<web-view src="{{outerLink}}"></web-view>
/* pages/outSite/outSite.wxss */
\ No newline at end of file
// pages/videoPlayer/AllBugPages/page1/bugPage1.js
const util = require('../../../../utils/util.js')
Page({
data: {
isVideoShow: false,
currentTime: 0,
totalTime: 0,
video: {
src: ''
}
},
_audio: null,
_video: null,
playVideo: false,
playAudio: false,
onHide: function () { this.videoPause() },
onReady: function () {
this.setData({ 'isVideoShow': true })
this.setData({ 'video.src': 'https://cd15-c120-1.play.bokecc.com/flvs/C67C24BF493FE39E/2016-03-29/CD319C8C0265B11A9C33DC5901307461-20.m3u8?t=1536297247&key=2467F8448E028A1614E354B75A457951' })
setTimeout(() => {
this._video = wx.createVideoContext('video-play')
}, 1000)
this._audio = wx.createAudioContext('audio-play')
},
audioPlay: function () { this._audio.play(); this.playAudio = true; this.playVideo = false; },
videoPlay: function () { this._video.play(); this.playAudio = false; this.playVideo = true; },
audioPause: function () { this._audio.pause(); this.playAudio = false; },
videoPause: function () { this._video.pause(); this.playVideo = false; },
videoShowOrHide: function () { this.setData({ 'isVideoShow': !this.data.isVideoShow }) },
changeVideo: function () { this.setData({ 'video.src': 'http://pd4t7ae3m.bkt.clouddn.com/test.mp4' }); },
timeUpdate: function (e) {
let _data = this.data, _status = _data.status, _detail = e.detail, _obj = {}
console.log('视频时间变化', parseInt(_detail.currentTime))
_obj.currentTime = parseInt(_detail.currentTime)
_obj.totalTime = parseInt(_detail.duration)
this.setData({ 'ctrlBar.progress': _obj.currentTime / _obj.totalTime * 100 + '%' });
this.setData({ 'currentTime': util.durationToTimeString(_obj.currentTime) });
this.setData({ 'totalTime': util.durationToTimeString(_obj.totalTime) })
},
/**
* 第一种情况:
* 在播放音视频时,打开预览大图,会暂停播放音视频。
*/
viewImage1: function () {
let _ = this
wx.previewImage({
urls: [
'http://pd4t7ae3m.bkt.clouddn.com/imgs-test1.jpg',
'http://pd4t7ae3m.bkt.clouddn.com/imgs-test2.jpg',
'http://pd4t7ae3m.bkt.clouddn.com/imgs-test3.jpg'
],
current: 0,
success: () => {
_.playAudio && _._audio.play()
_.playVideo && _._video.play()
}
})
_.playAudio && _._audio.play()
_.playVideo && _._video.play()
},
/**
* 第二种情况:
* 音视频播放过程中,在打开预览图片前,手动调用方法暂停播放,但是关闭预览图片后,发现问题。
* android 视频播放未暂停,ios 正常
*/
viewImage2: function () {
let _ = this
this.audioPause()
this.videoPause()
wx.previewImage({
urls: [
'http://pd4t7ae3m.bkt.clouddn.com/imgs-test1.jpg',
'http://pd4t7ae3m.bkt.clouddn.com/imgs-test2.jpg',
'http://pd4t7ae3m.bkt.clouddn.com/imgs-test3.jpg'
],
current: 0,
success: () => {}
})
}
})
\ No newline at end of file
<!--pages/videoPlayer/AllBugPages/page1/bugPage1.wxml-->
<button bindtap='viewImage1'>点击预览图片-方法1</button>
<button bindtap='viewImage2'>点击预览图片-方法2</button>
<button bindtap='changeVideo'>视频切换</button>
<button bindtap='audioPlay'>音频播放</button>
<button bindtap='audioPause'>音频暂停</button>
<button bindtap='videoPlay'>视频播放</button>
<button bindtap='videoPause'>视频暂停</button>
<button bindtap='videoShowOrHide'>视频显示/隐藏</button>
<view class='start-time'>播放时间:{{currentTime}}</view>
<view class='end-time'>总时间:{{totalTime}}</view>
<audio id='audio-play' src='http://pd4t7ae3m.bkt.clouddn.com/audio-test.mp3'></audio>
<view style='{{isVideoShow ? "": "display:none"}}'>
<video id='video-play' style="width: 750rpx;" src='{{video.src}}' bindtimeupdate='timeUpdate' show-center-play-btn='{{false}}' controls='{{false}}'></video>
</view>
\ No newline at end of file
/* pages/videoPlayer/AllBugPages/page1/bugPage1.wxss */
.start-time { float: left; margin-left: 20rpx; }
.end-time { float: right; margin-right: 20rpx; }
\ No newline at end of file
// pages/videoPlayer/AllBugPages/test.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
<!--pages/videoPlayer/AllBugPages/test.wxml-->
<text>pages/videoPlayer/AllBugPages/test.wxml</text>
/* pages/videoPlayer/AllBugPages/test.wxss */
\ No newline at end of file
/**
* 创建一个audio对象
* @param {[string]} selectorId [audio组件id对应选择器字符串]
*/
var Audio = function (selectorId) {
if (!(this instanceof Audio)) {
return new Audio(selectorId);
} else {
this._audio = this.init(selectorId);
this.currentTime = 0; // 当前时间
this.totalTime = 0; // 总时间
this.rateIndex = 2; // 取值为 RATE中的 下标 0,1,2,3,4
}
}
/**
* audio对象创建后,提供的方法
* init - 初始化方法
* play - 视频播放
* pause - 视频暂停
* stop - 视频停止
* seek - 视频跳到某个位置再播放
* rate - 视频播放速率调整
*
*/
Audio.prototype = {
constructor: Audio,
RATE: ['0.5', '0.8', '1.0', '1.25', '1.5'],
init: function (selectorId) {
return wx.createAudioContext(selectorId);
},
play: function () {
this._audio.play();
},
pause: function () {
this._audio.pause();
},
stop: function () {
this._audio.stop();
},
seek: function (time) {
this._audio.seek(time);
},
fastSlow15: function (timeStr) {
this._audio.seek(this.currentTime + parseInt(timeStr));
},
rate: function () {
this.rateIndex++;
if (this.rateIndex > 4) this.rateIndex = 0;
this._audio.playbackRate(parseFloat(this.RATE[this.rateIndex]));
}
}
module.exports = {
Audio: Audio
}
<template name='contentAudio'>
<view class='content-audio'
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 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>
<audio id="my-audio" class='my-audio' src='{{audio.src}}' controls='{{false}}' bindtimeupdate='timeUpdate' binderror='playError'></audio>
</view>
</template>
\ No newline at end of file
.content-audio { position: absolute; z-index: 0; top: 0; left: 0; right: 0; bottom: 300rpx; background: #313131; }
.content-audio .slide-image { position: absolute; top: 50%; left: 50%; display: block; width: 750rpx; height: 422rpx; color: #7d7d7d; font-size: 30rpx; text-align: center; line-height: 450rpx; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); }
/* 图片过大时,都要先加载再显示 */
.content-audio .loading-image { position: absolute; z-index: 1; top: 50%; left: 50%; display: block; width: 750rpx; height: 50rpx; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); background: transparent; }
.content-audio .loading-image.none { display: none; }
\ No newline at end of file
<template name='contentImages'>
<view class='content-images'>
<block wx:if='{{image.imgUrls.length}}'>
<swiper class='swiper-images' bindchange='imageSelectIndexUpdate' current='{{image.current}}'>
<block wx:for='{{image.imgUrls}}' wx:key='{{index}}'>
<swiper-item>
<image src='{{item}}' class='slide-image' mode='aspectFit' bindtap='showBigImage'/>
</swiper-item>
</block>
</swiper>
</block>
<block wx:else>
<view class='swiper-images'><view class='slide-image'>本课程暂无PPT</view></view>
</block>
</view>
</template>
.content-images { position: absolute; z-index: 1; top: 0; left: 0; right: 0; bottom: 300rpx; background: #313131; }
.content-images .swiper-images { position: absolute; top: 50%; width: 750rpx; height: 422rpx; -webkit-transform: translateY(-50%); transform: translateY(-50%); }
.content-images .swiper-images .slide-image { display: block; width: 750rpx; height: 422rpx; color: #7d7d7d; font-size: 30rpx; text-align: center; line-height: 450rpx; background: #313131; }
/* 图片过大时,都要先加载再显示 */
.content-images .swiper-images .loading-image { position: absolute; z-index: 1; top: 50%; left: 50%; display: block; width: 750rpx; height: 50rpx; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); background: transparent; }
.content-images .swiper-images .loading-image.none { display: none; }
\ No newline at end of file
<template name='contentVideo'>
<!-- 这里加 这么多判断原因,video组件在真机上测试,一定在最上层,其他任何元素都挡不住,只能先隐藏,需要时再显示 -->
<view class='content-video'
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}}' initial-time='{{ctrlBar.initial_time}}' show-center-play-btn='{{false}}' controls='{{false}}' bindtimeupdate='timeUpdate' bindplay='beginPlayVA' binderror='playError' autoplay='{{false}}'></video>
</view>
</template>
\ No newline at end of file
.content-video { position: absolute; top: 0; left: 0; right: 0; bottom: 300rpx; background: #313131; }
.content-video .my-video { position: absolute; top: 50%; width: 750rpx; height: 422rpx; -webkit-transform: translateY(-50%); transform: translateY(-50%); }
\ No newline at end of file
/**
* 创建一个video对象
* @param {[string]} selectorId [video组件id对应选择器字符串]
*/
var Video = function (selectorId) {
if (!(this instanceof Video)) {
return new Video(selectorId);
} else {
this._video = this.init(selectorId);
this.currentTime = 0; // 当前时间
this.totalTime = 0; // 总时间
this.rateIndex = 2; // 取值为 RATE中的 下标 0,1,2,3,4
}
}
/**
* video对象创建后,提供的方法
* init - 初始化方法
* play - 视频播放
* pause - 视频暂停
* stop - 视频停止
* seek - 视频跳到某个位置再播放
* rate - 视频播放速率调整
*
*/
Video.prototype = {
constructor: Video,
RATE: ['0.5', '0.8', '1.0', '1.25', '1.5'],
init: function (selectorId) {
return wx.createVideoContext(selectorId);
},
play: function () {
this._video.play();
},
pause: function () {
this._video.pause();
},
stop: function () {
this._video.stop();
},
seek: function (time) {
this._video.seek(time);
},
fastSlow15: function (timeStr) {
this._video.seek(this.currentTime + parseInt(timeStr));
},
rate: function () {
this.rateIndex ++;
if (this.rateIndex > 4) this.rateIndex = 0;
this._video.playbackRate(parseFloat(this.RATE[this.rateIndex]));
}
}
module.exports = {
Video: Video
}
<template name='controlBar'>
<view class='control-bar'>
<view class='ctrl {{status.isImages && "ppt"}} {{status.isAudio && "audio"}} {{status.isVideo && "normal"}}'>
<image class='img see-audio' src='./controlBar/icons/see-audio.png' mode='scaleToFill' bindtap='showContentAudio'></image>
<image class='img see-video' src='./controlBar/icons/see-video.png' mode='scaleToFill' bindtap='showContentVideo'></image>
<image class='img see-ppt' src='./controlBar/icons/see-ppt.png' mode='scaleToFill' bindtap='openContentImages'></image>
<image class='img see-notppt' src='./controlBar/icons/see-notppt.png' mode='scaleToFill' bindtap='closeContentImages'></image>
<!-- <image class='img see-set' src='./controlBar/icons/see-set.png' mode='scaleToFill'></image> -->
</view>
<view class='control-progress' bindtouchstart='tapToSeek'>
<view class='progress-line'>
<view class='cache-line' style='width: 100%;'></view>
<view class='current-line' style='width: {{ctrlBar.progress}};'></view>
</view>
<view class='progress-time'>
<view class='current-time'>{{ctrlBar.currentTime}}</view>
<view class='total-time'>{{ctrlBar.totalTime}}</view>
</view>
</view>
<view class='control-btns'>
<view class='left-btn' bindtap='openSelectChapterList'>
<image class='img normal' src='./controlBar/icons/left-btn-normal.png' mode='scaleToFill'></image>
<image class='img active' src='./controlBar/icons/left-btn-active.png' mode='scaleToFill'></image>
<view class='text'>章节</view>
</view>
<view class='main-btns'>
<view class='btn-back'>
<image class='img' src='./controlBar/icons/btn-back.png' mode='scaleToFill' data-id='{{chapterList.prevVideo.id}}' data-hasVA='{{chapterList.prevVideo.time}}' data-name='{{chapterList.prevVideo.name}}' bindtap='prevChapter'></image>
</view>
<view class='opt'>
<image class='img init-page {{initPageFlag ? "" : "none"}}' src='./controlBar/icons/loading_small.gif' mode='aspectFit'></image>
<image class='img play {{initPageFlag ? "none" : ""}} {{!ctrlBar.isPlay ? "" : "none"}}' src='./controlBar/icons/btn-play.png' mode='scaleToFill' bindtap='playVA'></image>
<image class='img pause {{initPageFlag ? "none" : ""}} {{!ctrlBar.isPlay ? "none" : ""}}' src='./controlBar/icons/btn-pause.png' mode='scaleToFill' bindtap='pauseVA'></image>
</view>
<view class='btn-front'>
<image class='img' src='./controlBar/icons/btn-front.png' mode='scaleToFill' data-id='{{chapterList.nextVideo.id}}' data-hasVA='{{chapterList.nextVideo.time}}' data-name='{{chapterList.nextVideo.name}}' bindtap='nextChapter'></image>
</view>
</view>
<view class='right-btn' bindtap='openSetContent'>
<image class='img' src='./controlBar/icons/see-set.png' mode='scaleToFill'></image>
<view class='text'>设置</view>
</view>
</view>
</view>
</template>
\ No newline at end of file
.control-bar { position: absolute; z-index: 1; left: 0; right: 0; bottom: 0; height: 300rpx; background: #3f3f3f; }
/* 内容 控制区 控制看视频、音频还是PPT */
.control-bar .ctrl { position: absolute; top: -90rpx; width: 100%; text-align: center; }
.control-bar .ctrl .img { display: inline-block; vertical-align: middle; margin: 0 18rpx; padding: 20rpx; }
.control-bar .ctrl .img.see-audio { width: 29rpx; height: 42rpx; }
.control-bar .ctrl .img.see-video { width: 46rpx; height: 29rpx; }
.control-bar .ctrl .img.see-ppt { width: 33rpx; height: 41rpx; }
.control-bar .ctrl .img.see-notppt { width: 60rpx; height: 44rpx; }
.control-bar .ctrl.normal .img.see-video, .control-bar .ctrl.normal .img.see-notppt { display: none; }
.control-bar .ctrl.audio .img.see-audio, .control-bar .ctrl.audio .img.see-notppt { display: none; }
.control-bar .ctrl.ppt .img.see-ppt, .control-bar .ctrl.ppt .img.see-audio, .control-bar .ctrl.ppt .img.see-video { display: none; }
.control-bar .ctrl.ppt .img.see-notppt { display: inline-block; }
/* 进度条+时间 */
.control-bar .control-progress { margin: 7rpx 17rpx 0 17rpx; padding-top: 30rpx; overflow: hidden; }
.control-bar .control-progress .progress-line { position: relative; width: 100%; height: 4rpx; background: #898989; }
.cache-line { position: absolute; z-index: 1; left: 0; top: 0; height: 100%; background: #b5b5b5; }
.current-line { position: absolute; z-index: 2; left: 0; top: 0; height: 100%; background: #d3a010; }
.control-bar .control-progress .progress-time { width: 100%; overflow: hidden; }
.control-bar .control-progress .progress-time .current-time { float:left; height: 45rpx; font-size: 22rpx; color: #c9c9c9; line-height: 45rpx; }
.control-bar .control-progress .progress-time .total-time { float:right; height: 45rpx; font-size: 22rpx; color: #c9c9c9; line-height: 45rpx; }
/* 控制按钮 */
.control-btns { position: relative; margin: 25rpx 17rpx 0 17rpx; }
.control-btns .left-btn { float: left; margin: 20rpx 0 0 40rpx; padding: 10rpx 20rpx; }
.control-btns .left-btn .active, .control-btns .left-btn.on .normal { display: none; }
.control-btns .left-btn .normal, .control-btns .left-btn.on .active { display: block; }
.control-btns .left-btn .img { margin: 0 auto; width: 54rpx; height: 47rpx; }
.control-btns .left-btn .text { margin-top: 10rpx; font-size: 22rpx; line-height: 25rpx; color: #fff; text-align: center; }
.control-btns .right-btn { float: right; margin: 20rpx 40rpx 0 0; padding: 10rpx 20rpx; }
.control-btns .right-btn .img { margin: 0 auto; width: 47rpx; height: 47rpx; }
.control-btns .right-btn .text { margin-top: 10rpx; font-size: 22rpx; line-height: 25rpx; color: #fff; }
.control-btns .main-btns { position: absolute; left: 50%; -webkit-transform: translateX(-50%); transform: translateX(-50%); }
.control-btns .main-btns .btn-back, .control-btns .main-btns .opt, .control-btns .main-btns .btn-front { display: inline-block; vertical-align: middle; overflow: hidden; }
.control-btns .main-btns .btn-back .img { display: block; width: 33rpx; height: 34rpx; }
.control-btns .main-btns .opt .img { display: block; margin: 0 54rpx; width: 121rpx; height: 120rpx; }
.control-btns .main-btns .opt .img.init-page { display: block; margin: 0 54rpx; width: 121rpx; height: 50rpx; padding: 35rpx 0; }
.control-btns .main-btns .opt .img.none { display: none; }
.control-btns .main-btns .btn-front .img { display: block; width: 32rpx; height: 34rpx; }
<template name='noSupport'>
<view class='no-support'>
<view class='text'>本课程暂不支持手机端播放</view>
</view>
</template>
\ No newline at end of file
.no-support { position: absolute; top: 0; left: 0; right: 0; bottom: 300rpx; background: #535353; }
.no-support .text { position: absolute; top: 50%; left: 50%; color: #7d7d7d; font-size: 30rpx; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); }
\ No newline at end of file
<template name='pageLoading'>
<view class='page-loading'>
<image src='./pageLoading/icons/loading_small.gif' class='loading-image' mode='aspectFit'/>
<view class='text'>内容加载中</view>
</view>
</template>
\ No newline at end of file
.page-loading { position: absolute; z-index: 10; top: 0; left: 0; right: 0; bottom: 0; background: #313131; }
.page-loading .loading-image { position: absolute; z-index: 1; top: 50%; left: 50%; display: block; width: 750rpx; height: 50rpx; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); background: transparent; }
.page-loading .text { position: absolute; z-index: 1; top: 55%; left: 50%; display: block; width: 750rpx; text-align: center; font-size: 20rpx; color: #fff; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); background: transparent; }
\ No newline at end of file
<template name='selectChapterList'>
<view class='select-chapter-list' style='{{!chapterList.isShow && "display:none;"}}'>
<view class='bg' bindtap='closeSelectChapterList'></view>
<view class="content">
<block wx:for='{{chapterList.course}}' wx:key='{{index}}'>
<view class='content-group'>
<view class='title'>{{item.title}}</view>
<block wx:for='{{item.chapters}}' wx:key='{{index}}' wx:for-item="item1">
<view class='body {{item1.id === chapterList.currentChapterId && "on"}}'>
<view class='name' data-id='{{item1.id}}' data-hasVA='{{item1.time}}' data-name='{{item1.name}}' bindtap='jumpToOtherVA'>
{{item1.name}}
<view class='time'>{{item1.time}}</view>
</view>
</view>
</block>
</view>
</block>
</view>
</view>
</template>
\ No newline at end of file
.select-chapter-list { position: fixed; z-index: 10; top: 0; bottom: 0; left: 0; right: 0; }
.select-chapter-list .bg { position: absolute; z-index: 1; top: 0; bottom: 0; left: 0; right: 0; background: rgba(0, 0, 0, 0.3); }
.select-chapter-list .content { position: absolute; z-index: 2; width: 750rpx; bottom: 0; top: 418rpx; overflow: auto; background-color: #eee; padding: 33rpx 0; }
.select-chapter-list .content .content-group { padding: 0 26rpx; }
.select-chapter-list .content .content-group .title { position: relative; padding: 0 24rpx; color: #313131; font-size: 30rpx; line-height: 80rpx; background: #c9c9c9; }
.select-chapter-list .content .content-group .body { position: relative; padding: 0 24rpx; font-size: 30rpx; line-height: 42rpx; color: #505050; }
.select-chapter-list .content .content-group .body.on .name { color: #b2183e; }
.select-chapter-list .content .content-group .body .name { padding: 20rpx 70rpx 20rpx 40rpx; border-left: 2rpx solid #c9c9c9; }
.select-chapter-list .content .content-group .body .name:before { width: 30rpx; height: 30rpx; border-radius: 32rpx; border:4rpx solid #c9c9c9;
background: #e5e5e5; position: absolute; left: 6rpx; top: 20rpx; content: ""; display: block; z-index: 10; }
.select-chapter-list .content .content-group .body .name .time { position: absolute; right: 16rpx; top: 20rpx; }
/* .play-chapter-progress{position:absolute;left:7px;top:8px;z-index:60;display:none\0;}
.play-chapter .play-prog{position:absolute;top:8px;left:7px;z-index:10;} */
\ No newline at end of file
<template name='setContent'>
<view class='set-content'>
<view class='content'>
<view class='progress-time'>
<view class='time current-time'>{{ctrlBar.currentTime}}</view><view class='time'>/</view><view class='time total-time'>{{ctrlBar.totalTime}}</view>
</view>
<view class='ctrl-time-pos'>
<view class='skip-head {{ctrlBar.jumpFlag ? "on" : ""}}' bindtouchend='jumpHead'>
<image class='img normal' src='./setContent/icons/jump-normal.png' mode='scaleToFill'></image>
<image class='img active' src='./setContent/icons/jump-active.png' mode='scaleToFill'></image>
<view class='text'>跳过片头</view>
</view>
<image class='img slow-15s' src='./setContent/icons/slow-15s.png' mode='scaleToFill' bindtouchend='slow15s'></image>
<image class='img fast-15s' src='./setContent/icons/fast-15s.png' mode='scaleToFill' bindtouchend='fast15s'></image>
<view class='speed-rate' bindtouchend='setRate'>
<view class='rate'>{{ctrlBar.curRate}}</view>
<view class='text'>倍速播放</view>
</view>
</view>
</view>
<image class='back' src='./setContent/icons/back.png' mode='scaleToFill' bindtouchend='closeSetContent'></image>
</view>
</template>
\ No newline at end of file
.set-content { position: absolute; z-index: 2; top: 0; left: 0; right: 0; bottom: 300rpx; background: #eeeeee; }
.set-content .back { position: absolute; right: 40rpx; bottom: 30rpx; padding: 20rpx; width: 40rpx; height: 40rpx; }
.set-content .content { position: absolute; top: 50%; width: 100%; -webkit-transform: translateY(-50%); transform: translateY(-50%); }
/* 显示时间 */
.set-content .content .progress-time { font-size: 86rpx; line-height: 100rpx; font-weight: 700; color: #313131; text-align: center; }
.set-content .content .progress-time .time { display: inline-block; vertical-align: middle; }
.set-content .content .progress-time .current-time { color: #b2183e; }
/* 其他控制 */
.set-content .content .ctrl-time-pos { margin-top: 100rpx; text-align: center; color: #313131; }
.set-content .content .ctrl-time-pos .skip-head { display: inline-block; vertical-align: middle; margin-right: 20rpx; }
.set-content .content .ctrl-time-pos .skip-head .active, .set-content .content .ctrl-time-pos .skip-head.on .normal { display: none; }
.set-content .content .ctrl-time-pos .skip-head .normal, .set-content .content .ctrl-time-pos .skip-head.on .active { display: block; }
.set-content .content .ctrl-time-pos .skip-head .img { margin: 4rpx auto; width: 32rpx; height: 32rpx; }
.set-content .content .ctrl-time-pos .skip-head .text { margin-top: 15rpx; font-size: 22rpx; line-height: 30rpx; }
.set-content .content .ctrl-time-pos .img { display: inline-block; vertical-align: middle; margin: 0 20rpx; width: 118rpx; height: 111rpx; }
.set-content .content .ctrl-time-pos .speed-rate { display: inline-block; vertical-align: middle; margin-left: 20rpx; }
.set-content .content .ctrl-time-pos .speed-rate .rate { font-size: 32rpx; line-height: 40rpx; }
.set-content .content .ctrl-time-pos .speed-rate .text { margin-top: 10rpx; font-size: 22rpx; line-height: 30rpx; }
\ No newline at end of file
差异被折叠。
{
"navigationBarBackgroundColor": "#3f3f3f",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "MBA学习系统",
"backgroundColor": "#535353",
"disableScroll": true
}
\ No newline at end of file
<!--pages/videoPlayer/show.wxml-->
<import src='contentAudio/contentAudio.wxml' />
<import src='contentVideo/contentVideo.wxml' />
<import src='contentImages/contentImages.wxml' />
<import src='pageLoading/pageLoading.wxml' />
<import src='noSupport/noSupport.wxml' />
<import src='setContent/setContent.wxml' />
<import src='controlBar/controlBar.wxml' />
<import src='selectChapterList/selectChapterList.wxml' />
<block wx:if='{{status.isLoading}}'>
<template is='pageLoading'></template>
</block>
<block wx:if='{{status.isSupport}}'>
<block wx:if='{{status.isSet}}'>
<template is='setContent' data='{{ctrlBar}}'></template>
</block><block wx:elif='{{status.isImages}}'>
<template is='contentImages' data='{{status, image}}'></template>
</block>
<template is='contentAudio' data='{{status, audio, image, ctrlBar}}'></template>
<template is='contentVideo' data='{{status, video, chapterList, ctrlBar}}'></template>
</block><block wx:else>
<template is='noSupport'></template>
</block>
<template is='controlBar' data='{{status, video, ctrlBar, chapterList, initPageFlag}}'></template>
<template is='selectChapterList' data='{{status, chapterList}}'></template>
/* pages/videoPlayer/show.wxss */
@import "contentAudio/contentAudio.wxss";
@import "contentVideo/contentVideo.wxss";
@import "contentImages/contentImages.wxss";
@import "pageLoading/pageLoading.wxss";
@import "noSupport/noSupport.wxss";
@import "setContent/setContent.wxss";
@import "controlBar/controlBar.wxss";
@import "selectChapterList/selectChapterList.wxss";
\ No newline at end of file
{
"description": "项目配置文件。",
"setting": {
"urlCheck": true,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true
},
"compileType": "miniprogram",
"libVersion": "2.2.3",
"appid": "wx944151f4ea4203a4",
"projectname": "learnOnline",
"isGameTourist": false,
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": []
}
}
}
\ No newline at end of file
/**
* 所有相关配置项
*/
const config = {
// URL_PATH: 'http://dev.ezijing.com:3000/api', // 本地开发域名
// outSiteLink: 'https://applets.ezijing.com', // 本地测试外链
// URL_PATH: 'https://api2.ezijing.com', // 测试域名
URL_PATH: 'https://api.ezijing.com', // 正式域名
outSiteLink: 'https://e-learning.ezijing.com', //正式外链
}
/* 请求接口统一 重定义 */
const requestApi = (obj) => {
wx.request({
url: obj.url,
data: obj.data || '', // 不必填
header: {
'skey': wx.getStorageSync('userSession').sessionKey,
'tenant': 'sofia',
'content-type': 'application/x-www-form-urlencoded',
// 测试用
// 'Cookie': '_idt=jjhz92fn0.le2a6c06c9g0.thhg7ekb1f8; _ga=GA1.2.1777311393.1531910388; Hm_lvt_64d86060eda3e464ab4928484860b4ea=1531998677; pt_37c2513b=uid=K0MVCaW1zOQbL9Hlh4nwcA&nid=0&vid=j38J/KRanp7TFqxsiK0Ryw&vn=14&pvn=3&sact=1533523932802&to_flag=0&pl=NbnhKybdedL6K-YTE0zzsQ*pt*1533523932802; _pk_id.8.50b6=5e9684d55d7b51d1.1534129436.5.1534223988.1534222943.; Hm_lvt_35891a16eff03ec8bb219e4a00dbaf7a=1534307203; looyu_id=3aa78c2b7a744584f9f6fef015c4157b66_10036753%3A6; Qs_lvt_217181=1534307202; pt_s_6d83a9d6=vt=1534308606705&cad=; Hm_lpvt_35891a16eff03ec8bb219e4a00dbaf7a=1534308607; Qs_pv_217181=4039008301502242300%2C2643992663734177300%2C23948192170497664%2C3823352575569261000; pt_6d83a9d6=uid=EXg24v5T9wUibq5/wWWZCg&nid=0&vid=4NDbaXQ0RlX8HEv7TTSzkA&vn=8&pvn=2&sact=1534308606705&to_flag=1&pl=Rcddj0FCL0MTlYRofJeCeA*pt*1534308606705; Hm_lvt_81efeffaf531027591c4d577ee4a5cb4=1533525823,1534473796; _SUP=00da585a6b1b53bd453d1b30cbf9812ff9ef0313e4f5756651f3218543452c27a%3A2%3A%7Bi%3A0%3Bs%3A4%3A%22_SUP%22%3Bi%3A1%3Bs%3A144%3A%22MFpTR3h1QmtTSlM1Z3JvLmVscG1heGUuMTBzYWMtZWRPWnFoeDdsMFlCTkFiTFNjZFl3UVVDZkVwa3N3UlgxZEFVQTlkTnFhRU54c3RLUGEtMTI1LVRHVDAuNDI3NDQ0ODQ4ODA1MzQ5MDU%3D%22%3B%7D; Hm_lpvt_81efeffaf531027591c4d577ee4a5cb4=1535072424; _pk_id.7.50b6=a73f1add4efca30d.1531815381.52.1535110040.1535110040.; _pk_ses.7.50b6=*'
},
method: obj.method || 'GET', // 不必填,默认 GET
dataType: 'json',
success: function (res) {
if (res.statusCode === 200) {
// if (res.data.status === 200) {
// obj.callback(res.data) // 直接把数据处理好,然后直接 返回
// } else {
// wx.showToast({ title: JSON.stringify(res.data), icon: 'none' }) // 自己后台封装返回
// }
obj.callback(res)
} else {
wx.showToast({ title: res.errMsg, icon: 'none' }) // 微信封装返回
}
},
fail: function (res) {
wx.showToast({ title: JSON.stringify(res), icon: 'none' })
}
})
}
/* 工具方法 - 播放时间 转化 h:m:s */
const durationToTimeString = (duration) => {
let h = Math.floor(duration / 3600);
let m = Math.floor((duration - h * 3600) / 60);
let s = (duration - h * 3600 - m * 60) % 60;
function tenify(a) {
return a >= 10 ? a : '0' + a;
}
let to = { h: tenify(h), m: tenify(m), s: tenify(s) }
let format = 'h:m:s';
return format.replace(/h|m|s/g, k => to[k]).replace(/^00\:/, '');
}
/**
* 小程序 - 获取用户信息
*/
const miniGetInfo = (callback) => {
// 获取用户凭证code - 使用 login API获取
wx.login({
success: res => {
let obj = {}
obj.code = res.code
// 获取用户授权设置 - 使用 getSetting API获取
wx.getSetting({
success: res1 => {
if (res1.authSetting['scope.userInfo']) {
// 获取用户信息 - 使用 getUserInfo API获取
wx.getUserInfo({
withCredentials: true,
success: res2 => {
obj.encryptedData = res2.encryptedData
obj.iv = res2.iv
obj.userInfo = res2.userInfo
/**
* 这里 调用后台接口 loginApi,传参如下
* obj.code
* obj.encryptedData
* obj.iv
* obj.userInfo
*/
loginApi(obj, (res, obj) => { callback(res, obj); })
},
fail: res2 => { wx.hideLoading(); wx.showToast({ title: '用户信息获取失败,请重试', icon: 'none' }); }
})
} else {
wx.hideLoading(); wx.showToast({ title: '请先点击登录', icon: 'none' });
}
},
fail: res1 => { wx.hideLoading(); wx.showToast({ title: '用户授权设置获取失败,请重试', icon: 'none' }); }
})
},
fail: res => { wx.hideLoading(); wx.showToast({ title: '用户凭证code获取失败,请重试', icon: 'none' }); }
})
}
/**
* 登录api - 获取 openId 、userName等内容
*/
const loginApi = (obj, callback) => {
wx.request({
url: config.URL_PATH + '/tenant/user/applets-login',
data: { code: obj.code, encrypted_data: obj.encryptedData, iv: obj.iv }, method: 'POST', header: {
tenant: 'sofia'
},
success: res => { callback(res, obj); }
})
}
/**
* 小程序 - 判断是否需要再次登录 并 跳转页面
*/
const LoginAgainAndJumpPage = (callback) => {
let userSession = wx.getStorageSync('userSession') || {}
let _userInfo = wx.getStorageSync('userInfo') || {}
/* 可能存在,多微信绑定同一个手机问题,所以这里暂时不再做鉴定,永远重新请求 */
// if (userSession.sessionKey && _userInfo.nickName) {
// wx.checkSession({
// success: () => {
// callback()
// }, // session_key 未过期,并且在本生命周期一直有效
// fail: () => {
// // session_key 已经失效,需要重新执行登录流程
// miniGetInfo((res, obj) => { callback(res, obj); })
// }
// })
// } else {
// // session_key 未存本地,则本地数据缺失
// miniGetInfo((res, obj) => { callback(res, obj); })
// }
miniGetInfo((res, obj) => { callback(res, obj); })
}
module.exports = {
config: config,
requestApi: requestApi,
durationToTimeString: durationToTimeString,
LoginAgainAndJumpPage: LoginAgainAndJumpPage,
}
/**
* localStorage 中存放的 各种值
* userSession - 调用 login 获取对应的 sessionKey openId等值
* userInfo - 存放用户 头像、昵称等基本信息值
*
* videoCacheCtrlBar
* audioCacheCtrlBar
*/
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论