|
@@ -185,7 +185,7 @@ Page({
|
|
|
// console.log("gadsfadsfadsfa==888===" + type);
|
|
|
var that = this;
|
|
|
let payloads = null;
|
|
|
- if (option) {
|
|
|
+ if (option && option.payload) {
|
|
|
payloads = JSON.parse(option.payload);
|
|
|
};
|
|
|
|
|
@@ -201,84 +201,86 @@ Page({
|
|
|
case "message":
|
|
|
///获取频道数据
|
|
|
///锁定播放哪一个频道
|
|
|
- if (payloads.type === "get_position" && payloads.other) {
|
|
|
- let actionIndex = null;
|
|
|
- that.data.channelData.map((v, index) => {
|
|
|
- if (v.channelNum === payloads.other.channel) {
|
|
|
- actionIndex = index;
|
|
|
- }
|
|
|
- });
|
|
|
- that.setData({
|
|
|
- actionIndex,
|
|
|
- });
|
|
|
- }
|
|
|
- ///获取播放状态
|
|
|
- else if (payloads.type === "play" || payloads.type === "play_state") {
|
|
|
- var deviceList = that.data.deviceList;
|
|
|
- var deviceListSelect = that.data.deviceListSelect;
|
|
|
- if (deviceList.length <= deviceListSelect) {
|
|
|
- return;
|
|
|
- };
|
|
|
-
|
|
|
- var deviceId = deviceList[deviceListSelect].deviceId;
|
|
|
- // 接收设备当前播放状态
|
|
|
- const obj = {
|
|
|
- DstDeviceName: that.getThisDeviceID(deviceId)
|
|
|
+ if (payloads) {
|
|
|
+ if (payloads.type === "get_position" && payloads.other) {
|
|
|
+ let actionIndex = null;
|
|
|
+ that.data.channelData.map((v, index) => {
|
|
|
+ if (v.channelNum === payloads.other.channel) {
|
|
|
+ actionIndex = index;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ that.setData({
|
|
|
+ actionIndex,
|
|
|
+ });
|
|
|
}
|
|
|
- app.PubMsg({
|
|
|
- type: "get_position",
|
|
|
- ...obj
|
|
|
- });
|
|
|
- }
|
|
|
- ///获取频道列表数据
|
|
|
- else if (payloads.type === "get_dev_info") {
|
|
|
- // 接收设备当前信息
|
|
|
- that.getchannelData(payloads.other.ProdModel);
|
|
|
- // 电量
|
|
|
- that.setData({
|
|
|
- battery: that._battery(payloads.other.Power),
|
|
|
- })
|
|
|
- // 当前设备木有设置定时
|
|
|
- that.setData({
|
|
|
- isSetWake: false,
|
|
|
- });
|
|
|
- payloads.other.alarm.map((v) => {
|
|
|
- if (v.enable === "1") {
|
|
|
- that.setData({
|
|
|
- isSetWake: true
|
|
|
- });
|
|
|
+ ///获取播放状态
|
|
|
+ else if (payloads.type === "play" || payloads.type === "play_state") {
|
|
|
+ var deviceList = that.data.deviceList;
|
|
|
+ var deviceListSelect = that.data.deviceListSelect;
|
|
|
+ if (deviceList.length <= deviceListSelect) {
|
|
|
+ return;
|
|
|
+ };
|
|
|
+
|
|
|
+ var deviceId = deviceList[deviceListSelect].deviceId;
|
|
|
+ // 接收设备当前播放状态
|
|
|
+ const obj = {
|
|
|
+ DstDeviceName: that.getThisDeviceID(deviceId)
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
- // 更新信息
|
|
|
- ///连上就调用2次 payloads.SrcDeviceName:AIrSMArT_7cdfa1fcbb24
|
|
|
- var isUpdate = false;
|
|
|
- var deviceList = that.data.deviceList;
|
|
|
- if (!strings.isEmpty(deviceList)) {
|
|
|
- for (var i = 0; i < deviceList.length; i++) {
|
|
|
- if (payloads.SrcDeviceName) {
|
|
|
- var deviceId = deviceList[i].deviceId;
|
|
|
- var splitDeviceId = deviceId.split("BLUFI_");
|
|
|
- if (splitDeviceId.length == 2) {
|
|
|
- var index = payloads.SrcDeviceName.indexOf(splitDeviceId[1]);
|
|
|
- if (index !== -1 && (deviceList[i].ProdModel != payloads.other.ProdModel || deviceList[i].devName != payloads.other.devName)) {
|
|
|
- isUpdate = true;
|
|
|
- deviceList[i].ProdModel = payloads.other.ProdModel;
|
|
|
- deviceList[i].devName = payloads.other.devName;
|
|
|
- break;
|
|
|
+ app.PubMsg({
|
|
|
+ type: "get_position",
|
|
|
+ ...obj
|
|
|
+ });
|
|
|
+ }
|
|
|
+ ///获取频道列表数据
|
|
|
+ else if (payloads.type === "get_dev_info") {
|
|
|
+ // 接收设备当前信息
|
|
|
+ that.getchannelData(payloads.other.ProdModel);
|
|
|
+ // 电量
|
|
|
+ that.setData({
|
|
|
+ battery: that._battery(payloads.other.Power),
|
|
|
+ })
|
|
|
+ // 当前设备木有设置定时
|
|
|
+ that.setData({
|
|
|
+ isSetWake: false,
|
|
|
+ });
|
|
|
+ payloads.other.alarm.map((v) => {
|
|
|
+ if (v.enable === "1") {
|
|
|
+ that.setData({
|
|
|
+ isSetWake: true
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 更新信息
|
|
|
+ ///连上就调用2次 payloads.SrcDeviceName:AIrSMArT_7cdfa1fcbb24
|
|
|
+ var isUpdate = false;
|
|
|
+ var deviceList = that.data.deviceList;
|
|
|
+ if (!strings.isEmpty(deviceList)) {
|
|
|
+ for (var i = 0; i < deviceList.length; i++) {
|
|
|
+ if (payloads.SrcDeviceName) {
|
|
|
+ var deviceId = deviceList[i].deviceId;
|
|
|
+ var splitDeviceId = deviceId.split("BLUFI_");
|
|
|
+ if (splitDeviceId.length == 2) {
|
|
|
+ var index = payloads.SrcDeviceName.indexOf(splitDeviceId[1]);
|
|
|
+ if (index !== -1 && (deviceList[i].ProdModel != payloads.other.ProdModel || deviceList[i].devName != payloads.other.devName)) {
|
|
|
+ isUpdate = true;
|
|
|
+ deviceList[i].ProdModel = payloads.other.ProdModel;
|
|
|
+ deviceList[i].devName = payloads.other.devName;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ ///数据有更新
|
|
|
+ if (isUpdate) {
|
|
|
+ that.updateDeviceList(deviceList, false);
|
|
|
+ }
|
|
|
+ } else if (payloads.type === "battery" && payloads.other) {
|
|
|
+ that.setData({
|
|
|
+ battery: that._battery(payloads.other.battery),
|
|
|
+ })
|
|
|
}
|
|
|
- ///数据有更新
|
|
|
- if (isUpdate) {
|
|
|
- that.updateDeviceList(deviceList, false);
|
|
|
- }
|
|
|
- } else if (payloads.type === "battery" && payloads.other) {
|
|
|
- that.setData({
|
|
|
- battery: that._battery(payloads.other.battery),
|
|
|
- })
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
@@ -318,7 +320,7 @@ Page({
|
|
|
var deviceList = that.data.deviceList;
|
|
|
if (!strings.isEmpty(deviceList)) {
|
|
|
for (var i = 0; i < deviceList.length; i++) {
|
|
|
- if (payloads.uuid) {
|
|
|
+ if (payloads && payloads.uuid) {
|
|
|
var deviceId = deviceList[i].deviceId;
|
|
|
var splitDeviceId = deviceId.split("BLUFI_");
|
|
|
if (splitDeviceId.length == 2) {
|