155 lines
3.4 KiB
JavaScript
Raw Normal View History

2024-08-05 11:01:19 +08:00
const app = getApp()
2024-07-31 11:26:48 +08:00
2024-08-14 19:07:39 +08:00
import {
getDetailRq,
getStatusName
} from "../../../../api/repair/repair.js"
2024-08-05 11:01:19 +08:00
Page({
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
/**
* 页面的初始数据
*/
data: {
IMG_NAME: app.IMG_NAME,
2024-08-14 19:07:39 +08:00
id: '',
detail: {},
files: [],
innerAudioContext: null, // 音频对象
innerAudioContextIsPlay: false, // 音频对象-是否播放
statusList: [{
name: '已解决',
status: 1,
2024-08-05 15:10:41 +08:00
isSelect: true,
},
{
2024-08-14 19:07:39 +08:00
name: '未解决',
status: 2,
2024-08-05 15:10:41 +08:00
isSelect: false,
}
]
2024-08-05 11:01:19 +08:00
},
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
2024-08-14 19:07:39 +08:00
console.log('onLoad', options);
let _this = this
_this.setData({
...options
})
_this.getDetail(options.id)
},
getDetail(id) {
let _this = this
getDetailRq({
id
}).then(res => {
console.log("getDetailRq", res);
// 详情
let detail = res.repair
detail.statusName = getStatusName(detail.status)
// 附件
let files = res.files
files.repair = files.repair.map(item => {
item.url = app.IMG_NAME + item.url
return item
})
files.voice = files.voice.map(item => {
item.url = app.IMG_NAME + item.url
return item
})
_this.setData({
detail,
files
})
})
},
2024-07-31 11:26:48 +08:00
2024-08-14 19:07:39 +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.files.voice[0].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-05 11:01:19 +08:00
},
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
},
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
/**
* 生命周期函数--监听页面显示
*/
onShow() {
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
},
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
},
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
},
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
},
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
},
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
2024-07-31 11:26:48 +08:00
2024-08-05 11:01:19 +08:00
}
2024-07-31 11:26:48 +08:00
})