deviceList.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. const constant = require('../../../utils/constant.js');
  2. Page({
  3. data: {
  4. nvabarData: {
  5. showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
  6. title: '设备列表', //导航栏 中间的标题
  7. },
  8. deviceList: constant.app.globalData.classifyProducts,
  9. },
  10. onLoad(options) {
  11. var that = this
  12. var classifyProducts = constant.app.globalData.classifyProducts;
  13. if (!constant.strings.isEmpty(classifyProducts)) {
  14. that.setDeviceList(classifyProducts, false);
  15. }
  16. ///数据请求
  17. constant.dRequest.deviceList({
  18. unShowLoad: true
  19. }).then((res) => {
  20. if (res) {
  21. that.setDeviceList(res, true);
  22. }
  23. });
  24. },
  25. ///设备列表赋值
  26. setDeviceList(res, isLoad) {
  27. var that = this;
  28. try {
  29. // {"applicationType":"[0, 1]","deviceId":430635766251545,"img":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20220812113416291791429.png","offlineImg":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20220812113421204031133.png","connectImg":null,"name":"猫王音响x阿基米德 SR1 妙播收音机","bluetoothName":"SR1妙播收音机","bluetoothNames":["SR1妙播收音机","猫王XOG·CyberRadio 001"],"isChannelsPlatforms":1,"platform":0,"typeList":[{"is5g":0,"type":1,"connectType":1,"functionList":[6,1,3],"deviceLinkResp":{"icon1":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20220812113427142232548.png","icon2":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20220812113431143471942.png","icon":null,"guideUrl":null}},{"is5g":0,"type":2,"connectType":3,"functionList":[1,3],"deviceLinkResp":{"icon1":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20220812113437930271177.png","icon2":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20220812113441600058940.png","icon":null,"guideUrl":null}},{"is5g":0,"type":4,"connectType":3,"functionList":[1,3],"deviceLinkResp":{"icon1":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20220812113446634000744.png","icon2":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20220812113450885467009.png","icon":null,"guideUrl":null}}],"clientType":"MW-SR1(4G_WIFI)","firstVersion":"1","filter":null,"guideUrl":null,"manufacturer":"ShanJing","deviceType":0}
  30. var devices = res;
  31. // var devices = [];
  32. // var clientTypes = constant.lexinDevices.clientTypes;
  33. // res.forEach(element => {
  34. // ///MW-SR1(4G_WIFI),MW-2AX(WIFI)
  35. // for (var i = 0; i < clientTypes.length; i++) {
  36. // if (element.clientType == clientTypes[i]) {
  37. // if (!devices.includes(element)) {
  38. // devices.push(element);
  39. // }
  40. // break;
  41. // }
  42. // }
  43. // });
  44. if (isLoad) {
  45. constant.store.setStore("classifyProducts", res);
  46. constant.app.globalData.classifyProducts = devices;
  47. }
  48. console.log(devices);
  49. that.setData({
  50. deviceList: devices
  51. });
  52. } catch (e) {}
  53. },
  54. deviceTap(e) {
  55. var device = e.currentTarget.dataset.device;
  56. console.log(device)
  57. if (!device) {
  58. console.log("设备为空")
  59. return;
  60. }
  61. var clientTypes = constant.lexinDevices.clientTypes;
  62. if (clientTypes.includes(device.clientType)) {
  63. var param = "?param=" + JSON.stringify(device);
  64. // pages/pageB/deviceConnect0/deviceConnect0?param={"clientType":"MW-Mate X(4G_WIFI)"}
  65. // ?param={"applicationType":"[0, 1]","deviceId":432698392051714,"img":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20230410102304552692164.png","offlineImg":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20230410102740684077340.png","connectImg":null,"name":"X2 妙播音箱","bluetoothName":"猫王音响·Mate_X2","bluetoothNames":["猫王音响·Mate_X2","猫王音响·X2妙播音箱","猫王音响·Mate_X"],"isChannelsPlatforms":0,"platform":0,"typeList":[{"is5g":0,"type":1,"connectType":1,"functionList":[1,3],"deviceLinkResp":{"icon1":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20230410102357244734373.png","icon2":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20230410102404705282697.png","icon":null,"guideUrl":null}},{"is5g":0,"type":2,"connectType":3,"functionList":[1,3,6],"deviceLinkResp":{"icon1":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20230313152650116909154.png","icon2":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20230313152717095912088.png","icon":null,"guideUrl":null}},{"is5g":0,"type":4,"connectType":3,"functionList":[1,3,6],"deviceLinkResp":{"icon1":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20230313152749792939577.png","icon2":"https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20230313152759963002418.png","icon":null,"guideUrl":null}}],"clientType":"MW-Mate X(4G_WIFI)","firstVersion":"0.0.1","filter":null,"guideUrl":null,"manufacturer":"ShanJing","deviceType":0}
  66. constant.routeUtil.jumpParam(constant.routePath.deviceConnect0, param);
  67. } else if (device.clientType === "MW-S2" || device.clientType === "猫王妙播黑胶音箱(BLE)") {
  68. var param = "?param=" + JSON.stringify(device);
  69. constant.routeUtil.jumpParam(constant.routePath.connectBle, param);
  70. } else {
  71. wx.showToast({
  72. title: '暂不支持该设备',
  73. })
  74. }
  75. },
  76. })