2022-07-28 10:19:08 +00:00
|
|
|
|
<script>
|
|
|
|
|
// import io from '@/jsFile/socket.io.js';
|
|
|
|
|
// const socket = io("ws://7and5.cn:2120",{
|
|
|
|
|
// query: {},
|
|
|
|
|
// transports: [ 'websocket', 'polling' ],
|
|
|
|
|
// timeout: 5000,
|
|
|
|
|
// });
|
2022-03-14 09:09:10 +00:00
|
|
|
|
export default {
|
|
|
|
|
globalData:{
|
|
|
|
|
projectname:'', // 项目名称
|
|
|
|
|
lat:'', // 公司地址维度
|
2022-03-28 10:40:48 +00:00
|
|
|
|
lng:'' ,// 公司地址经度
|
2022-07-28 10:19:08 +00:00
|
|
|
|
hostapi:'https://7and5.cn' ,// 域名配置
|
|
|
|
|
// uid:1,
|
|
|
|
|
// socketInit:false,
|
|
|
|
|
// bgmMusic:null,
|
|
|
|
|
// ifPlayIng:false,
|
2022-03-14 09:09:10 +00:00
|
|
|
|
},
|
|
|
|
|
// 优先于show方法
|
|
|
|
|
onLaunch: function() {
|
2022-07-28 10:19:08 +00:00
|
|
|
|
// this.connect();
|
2022-03-14 09:09:10 +00:00
|
|
|
|
// 配置全局域名
|
2022-07-28 10:19:08 +00:00
|
|
|
|
// #ifdef H5 || APP-PLUS
|
|
|
|
|
this.globalData.bgmMusic = uni.createInnerAudioContext();
|
|
|
|
|
// #endif
|
|
|
|
|
// #ifdef MP-WEIXIN
|
|
|
|
|
this.globalData.bgmMusic = wx.createInnerAudioContext();
|
2022-04-02 01:42:53 +00:00
|
|
|
|
// #endif
|
2022-03-14 09:09:10 +00:00
|
|
|
|
},
|
|
|
|
|
onShow: function() {
|
2022-04-24 09:35:39 +00:00
|
|
|
|
if(uni.getStorageSync('token')){
|
2022-04-13 12:36:32 +00:00
|
|
|
|
// 每十分钟更新用户地理位置
|
|
|
|
|
this.$toolAll.tools.renewLocationEv();
|
2022-04-24 09:35:39 +00:00
|
|
|
|
// 检测是否开启GPS定位服务
|
|
|
|
|
this.$toolAll.tools.checkOpenGPSServiceByAndroidIOS();
|
|
|
|
|
}
|
2022-07-28 10:19:08 +00:00
|
|
|
|
},
|
|
|
|
|
onLoad() {
|
|
|
|
|
|
2022-03-14 09:09:10 +00:00
|
|
|
|
},
|
|
|
|
|
onHide: function() {
|
2022-03-30 10:04:40 +00:00
|
|
|
|
|
2022-07-28 10:19:08 +00:00
|
|
|
|
},
|
|
|
|
|
methods:{
|
|
|
|
|
connect() {
|
|
|
|
|
socket.io.reconnect();
|
|
|
|
|
console.log(this.uid,1234);
|
|
|
|
|
socket.on('connect', ()=> {
|
|
|
|
|
socket.emit('login', this.uid);
|
|
|
|
|
console.log('连接成功');
|
|
|
|
|
});
|
|
|
|
|
//监听断线
|
|
|
|
|
socket.on('disconnect', ()=> {
|
|
|
|
|
socket.connect();//这里必须要有,不然不会重新链接
|
|
|
|
|
console.log('关闭链接后重新链接');
|
|
|
|
|
// this.openSettings();
|
|
|
|
|
});
|
|
|
|
|
//监听全部会员的下线广播
|
|
|
|
|
socket.on('loginout', (data)=> {
|
|
|
|
|
console.log("会员下线",data);
|
|
|
|
|
});
|
|
|
|
|
//监听全部会员的上线广播
|
|
|
|
|
socket.on('login_msg', (msg)=> {
|
|
|
|
|
console.log("会员上线",msg);
|
|
|
|
|
});
|
|
|
|
|
// 接收消息
|
|
|
|
|
socket.on('new_msg', (msg)=> {
|
|
|
|
|
console.log(msg);
|
|
|
|
|
this.offMusic();
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title:msg
|
|
|
|
|
})
|
|
|
|
|
this.bofang();
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
bofang(){
|
|
|
|
|
this.globalData.bgmMusic.autoplay = true;//自动播放
|
|
|
|
|
// this.bgmMusic.loop = true;//循环播放
|
|
|
|
|
this.globalData.bgmMusic.src = 'http://m801.music.126.net/20220728102722/4a7c3c7692a5f0b808f03f8ab7d02bfb/jdymusic/obj/wo3DlMOGwrbDjj7DisKw/4800358085/4a32/22b6/02f5/d96abc3bed5758b0e7172ea66aec841d.mp3';//背景音乐地址
|
|
|
|
|
this.globalData.bgmMusic.volume = 1;//音量
|
|
|
|
|
this.globalData.bgmMusic.onPlay(()=>{
|
|
|
|
|
console.log('背景音乐播放中');
|
|
|
|
|
this.globalData.ifPlayIng = true;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 关掉音乐
|
|
|
|
|
offMusic(){
|
|
|
|
|
if(this.globalData.ifPlayIng){
|
|
|
|
|
this.globalData.bgmMusic.stop();
|
|
|
|
|
this.globalData.bgmMusic.onStop(()=>{
|
|
|
|
|
console.log('背景音乐停止了');
|
|
|
|
|
});
|
|
|
|
|
this.globalData.ifPlayIng = false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// uniapp设置消息提醒(调用手机系统静音或铃声)
|
|
|
|
|
openSettings() {
|
|
|
|
|
uni.getSystemInfo({
|
|
|
|
|
success(res) {
|
|
|
|
|
if(res.platform == 'ios'){
|
|
|
|
|
plus.runtime.openURL("app-settings://");
|
|
|
|
|
} else if (res.platform == 'android'){
|
|
|
|
|
var main = plus.android.runtimeMainActivity();
|
|
|
|
|
var Intent = plus.android.importClass("android.content.Intent");
|
|
|
|
|
var mIntent = new Intent('android.settings.SOUND_SETTINGS');
|
|
|
|
|
main.startActivity(mIntent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2022-03-14 09:09:10 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
/*每个页面公共css */
|
2022-03-30 10:04:40 +00:00
|
|
|
|
|
2022-03-14 09:09:10 +00:00
|
|
|
|
/* 阿里巴巴矢量图标库 start */
|
|
|
|
|
@import url("./commons/icon-font.css");
|
|
|
|
|
/* 阿里巴巴矢量图标库 end */
|
2022-03-16 00:58:52 +00:00
|
|
|
|
/* 项目基础样式 start */
|
2022-03-14 09:09:10 +00:00
|
|
|
|
@import url("./commons/base.css");
|
2022-03-16 00:58:52 +00:00
|
|
|
|
/* 项目基础样式 end */
|
|
|
|
|
/* 项目页面样式 start */
|
|
|
|
|
@import url("./commons/flying-monkey.css");
|
|
|
|
|
/* 项目页面样式 end */
|
2022-03-17 05:47:40 +00:00
|
|
|
|
|
2022-03-14 09:09:10 +00:00
|
|
|
|
/* 动画样式 start */
|
|
|
|
|
@import url("./commons/animate.min.css");
|
|
|
|
|
/* 动画样式 end */
|
|
|
|
|
|
2022-03-17 07:49:07 +00:00
|
|
|
|
page {background-color: #f7f7f7;}
|
2022-03-14 09:09:10 +00:00
|
|
|
|
</style>
|