From 45eefe8d73f91394f1e37a78237ed1a6bd996421 Mon Sep 17 00:00:00 2001 From: Lee1203 <342694918@qq.com> Date: Tue, 16 Aug 2022 16:56:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E6=B6=88=E6=81=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/tabbar/pagehome/pagehome.vue | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/pages/tabbar/pagehome/pagehome.vue b/pages/tabbar/pagehome/pagehome.vue index 0ea7ed8..e4b3ec0 100644 --- a/pages/tabbar/pagehome/pagehome.vue +++ b/pages/tabbar/pagehome/pagehome.vue @@ -417,23 +417,25 @@ console.log("会员上线",msg); }); // 接收消息 - socket.on('new_msg', (msg)=> { - console.log(msg); - console.log(uni.getStorageSync('ifVoice'),uni.getStorageSync('ifMessage'),55555); - // this.offMusic(); - if(uni.getStorageSync('ifVoice') || uni.getStorageSync('ifMessage')){ - console.log('进入接收消息'); - uni.showToast({ - title:msg - }) - this.bofang(); - } - }); + if(uni.getStorageSync('ifMessage')){ + socket.on('new_msg', (msg)=> { + console.log(msg,121212) + // this.offMusic(); + if(uni.getStorageSync('ifVoice')){ + console.log('进入接收消息'); + // uni.showToast({ + // title:'您有新消息!' + // }) + this.bofang(msg); + } + }); + } + }, - bofang(){ + bofang(msg){ this.bgmMusic.autoplay = true;//自动播放 // this.bgmMusic.loop = true;//循环播放 - this.bgmMusic.src = 'https://img-cdn2.yespik.com/sound/00/29/33/70/293370_548da270e343f070330174bd880d2e83.mp3';//背景音乐地址 + this.bgmMusic.src = msg;//背景音乐地址 this.bgmMusic.volume = 1;//音量 this.bgmMusic.play(()=>{ console.log('背景音乐播放中');