优化小秤的稳定性
This commit is contained in:
@@ -91,7 +91,7 @@ Component({
|
|||||||
status: true
|
status: true
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
app.globalData.ppScale.plugin.Blue.disconnect();
|
app.globalData.ppScale.plugin.Blue.stop();
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
title: "绑定失败,请重试。",
|
title: "绑定失败,请重试。",
|
||||||
icon: "none"
|
icon: "none"
|
||||||
@@ -104,7 +104,7 @@ Component({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
app.globalData.ppScale.plugin.Blue.disconnect();
|
app.globalData.ppScale.plugin.Blue.stop();
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
icon: "none",
|
icon: "none",
|
||||||
title: res.message
|
title: res.message
|
||||||
@@ -116,7 +116,7 @@ Component({
|
|||||||
}, 1500)
|
}, 1500)
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
app.globalData.ppScale.plugin.Blue.disconnect();
|
app.globalData.ppScale.plugin.Blue.stop();
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
icon: "none",
|
icon: "none",
|
||||||
title: err.message
|
title: err.message
|
||||||
@@ -128,7 +128,7 @@ Component({
|
|||||||
}, 1500)
|
}, 1500)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
app.globalData.ppScale.plugin.Blue.disconnect();
|
app.globalData.ppScale.plugin.Blue.stop();
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
icon: "none",
|
icon: "none",
|
||||||
title: "Mac 地址与 deviceId 获取失败,请重新绑定"
|
title: "Mac 地址与 deviceId 获取失败,请重新绑定"
|
||||||
@@ -140,7 +140,7 @@ Component({
|
|||||||
}, 1500)
|
}, 1500)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app.globalData.ppScale.plugin.Blue.disconnect();
|
app.globalData.ppScale.plugin.Blue.stop();
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
icon: "none",
|
icon: "none",
|
||||||
title: "配网失败,错误码:" + res
|
title: "配网失败,错误码:" + res
|
||||||
|
|||||||
@@ -1,22 +1,4 @@
|
|||||||
const app = getApp();
|
|
||||||
import $ from "../../utils/request";
|
|
||||||
|
|
||||||
Component({
|
Component({
|
||||||
data: {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
lifetimes: {
|
|
||||||
attached() {
|
|
||||||
|
|
||||||
},
|
|
||||||
detached() {
|
|
||||||
// 在组件实例被从页面节点树移除时执行
|
|
||||||
console.log('MyComponent detached!');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// 组件的方法
|
|
||||||
methods: {
|
methods: {
|
||||||
bindOk() {
|
bindOk() {
|
||||||
this.triggerEvent('deviceEvent', {
|
this.triggerEvent('deviceEvent', {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ Component({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app.globalData.ppScale.plugin.Blue.disconnect();
|
app.globalData.ppScale.plugin.Blue.stop();
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
icon: "none",
|
icon: "none",
|
||||||
title: "配网失败,错误码:" + res
|
title: "配网失败,错误码:" + res
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ Page({
|
|||||||
equipmentCode: scaleDeviceId,
|
equipmentCode: scaleDeviceId,
|
||||||
};
|
};
|
||||||
$.ajax("weighingScale/del/device", params, "POST", true, "正在初始化设备...").then(res => {
|
$.ajax("weighingScale/del/device", params, "POST", true, "正在初始化设备...").then(res => {
|
||||||
ppScale.plugin.Blue.disconnect();
|
ppScale.plugin.Blue.stop();
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
icon: "none",
|
icon: "none",
|
||||||
title: "设备初始化成功,请重新绑定。",
|
title: "设备初始化成功,请重新绑定。",
|
||||||
@@ -64,7 +64,7 @@ Page({
|
|||||||
}, 1500);
|
}, 1500);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
ppScale.plugin.Blue.disconnect();
|
ppScale.plugin.Blue.stop();
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
icon: "none",
|
icon: "none",
|
||||||
title: "设备初始化失败。",
|
title: "设备初始化失败。",
|
||||||
@@ -73,7 +73,7 @@ Page({
|
|||||||
})
|
})
|
||||||
} else if (res.cancel) {
|
} else if (res.cancel) {
|
||||||
// device.mac = null;
|
// device.mac = null;
|
||||||
ppScale.plugin.Blue.disconnect();
|
ppScale.plugin.Blue.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -171,7 +171,7 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setConfigSuccessful() {
|
setConfigSuccessful() {
|
||||||
ppScale.plugin.Blue.disconnect();
|
ppScale.plugin.Blue.stop();
|
||||||
wx.switchTab({
|
wx.switchTab({
|
||||||
url: "/pages/home/home"
|
url: "/pages/home/home"
|
||||||
})
|
})
|
||||||
@@ -181,5 +181,9 @@ Page({
|
|||||||
this.setData({
|
this.setData({
|
||||||
["progress.index"]: this.data.progress.index + 1
|
["progress.index"]: this.data.progress.index + 1
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
onUnload() {
|
||||||
|
ppScale.plugin.Blue.stop();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -244,7 +244,7 @@ Page({
|
|||||||
|
|
||||||
// 卸载事件监听
|
// 卸载事件监听
|
||||||
onUnload() {
|
onUnload() {
|
||||||
app.globalData.ppScale.plugin.Blue.disconnect();
|
app.globalData.ppScale.plugin.Blue.stop();
|
||||||
if (this._connectStateWatcher) {
|
if (this._connectStateWatcher) {
|
||||||
app.unwatch('ppScale.device.connectState', this._connectStateWatcher);
|
app.unwatch('ppScale.device.connectState', this._connectStateWatcher);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onUnload() {
|
onUnload() {
|
||||||
app.globalData.ppScale.plugin.Blue.disconnect();
|
app.globalData.ppScale.plugin.Blue.stop();
|
||||||
if (this._connectStateWatcher) {
|
if (this._connectStateWatcher) {
|
||||||
app.unwatch('ppScale.device.connectState', this._connectStateWatcher);
|
app.unwatch('ppScale.device.connectState', this._connectStateWatcher);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user