新增语音收款播报
This commit is contained in:
parent
d0e4a8b096
commit
10b470bf76
44
App.vue
44
App.vue
@ -25,6 +25,11 @@
|
||||
import Routine from './libs/routine.js';
|
||||
import Cache from '@/utils/cache';
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
audioTeam: [],
|
||||
}
|
||||
},
|
||||
globalData: {
|
||||
spid: 0,
|
||||
code: 0,
|
||||
@ -131,11 +136,9 @@
|
||||
if (this.audioTeam.length > 0) {
|
||||
this.audioTeam.push(result.extras.type);
|
||||
} else {
|
||||
this.audio()
|
||||
this.audio(result.extras.mp3)
|
||||
this.audioTeam.push(result.extras.type);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// 点击事件
|
||||
if (notificationEventType == 'notificationOpened') {
|
||||
@ -201,9 +204,12 @@
|
||||
}
|
||||
// #endif
|
||||
that.getConfigData();
|
||||
// setTimeout(()=>{
|
||||
// this.audio('https://lihai001.oss-cn-chengdu.aliyuncs.com/app/out.wav')
|
||||
// // this.audio()
|
||||
// }, 1500)
|
||||
},
|
||||
onShow() {
|
||||
|
||||
let that = this
|
||||
that.$store.commit('SETUUID', uni.getStorageSync('uuid') || that.randomString());
|
||||
// 记录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) {
|
||||
// len = len || 32;
|
||||
|
Loading…
x
Reference in New Issue
Block a user