contacts.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const APP = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. set: {},//设置信息
  8. },
  9. /**
  10. * 生命周期函数--监听页面加载
  11. */
  12. onLoad: function () {
  13. this.getSetInfo(APP.globalData.openNum);
  14. },
  15. /**
  16. * 设置按键
  17. */
  18. submit: function (form) {
  19. const that = this;
  20. const params = {
  21. openNum: this.data.set.openNum,
  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.openNum)
  31. APP.Modal.tips("保存成功!")
  32. }).catch(res => {
  33. APP.Modal.tips("保存失败!")
  34. })
  35. },
  36. /**
  37. * 获取设备设置信息
  38. */
  39. getSetInfo: function (openNum) {
  40. const params = {
  41. openNum: openNum,
  42. }
  43. APP.Get(APP.Url.getSos, params, false).then(res => {
  44. this.setData({
  45. set: res.data
  46. })
  47. })
  48. },
  49. })