list.js 829 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const APP = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. devices: []
  8. },
  9. /**
  10. * 生命周期函数--监听页面加载
  11. */
  12. onLoad: function (options) {
  13. this.getList();
  14. },
  15. /**
  16. * 设备列表
  17. */
  18. getList: function () {
  19. const param = {
  20. openId: APP.globalData.openId
  21. }
  22. APP.Get(APP.Url.getDeviceList, param).then(res => {
  23. this.setData({
  24. devices: res.data
  25. })
  26. })
  27. },
  28. /**
  29. * 切换当前设备
  30. */
  31. changeDevice: function (event) {
  32. const params = {
  33. openNum: event.currentTarget.dataset.opennum
  34. }
  35. APP.Post(APP.Url.changeDefault, params).then(res => {
  36. APP.Modal.tips("切换成功");
  37. this.getList();
  38. })
  39. },
  40. toAdd: function () {
  41. wx.navigateTo({
  42. url: '/pages/device/add/add',
  43. })
  44. }
  45. })