deviceList.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // pages/deviceList/deviceList.js
  2. import dRequest from '../../request/deviceListRequest'
  3. import routeUtil from '../../utils/route_util'
  4. import route_constant from '../../utils/route_constant.js'
  5. Page({
  6. data: {
  7. deviceList: [
  8. ],
  9. nvabarData: {
  10. showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
  11. title: '设备列表', //导航栏 中间的标题
  12. },
  13. },
  14. onLoad(options) {
  15. let _this = this
  16. let app = getApp()
  17. if (app.globalData.classifyProducts.length > 0) {
  18. _this.setData({
  19. deviceList: app.globalData.classifyProducts
  20. })
  21. return;
  22. }
  23. dRequest.deviceList({}).then((res) => {
  24. // console.log("设备列表", res);
  25. let devices = []
  26. res.forEach(element => {
  27. // if (element.applicationType.indexOf("0") >= 0) {
  28. devices.push(element)
  29. // }
  30. });
  31. console.log("设备列表2:", devices)
  32. app.globalData.classifyProducts = devices;
  33. _this.setData({
  34. deviceList: devices
  35. })
  36. })
  37. // dRequest.deviceTypeList({}).then((res)=>{
  38. // console.log("设备类型", res);
  39. // })
  40. // dRequest.deviceCategoryList({}).then((res)=>{
  41. // console.log("设备分类列表", res);
  42. // })
  43. },
  44. deviceTap(e) {
  45. console.log(e)
  46. let device = e.currentTarget.dataset.device
  47. if (!device) {
  48. console.log("设备为空")
  49. return;
  50. }
  51. let param = JSON.stringify(device)
  52. routeUtil.jumpParam(route_constant.connectMode, param)
  53. // routeUtil.jumpParam('/pages/piano/wallpaper/wallpaper', param)
  54. },
  55. })