contacts.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const APP = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. setInfo: null,//设置信息
  8. },
  9. /**
  10. * 生命周期函数--监听页面加载
  11. */
  12. onLoad: function () {
  13. this.getSetInfo(APP.getCurrentDevice().deviceId);
  14. },
  15. /**
  16. * 设置按键
  17. */
  18. setSos: function (form) {
  19. const that = this;
  20. const params = {
  21. deviceId: this.data.setInfo.deviceId,
  22. key0Name: form.detail.value.key0Name,
  23. key0Phone: form.detail.value.key0Phone,
  24. key1Name: form.detail.value.key1Name,
  25. key1Phone: form.detail.value.key1Phone,
  26. key2Name: form.detail.value.key2Name,
  27. key2Phone: form.detail.value.key2Phone,
  28. }
  29. APP.Post(APP.Url.setSos, params).then(res => {
  30. that.getSetInfo(params.deviceId)
  31. APP.Modal.tips("设置成功!")
  32. }).catch(res => {
  33. APP.Modal.tips("设置失败!")
  34. })
  35. },
  36. /**
  37. * 获取设备设置信息
  38. */
  39. getSetInfo: function (deviceId) {
  40. const params = {
  41. deviceId: deviceId,
  42. }
  43. APP.Get(APP.Url.getSos, params,false).then(res => {
  44. this.setData({
  45. setInfo: res.data
  46. })
  47. })
  48. },
  49. })