新增语音收款播报

This commit is contained in:
weipengfei 2024-03-28 14:40:39 +08:00
parent d0e4a8b096
commit 10b470bf76

44
App.vue
View File

@ -25,6 +25,11 @@
import Routine from './libs/routine.js'; import Routine from './libs/routine.js';
import Cache from '@/utils/cache'; import Cache from '@/utils/cache';
export default { export default {
data(){
return {
audioTeam: [],
}
},
globalData: { globalData: {
spid: 0, spid: 0,
code: 0, code: 0,
@ -131,11 +136,9 @@
if (this.audioTeam.length > 0) { if (this.audioTeam.length > 0) {
this.audioTeam.push(result.extras.type); this.audioTeam.push(result.extras.type);
} else { } else {
this.audio() this.audio(result.extras.mp3)
this.audioTeam.push(result.extras.type); this.audioTeam.push(result.extras.type);
} }
} }
// //
if (notificationEventType == 'notificationOpened') { if (notificationEventType == 'notificationOpened') {
@ -201,9 +204,12 @@
} }
// #endif // #endif
that.getConfigData(); that.getConfigData();
// setTimeout(()=>{
// this.audio('https://lihai001.oss-cn-chengdu.aliyuncs.com/app/out.wav')
// // this.audio()
// }, 1500)
}, },
onShow() { onShow() {
let that = this let that = this
that.$store.commit('SETUUID', uni.getStorageSync('uuid') || that.randomString()); that.$store.commit('SETUUID', uni.getStorageSync('uuid') || that.randomString());
// H5 // H5
@ -292,6 +298,36 @@
}) })
},
/**
* 语音播报
*
*
*/
async audio(url) {
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.src = url || `/static/audio/order.mp3`;
innerAudioContext.autoplay = true;
innerAudioContext.onPlay(() => {
console.log('开始播放')
});
innerAudioContext.onEnded(() => {
console.log('语音播报结束')
innerAudioContext.destroy() //
if (this.audioTeam.length > 1) {
this.audioTeam.splice(0, 1);
console.log('队列中');
this.audio()
} else {
console.log('队列为零');
this.audioTeam = []
}
});
innerAudioContext.onError((err) => {
console.log('语音播报失败', err)
innerAudioContext.destroy() //
});
}, },
randomString(len) { randomString(len) {
//   len = len || 32; //   len = len || 32;