|
@@ -4,10 +4,10 @@ import strings from './utils/strings';
|
|
|
import store from './utils/store.js';
|
|
|
//连接的服务器域名
|
|
|
// const host = 'wxs://mqtt.test.radio1964.com';
|
|
|
-const host = 'wxs://mqtt.ssl.keepradioon.net:8884'
|
|
|
-
|
|
|
-// const host = 'wxs://mqtt.test.radio1964.com:8884';
|
|
|
// const host = 'wxs://mqtt.ssl.keepradioon.net:8884'
|
|
|
+
|
|
|
+const iosHost = 'wxs://mqtt.test.radio1964.com:8884';
|
|
|
+const androidHost = 'wxs://mqtt.ssl.keepradioon.net:8884'
|
|
|
App({
|
|
|
globalData: {
|
|
|
userInfo: null,
|
|
@@ -31,6 +31,7 @@ App({
|
|
|
// 设备列表,跟app同步字段
|
|
|
classifyProducts: [],
|
|
|
//MQTT连接的配置
|
|
|
+ host: iosHost,
|
|
|
options: {
|
|
|
clientId: "wx_" + parseInt(Math.random() * 100 + 800, 10),
|
|
|
reconnectPeriod: 1000, //1000毫秒,两次重新连接之间的间隔
|
|
@@ -54,12 +55,25 @@ App({
|
|
|
if (!strings.isEmpty(classifyProducts)) {
|
|
|
that.globalData.classifyProducts = classifyProducts;
|
|
|
}
|
|
|
+ //自定义导航栏 获取设备顶部窗口的高度(不同设备窗口高度不一样,根据这个来设置自定义导航栏的高度)
|
|
|
+ const res = wx.getSystemInfoSync(); // 获取系统信息
|
|
|
+ /// android ios
|
|
|
+ const platform = res.platform; // 获取平台类型
|
|
|
+ if (platform === 'android') {
|
|
|
+ that.globalData.host = androidHost;
|
|
|
+ }
|
|
|
+
|
|
|
+ let custom = wx.getMenuButtonBoundingClientRect();
|
|
|
+ that.globalData.navBarHeight = res.statusBarHeight + custom.height + (custom.top - res.statusBarHeight) * 2;
|
|
|
+ that.globalData.MenuButtonheight = custom.height;
|
|
|
+ that.globalData.MenuButtonTop = custom.top;
|
|
|
+ // var platform = res.platform;
|
|
|
+ // that.globalData.isIOS = platform == "ios";
|
|
|
+ // that.globalData.isAndroid = platform == "android";
|
|
|
|
|
|
///显示界面
|
|
|
wx.onAppShow(() => {
|
|
|
- console.log("gadsfasdfaf==22==");
|
|
|
if (!(that.globalData.client && that.globalData.client.connected)) {
|
|
|
- console.log("gadsfasdfaf==333==");
|
|
|
that.connect();
|
|
|
}
|
|
|
});
|
|
@@ -70,20 +84,6 @@ App({
|
|
|
// that.globalData.client.end(true);
|
|
|
// };
|
|
|
});
|
|
|
-
|
|
|
- // that.getBluetoothStatus();
|
|
|
- //自定义导航栏 获取设备顶部窗口的高度(不同设备窗口高度不一样,根据这个来设置自定义导航栏的高度)
|
|
|
- wx.getSystemInfo({
|
|
|
- success: (res) => {
|
|
|
- let custom = wx.getMenuButtonBoundingClientRect();
|
|
|
- that.globalData.navBarHeight = res.statusBarHeight + custom.height + (custom.top - res.statusBarHeight) * 2;
|
|
|
- that.globalData.MenuButtonheight = custom.height;
|
|
|
- that.globalData.MenuButtonTop = custom.top;
|
|
|
- // var platform = res.platform;
|
|
|
- // that.globalData.isIOS = platform == "ios";
|
|
|
- // that.globalData.isAndroid = platform == "android";
|
|
|
- }
|
|
|
- });
|
|
|
},
|
|
|
|
|
|
onShow: function () {
|
|
@@ -96,15 +96,11 @@ App({
|
|
|
connect() {
|
|
|
var that = this;
|
|
|
var options = that.globalData.options;
|
|
|
- console.log("gadsfasdfaf==444==");
|
|
|
+ var host = that.globalData.host;
|
|
|
that.globalData.client = mqtt.connect(host, options);
|
|
|
- console.log("gadsfasdfaf==555==" + that.globalData.client);
|
|
|
- console.log("gadsfasdfaf==aaaa==" + JSON.stringify(that.globalData.client));
|
|
|
- console.log("gadsfasdfaf==666==" + that.globalData.client.connected);
|
|
|
|
|
|
// 设备连接
|
|
|
that.globalData.client.on('connect', () => {
|
|
|
- console.log("gadsfasdfaf==777==");
|
|
|
var pages = getCurrentPages();
|
|
|
var length = pages.length;
|
|
|
var currentPage = pages[length - 1];
|