|
@@ -23,8 +23,68 @@ Page({
|
|
|
updateData: {},
|
|
|
powerOpen: false,
|
|
|
isShowWallpaper: false,
|
|
|
+ },
|
|
|
+
|
|
|
+ onLoad: function (options) {
|
|
|
+ // let device = JSON.parse(options.param);
|
|
|
+ console.log(getApp().globalData.mDeviceList.length)
|
|
|
+ let device = JSON.parse(options.param);
|
|
|
+ // let device = getApp().globalData.mDeviceList[0] ?? JSON.parse(options.param);
|
|
|
+ if (device.connectType != '1') {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ device.clientType = device.clientType ?? device.ProdModel
|
|
|
+
|
|
|
+ console.log("设备详情", device)
|
|
|
+ let isConnect = device.state === 'online'
|
|
|
+ if (!isConnect) {
|
|
|
+ // btHelper
|
|
|
+ wx.showToast({
|
|
|
+ title: '设备已经失去连接',
|
|
|
+ })
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ device: device,
|
|
|
+ powerOpen: (device.pauseSleep ?? -1) > 0,
|
|
|
+ isShowWallpaper: device.clientType === 'MW-S2'
|
|
|
+ })
|
|
|
|
|
|
+ const btHelper = BtHelper.getInstance();
|
|
|
+ let isShowOta = device.clientType === 'MW-S2'
|
|
|
+ if (isShowOta) {
|
|
|
+ btHelper.getVersion()
|
|
|
+ // this.checkOtaVersion(device);
|
|
|
+ }
|
|
|
+ // btHelper.getPauseSleep()
|
|
|
+
|
|
|
+ let _this = this;
|
|
|
+ EventManager.addNotification(CmdEvent.eventName, function (event) {
|
|
|
+ let name = event.cmdEvent;
|
|
|
+ // console.log("详情页:", name, event)
|
|
|
+ switch (name) {
|
|
|
+ case EnumCmdEvent.version:
|
|
|
+ _this.data.device.version = event.version;
|
|
|
+ console.log("详情页1:", event.version)
|
|
|
+
|
|
|
+ _this.checkOtaVersion(_this.data.device);
|
|
|
+ break;
|
|
|
+ case EnumCmdEvent.authSleepStatus:
|
|
|
+ let value = event.pauseSleep;
|
|
|
+ console.log("详情页2:", value)
|
|
|
+ _this.setData({
|
|
|
+ powerOpen: (value ?? -1) > 0
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case EnumCmdEvent.onoffline:
|
|
|
+ console.log("详情页3:")
|
|
|
+ //目前只有下线
|
|
|
+ _this.data.device.state = "offline"
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }, this);
|
|
|
},
|
|
|
+
|
|
|
checkOtaVersion(device) {
|
|
|
let _this = this;
|
|
|
device.clientType = "MW-S2"
|
|
@@ -40,7 +100,6 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
-
|
|
|
goToWallpaper: function () {
|
|
|
var param = '?param=' + JSON.stringify(this.data.device);
|
|
|
route_util.jumpParam('/pages/piano/wallpaper/wallpaper', param);
|
|
@@ -87,68 +146,6 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面加载
|
|
|
- */
|
|
|
- onLoad: function (options) {
|
|
|
- // let device = JSON.parse(options.param);
|
|
|
- console.log(getApp().globalData.mDeviceList.length)
|
|
|
- let device = JSON.parse(options.param);
|
|
|
- // let device = getApp().globalData.mDeviceList[0] ?? JSON.parse(options.param);
|
|
|
- if (device.connectType != '1') {
|
|
|
- return
|
|
|
- }
|
|
|
- device.clientType = device.clientType ?? device.ProdModel
|
|
|
-
|
|
|
- console.log("设备详情", device)
|
|
|
- let isConnect = device.state === 'online'
|
|
|
- if (!isConnect) {
|
|
|
- // btHelper
|
|
|
- wx.showToast({
|
|
|
- title: '设备已经失去连接',
|
|
|
- })
|
|
|
- return;
|
|
|
- }
|
|
|
- this.setData({
|
|
|
- device: device,
|
|
|
- powerOpen: (device.pauseSleep ?? -1) > 0,
|
|
|
- isShowWallpaper: device.clientType === 'MW-S2'
|
|
|
- })
|
|
|
-
|
|
|
- const btHelper = BtHelper.getInstance();
|
|
|
- let isShowOta = device.clientType === 'MW-S2'
|
|
|
- if (isShowOta) {
|
|
|
- btHelper.getVersion()
|
|
|
- // this.checkOtaVersion(device);
|
|
|
- }
|
|
|
- // btHelper.getPauseSleep()
|
|
|
-
|
|
|
- let _this = this;
|
|
|
- EventManager.addNotification(CmdEvent.eventName, function (event) {
|
|
|
- let name = event.cmdEvent;
|
|
|
- // console.log("详情页:", name, event)
|
|
|
- switch (name) {
|
|
|
- case EnumCmdEvent.version:
|
|
|
- _this.data.device.version = event.version;
|
|
|
- console.log("详情页1:", event.version)
|
|
|
-
|
|
|
- _this.checkOtaVersion(_this.data.device);
|
|
|
- break;
|
|
|
- case EnumCmdEvent.authSleepStatus:
|
|
|
- let value = event.pauseSleep;
|
|
|
- console.log("详情页2:", value)
|
|
|
- _this.setData({
|
|
|
- powerOpen: (value ?? -1) > 0
|
|
|
- })
|
|
|
- break;
|
|
|
- case EnumCmdEvent.onoffline:
|
|
|
- console.log("详情页3:")
|
|
|
- //目前只有下线
|
|
|
- _this.data.device.state = "offline"
|
|
|
- break;
|
|
|
- }
|
|
|
- }, this)
|
|
|
- },
|
|
|
|
|
|
onUnload() {
|
|
|
EventManager.removeNotification(CmdEvent.eventName, this)
|