12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- const constant = require('../../../utils/constant.js');
- Page({
- data: {
- nvabarData: {
- showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
- title: '设备列表', //导航栏 中间的标题
- },
- deviceList: constant.app.globalData.classifyProducts,
- },
- onLoad(options) {
- var that = this
- var classifyProducts = constant.app.globalData.classifyProducts;
- if (!constant.strings.isEmpty(classifyProducts)) {
- that.setDeviceList(classifyProducts, false);
- }
- ///数据请求
- constant.dRequest.deviceList({
- unShowLoad: true
- }).then((res) => {
- if (res) {
- that.setDeviceList(res, true);
- }
- });
- },
- ///设备列表赋值
- setDeviceList(res, isLoad) {
- var that = this;
- try {
- // {"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}
- var devices = res;
- // var devices = [];
- // var clientTypes = constant.lexinDevices.clientTypes;
- // res.forEach(element => {
- // ///MW-SR1(4G_WIFI),MW-2AX(WIFI)
- // for (var i = 0; i < clientTypes.length; i++) {
- // if (element.clientType == clientTypes[i]) {
- // if (!devices.includes(element)) {
- // devices.push(element);
- // }
- // break;
- // }
- // }
- // });
- if (isLoad) {
- constant.store.setStore("classifyProducts", res);
- constant.app.globalData.classifyProducts = devices;
- }
- console.log(devices);
- that.setData({
- deviceList: devices
- });
- } catch (e) {}
- },
- deviceTap(e) {
- var device = e.currentTarget.dataset.device;
- console.log(device)
- if (!device) {
- console.log("设备为空")
- return;
- }
- var clientTypes = constant.lexinDevices.clientTypes;
- if (clientTypes.includes(device.clientType)) {
- var param = "?param=" + JSON.stringify(device);
- constant.routeUtil.jumpParam(constant.routePath.deviceConnect0, param);
- } else if (device.clientType === "MW-S2" || device.clientType === "猫王妙播黑胶音箱(BLE)") {
- var param = "?param=" + JSON.stringify(device);
- constant.routeUtil.jumpParam(constant.routePath.connectBle, param);
- } else {
- wx.showToast({
- title: '暂不支持该设备',
- })
- }
- },
- })
|