deviceList.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. deviceList: [
  11. ],
  12. nvabarData: {
  13. showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
  14. title: '设备列表', //导航栏 中间的标题
  15. },
  16. },
  17. deviceTap(e) {
  18. console.log(e)
  19. let device = e.currentTarget.dataset.device
  20. if (!device) {
  21. console.log("设备为空")
  22. return;
  23. }
  24. let param = JSON.stringify(device)
  25. routeUtil.jumpParam(route_constant.connectMode, param)
  26. // routeUtil.jumpParam('/pages/piano/wallpaper/wallpaper', param)
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad(options) {
  32. let _this = this
  33. let app = getApp()
  34. if (app.globalData.classifyProducts.length > 0) {
  35. _this.setData({
  36. deviceList: app.globalData.classifyProducts
  37. })
  38. return;
  39. }
  40. dRequest.deviceList({}).then((res) => {
  41. // console.log("设备列表", res);
  42. let devices = []
  43. res.forEach(element => {
  44. // if (element.applicationType.indexOf("0") >= 0) {
  45. devices.push(element)
  46. // }
  47. });
  48. console.log("设备列表2:", devices)
  49. app.globalData.classifyProducts = devices;
  50. _this.setData({
  51. deviceList: devices
  52. })
  53. })
  54. // dRequest.deviceTypeList({}).then((res)=>{
  55. // console.log("设备类型", res);
  56. // })
  57. // dRequest.deviceCategoryList({}).then((res)=>{
  58. // console.log("设备分类列表", res);
  59. // })
  60. },
  61. })