const APP = getApp(); Page({ /** * 页面的初始数据 */ data: { devices: [] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getList(); }, /** * 设备列表 */ getList: function () { const param = { openId: APP.globalData.openId } APP.Get(APP.Url.getDeviceList, param).then(res => { this.setData({ devices: res.data }) }) }, /** * 切换当前设备 */ changeDevice: function (event) { const params = { openNum: event.currentTarget.dataset.opennum } APP.Post(APP.Url.changeDefault, params).then(res => { APP.Modal.tips("切换成功"); this.getList(); }) }, toAdd: function () { wx.navigateTo({ url: '/pages/device/add/add', }) } })