const app = getApp() import dRequest from '../../request/deviceListRequest' import routeUtil from '../../utils/route_util' import route_constant from '../../utils/route_constant.js' import strings from '../../utils/strings.js'; import store from '../../utils/store.js'; Page({ data: { nvabarData: { showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示 title: '设备列表', //导航栏 中间的标题 }, deviceList: app.globalData.classifyProducts, }, onLoad(options) { var that = this var classifyProducts = app.globalData.classifyProducts; if (!strings.isEmpty(classifyProducts)) { that.setDeviceList(classifyProducts); } ///数据请求 dRequest.deviceList({}).then((res) => { if (res) { store.setStore("classifyProducts", res); that.setDeviceList(res); } }); }, ///设备列表赋值 setDeviceList(res) { var that = this; try { var devices = []; res.forEach(element => { if (element.applicationType.indexOf("0") >= 0) { devices.push(element) } }); that.setData({ deviceList: devices }); } catch (e) {} }, deviceTap(e) { var device = e.currentTarget.dataset.device; if (!device) { console.log("设备为空") return; } var param = JSON.stringify(device); routeUtil.jumpParam(route_constant.deviceConnect0, param); }, })