nowDateHandel(data) {
setInterval(() => {
const now = new Date();
const year = now.getFullYear();
let month = now.getMonth() + 1; // 注意JavaScript中月份是从0开始的
let date = now.getDate();
const hours = now.getHours();
const minutes = now.getMinutes();
let seconds = now.getSeconds();
month = month > 9 ? month : '0' + month;
date = date > 9 ? date : '0' + date;
seconds = seconds > 9 ? seconds : '0' + seconds;
this.nowDate = `${year}-${month}-${date} ${hours}:${minutes}:${seconds}`;
// console.log(this.nowDate);
if (data.length) {
data.map((item) => {
if (this.nowDate == item.datetimesingle) {
//音乐
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.loop = true;
innerAudioContext.obeyMuteSwitch = false;
innerAudioContext.src = 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-hello-uniapp/2cc220e0-c27a-11ea-9dfb-6da8e309e0d8.mp3';
innerAudioContext.onPlay(() => {
console.log('开始播放');
});
uni.showModal({
content: '“' + item.name + '”' + '订单该派送了',
success: function (res) {
innerAudioContext.stop();
innerAudioContext.destroy();
}
});
} else {
return;
}
});
}
}, 1000);
},
微信小程序闹钟
最新推荐文章于 2024-05-28 10:27:05 发布