123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- const APP = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- //设备集合
- devices: [],
- //默认设备
- defaultDevice: 1,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.list()
- },
- /**
- * 设备列表
- */
- list() {
- const params = {
- openId: APP.globalData.openId
- }
- APP.Get(APP.Url.listBindDevices, params).then(res => {
- this.setData({
- devices: res.data
- })
- })
- },
- /**
- * 切换当前设备
- */
- changeDevice(event) {
- const that = this;
- const params = {
- openNum: event.currentTarget.dataset.opennum
- }
- wx.showModal({
- title: '提示',
- content: '确定切换到该设备吗',
- success(res) {
- if (res.confirm) {
- APP.Post(APP.Url.switchDefaultDevice, params).then(res => {
- APP.Modal.tips("切换成功");
- that.list();
- })
- }
- }
- })
- },
- unbind(event) {
- const that = this;
- const params = {
- openNum: event.currentTarget.dataset.opennum
- }
- wx.showModal({
- title: '提示',
- content: '确定解绑该设备吗?',
- success(res) {
- if (res.confirm) {
- APP.Post(APP.Url.unbind, params).then(res => {
- APP.Modal.tips("解除成功");
- that.list();
- })
- }
- }
- })
- }
- })
|