deviceList.js 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. constant.routeUtil.jumpParam(constant.routePath.deviceConnect0, param);
  65. } else if (device.clientType === "MW-S2" || device.clientType === "猫王妙播黑胶音箱(BLE)") {
  66. var param = "?param=" + JSON.stringify(device);
  67. constant.routeUtil.jumpParam(constant.routePath.connectBle, param);
  68. } else {
  69. wx.showToast({
  70. title: '暂不支持该设备',
  71. })
  72. }
  73. },
  74. })