volume.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const APP = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. setInfo: null //设置信息
  8. },
  9. /**
  10. * 生命周期函数--监听页面加载
  11. */
  12. onLoad: function () {
  13. this.getVolume(APP.getCurrentDevice().deviceId);
  14. },
  15. /**
  16. * 提交表单
  17. */
  18. submit: function (form) {
  19. const parmas = {
  20. deviceId: this.data.setInfo.deviceId,
  21. ringVol: form.detail.value.ringVol === "" ? 0 : form.detail.value.ringVol,
  22. msgVol: form.detail.value.msgVol === "" ? 0 : form.detail.value.msgVol,
  23. phoneVol: form.detail.value.phoneVol === "" ? 0 : form.detail.value.phoneVol,
  24. }
  25. APP.Post(APP.Url.setVolume, parmas).then(res => {
  26. this.getVolume(parmas.deviceId);
  27. APP.Modal.tips("设置成功!")
  28. }).catch(res => {
  29. console.log(res)
  30. APP.Modal.tips("设置失败!")
  31. })
  32. },
  33. /**
  34. * 获取设备音量设置
  35. */
  36. getVolume: function (deviceId) {
  37. const that = this;
  38. const params = {
  39. deviceId: deviceId,
  40. }
  41. APP.Get(APP.Url.getVolume, params,false).then(res => {
  42. that.setData({
  43. setInfo: res.data
  44. })
  45. })
  46. },
  47. })