//app.js
|
import Request from "./utils/api"
|
var Constant = require('./utils/constant');
|
App({
|
onLaunch: function () {
|
//var that = this;
|
console.log(222)
|
//获取当前系统信息
|
this.globalData.sysInfo = wx.getSystemInfoSync();
|
// console.log(this.globalData.sysInfo);
|
//获取当前设备信息
|
this.getDeviceInfo();
|
this.getAllAlarmList()
|
//获取当前用户信息
|
var getUserInfoFromCache = wx.getStorageSync('LoginUserInfo');
|
// console.log(getUserInfoFromCache);
|
if (getUserInfoFromCache) {
|
//
|
this.globalData.userInfo = getUserInfoFromCache;
|
} else {
|
this.globalData.userInfo = null;
|
}
|
},
|
|
//获取报警记录
|
getAllAlarmList() {
|
var that=this
|
if(that.globalData.timer){
|
clearInterval(that.globalData.timer)
|
}
|
Request({
|
url: Constant.BASE_SERVER_URL + 'Monitor/Value/Alarm/Record/Std/GetFluzzyPageList@V1.0',
|
method: 'GET',
|
data: {
|
AlarmStatus: 0,
|
PageIndex: that.globalData.PageIndex,
|
PageSize: that.globalData.PageSize,
|
},
|
success: (res) => {
|
var result = res.data
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '提示',
|
content: result.Message,
|
showCancel: false,
|
})
|
return;
|
}
|
if (result.Data.List == null && result.Data.Total == 0) {
|
wx.showModal({
|
title: '暂无报警数据',
|
});
|
return
|
}
|
if(that.globalData.monitorModalName) return
|
that.getMonitorDialog()
|
that.globalData.monitorModalName=true
|
}
|
})
|
},
|
//初始化时打开报警消息通知弹窗
|
getMonitorDialog() {
|
var that=this
|
that.globalData.timer = setInterval(() => {
|
wx.showModal({
|
title: '消息报警',
|
content: '您有新的报警消息需要处理,点击前往报警处理查看',
|
success: function (res) {
|
if (res.confirm) {
|
that.workMonitorSure()
|
that.globalData.monitorModalName=false
|
} else {
|
that.globalData.monitorModalName=false
|
}
|
}
|
})
|
}, 300000)
|
},
|
//报警消息通知跳转到报警处理
|
workMonitorSure() {
|
var that=this
|
wx.navigateTo({
|
url: '/other/alarm/index',
|
})
|
if(that.globalData.timer){
|
clearInterval(that.globalData.timer)
|
}
|
},
|
// 获取当前设备信息
|
getDeviceInfo: function (callback) {
|
var that = this;
|
//
|
if (this.globalData.deviceInfo) {
|
typeof callback == "function" && callback(this.globalData.deviceInfo)
|
} else {
|
wx.getSystemInfo({
|
success: function (res) {
|
that.globalData.deviceInfo = res;
|
var e = res
|
//获取屏幕尺寸,放到全局结构中
|
that.globalData.screenSize = {
|
height: res.windowHeight,
|
width: res.windowWidth
|
};
|
typeof callback == "function" && callback(that.globalData.deviceInfo)
|
//自定义顶部custom组件的属性
|
that.globalData.StatusBar = e.statusBarHeight;
|
let capsule = wx.getMenuButtonBoundingClientRect();
|
if (capsule) {
|
that.globalData.Custom = capsule;
|
that.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
|
} else {
|
that.globalData.CustomBar = e.statusBarHeight + 50;
|
}
|
}
|
})
|
}
|
},
|
getSystemInfo: function () {
|
wx.getSystemInfo({ //获取系统信息
|
success: e => {
|
this.globalData.StatusBar = e.statusBarHeight;
|
let capsule = wx.getMenuButtonBoundingClientRect();
|
if (capsule) {
|
this.globalData.Custom = capsule;
|
this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
|
} else {
|
this.globalData.CustomBar = e.statusBarHeight + 50;
|
}
|
}
|
})
|
},
|
getModel: function () {
|
return this.globalData.sysInfo["model"]
|
},
|
getVersion: function () {
|
return this.globalData.sysInfo["version"]
|
},
|
getSystem: function () {
|
return this.globalData.sysInfo["system"]
|
},
|
getPlatform: function () {
|
return this.globalData.sysInfo["platform"]
|
},
|
getSDKVersion: function () {
|
return this.globalData.sysInfo["SDKVersion"]
|
},
|
getWindowWidth: function () {
|
return this.globalData.sysInfo["windowWidth"]
|
},
|
getWindowHeight: function () {
|
return this.globalData.sysInfo["windowHeight"]
|
},
|
|
|
|
//检测用户是否登陆
|
onCheckLogin: function (cbSuccess, cbFail) {
|
var that = this;
|
var userInfo = that.globalData.userInfo;
|
//console.log(userInfo)
|
if (!userInfo) {
|
wx.navigateTo({
|
url: '/login/login/index',
|
});
|
}
|
return;
|
wx.getStorage({ //如果没有缓存内容直接 跳转 登录页授权
|
key: 'LoginUserInfo',
|
success: function (res) {
|
//console.log("用户信息来源缓存",res)
|
that.globalData.userInfo = res.data;
|
//wx.redirectTo({ url: '/Start/author/index', })
|
//if (res.data) {
|
//return;
|
//} else {
|
//return;
|
//}
|
},
|
fail: function (res) {
|
console.log(res)
|
//if (res.errMsg == "getStorage:fail data not found") {
|
//wx.redirectTo({ url: '/Start/author/index', })
|
//}
|
return;
|
},
|
})
|
},
|
globalData: {
|
// 设备信息,主要用于获取屏幕尺寸而做适配
|
deviceInfo: null,
|
//系统信息
|
sysInfo: null,
|
// 用户信息
|
userInfo: null, //null/!null
|
screenSize: null, //全局的屏幕尺寸,已经去掉了上边的标题栏
|
timer: null,
|
PageIndex: 1,
|
PageSize: 9,
|
alarmList: [],
|
alarmTotal: 0,
|
monitorModalName: false, //是否显示报警提示
|
}
|
})
|