|
@@ -2,6 +2,8 @@
|
|
|
const app = getApp()
|
|
|
const util = require("../../utils/util")
|
|
|
const urlDef = require("../../utils/urls")
|
|
|
+
|
|
|
+const audioContext = wx.createInnerAudioContext() //音频播放对象
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -63,34 +65,38 @@ Page({
|
|
|
|
|
|
showImg: function (e) {
|
|
|
// var list = e.currentTarget.dataset.url
|
|
|
+ const index = e.currentTarget.dataset.index
|
|
|
wx.previewImage({
|
|
|
+ current: this.data.imgList[index],
|
|
|
urls: this.data.imgList,
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- audioShow: function (e) {
|
|
|
- if (this.data.audioPause == 0 && this.data.curAudioIndex != e.currentTarget.dataset.index) {//播放语音,切换
|
|
|
- this.setData({
|
|
|
- curAudio: ""
|
|
|
- })
|
|
|
- this.setData({
|
|
|
- curAudioIndex: e.currentTarget.dataset.index,
|
|
|
- curAudio: e.currentTarget.dataset.url,
|
|
|
- })
|
|
|
- this.audioContext.play()
|
|
|
- this.setData({
|
|
|
- audioPause: 0
|
|
|
- })
|
|
|
- } else if (this.data.audioPause == 1 && this.data.curAudioIndex == e.currentTarget.dataset.index) {//暂停后恢复播放
|
|
|
- this.audioContext.play()
|
|
|
+ showAudio: function (e) {
|
|
|
+ const index = e.currentTarget.dataset.index
|
|
|
+ if (this.data.curAudioIndex != index) {
|
|
|
this.setData({
|
|
|
- audioPause: 0
|
|
|
+ curAudioIndex: index,
|
|
|
})
|
|
|
- } else if (this.data.audioPause == 0 && this.data.curAudioIndex == e.currentTarget.dataset.index) {//暂停播放
|
|
|
- this.audioContext.pause()
|
|
|
- this.setData({
|
|
|
- audioPause: 1
|
|
|
+ audioContext.src = this.data.item.records[index].url
|
|
|
+ audioContext.play()
|
|
|
+ audioContext.onEnded((res) => {
|
|
|
+ this.setData({
|
|
|
+ curAudioIndex: '-1',
|
|
|
+ })
|
|
|
})
|
|
|
+ } else {
|
|
|
+ if (this.data.audioPause) {
|
|
|
+ audioContext.play()
|
|
|
+ this.setData({
|
|
|
+ audioPause: false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ audioContext.pause()
|
|
|
+ this.setData({
|
|
|
+ audioPause: true
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -113,7 +119,6 @@ Page({
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
- this.audioContext = wx.createAudioContext('audio-play')
|
|
|
this.videoContext = wx.createVideoContext('play-video');// 创建 video 上下文 VideoContext 对象。
|
|
|
const urls = urlDef.urls;
|
|
|
let it = JSON.parse(options.item)
|
|
@@ -137,8 +142,8 @@ Page({
|
|
|
}
|
|
|
|
|
|
let stu = wx.getStorageSync('student')
|
|
|
- util.apiPost(urls.query_student_star + '&q.orgId=' + stu.orgId + '&q.studentId='
|
|
|
- + stu.studentId + '&q.headId=' + it.id).then((st) => {
|
|
|
+ util.apiPost(urls.query_student_star + '&q.orgId=' + stu.orgId + '&q.classesId=' + it.classesId + '&q.studentId='
|
|
|
+ + stu.studentId + '&q.headId=' + it.headId).then((st) => {
|
|
|
it.stars = st;
|
|
|
this.reloadItems(it)
|
|
|
}, e => {
|
|
@@ -196,7 +201,7 @@ Page({
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload: function () {
|
|
|
-
|
|
|
+ audioContext.stop()
|
|
|
},
|
|
|
|
|
|
/**
|