diff --git a/pages/tabbar/pagehome/pagehome.vue b/pages/tabbar/pagehome/pagehome.vue index c9b1702..ae2e255 100644 --- a/pages/tabbar/pagehome/pagehome.vue +++ b/pages/tabbar/pagehome/pagehome.vue @@ -417,22 +417,24 @@ console.log("会员上线",msg); }); // 接收消息 - socket.on('new_msg', (msg)=> { - console.log(msg); - // 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('背景音乐播放中');