阶段性上传

This commit is contained in:
@fawn-nine
2023-09-08 18:06:39 +08:00
parent 7b9044f4df
commit b0cc2b8663
62 changed files with 5075 additions and 506 deletions

View File

@@ -62,21 +62,29 @@ var music = {
console.log('暂停背景音乐');
this.saveTimes()
clearInterval(bgm.interval)
bgm.interval = null
bgm.playing = false
store.commit('setUserInfo',{'playFlag': false})
})
bgm.onPlay(() => {
store.commit('setUserInfo',{'playFlag': true})
console.log('开始播放音乐#######');
bgm.playing = true
console.log('开始播放音乐#######');
store.commit('setUserInfo',{'playingInfo': bgm.musicList[bgm.playIndex]})
console.log(store.state.userInfo.playingInfo,'chapterName2222')
uni.hideLoading()
bgm.interval = setInterval(()=>{
console.log('存一次')
this.saveIndex()
// this.saveIndex()
store.commit('setUserInfo',{'playTimes': bgm.currentTime}) // 本地存储
this.saveRate(bgm.musicList[bgm.playIndex]) // 线上存储
},180000)
})
bgm.onError((res) => {
console.log(res)
bgm.playing = false
uni.showModal({
title: '提示',
showCancel:false,
@@ -103,46 +111,57 @@ var music = {
})
bgm.onCanplay(() => {
// 可以播放时
// console.log('可以播放时')
console.log('可以播放时')
uni.hideLoading()
// this.saveIndex()
console.log('历史播放进度,秒数', bgm.htimes)
this.saveIndex()
this.saveRate(bgm.musicList[bgm.playIndex])
// console.log('历史播放进度,秒数', bgm.htimes)
bgm.seek(bgm.htimes)
bgm.htimes = 0 // 重置播放秒数
// store.commit('setUserInfo',{'duration':bgm.duration})
// store.commit('setUserInfo',{'playTitle': bgm.title})
// store.commit('setUserInfo',{'fengImg': bgm.coverImgUrl})
// store.commit('setUserInfo',{'playFlag': true})
// store.commit('setUserInfo',{'playingInfo': bgm.musicList[bgm.playIndex]})
console.log(store.state.userInfo.playingInfo,'chapterName2222',bgm.playIndex)
// console.log(bgm,'bgm')
})
bgm.onEnded(() => {
bgm.htimes = 0 // 重置播放秒数
bgm.playing = false
console.log('播放完毕了',bgm.playing)
store.commit('setUserInfo',{'playFlag': false})
this.setPlayIndex('next') // 下一首
})
},
// 添加播放列表
setList(list,op,playindex){
setList(list,op,playindex,time){
// console.log(time,'time',playindex,'playindex')
bgm.musicList = list
bgm.oldIndex = bgm.playIndex // 暂存上一个播放得index
console.log('地址异常报错前index:',bgm.oldIndex)
playindex ? bgm.playIndex = playindex : bgm.playIndex = 0
// console.log(bgm.playIndex,'playindex')
store.commit('setUserInfo',{'playingInfo': {}})
this.getListenRate(bgm.musicList[0], op)
// if(op == 'autoPlay'){
// store.commit('setUserInfo',{'playTimes': 0})
// if(bgm._options.src == ''){
// // this.getChartUrl()
// this.playBgm({mute:false})
// console.log('playBgm')
// }else{
// this.getChartUrl() // 获取对应的播放路径
// // console.log('getChartUrl')
// }
// }
bgm.oldIndex = bgm.playIndex // 暂存上一个播放得index
// console.log('地址异常报错前index:',bgm.oldIndex)
// playindex ? bgm.playIndex = playindex : bgm.playIndex = 0
store.commit('setUserInfo',{'playingInfo': {}})
if(playindex){
bgm.playIndex = playindex
console.log(playindex,'传值了')
if(time){ // 如果传了历史播放秒数
bgm.htimes = time
}else{
// console.log('重置播放秒数')
bgm.htimes = 0
}
}else{
console.log('---------')
bgm.htimes = 0
bgm.playIndex = 0
}
if(op == 'autoPlay'){
store.commit('setUserInfo',{'playTimes': 0})
if(bgm._options.src == ''){
// this.getChartUrl()
// console.log(bgm,'+++++++++++')
this.playBgm({mute:false})
}else{
console.log(bgm, '----')
this.getChartUrl() // 获取对应的播放路径
}
}
},
// 获取线上听书进度
getListenRate(val,op){
@@ -169,8 +188,7 @@ var music = {
}
})
store.commit('setUserInfo',{'playingInfo':bgm.musicList[bgm.playIndex] })
console.log('线的播放index是',bgm.playIndex)
console.log('线上的播放index是', store.state.userInfo.playingInfo)
// console.log('线的播放index是', store.state.userInfo.playingInfo)
}else{
// 没有听书进度
}
@@ -205,6 +223,9 @@ var music = {
// bgm.stop()
// 有听权限时
if(res.bookCatalogue[0].url){ // 空值url:null
// 先清除定时器
clearInterval(bgm.interval)
bgm.interval = null
bgm.src = res.bookCatalogue[0].url
// bgm.title = res.bookCatalogue[0].name
// bgm.coverImgUrl = res.image
@@ -240,12 +261,12 @@ var music = {
bgm.playIndex = bgm.oldIndex
// bgm.stop()
// store.commit('setUserInfo',{'playFlag': false})
if(e.errMsg.indexOf('未购买书籍') != -1){
uni.showModal({
title: '提示',
cancelText: '暂不购买',
confirmText:'立即购买',
content: '抱歉!当前章节不支持试听,购买后可收听',
content: '抱歉!当前书籍未购买!',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
@@ -255,17 +276,8 @@ var music = {
}
}
});
}
// uni.showModal({
// title: '提示',
// confirmText:'知道了',
// content: '当前书籍音频功能未开通,请联系管理员',
// success: function (res) {
// if (res.confirm) {
// console.log('用户点击确定');
// }
// }
// });
})
},
@@ -274,12 +286,17 @@ var music = {
console.log(bgm.playIndex,'存储得index')
store.commit('setUserInfo',{'playIndex': bgm.playIndex})
store.commit('setUserInfo',{'duration':bgm.duration})
store.commit('setUserInfo',{'playTitle': bgm.title})
store.commit('setUserInfo',{'fengImg': bgm.coverImgUrl})
store.commit('setUserInfo',{'playTitle': bgm.musicList[bgm.playIndex].chapterName})
store.commit('setUserInfo',{'fengImg': bgm.musicList[bgm.playIndex].images})
store.commit('setUserInfo',{'playFlag': true})
store.commit('setUserInfo',{'playingInfo': bgm.musicList[bgm.playIndex]})
store.commit('setUserInfo',{'playTimes': bgm.currentTime})
this.saveRate(bgm.musicList[bgm.playIndex])
uni.setStorage({
key: 'playingInfo',
data: bgm.musicList[bgm.playIndex],
success: function () {
console.log('success');
}
});
},
// 存储播放(本地)
saveTimes(){
@@ -292,10 +309,8 @@ var music = {
'userId': store.state.userInfo.id,
'bookId': val.bookid,
'chapterId': val.chapterId,
'chapterName': val.chapterName,
//'precent': bgm.currentTime
'precent': Math.ceil(bgm.currentTime),
//'contentId'
'chapterName': val.chapterName,
'precent': Math.ceil(bgm.currentTime),
'loadAnimate':'none', // 请求加载动画
})
.then(res => {
@@ -346,15 +361,11 @@ var music = {
getCoverImg(){
// console.log(bgm.coverImgUrl,'bgm.coverImgUrl')
return bgm.coverImgUrl
},
// 获取播放列表
// getLibList(){
// return bgm.musicList
// },
},
// 播放单曲
setOneMusic(item){
console.log(item,'item')
console.log(item,'item')
// 显示播放组件
store.commit('setUserInfo',{'playVisible': true})
uni.setStorage({