|
@@ -346,74 +346,77 @@ Page({
|
|
|
// console.log("gadsfadsfadsfa==999===" + type + "====" + JSON.stringify(option));
|
|
|
var that = this;
|
|
|
let payloads = null;
|
|
|
- if (option && option.payload) {
|
|
|
- payloads = JSON.parse(option.payload);
|
|
|
- };
|
|
|
|
|
|
- switch (type) {
|
|
|
- ///先走订阅
|
|
|
- case "connect":
|
|
|
- lexin_subscribe.subscribeAllDevice();
|
|
|
- break;
|
|
|
- ///再走有在线
|
|
|
- case "message_onoffline":
|
|
|
- lexin_connect.searchOnlineDevice(payloads, function (list) {
|
|
|
- that.updateDeviceList(list, false, false);
|
|
|
- }, function () {
|
|
|
- var indexPage = that.data.indexPage;
|
|
|
- that.setData({
|
|
|
- actionIndex: null,
|
|
|
- deviceListSelect: null,
|
|
|
- indexPage: indexPage == 1 ? 0 : indexPage,
|
|
|
- });
|
|
|
- }, function () {
|
|
|
- var indexPage = that.data.indexPage;
|
|
|
- that.setData({
|
|
|
- actionIndex: null,
|
|
|
- deviceListSelect: null,
|
|
|
- indexPage: indexPage == 1 ? 0 : indexPage,
|
|
|
+ try {
|
|
|
+ if (option && option.payload) {
|
|
|
+ payloads = JSON.parse(option.payload);
|
|
|
+ };
|
|
|
+
|
|
|
+ switch (type) {
|
|
|
+ ///先走订阅
|
|
|
+ case "connect":
|
|
|
+ lexin_subscribe.subscribeAllDevice();
|
|
|
+ break;
|
|
|
+ ///再走有在线
|
|
|
+ case "message_onoffline":
|
|
|
+ lexin_connect.searchOnlineDevice(payloads, function (list) {
|
|
|
+ that.updateDeviceList(list, false, false);
|
|
|
+ }, function () {
|
|
|
+ var indexPage = that.data.indexPage;
|
|
|
+ that.setData({
|
|
|
+ actionIndex: null,
|
|
|
+ deviceListSelect: null,
|
|
|
+ indexPage: indexPage == 1 ? 0 : indexPage,
|
|
|
+ });
|
|
|
+ }, function () {
|
|
|
+ var indexPage = that.data.indexPage;
|
|
|
+ that.setData({
|
|
|
+ actionIndex: null,
|
|
|
+ deviceListSelect: null,
|
|
|
+ indexPage: indexPage == 1 ? 0 : indexPage,
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
- break;
|
|
|
-
|
|
|
- case "message":
|
|
|
- if (payloads) {
|
|
|
- var payloadType = payloads.type;
|
|
|
- var other = payloads.other;
|
|
|
-
|
|
|
- ///获取频道位置
|
|
|
- if (payloadType === "get_position" && other) {
|
|
|
- lexin_message.getPosition(other, function (actionIndex) {
|
|
|
- that.setData({
|
|
|
- actionIndex: actionIndex,
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "message":
|
|
|
+ if (payloads) {
|
|
|
+ var payloadType = payloads.type;
|
|
|
+ var other = payloads.other;
|
|
|
+
|
|
|
+ ///获取频道位置
|
|
|
+ if (payloadType === "get_position" && other) {
|
|
|
+ lexin_message.getPosition(other, function (actionIndex) {
|
|
|
+ that.setData({
|
|
|
+ actionIndex: actionIndex,
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- // 获取歌曲信息
|
|
|
- else if (payloadType === "get_dev_info" && other) {
|
|
|
- that.setDeviceInfor(other);
|
|
|
- lexin_message.getDeviceInfo(payloads);
|
|
|
- }
|
|
|
+ // 获取歌曲信息
|
|
|
+ else if (payloadType === "get_dev_info" && other) {
|
|
|
+ that.setDeviceInfor(other);
|
|
|
+ lexin_message.getDeviceInfo(payloads);
|
|
|
+ }
|
|
|
|
|
|
- ///获取电量
|
|
|
- else if (payloadType === "battery" && other) {
|
|
|
- if (other.battery) {
|
|
|
- var battery = lexin_message.getBattery(other.battery);
|
|
|
- that.setData({
|
|
|
- battery: battery,
|
|
|
- });
|
|
|
+ ///获取电量
|
|
|
+ else if (payloadType === "battery" && other) {
|
|
|
+ if (other.battery) {
|
|
|
+ var battery = lexin_message.getBattery(other.battery);
|
|
|
+ that.setData({
|
|
|
+ battery: battery,
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- ///获取播放状态
|
|
|
- else if (payloadType === "play" || payloadType === "play_state") {
|
|
|
- lexin_message.getPlay();
|
|
|
+ ///获取播放状态
|
|
|
+ else if (payloadType === "play" || payloadType === "play_state") {
|
|
|
+ lexin_message.getPlay();
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ } catch (e) {}
|
|
|
},
|
|
|
|
|
|
///去连接设备数据
|