|
@@ -22,7 +22,6 @@ Page({
|
|
|
deviceInfo: null,
|
|
|
isInitOK: false,
|
|
|
customData: '',
|
|
|
- isOne: true,
|
|
|
isSubmit: false,
|
|
|
islanya: false,
|
|
|
isOnBluetooth: false,
|
|
@@ -47,33 +46,24 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- const isOne = setTimeout(() => {
|
|
|
- clearTimeout(isOne);
|
|
|
- if (that.data.isOne) {
|
|
|
- that.setData({
|
|
|
- isOne: false,
|
|
|
- });
|
|
|
- }
|
|
|
- }, 2000);
|
|
|
-
|
|
|
if (app.globalData.oneInitBluetooth) {
|
|
|
app.globalData.oneInitBluetooth = false;
|
|
|
xBlufi.initXBlufi(1);
|
|
|
};
|
|
|
|
|
|
xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent);
|
|
|
- that.Search();
|
|
|
+ that.search();
|
|
|
},
|
|
|
|
|
|
- onShow() {
|
|
|
- var that = this;
|
|
|
- if (!that.data.isOne) {
|
|
|
- that.Search();
|
|
|
- }
|
|
|
+ ///停止搜索
|
|
|
+ stopSearch: function () {
|
|
|
+ xBlufi.notifyStartDiscoverBle({
|
|
|
+ 'isStart': false,
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
///开始或结束,也可以过滤名称
|
|
|
- Search: function () {
|
|
|
+ search: function () {
|
|
|
xBlufi.notifyStartDiscoverBle({
|
|
|
'isStart': true,
|
|
|
});
|
|
@@ -143,7 +133,6 @@ Page({
|
|
|
});
|
|
|
|
|
|
setTimeout(() => {
|
|
|
- that.data.isSubmit = false;
|
|
|
that.setData({
|
|
|
islanya: false,
|
|
|
devicesList: [],
|
|
@@ -152,10 +141,9 @@ Page({
|
|
|
|
|
|
var p = JSON.stringify(that.data.connectDevice);
|
|
|
var param = '?deviceId=' + options.data.deviceId + '&name=' + options.data.name + "¶m=" + p;
|
|
|
- routeUtil.redirectParam(routePath.deviceConnect3, param);
|
|
|
+ routeUtil.jumpParam(routePath.deviceConnect3, param);
|
|
|
}, 200);
|
|
|
} else {
|
|
|
- that.data.isSubmit = false;
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '连接失败',
|
|
@@ -197,13 +185,10 @@ Page({
|
|
|
if (that.data.isSubmit) {
|
|
|
return;
|
|
|
};
|
|
|
-
|
|
|
that.data.isSubmit = true;
|
|
|
|
|
|
// 停止搜索
|
|
|
- xBlufi.notifyStartDiscoverBle({
|
|
|
- 'isStart': false,
|
|
|
- });
|
|
|
+ that.stopSearch();
|
|
|
|
|
|
var name = devicesList[0].name;
|
|
|
var deviceId = devicesList[0].deviceId;
|
|
@@ -212,7 +197,7 @@ Page({
|
|
|
|
|
|
if (isJungzheng1 || isJungzheng2) {
|
|
|
var param = '?deviceId=' + deviceId + '&name=' + name + "¶m=" + JSON.stringify(that.data.connectDevice);
|
|
|
- routeUtil.redirectParam(routePath.deviceConnect4, param);
|
|
|
+ routeUtil.jumpParam(routePath.deviceConnect4, param);
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -240,6 +225,14 @@ Page({
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ onShow: function () {
|
|
|
+ var that = this;
|
|
|
+ if (that.data.isSubmit) {
|
|
|
+ that.data.isSubmit = false;
|
|
|
+ that.search();
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
onUnload: function () {
|
|
|
var that = this;
|
|
|
xBlufi.listenDeviceMsgEvent(false, that.funListenDeviceMsgEvent);
|