const APP = getApp(); Page({ /** * 页面的初始数据 */ data: { time: "点击选择时间", typeIdx: 0, typeList: [{ id: 1, name: "实时播报" }, // { // id: 0, // name: "固定播报" // } ], weekList: [{ id: 7, name: "日" }, { id: 1, name: "一" }, { id: 2, name: "二" }, { id: 3, name: "三" }, { id: 4, name: "四" }, { id: 5, name: "五" }, { id: 6, name: "六" }] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) {}, /** * 监听-时间选择切换 */ bindTimeChange: function (event) { this.setData({ time: event.detail.value, }) }, /** * 监听-播报类型切换 */ bindTypeChange: function (event) { this.setData({ typeIdx: event.detail.value, }) }, /** * 发送播报消息 */ setNews: function (form) { const data = { deviceId: APP.getCurrentDevice().deviceId, newsType: this.data.typeList[this.data.typeIdx].id, newTime: "", news: form.detail.value.news } if (data.newsType == 0) { if (this.data.time === "点击选择时间") { APP.Modal.tips("时间不为空!") return; } data.newsTime = this.data.time + ":00"; } if (data.news == null || data.news == "") { APP.Modal.tips("播报内容不为空!") return; } APP.Post(APP.Url.setNews, data).then(res => { APP.Modal.tips("设置成功!") }).catch(res => { console.log(res) APP.Modal.tips("设置失败!") }) }, })