const APP = getApp(); Page({ /** * 页面的初始数据 */ data: { setInfo: null //设置信息 }, /** * 生命周期函数--监听页面加载 */ onLoad: function () { this.getVolume(APP.getCurrentDevice().deviceId); }, /** * 提交表单 */ submit: function (form) { const parmas = { deviceId: this.data.setInfo.deviceId, ringVol: form.detail.value.ringVol === "" ? 0 : form.detail.value.ringVol, msgVol: form.detail.value.msgVol === "" ? 0 : form.detail.value.msgVol, phoneVol: form.detail.value.phoneVol === "" ? 0 : form.detail.value.phoneVol, } APP.Post(APP.Url.setVolume, parmas).then(res => { this.getVolume(parmas.deviceId); APP.Modal.tips("设置成功!") }).catch(res => { console.log(res) APP.Modal.tips("设置失败!") }) }, /** * 获取设备音量设置 */ getVolume: function (deviceId) { const that = this; const params = { deviceId: deviceId, } APP.Get(APP.Url.getVolume, params,false).then(res => { that.setData({ setInfo: res.data }) }) }, })