|
|
|
@ -18,6 +18,7 @@ Page({
@@ -18,6 +18,7 @@ Page({
|
|
|
|
|
|
|
|
|
|
toastShow: false, |
|
|
|
|
toastType: 3, |
|
|
|
|
currentTime: 0, |
|
|
|
|
}, |
|
|
|
|
innerAudioContext: null as WechatMiniprogram.InnerAudioContext | null, |
|
|
|
|
onLoad(options) { |
|
|
|
@ -25,6 +26,11 @@ Page({
@@ -25,6 +26,11 @@ Page({
|
|
|
|
|
this.setData({ |
|
|
|
|
BookId: options.id, |
|
|
|
|
}); |
|
|
|
|
if (options.cid) { |
|
|
|
|
this.setData({ |
|
|
|
|
ChapterId: options.cid, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
app.waitLogin(false, true).then(() => { |
|
|
|
|
this.getChapterList(); |
|
|
|
|
this.getDetail(); |
|
|
|
@ -78,6 +84,7 @@ Page({
@@ -78,6 +84,7 @@ Page({
|
|
|
|
|
time, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
this.handleView(); |
|
|
|
|
}) |
|
|
|
|
.catch(() => { |
|
|
|
|
this.setData({ |
|
|
|
@ -86,6 +93,16 @@ Page({
@@ -86,6 +93,16 @@ Page({
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
handleView() { |
|
|
|
|
wx.ajax({ |
|
|
|
|
method: 'POST', |
|
|
|
|
url: '?r=shizhong/book/add-browse-record', |
|
|
|
|
data: { |
|
|
|
|
BookId: this.data.BookId, |
|
|
|
|
ChapterId: this.data.ChapterId, |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
handleDirectory() { |
|
|
|
|
this.setData({ |
|
|
|
|
show: true, |
|
|
|
@ -140,7 +157,7 @@ Page({
@@ -140,7 +157,7 @@ Page({
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
handlePlay() { |
|
|
|
|
const { chapter, play } = this.data; |
|
|
|
|
const { chapter, play, currentTime } = this.data; |
|
|
|
|
if (this.innerAudioContext) { |
|
|
|
|
if (play) { |
|
|
|
|
this.innerAudioContext.stop(); |
|
|
|
@ -148,10 +165,8 @@ Page({
@@ -148,10 +165,8 @@ Page({
|
|
|
|
|
} |
|
|
|
|
this.innerAudioContext.stop(); |
|
|
|
|
this.innerAudioContext.src = chapter.AudioUrl.url; |
|
|
|
|
this.innerAudioContext.seek(currentTime); |
|
|
|
|
this.innerAudioContext.play(); |
|
|
|
|
this.setData({ |
|
|
|
|
play: true, |
|
|
|
|
}); |
|
|
|
|
const listener = () => { |
|
|
|
|
if (this.innerAudioContext) { |
|
|
|
|
const { currentTime, duration } = this.innerAudioContext; |
|
|
|
@ -160,6 +175,8 @@ Page({
@@ -160,6 +175,8 @@ Page({
|
|
|
|
|
this.setData({ |
|
|
|
|
time, |
|
|
|
|
progress, |
|
|
|
|
currentTime, |
|
|
|
|
play: true, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -169,7 +186,12 @@ Page({
@@ -169,7 +186,12 @@ Page({
|
|
|
|
|
play: false, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
this.innerAudioContext.onStop(() => { |
|
|
|
|
this.innerAudioContext.onPlay(() => { |
|
|
|
|
this.setData({ |
|
|
|
|
play: true, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
this.innerAudioContext.onPause(() => { |
|
|
|
|
this.setData({ |
|
|
|
|
play: false, |
|
|
|
|
}); |
|
|
|
@ -179,9 +201,10 @@ Page({
@@ -179,9 +201,10 @@ Page({
|
|
|
|
|
handlePause() { |
|
|
|
|
if (this.innerAudioContext) { |
|
|
|
|
this.innerAudioContext.pause(); |
|
|
|
|
this.setData({ |
|
|
|
|
play: false, |
|
|
|
|
}); |
|
|
|
|
this.innerAudioContext.offTimeUpdate() |
|
|
|
|
this.innerAudioContext.offEnded() |
|
|
|
|
this.innerAudioContext.offPlay() |
|
|
|
|
this.innerAudioContext.offPause() |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
formatTime(time: number) { |
|
|
|
@ -199,8 +222,8 @@ Page({
@@ -199,8 +222,8 @@ Page({
|
|
|
|
|
this.setData({ |
|
|
|
|
toastShow: false, |
|
|
|
|
}); |
|
|
|
|
wx.reLaunch({ |
|
|
|
|
url: '/pages/login/index', |
|
|
|
|
wx.navigateTo({ |
|
|
|
|
url: '/pages/login/index?back=1', |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|