引入日历前

This commit is contained in:
@fawn-nine
2023-08-21 18:05:19 +08:00
parent 57d70c40f2
commit ef6c52c0d4
48 changed files with 4003 additions and 386 deletions

View File

@@ -11,6 +11,7 @@ bgm.coverImgUrl = ''
bgm.oldIndex = 0 // 前面一首的播放索引
bgm.playIndex = 0
bgm.playing = false // 播放进行时
store.state.userInfo.playIndex !== undefined ? bgm.playIndex = store.state.userInfo.playIndex : bgm.playIndex = 0
var music = {
//
//mute 表示是否是播放,,默认不播放
@@ -19,15 +20,16 @@ var music = {
if (!bgm) return;
if(mute){
bgm.pause()
}else{
}else{
// bgm.src = bgm.musicList[bgm.playIndex].url
// 判断播放列表是否空
// 判断播放列表是否空
if(bgm.musicList.length == 0){
uni.showModal({
title: '提示',
showCancel:false,
confirmText:'好的',
content: '请先添加音频到播放列表,再点播放键开始听书',
content: '请先选择要播放的音频',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
@@ -39,10 +41,13 @@ var music = {
return
}
// 没有就添加添加url到播放器播放新的
if(bgm.src == ''){
store.state.userInfo.playIndex !== undefined ? bgm.playIndex = store.state.userInfo.playIndex : bgm.playIndex = 0
// console.log(bgm.playIndex,'初始化播放index');
this.getChartUrl()
if(bgm.src == ''){
console.log(bgm.playIndex,'播放的索引',store.state.userInfo.playIndex)
store.commit('setUserInfo',{'playTitle': bgm.musicList[bgm.playIndex].chapterName})
store.commit('setUserInfo',{'fengImg': bgm.musicList[bgm.playIndex].images})
store.commit('setUserInfo',{'playingInfo': bgm.musicList[bgm.playIndex]})
console.log(store.state.userInfo,'chapterName',bgm.playIndex)
this.getChartUrl()
}else{
// 如果有正在播放的url暂停改为播放
// bgm.play()
@@ -65,7 +70,7 @@ var music = {
content: '音频路径异常,请联系管理员',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
console.log('用户点击确定');
}
}
});
@@ -84,14 +89,15 @@ var music = {
})
bgm.onCanplay(() => {
// 可以播放时
// console.log('可以播放时')
uni.hideLoading()
this.saveIndex()
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]})
// 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)
})
bgm.onEnded(() => {
console.log('播放完毕了',bgm.playing)
@@ -100,9 +106,11 @@ var music = {
})
},
// 添加播放列表
setList(list,op){
setList(list,op,playindex){
bgm.musicList = list
bgm.playIndex = 0
playindex ? bgm.playIndex = playindex : bgm.playIndex = 0
console.log(bgm.playIndex,'playindex')
store.commit('setUserInfo',{'playingInfo': {}})
if(op == 'autoPlay'){
if(bgm._options.src == ''){
@@ -123,7 +131,7 @@ var music = {
'bookid': bgm.musicList[bgm.playIndex].bookid,
'chapterid': bgm.musicList[bgm.playIndex].chapterId
}
// console.log(data,'data')
console.log(data,'data')
$http.post('book/bookchaptercontent/appBooksChapterContent', data)
.then(res => {
console.log(res,'res')
@@ -142,7 +150,7 @@ var music = {
bgm.title = ''
bgm.coverImgUrl = ''
// this.setCoverImg('../../static/icon/x1.jpg')
// bgm.pause()
bgm.stop()
uni.showToast({
title:'音频地址异常',
icon:'error',
@@ -154,10 +162,10 @@ var music = {
store.commit('setUserInfo',{'fengImg': bgm.coverImgUrl})
}
console.log(res.bookCatalogue,'单章节信息')
}).catch((e)=>{
// bgm.pause()
bgm.playIndex = bgm.oldIndex
bgm.stop()
}).catch((e)=>{
// bgm.pause()
bgm.playIndex = bgm.oldIndex
// bgm.stop()
store.commit('setUserInfo',{'playFlag': false})
uni.showModal({
title: '提示',
@@ -167,15 +175,23 @@ var music = {
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
uni.navigateTo({
url: '../bookShop/settlementBook?type=2&list=' + data.bookid
});
}
}
});
})
},
// 存储播放index
// 存储播放信息
saveIndex(){
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',{'playFlag': true})
store.commit('setUserInfo',{'playingInfo': bgm.musicList[bgm.playIndex]})
},
// 存储播放
saveTimes(){
store.commit('setUserInfo',{'playTimes': bgm.currentTime})
@@ -239,45 +255,16 @@ var music = {
success: function () {
console.log('success');
}
});
// 先检查列表里是否存在item避免重复添加
// 存在就不添加找到对应的index,通过参数获得url
// 不存在就添加进列表,直接切换下一章节
var has = false
for (var i = 0; i < bgm.musicList.length; i++) {
if(item.chapterId == bgm.musicList[i].chapterId && item.bookid == bgm.musicList[i].bookid){
has = true
break
}
}
if(has){
bgm.playIndex = bgm.musicList.findIndex(function(info){
});
bgm.playIndex = bgm.musicList.findIndex(function(info){
// console.log(info,'info')
if(item.chapterId == info.chapterId && item.bookid == info.bookid ){
return info;
}
})
console.log(bgm.playIndex,'bgm.playIndex')
this.getChartUrl()
}else{
bgm.musicList.push(item) // 添加到播放目录
var newVal ={ // 本地播放数据更新
'myList' : bgm.musicList,
}
uni.setStorage({
key: 'playData',
data: newVal,
success: function () {
console.log('success');
}
});
bgm.playIndex = bgm.musicList.length - 2
console.log(bgm.playIndex,'bgm.playIndex')
// this.getChartUrl()
this.setPlayIndex('next')
}
console.log(bgm.playIndex,'bgm.playIndex')
this.getChartUrl()
},