// pages/home/home.js
const app = getApp();//获取全局对象
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrl: "../../images/yijianqiujiuguan.png",
    
    colour: "white",
    font_weight: "400",
    font_size: "1em",

    yanwucolour: "white",
    yanwufont_weight: "400",
    yanwufont_size: "1em",

    ranqicolour: "white",
    ranqifont_weight: "400",
    ranqifont_size: "1em",

    toptabel: 'Welcome Home!',
    userName: '吴彦祖',
    userPhone: '15347232723',
    province: '华东区',
    addrDetail: '1号',
    ranqiID: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
    ranqisingl: '',
    ranqiarea: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
    ranqistate: '',
    ywID: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
    ywsingl: '',
    ywDL: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
    ywstate: '',
    ywarea: '',
    sosID: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
    sossingl: '',
    sosDL: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
    sosarea: '',
    state: "",

    userid:'',
  },
  btnclick: function () {
    wx.showToast({
      title: '已消音！',
      icon: 'none',
      duration: 2000
    })
  },
  btnclicksos: function (e) {
    this.setData({
      imgUrl: "../../images/yijianqiujiuguan.png",
      state:"正常",
      colour:"white",
      font_weight:"400",
      font_size:"1em"
    })
    wx.showToast({
      title: '已解除警报！',
      icon: 'none',
      duration: 2000
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let name = app.globalData.userid;
    this.setData({
      userid: name
    })
    wx.request({
      url: 'https://www.mpecloud.com:8443/na/iocm/devNotify/v1.1.0/detailInfo/' + app.globalData.userid, 
      header: {'content-type': 'application/json'},
      success: res => {      
        var rrr=new Array();
        rrr = res.data.user['deviceList'];
        
        //报警数据
        var jjj = new Array();
        jjj = res.data.alarms;

        var ranqi=111;
        var yanwu=222;
        var sos=333;
        if(rrr.length==3)
        {
          //燃气预警设备
          if (res.data.user['deviceList'][0]['name'] =='燃气预警设备'){
            this.setData({
              ranqiID: res.data.user['deviceList'][0]['nodeId'],
              ranqisingl: '优',
              ranqiarea: res.data.user['deviceList'][0]['installLocal'],
              ranqistate: '正常',
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId'])
              {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][0]['deviceId'])
              {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }          
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }

            }
          }
          else if (res.data.user['deviceList'][1]['name'] == '燃气预警设备') {
            this.setData({
              ranqiID: res.data.user['deviceList'][1]['nodeId'],
              ranqisingl: '优',
              ranqiarea: res.data.user['deviceList'][1]['installLocal'],
              ranqistate: '正常',
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }

            }
          }
          else if (res.data.user['deviceList'][2]['name'] == '燃气预警设备') {
            this.setData({
              ranqiID: res.data.user['deviceList'][2]['nodeId'],
              ranqisingl: '优',
              ranqiarea: res.data.user['deviceList'][2]['installLocal'],
              ranqistate: '正常',
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }

            }
          }

          //烟感设备
          if (res.data.user['deviceList'][0]['name'] == '烟感设备') {
            if (res.data.user['deviceList'][0]['attr1']<10)
            {
              res.data.user['deviceList'][0]['attr1'] = '0' + res.data.user['deviceList'][0]['attr1']
            }
            this.setData({
              ywID: res.data.user['deviceList'][0]['nodeId'],
              ywsingl: '优',
              ywDL: res.data.user['deviceList'][0]['attr1']+'%',
              ywstate: '正常',
              ywarea: res.data.user['deviceList'][0]['installLocal'],
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }

            }
          }
          else if (res.data.user['deviceList'][1]['name'] == '烟感设备') {
            if (res.data.user['deviceList'][1]['attr1'] < 10) {
              res.data.user['deviceList'][1]['attr1'] = '0' + res.data.user['deviceList'][1]['attr1']
            }
            this.setData({
              ywID: res.data.user['deviceList'][1]['nodeId'],
              ywsingl: '优',
              ywDL: res.data.user['deviceList'][1]['attr1'] + '%',
              ywstate: '正常',
              ywarea: res.data.user['deviceList'][1]['installLocal'],
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }

            }
          }
          else if (res.data.user['deviceList'][2]['name'] == '烟感设备') {
            if (res.data.user['deviceList'][2]['attr1'] < 10) {
              res.data.user['deviceList'][2]['attr1'] = '0' + res.data.user['deviceList'][2]['attr1']
            }
            this.setData({
              ywID: res.data.user['deviceList'][2]['nodeId'],
              ywsingl: '优',
              ywDL: res.data.user['deviceList'][2]['attr1']+'%',
              ywstate: '正常',
              ywarea: res.data.user['deviceList'][2]['installLocal'],
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }

            }
          }

          //一键报警设备
          if (res.data.user['deviceList'][0]['name'] == '一键报警设备') {
            if (res.data.user['deviceList'][0]['attr1'] < 10) {
              res.data.user['deviceList'][0]['attr1'] = '0' + res.data.user['deviceList'][0]['attr1']
            }
            this.setData({
              sosID: res.data.user['deviceList'][0]['nodeId'],
              sossingl: '优',
              sosDL: res.data.user['deviceList'][0]['attr1'] + '%',
              state: '正常',
              sosarea: res.data.user['deviceList'][0]['installLocal'],
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }

            }
          }
          else if (res.data.user['deviceList'][1]['name'] == '一键报警设备') {
            if (res.data.user['deviceList'][1]['attr1'] < 10) {
              res.data.user['deviceList'][1]['attr1'] = '0' + res.data.user['deviceList'][1]['attr1']
            }
            this.setData({
              sosID: res.data.user['deviceList'][1]['nodeId'],
              sossingl: '优',
              sosDL: res.data.user['deviceList'][1]['attr1'] + '%',
              state: '正常',
              sosarea: res.data.user['deviceList'][1]['installLocal'],
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }

            }
          }
          else if (res.data.user['deviceList'][2]['name'] == '一键报警设备') {
            if (res.data.user['deviceList'][2]['attr1'] < 10) {
              res.data.user['deviceList'][2]['attr1'] = '0' + res.data.user['deviceList'][2]['attr1']
            }
            this.setData({
              sosID: res.data.user['deviceList'][2]['nodeId'],
              sossingl: '优',
              sosDL: res.data.user['deviceList'][2]['attr1'] + '%',
              state: '正常',
              sosarea: res.data.user['deviceList'][2]['installLocal'],
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }

            }
          }

        }
        else if(rrr.length==2)
        {
          //燃气预警设备
          if (res.data.user['deviceList'][0]['name'] == '燃气预警设备') {
            this.setData({
              ranqiID: res.data.user['deviceList'][0]['nodeId'],
              ranqisingl: '优',
              ranqiarea: res.data.user['deviceList'][0]['installLocal'],
              ranqistate: '正常',
            })
            if (jjj.length == 2) {
              this.setData({
                ranqistate: '报警',
              })
              this.setData({
                ranqicolour: 'red',
                ranqifont_weight: '800',
                ranqifont_size: '1.5em',
              })
            }
            else if(jjj.length==1)
            {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId'])
              {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }
              
            }
            ranqi=0;
          }
          else if (res.data.user['deviceList'][1]['name'] == '燃气预警设备') {
            this.setData({
              ranqiID: res.data.user['deviceList'][1]['nodeId'],
              ranqisingl: '优',
              ranqiarea: res.data.user['deviceList'][1]['installLocal'],
              ranqistate: '正常',
            })
            if (jjj.length == 2) {
              this.setData({
                ranqistate: '报警',
              })
              this.setData({
                ranqicolour: 'red',
                ranqifont_weight: '800',
                ranqifont_size: '1.5em',
              })
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }

            }
            ranqi = 1;
          }

          //烟感设备
          if (res.data.user['deviceList'][0]['name'] == '烟感设备') {
            if (res.data.user['deviceList'][0]['attr1'] < 10) {
              res.data.user['deviceList'][0]['attr1'] = '0' + res.data.user['deviceList'][0]['attr1']
            }
            this.setData({
              ywID: res.data.user['deviceList'][0]['nodeId'],
              ywsingl: '优',
              ywDL: res.data.user['deviceList'][0]['attr1'] + '%',
              ywstate: '正常',
              ywarea: res.data.user['deviceList'][0]['installLocal'],
            })
            if (jjj.length == 2) {
              this.setData({
                
                ywstate: '报警',
                
              })
              this.setData({
                yanwucolour: 'red',
                yanwufont_weight: '800',
                yanwufont_size: '1.5em',
              })
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }

            }
            yanwu=0;
          }
          else if (res.data.user['deviceList'][1]['name'] == '烟感设备') {
            if (res.data.user['deviceList'][1]['attr1'] < 10) {
              res.data.user['deviceList'][1]['attr1'] = '0' + res.data.user['deviceList'][1]['attr1']
            }
            this.setData({
              ywID: res.data.user['deviceList'][1]['nodeId'],
              ywsingl: '优',
              ywDL: res.data.user['deviceList'][1]['attr1'] + '%',
              ywstate: '正常',
              ywarea: res.data.user['deviceList'][1]['installLocal'],
            })
            if (jjj.length == 2) {
              this.setData({
                
                ywstate: '报警',
               
              })
              this.setData({
                yanwucolour: 'red',
                yanwufont_weight: '800',
                yanwufont_size: '1.5em',
              })
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }

            }
            
            yanwu=1;
          }

          //一键报警设备
          if (res.data.user['deviceList'][0]['name'] == '一键报警设备') {
            if (res.data.user['deviceList'][0]['attr1'] < 10) {
              res.data.user['deviceList'][0]['attr1'] = '0' + res.data.user['deviceList'][0]['attr1']
            }
            this.setData({
              sosID: res.data.user['deviceList'][0]['nodeId'],
              sossingl: '优',
              sosDL: res.data.user['deviceList'][0]['attr1'] + '%',
              state: '正常',
              sosarea: res.data.user['deviceList'][0]['installLocal'],
            })
            if (jjj.length == 2) {
              this.setData({
                
                state: '报警'
              })
              this.setData({
                imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                colour: 'red',
                font_weight: '800',
                font_size: '1.5em',
              })
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  state: '报警'
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }

            }
            sos=0;
          }
          else if (res.data.user['deviceList'][1]['name'] == '一键报警设备') {
            if (res.data.user['deviceList'][1]['attr1'] < 10) {
              res.data.user['deviceList'][1]['attr1'] = '0' + res.data.user['deviceList'][1]['attr1']
            }
            this.setData({
              sosID: res.data.user['deviceList'][1]['nodeId'],
              sossingl: '优',
              sosDL: res.data.user['deviceList'][1]['attr1'] + '%',
              state: '正常',
              sosarea: res.data.user['deviceList'][1]['installLocal'],
            })
            if (jjj.length == 2) {
              this.setData({
                
                state: '报警'
              })
              this.setData({
                imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                colour: 'red',
                font_weight: '800',
                font_size: '1.5em',
              })
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  state: '报警'
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }

            }
            sos=1;
          }

          if (ranqi == 111) {
            this.setData({
              ranqiID: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ranqisingl: '',
              ranqiarea: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ranqistate: '',
            })
          }
          else if (yanwu == 222) {
            this.setData({
              ywID: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ywsingl: '',
              ywDL: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ywstate: '',
              ywarea: '',
            })
          }
          else if (sos == 333) {
            this.setData({
              sosID: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              sossingl: '',
              sosDL: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              state: '',
              sosarea: '',
            })
          }
        }
        else if(rrr.length==1)
        {
          //燃气预警设备
          if (res.data.user['deviceList'][0]['name'] == '燃气预警设备') {
            this.setData({
              ranqiID: res.data.user['deviceList'][0]['nodeId'],
              ranqisingl: '优',
              ranqiarea: res.data.user['deviceList'][0]['installLocal'],
              ranqistate: '正常',
            })
            if (jjj.length == 1) {
              this.setData({
                ranqistate: '报警',
              })
              this.setData({
                ranqicolour: 'red',
                ranqifont_weight: '800',
                ranqifont_size: '1.5em',
              })
            }
            ranqi=0;
          }

          //烟感设备
          if (res.data.user['deviceList'][0]['name'] == '烟感设备') {
            if (res.data.user['deviceList'][0]['attr1'] < 10) {
              res.data.user['deviceList'][0]['attr1'] = '0' + res.data.user['deviceList'][0]['attr1']
            }
            this.setData({
              ywID: res.data.user['deviceList'][0]['nodeId'],
              ywsingl: '优',
              ywDL: res.data.user['deviceList'][0]['attr1'] + '%',
              ywstate: '正常',
              ywarea: res.data.user['deviceList'][0]['installLocal'],
            })
            if (jjj.length == 1) {
              this.setData({
                ywstate: '报警',
              })
              this.setData({
                yanwucolour: 'red',
                yanwufont_weight: '800',
                yanwufont_size: '1.5em',
              })
            }
            yanwu=0;
          }

          //一键报警设备
          if (res.data.user['deviceList'][0]['name'] == '一键报警设备') {
            if (res.data.user['deviceList'][0]['attr1'] < 10) {
              res.data.user['deviceList'][0]['attr1'] = '0' + res.data.user['deviceList'][0]['attr1']
            }
            this.setData({
              sosID: res.data.user['deviceList'][0]['nodeId'],
              sossingl: '优秀',
              sosDL: res.data.user['deviceList'][0]['attr1'] + '%',
              state: '正常',
              sosarea: res.data.user['deviceList'][0]['installLocal'],
            })
            if (jjj.length == 1) {
              this.setData({
               
                state: '报警'
              })
              this.setData({
                imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                colour: 'red',
                font_weight: '800',
                font_size: '1.5em',
              })
            }
            sos=0;
          }

          if (ranqi == 111) {
            this.setData({
              ranqiID: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ranqisingl: '',
              ranqiarea: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ranqistate: '',
            })
          }
          else if (yanwu == 222) {
            this.setData({
              ywID: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ywsingl: '',
              ywDL: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ywstate: '',
              ywarea: '',
            })
          }
          else if (sos == 333) {
            this.setData({
              sosID: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              sossingl: '',
              sosDL: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              state: '',
              sosarea: '',
            })
          }
        }
        this.setData({
          userName: res.data.user['userName'],
          userPhone: res.data.user['userPhone'],
          province: res.data.user['province'] + res.data.user['city'],
          addrDetail: res.data.user['area'] + res.data.user['addrDetail']
        })
        
        if(0<jjj.length<4)
        {
          if(jjj.length==3)
          {
            this.setData({
              ranqistate:'报警',
              ywstate:'报警',
              state:'报警'
            })
            this.setData({
              yanwucolour: 'red',
              yanwufont_weight: '800',
              yanwufont_size: '1.5em',
            })
            this.setData({
              ranqicolour: 'red',
              ranqifont_weight: '800',
              ranqifont_size: '1.5em',
            })
            this.setData({
              imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
              colour: 'red',
              font_weight: '800',
              font_size: '1.5em',
            })
          }      
        }


      },fail:function(){
        wx.showToast({
          title: app.globalData.userid + '接口null',
          icon: 'none',
          duration: 2000
        })
      } 
      
    })
    if (this.data.state =='报警')
    {
      this.setData({
        imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
        colour: 'red',
        font_weight: '800',
        font_size: '1.5em',
      })
    }
    if (this.data.ranqistate == '报警') {
      this.setData({
        ranqicolour: 'red',
        ranqifont_weight: '800',
        ranqifont_size: '1.5em',
      })
    }
    if (this.data.ywstate == '报警') {
      this.setData({
        yanwucolour: 'red',
        yanwufont_weight: '800',
        yanwufont_size: '1.5em',
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    //setInterval(function () {      
    //  console.log(1111)
    //}, 5000) 
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  onPullDownRefresh: function () {
    this.refreshweb()
  },
  refreshweb:function()
  {
    let name = app.globalData.userid;
    this.setData({
      userid: name
    })
    wx.request({
      url: 'https://www.mpecloud.com:8443/na/iocm/devNotify/v1.1.0/detailInfo/' + app.globalData.userid,
      header: { 'content-type': 'application/json' },
      success: res => {
        var rrr = new Array();
        rrr = res.data.user['deviceList'];

        //报警数据
        var jjj = new Array();
        jjj = res.data.alarms;

        var ranqi = 111;
        var yanwu = 222;
        var sos = 333;
        if (rrr.length == 3) {
          //燃气预警设备
          if (res.data.user['deviceList'][0]['name'] == '燃气预警设备') {
            this.setData({
              ranqiID: res.data.user['deviceList'][0]['nodeId'],
              ranqisingl: '优',
              ranqiarea: res.data.user['deviceList'][0]['installLocal'],
              ranqistate: '正常',
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }

            }
          }
          else if (res.data.user['deviceList'][1]['name'] == '燃气预警设备') {
            this.setData({
              ranqiID: res.data.user['deviceList'][1]['nodeId'],
              ranqisingl: '优',
              ranqiarea: res.data.user['deviceList'][1]['installLocal'],
              ranqistate: '正常',
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }

            }
          }
          else if (res.data.user['deviceList'][2]['name'] == '燃气预警设备') {
            this.setData({
              ranqiID: res.data.user['deviceList'][2]['nodeId'],
              ranqisingl: '优',
              ranqiarea: res.data.user['deviceList'][2]['installLocal'],
              ranqistate: '正常',
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }

            }
          }

          //烟感设备
          if (res.data.user['deviceList'][0]['name'] == '烟感设备') {
            if (res.data.user['deviceList'][0]['attr1'] < 10) {
              res.data.user['deviceList'][0]['attr1'] = '0' + res.data.user['deviceList'][0]['attr1']
            }
            this.setData({
              ywID: res.data.user['deviceList'][0]['nodeId'],
              ywsingl: '优',
              ywDL: res.data.user['deviceList'][0]['attr1'] + '%',
              ywstate: '正常',
              ywarea: res.data.user['deviceList'][0]['installLocal'],
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }

            }
          }
          else if (res.data.user['deviceList'][1]['name'] == '烟感设备') {
            if (res.data.user['deviceList'][1]['attr1'] < 10) {
              res.data.user['deviceList'][1]['attr1'] = '0' + res.data.user['deviceList'][1]['attr1']
            }
            this.setData({
              ywID: res.data.user['deviceList'][1]['nodeId'],
              ywsingl: '优',
              ywDL: res.data.user['deviceList'][1]['attr1'] + '%',
              ywstate: '正常',
              ywarea: res.data.user['deviceList'][1]['installLocal'],
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }

            }
          }
          else if (res.data.user['deviceList'][2]['name'] == '烟感设备') {
            if (res.data.user['deviceList'][2]['attr1'] < 10) {
              res.data.user['deviceList'][2]['attr1'] = '0' + res.data.user['deviceList'][2]['attr1']
            }
            this.setData({
              ywID: res.data.user['deviceList'][2]['nodeId'],
              ywsingl: '优',
              ywDL: res.data.user['deviceList'][2]['attr1'] + '%',
              ywstate: '正常',
              ywarea: res.data.user['deviceList'][2]['installLocal'],
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }

            }
          }

          //一键报警设备
          if (res.data.user['deviceList'][0]['name'] == '一键报警设备') {
            if (res.data.user['deviceList'][0]['attr1'] < 10) {
              res.data.user['deviceList'][0]['attr1'] = '0' + res.data.user['deviceList'][0]['attr1']
            }
            this.setData({
              sosID: res.data.user['deviceList'][0]['nodeId'],
              sossingl: '优',
              sosDL: res.data.user['deviceList'][0]['attr1'] + '%',
              state: '正常',
              sosarea: res.data.user['deviceList'][0]['installLocal'],
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }

            }
          }
          else if (res.data.user['deviceList'][1]['name'] == '一键报警设备') {
            if (res.data.user['deviceList'][1]['attr1'] < 10) {
              res.data.user['deviceList'][1]['attr1'] = '0' + res.data.user['deviceList'][1]['attr1']
            }
            this.setData({
              sosID: res.data.user['deviceList'][1]['nodeId'],
              sossingl: '优',
              sosDL: res.data.user['deviceList'][1]['attr1'] + '%',
              state: '正常',
              sosarea: res.data.user['deviceList'][1]['installLocal'],
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }

            }
          }
          else if (res.data.user['deviceList'][2]['name'] == '一键报警设备') {
            if (res.data.user['deviceList'][2]['attr1'] < 10) {
              res.data.user['deviceList'][2]['attr1'] = '0' + res.data.user['deviceList'][2]['attr1']
            }
            this.setData({
              sosID: res.data.user['deviceList'][2]['nodeId'],
              sossingl: '优',
              sosDL: res.data.user['deviceList'][2]['attr1'] + '%',
              state: '正常',
              sosarea: res.data.user['deviceList'][2]['installLocal'],
            })
            if (jjj.length == 2) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }
              else if (res.data.alarms[1]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][2]['deviceId']) {
                this.setData({
                  state: '报警',
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }

            }
          }

        }
        else if (rrr.length == 2) {
          //燃气预警设备
          if (res.data.user['deviceList'][0]['name'] == '燃气预警设备') {
            this.setData({
              ranqiID: res.data.user['deviceList'][0]['nodeId'],
              ranqisingl: '优',
              ranqiarea: res.data.user['deviceList'][0]['installLocal'],
              ranqistate: '正常',
            })
            if (jjj.length == 2) {
              this.setData({
                ranqistate: '报警',
              })
              this.setData({
                ranqicolour: 'red',
                ranqifont_weight: '800',
                ranqifont_size: '1.5em',
              })
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }

            }
            ranqi = 0;
          }
          else if (res.data.user['deviceList'][1]['name'] == '燃气预警设备') {
            this.setData({
              ranqiID: res.data.user['deviceList'][1]['nodeId'],
              ranqisingl: '优',
              ranqiarea: res.data.user['deviceList'][1]['installLocal'],
              ranqistate: '正常',
            })
            if (jjj.length == 2) {
              this.setData({
                ranqistate: '报警',
              })
              this.setData({
                ranqicolour: 'red',
                ranqifont_weight: '800',
                ranqifont_size: '1.5em',
              })
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  ranqistate: '报警',
                })
                this.setData({
                  ranqicolour: 'red',
                  ranqifont_weight: '800',
                  ranqifont_size: '1.5em',
                })
              }

            }
            ranqi = 1;
          }

          //烟感设备
          if (res.data.user['deviceList'][0]['name'] == '烟感设备') {
            if (res.data.user['deviceList'][0]['attr1'] < 10) {
              res.data.user['deviceList'][0]['attr1'] = '0' + res.data.user['deviceList'][0]['attr1']
            }
            this.setData({
              ywID: res.data.user['deviceList'][0]['nodeId'],
              ywsingl: '优',
              ywDL: res.data.user['deviceList'][0]['attr1'] + '%',
              ywstate: '正常',
              ywarea: res.data.user['deviceList'][0]['installLocal'],
            })
            if (jjj.length == 2) {
              this.setData({

                ywstate: '报警',

              })
              this.setData({
                yanwucolour: 'red',
                yanwufont_weight: '800',
                yanwufont_size: '1.5em',
              })
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }

            }
            yanwu = 0;
          }
          else if (res.data.user['deviceList'][1]['name'] == '烟感设备') {
            if (res.data.user['deviceList'][1]['attr1'] < 10) {
              res.data.user['deviceList'][1]['attr1'] = '0' + res.data.user['deviceList'][1]['attr1']
            }
            this.setData({
              ywID: res.data.user['deviceList'][1]['nodeId'],
              ywsingl: '优',
              ywDL: res.data.user['deviceList'][1]['attr1'] + '%',
              ywstate: '正常',
              ywarea: res.data.user['deviceList'][1]['installLocal'],
            })
            if (jjj.length == 2) {
              this.setData({

                ywstate: '报警',

              })
              this.setData({
                yanwucolour: 'red',
                yanwufont_weight: '800',
                yanwufont_size: '1.5em',
              })
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  ywstate: '报警',
                })
                this.setData({
                  yanwucolour: 'red',
                  yanwufont_weight: '800',
                  yanwufont_size: '1.5em',
                })
              }

            }

            yanwu = 1;
          }

          //一键报警设备
          if (res.data.user['deviceList'][0]['name'] == '一键报警设备') {
            if (res.data.user['deviceList'][0]['attr1'] < 10) {
              res.data.user['deviceList'][0]['attr1'] = '0' + res.data.user['deviceList'][0]['attr1']
            }
            this.setData({
              sosID: res.data.user['deviceList'][0]['nodeId'],
              sossingl: '优',
              sosDL: res.data.user['deviceList'][0]['attr1'] + '%',
              state: '正常',
              sosarea: res.data.user['deviceList'][0]['installLocal'],
            })
            if (jjj.length == 2) {
              this.setData({

                state: '报警'
              })
              this.setData({
                imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                colour: 'red',
                font_weight: '800',
                font_size: '1.5em',
              })
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][0]['deviceId']) {
                this.setData({
                  state: '报警'
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }

            }
            sos = 0;
          }
          else if (res.data.user['deviceList'][1]['name'] == '一键报警设备') {
            if (res.data.user['deviceList'][1]['attr1'] < 10) {
              res.data.user['deviceList'][1]['attr1'] = '0' + res.data.user['deviceList'][1]['attr1']
            }
            this.setData({
              sosID: res.data.user['deviceList'][1]['nodeId'],
              sossingl: '优',
              sosDL: res.data.user['deviceList'][1]['attr1'] + '%',
              state: '正常',
              sosarea: res.data.user['deviceList'][1]['installLocal'],
            })
            if (jjj.length == 2) {
              this.setData({

                state: '报警'
              })
              this.setData({
                imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                colour: 'red',
                font_weight: '800',
                font_size: '1.5em',
              })
            }
            else if (jjj.length == 1) {
              if (res.data.alarms[0]['deviceId'] == res.data.user['deviceList'][1]['deviceId']) {
                this.setData({
                  state: '报警'
                })
                this.setData({
                  imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                  colour: 'red',
                  font_weight: '800',
                  font_size: '1.5em',
                })
              }

            }
            sos = 1;
          }

          if (ranqi == 111) {
            this.setData({
              ranqiID: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ranqisingl: '',
              ranqiarea: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ranqistate: '',
            })
          }
          else if (yanwu == 222) {
            this.setData({
              ywID: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ywsingl: '',
              ywDL: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ywstate: '',
              ywarea: '',
            })
          }
          else if (sos == 333) {
            this.setData({
              sosID: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              sossingl: '',
              sosDL: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              state: '',
              sosarea: '',
            })
          }
        }
        else if (rrr.length == 1) {
          //燃气预警设备
          if (res.data.user['deviceList'][0]['name'] == '燃气预警设备') {
            this.setData({
              ranqiID: res.data.user['deviceList'][0]['nodeId'],
              ranqisingl: '优',
              ranqiarea: res.data.user['deviceList'][0]['installLocal'],
              ranqistate: '正常',
            })
            if (jjj.length == 1) {
              this.setData({
                ranqistate: '报警',
              })
              this.setData({
                ranqicolour: 'red',
                ranqifont_weight: '800',
                ranqifont_size: '1.5em',
              })
            }
            ranqi = 0;
          }

          //烟感设备
          if (res.data.user['deviceList'][0]['name'] == '烟感设备') {
            if (res.data.user['deviceList'][0]['attr1'] < 10) {
              res.data.user['deviceList'][0]['attr1'] = '0' + res.data.user['deviceList'][0]['attr1']
            }
            this.setData({
              ywID: res.data.user['deviceList'][0]['nodeId'],
              ywsingl: '优',
              ywDL: res.data.user['deviceList'][0]['attr1'] + '%',
              ywstate: '正常',
              ywarea: res.data.user['deviceList'][0]['installLocal'],
            })
            if (jjj.length == 1) {
              this.setData({
                ywstate: '报警',
              })
              this.setData({
                yanwucolour: 'red',
                yanwufont_weight: '800',
                yanwufont_size: '1.5em',
              })
            }
            yanwu = 0;
          }

          //一键报警设备
          if (res.data.user['deviceList'][0]['name'] == '一键报警设备') {
            if (res.data.user['deviceList'][0]['attr1'] < 10) {
              res.data.user['deviceList'][0]['attr1'] = '0' + res.data.user['deviceList'][0]['attr1']
            }
            this.setData({
              sosID: res.data.user['deviceList'][0]['nodeId'],
              sossingl: '优秀',
              sosDL: res.data.user['deviceList'][0]['attr1'] + '%',
              state: '正常',
              sosarea: res.data.user['deviceList'][0]['installLocal'],
            })
            if (jjj.length == 1) {
              this.setData({

                state: '报警'
              })
              this.setData({
                imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
                colour: 'red',
                font_weight: '800',
                font_size: '1.5em',
              })
            }
            sos = 0;
          }

          if (ranqi == 111) {
            this.setData({
              ranqiID: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ranqisingl: '',
              ranqiarea: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ranqistate: '',
            })
          }
          else if (yanwu == 222) {
            this.setData({
              ywID: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ywsingl: '',
              ywDL: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              ywstate: '',
              ywarea: '',
            })
          }
          else if (sos == 333) {
            this.setData({
              sosID: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              sossingl: '',
              sosDL: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
              state: '',
              sosarea: '',
            })
          }
        }
        this.setData({
          userName: res.data.user['userName'],
          userPhone: res.data.user['userPhone'],
          province: res.data.user['province'] + res.data.user['city'],
          addrDetail: res.data.user['area'] + res.data.user['addrDetail']
        })

        if (0 < jjj.length < 4) {
          if (jjj.length == 3) {
            this.setData({
              ranqistate: '报警',
              ywstate: '报警',
              state: '报警'
            })
            this.setData({
              yanwucolour: 'red',
              yanwufont_weight: '800',
              yanwufont_size: '1.5em',
            })
            this.setData({
              ranqicolour: 'red',
              ranqifont_weight: '800',
              ranqifont_size: '1.5em',
            })
            this.setData({
              imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
              colour: 'red',
              font_weight: '800',
              font_size: '1.5em',
            })
          }
        }


      }, fail: function () {
        wx.showToast({
          title: app.globalData.userid + '接口null',
          icon: 'none',
          duration: 2000
        })
      }

    })
    if (this.data.state == '报警') {
      this.setData({
        imgUrl: 'http://q0cfgfdrb.bkt.clouddn.com/IMG_01252.gif',
        colour: 'red',
        font_weight: '800',
        font_size: '1.5em',
      })
    }
    if (this.data.ranqistate == '报警') {
      this.setData({
        ranqicolour: 'red',
        ranqifont_weight: '800',
        ranqifont_size: '1.5em',
      })
    }
    if (this.data.ywstate == '报警') {
      this.setData({
        yanwucolour: 'red',
        yanwufont_weight: '800',
        yanwufont_size: '1.5em',
      })
    }
    wx.stopPullDownRefresh();
  }
})