// pages/home/homefree.js const app = getApp();//获取全局对象 Page({ /** * 页面的初始数据 */ data: { imgUrl: "../../images/yijianqiujiuguan.png", toptabel: 'Welcome Home!', userName: '', userPhone: '', province: '', addrDetail: '', unitName:'', items: [], userid: '', code:'1', }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.refreshweb2() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.refreshweb2(); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, onPullDownRefresh: function () { this.refreshweb2(); wx.stopPullDownRefresh(); }, refreshweb2: function () { wx.login({ //获取code success: res=> { this.setData({ code:res.code, }) console.log(this.data.code) //获取OpenID wx.request({ url: 'https://www.mpecloud.com:8443/na/iocm/devNotify/v1.1.0/getOpenId/' + this.data.code, header: { 'content-type': 'application/json' }, success: res => { console.log(res.data) if (res.data.message == 'success') { wx.request({ url: 'https://www.mpecloud.com:8443/na/iocm/devNotify/v1.1.0/detailInfo/' + res.data.openid, header: { 'content-type': 'application/json' }, success: res => { var lenth =999999999; console.log(app.globalData.userid); for(var x = 0;x { console.log(res.data.code) if (res.data.code == 'Ok') { wx.showToast({ title: '持续静音已成功!', icon: 'none', duration: 2000 }) } else { wx.showToast({ title: '操作失败!', icon: 'none', duration: 2000 }) } }, fail: function () { wx.showToast({ title: '操作失败!', icon: 'none', duration: 2000 }) } }) }, btnclick_chefang: function (e) { var that = this; wx.request({ url: 'https://www.mpecloud.com:8443/na/iocm/devNotify/v1.1.0/command/' + e.target.id + '?command=CF', header: { 'content-type': 'application/json' }, success: res => { if (res.data.code =='Ok') { wx.showToast({ title: '撤防已成功!', icon: 'none', duration: 2000 }) } else { wx.showToast({ title: '操作失败!', icon: 'none', duration: 2000 }) } }, fail: function () { wx.showToast({ title: '操作失败!', icon: 'none', duration: 2000 }) } }) }, btnclick_cancelchefang: function (e) { var that = this; wx.request({ url: 'https://www.mpecloud.com:8443/na/iocm/devNotify/v1.1.0/command/' + e.target.id + '?command=BF', header: { 'content-type': 'application/json' }, success: res => { if (res.data.code == 'Ok') { wx.showToast({ title: '取消撤防已成功!', icon: 'none', duration: 2000 }) } else { wx.showToast({ title: '操作失败!', icon: 'none', duration: 2000 }) } }, fail: function () { wx.showToast({ title: '操作失败!', icon: 'none', duration: 2000 }) } }) } })