set.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. const APP = getApp()
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. setInfo: null,//设置信息
  8. },
  9. /**
  10. * 生命周期函数--监听页面加载
  11. */
  12. onLoad: function () {
  13. this.getOther(APP.getCurrentDevice().deviceId);
  14. },
  15. /**
  16. * 获取设备自动接听设置
  17. */
  18. getOther: function (deviceId) {
  19. const that = this;
  20. const params = {
  21. deviceId: deviceId,
  22. }
  23. APP.Get(APP.Url.getOther, params).then(res => {
  24. that.setData({
  25. setInfo: res.data,
  26. })
  27. })
  28. },
  29. /**
  30. * 监听自动接听开关
  31. */
  32. handleAutoAnswerChange: function (event) {
  33. const that = this;
  34. const params = {
  35. deviceId: that.data.setInfo.deviceId,
  36. autoAnswer: event.detail.value === true ? 1 : 0
  37. }
  38. APP.Post(APP.Url.setAutoAnswer, params).then(res => {
  39. that.getOther(params.deviceId)
  40. APP.Modal.tips("设置成功!")
  41. }).catch(res => {
  42. console.log(res)
  43. APP.Modal.tips("设置失败!")
  44. })
  45. },
  46. /**
  47. * 监听持续定位
  48. */
  49. handleContinueChange: function (event) {
  50. const that = this;
  51. const params = {
  52. deviceId: that.data.setInfo.deviceId,
  53. // highFreq: event.detail.value === true ? 1 : 0,
  54. highFreq: 1
  55. }
  56. APP.Post(APP.Url.setContinue, params).then(res => {
  57. that.getOther(params.deviceId)
  58. APP.Modal.tips("设置成功!")
  59. }).catch(res => {
  60. console.log(res)
  61. APP.Modal.tips("设置失败!")
  62. })
  63. },
  64. /**
  65. * 跳转至子页面页面
  66. */
  67. routeTo: function (event) {
  68. const path = event.currentTarget.dataset.path;
  69. APP.Route.routeTo(APP.Route.path[path])
  70. },
  71. })