devices.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // pages/deviceList/devices.js
  2. import dRequest from '../../request/deviceListRequest'
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. deviceList: [
  9. ],
  10. nvabarData: {
  11. showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
  12. title: '设备列表', //导航栏 中间的标题
  13. },
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad(options) {
  19. let _this = this
  20. let app = getApp()
  21. if (app.globalData.classifyProducts.length > 0) {
  22. _this.setData({
  23. deviceList: app.globalData.classifyProducts
  24. })
  25. return;
  26. }
  27. dRequest.deviceList({}).then((res) => {
  28. // console.log("设备列表", res);
  29. let devices = []
  30. res.forEach(element => {
  31. if (element.applicationType.indexOf("0") >= 0) {
  32. devices.push(element)
  33. }
  34. });
  35. console.log("设备列表2:", devices)
  36. app.globalData.classifyProducts = devices;
  37. _this.setData({
  38. deviceList: devices
  39. })
  40. })
  41. // dRequest.deviceTypeList({}).then((res)=>{
  42. // console.log("设备类型", res);
  43. // })
  44. // dRequest.deviceCategoryList({}).then((res)=>{
  45. // console.log("设备分类列表", res);
  46. // })
  47. },
  48. /**
  49. * 生命周期函数--监听页面初次渲染完成
  50. */
  51. onReady() {
  52. },
  53. /**
  54. * 生命周期函数--监听页面显示
  55. */
  56. onShow() {
  57. },
  58. /**
  59. * 生命周期函数--监听页面隐藏
  60. */
  61. onHide() {
  62. },
  63. /**
  64. * 生命周期函数--监听页面卸载
  65. */
  66. onUnload() {
  67. },
  68. /**
  69. * 页面相关事件处理函数--监听用户下拉动作
  70. */
  71. onPullDownRefresh() {
  72. },
  73. /**
  74. * 页面上拉触底事件的处理函数
  75. */
  76. onReachBottom() {
  77. },
  78. /**
  79. * 用户点击右上角分享
  80. */
  81. onShareAppMessage() {
  82. }
  83. })