一、
<audio controls="controls" ref="orderNotice" hidden>
<source :src="orderNoticeSrc">
</audio>
<audio controls="controls" ref="refundNotice" hidden>
<source :src="refundNoticeSrc">
</audio>
<p @click="PlayorderNotice" style="margin-bottom:30px;" hidden>播放</p>
<p @click="PlayRefundNotice" hidden>播放2</p>
orderNoticeSrc : "http://xxxx.mp3",
refundNoticeSrc : "http://xxx.mp3"
二、
PlayorderNotice () {
let audioPlay = this.$refs.orderNotice;
audioPlay.play(audioPlay)
},
PlayRefundNotice () {
let audioPlay = this.$refs.refundNotice;
audioPlay.play(audioPlay)
},
三、
created() {
let that = this
let timer = setTimeout(() => {
clearTimeout(timer)
that.startInterval()
},2000)
},
四、
startInterval () {
let that = this
let interval = async ()=>{
await queryData();
}
async function queryData() {
//# 2.1 添加await之后 当前的await 返回结果之后才会执行后面的代码
//#2.2 让异步代码看起来、表现起来更像同步代码
var ret = await getOrderList();
return ret;
}
interval();
getUntreatedOrderList();
function getUntreatedOrderList () {
clearInterval(that.$store.state.timer)
that.$store.state.timer = null
queryData().then(function (res) {
if (res.flag == true) {
that.$store.state.timer = setInterval(() => {
getUntreatedOrderList()
},5000)
}
})
}
}