170 lines
3.7 KiB
JavaScript
Raw Normal View History

2024-07-30 16:33:21 +08:00
const app = getApp()
2024-08-08 09:16:37 +08:00
import {
reportDetailRq
} from "../../../../api/repair/distributionCase.js"
2024-07-30 16:33:21 +08:00
Page({
/**
* 页面的初始数据
*/
data: {
IMG_NAME: app.IMG_NAME,
2024-08-08 09:16:37 +08:00
id: '',
detail: {},
2024-08-08 10:42:56 +08:00
innerAudioContext: null, // 音频对象
innerAudioContextIsPlay: false, // 音频对象-是否播放
2024-07-30 16:33:21 +08:00
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
2024-08-08 09:16:37 +08:00
console.log('onLoad', options);
let _this = this
_this.setData({
...options
})
_this.getDetail(options.id)
2024-07-30 16:33:21 +08:00
},
2024-08-08 09:16:37 +08:00
back() {
2024-07-30 16:33:21 +08:00
wx.navigateBack()
},
2024-08-08 09:16:37 +08:00
getDetail(id) {
2024-08-08 10:42:56 +08:00
let _this = this
reportDetailRq(id).then(res => {
console.log("reportDetailRq", res);
2024-08-08 09:16:37 +08:00
let detail = res.data
2024-08-08 10:42:56 +08:00
let repairVoice = detail.repairVoice
let repairImages = detail.repairImages
// 音频
if (repairVoice) {
detail.voiceObj = JSON.parse(repairVoice)
detail.voiceObj.url = app.IMG_NAME + detail.voiceObj.url
}
// 图片/视频
if (repairImages) {
detail.fileList = JSON.parse(repairImages).map(item => {
return {
url: app.IMG_NAME + item.url,
name: item.url,
}
})
}
_this.setData({
detail
})
2024-08-08 09:16:37 +08:00
})
},
2024-08-08 10:42:56 +08:00
// 播放语音
startAudio() {
console.log('startAudio');
let _this = this
// 获取innerAudioContext实例
let innerAudioContext = _this.data.innerAudioContext
let innerAudioContextIsPlay = _this.data.innerAudioContextIsPlay
if (!innerAudioContext) {
// 全局设置播放声音
wx.setInnerAudioOption({
obeyMuteSwitch: false
});
innerAudioContext = wx.createInnerAudioContext()
// 设置音频文件的路径
innerAudioContext.src = _this.data.detail.voiceObj.url
innerAudioContextIsPlay = false
innerAudioContext.onEnded(() => {
_this.setData({
innerAudioContextIsPlay: false
})
})
}
if (innerAudioContextIsPlay) { // 播放中
innerAudioContext.stop()
innerAudioContextIsPlay = false
} else { // 未播放
innerAudioContext.play()
innerAudioContextIsPlay = true
}
//
_this.setData({
innerAudioContext,
innerAudioContextIsPlay
})
},
2024-08-08 09:16:37 +08:00
// 确认损坏
jumpAffirm() {
2024-07-30 16:33:21 +08:00
wx.navigateTo({
2024-08-08 09:16:37 +08:00
url: '/pages/reportRepair/assign/affirm/affirm',
2024-07-30 16:33:21 +08:00
})
},
// 提交反馈
2024-08-08 09:16:37 +08:00
jumpFeedback() {
2024-07-30 16:33:21 +08:00
wx.navigateTo({
2024-08-08 09:16:37 +08:00
url: '/pages/reportRepair/assign/feedback/feedback',
2024-07-30 16:33:21 +08:00
})
},
// 无效
2024-08-08 09:16:37 +08:00
invalid() {
2024-07-30 16:33:21 +08:00
wx.navigateBack()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})