yangyin
2024-11-13 70b4dc4a2101ffd3e88395ee0adf22435748c3ff
app.js
@@ -8,7 +8,7 @@
    // console.log(this.globalData.sysInfo);
    //获取当前设备信息
    this.getDeviceInfo();
  //  this.getAllAlarmList()
    this.globalData.timer = null
    //获取当前用户信息
    var getUserInfoFromCache = wx.getStorageSync('LoginUserInfo');
    // console.log(getUserInfoFromCache);
@@ -19,14 +19,11 @@
      this.globalData.userInfo = null;
    }
  },
  //获取报警记录
  getAllAlarmList() {
    var that=this
    if(that.globalData.timer){
      clearInterval(that.globalData.timer)
      that.globalData.timer = null
    }
    var that = this
    // that.cancelTimer()
    Request({
      url: Constant.BASE_SERVER_URL + 'Monitor/Value/Alarm/Record/Std/GetFluzzyPageList@V1.0',
      method: 'GET',
@@ -43,12 +40,12 @@
      }, //请求失败
      success: (res) => {
        var result = res.data
        if(res.statusCode==404){
        if (res.statusCode == 404) {
          wx.showModal({
            title: '',
            content: '通讯失败',
          })
          that.globalData.alarmTotal=0
          that.globalData.alarmTotal = 0
          return
        }
        if (result.Code != 0) {
@@ -59,47 +56,72 @@
          })
          return;
        }
        if (result.Data.List == null && result.Data.Total == 0) {
          // wx.showModal({
          //   title: '暂无报警数据1',
          // });
          return
        // result.Data.Total=1
        if (result.Data.Total == 0) {
          that.globalData.monitorDataTimeOut = false
          that.startTimer()
          return;
        }
        that.getMonitorDialog()
        that.globalData.timer = setInterval(() => {
          that.getMonitorDialog()
        }, 300000)
        that.startTimer()
      }
    })
  },
  //初始化时打开报警消息通知弹窗
  getMonitorDialog() {
    var that=this
    if(that.globalData.monitorModalName) return
      wx.showModal({
        title: '消息报警',
        content: '您有新的报警消息需要处理,点击前往报警处理查看',
          success: function (res) {
            if (res.confirm) {
              that.workMonitorSure()
              that.globalData.monitorModalName=false
            } else {
              that.globalData.monitorModalName=false
            }
          }
        })
        that.globalData.monitorModalName=true
    var that = this
    if (that.globalData.monitorModalName) return
    wx.showModal({
      title: '消息报警',
      content: '您有新的报警消息需要处理,点击前往报警处理查看',
      success: function (res) {
        if (res.confirm) {
          that.workMonitorSure()
          that.globalData.monitorModalName = true
          that.globalData.monitorDataTimeOut = true
        } else {
          that.globalData.monitorModalName = false
          that.globalData.monitorDataTimeOut = false
          that.startTimer()
        }
      }
    })
    that.globalData.monitorModalName = true
    that.globalData.monitorDataTimeOut = true
    that.cancelTimer()
  },
  onStartAlarm(){
    this.globalData.monitorDataTimeOut = false
    this.globalData.monitorModalName = false
    this.startTimer()
  },
  onReset() {
    this.globalData.monitorDataTimeOut = true
    this.cancelTimer()
  },
  startTimer() {
    var that = this
    that.cancelTimer()
    if (that.globalData.monitorDataTimeOut) return
    that.globalData.timer = setInterval(() => {
      that.getAllAlarmList()
    }, 300000)
  },
  cancelTimer() {
    var that = this;
    // 取消定时器
    if (that.globalData.timer) {
      clearTimeout(that.globalData.timer);
      that.globalData.timer = null;
    }
  },
  //报警消息通知跳转到报警处理
  workMonitorSure() {
    var that=this
    wx.navigateTo({
      url: '/other/alarm/index',
    })
    if(that.globalData.timer){
      clearInterval(that.globalData.timer)
    }
    this.cancelTimer()
  },
  // 获取当前设备信息
  getDeviceInfo: function (callback) {
@@ -215,5 +237,7 @@
    alarmList: [],
    alarmTotal: 0,
    monitorModalName: false, //是否显示报警提示
    monitorDataTimeOut: false,
    mockData: []
  }
})