const APP = getApp(); Page({ /** * 页面的初始数据 */ data: { set: null //设置信息 }, /** * 生命周期函数--监听页面加载 */ onLoad: function () { this.getVolume(APP.globalData.openNum); }, /** * 提交表单 */ submit: function (form) { const parmas = { openNum: this.data.set.openNum, 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.openNum); APP.Modal.tips("设置成功!") }).catch(res => { console.log(res) APP.Modal.tips("设置失败!") }) }, /** * 获取设备音量设置 */ getVolume: function (openNum) { const that = this; const params = { openNum: openNum, } APP.Get(APP.Url.getVolume, params).then(res => { that.setData({ set: res.data }) }) }, })