volume.js 1.1 KB

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