broadcast.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. const APP = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. time: "点击选择时间",
  8. typeIdx: 0,
  9. typeList: [{
  10. id: 1,
  11. name: "实时播报"
  12. },
  13. // {
  14. // id: 0,
  15. // name: "固定播报"
  16. // }
  17. ],
  18. weekList: [{
  19. id: 7,
  20. name: "日"
  21. }, {
  22. id: 1,
  23. name: "一"
  24. }, {
  25. id: 2,
  26. name: "二"
  27. }, {
  28. id: 3,
  29. name: "三"
  30. }, {
  31. id: 4,
  32. name: "四"
  33. }, {
  34. id: 5,
  35. name: "五"
  36. }, {
  37. id: 6,
  38. name: "六"
  39. }]
  40. },
  41. /**
  42. * 生命周期函数--监听页面加载
  43. */
  44. onLoad: function (options) {},
  45. /**
  46. * 监听-时间选择切换
  47. */
  48. bindTimeChange: function (event) {
  49. this.setData({
  50. time: event.detail.value,
  51. })
  52. },
  53. /**
  54. * 监听-播报类型切换
  55. */
  56. bindTypeChange: function (event) {
  57. this.setData({
  58. typeIdx: event.detail.value,
  59. })
  60. },
  61. /**
  62. * 发送播报消息
  63. */
  64. setNews: function (form) {
  65. const data = {
  66. deviceId: APP.getCurrentDevice().deviceId,
  67. newsType: this.data.typeList[this.data.typeIdx].id,
  68. newTime: "",
  69. news: form.detail.value.news
  70. }
  71. if (data.newsType == 0) {
  72. if (this.data.time === "点击选择时间") {
  73. APP.Modal.tips("时间不为空!")
  74. return;
  75. }
  76. data.newsTime = this.data.time + ":00";
  77. }
  78. if (data.news == null || data.news == "") {
  79. APP.Modal.tips("播报内容不为空!")
  80. return;
  81. }
  82. APP.Post(APP.Url.setNews, data).then(res => {
  83. APP.Modal.tips("设置成功!")
  84. }).catch(res => {
  85. console.log(res)
  86. APP.Modal.tips("设置失败!")
  87. })
  88. },
  89. })