devices.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // pages/deviceList/devices.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. routeUtil.jumpParam(route_constant.connectMode, device)
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad(options) {
  30. let _this = this
  31. let app = getApp()
  32. if (app.globalData.classifyProducts.length > 0) {
  33. _this.setData({
  34. deviceList: app.globalData.classifyProducts
  35. })
  36. return;
  37. }
  38. dRequest.deviceList({}).then((res) => {
  39. // console.log("设备列表", res);
  40. let devices = []
  41. res.forEach(element => {
  42. if (element.applicationType.indexOf("0") >= 0) {
  43. devices.push(element)
  44. }
  45. });
  46. console.log("设备列表2:", devices)
  47. app.globalData.classifyProducts = devices;
  48. _this.setData({
  49. deviceList: devices
  50. })
  51. })
  52. // dRequest.deviceTypeList({}).then((res)=>{
  53. // console.log("设备类型", res);
  54. // })
  55. // dRequest.deviceCategoryList({}).then((res)=>{
  56. // console.log("设备分类列表", res);
  57. // })
  58. },
  59. /**
  60. * 生命周期函数--监听页面初次渲染完成
  61. */
  62. onReady() {
  63. },
  64. /**
  65. * 生命周期函数--监听页面显示
  66. */
  67. onShow() {
  68. },
  69. /**
  70. * 生命周期函数--监听页面隐藏
  71. */
  72. onHide() {
  73. },
  74. /**
  75. * 生命周期函数--监听页面卸载
  76. */
  77. onUnload() {
  78. },
  79. /**
  80. * 页面相关事件处理函数--监听用户下拉动作
  81. */
  82. onPullDownRefresh() {
  83. },
  84. /**
  85. * 页面上拉触底事件的处理函数
  86. */
  87. onReachBottom() {
  88. },
  89. /**
  90. * 用户点击右上角分享
  91. */
  92. onShareAppMessage() {
  93. }
  94. })