const APP = getApp(); Page({ /** * 页面的初始数据 */ data: { setInfo: null,//设置信息 }, /** * 生命周期函数--监听页面加载 */ onLoad: function () { this.getSetInfo(APP.getCurrentDevice().deviceId); }, /** * 设置按键 */ setSos: function (form) { const that = this; const params = { deviceId: this.data.setInfo.deviceId, key0Name: form.detail.value.key0Name, key0Phone: form.detail.value.key0Phone, key1Name: form.detail.value.key1Name, key1Phone: form.detail.value.key1Phone, key2Name: form.detail.value.key2Name, key2Phone: form.detail.value.key2Phone, } APP.Post(APP.Url.setSos, params).then(res => { that.getSetInfo(params.deviceId) APP.Modal.tips("设置成功!") }).catch(res => { APP.Modal.tips("设置失败!") }) }, /** * 获取设备设置信息 */ getSetInfo: function (deviceId) { const params = { deviceId: deviceId, } APP.Get(APP.Url.getSos, params,false).then(res => { this.setData({ setInfo: res.data }) }) }, })