467 lines
11 KiB
JavaScript
467 lines
11 KiB
JavaScript
// pages/main/main.js
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
yhtodonum: 0,
|
|
zytodonum: 0,
|
|
noread: 0,
|
|
dqdnum: 0,
|
|
dknum: 0,
|
|
gcnoread: 0,
|
|
wsnoread: 0,
|
|
jytodonum: 0,
|
|
tasknum: 0,
|
|
checknum:0,
|
|
sbtodonum:0,
|
|
yhgznum:0,
|
|
serverUrl: getApp().globalData.serverUrl,
|
|
isGjjt:false,
|
|
// Banner数据
|
|
images: [],
|
|
// 是否显示面板指示点
|
|
indicatorDots: true,
|
|
// 滑动方向是否为纵向
|
|
vertical: false,
|
|
// 自动切换
|
|
autoplay: true,
|
|
// 采用衔接滑动
|
|
circular: true,
|
|
// 自动切换时间间隔2s
|
|
interval: 8000,
|
|
// 滑动动画时长0.5s
|
|
duration: 1500,
|
|
// 前边距,可用于露出前一项的一小部分,接受 px 和 rpx 值
|
|
previousMargin: 0,
|
|
// 后边距,可用于露出后一项的一小部分,接受 px 和 rpx 值
|
|
nextMargin: 0,
|
|
msgList: [
|
|
{ title: "欢迎使用安全生产管理工具!" },{title:"每晚10-11点不定期更新,请尽量不在此时间使用"}]
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
var that = this
|
|
let images = [
|
|
that.data.serverUrl + 'media/banner/1.jpg',
|
|
that.data.serverUrl + 'media/banner/2.jpg',
|
|
that.data.serverUrl + 'media/banner/3.jpg',
|
|
that.data.serverUrl + 'media/banner/4.jpg',
|
|
]
|
|
that.setData({
|
|
images: images
|
|
})
|
|
},
|
|
callback: function () {
|
|
var that = this;
|
|
if (getApp().globalData.userInfo.companyid == 2681) {
|
|
this.setData({
|
|
isGjjt: true,
|
|
user__name:getApp().globalData.userInfo.name,
|
|
})
|
|
}
|
|
// let openid = getApp().globalData.userInfo.openid;
|
|
// if (openid == null && getApp().globalData.userInfo.companyid != 2681) {
|
|
// wx.showModal({
|
|
// title: '温馨提示',
|
|
// content: '您还未绑定通知,\n无法接收微信公众号提醒!',
|
|
// cancelText: '不用了',
|
|
// confirmText: '去绑定',
|
|
// success(res) {
|
|
// if (res.confirm) {
|
|
// wx.navigateTo({
|
|
// url: '/pages/bindwxtz/index',
|
|
// })
|
|
// } else if (res.cancel) {
|
|
// }
|
|
// }
|
|
// })
|
|
// }
|
|
this.getNew()
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
var that = this
|
|
that.getNew()
|
|
// if ((getApp().globalData.sessionId != null) && (getApp().globalData.sessionId.indexOf('sessionid') != -1)) {
|
|
// that.getNew()
|
|
// }
|
|
// else {
|
|
// getApp().mplogin()
|
|
// }
|
|
if (getApp().globalData.userInfo.companyid == 2681) {
|
|
this.setData({
|
|
isGjjt: true,
|
|
user__name: getApp().globalData.userInfo.name,
|
|
msgList: [
|
|
{ title: "知识竞赛火热进行中!" },]
|
|
})
|
|
}
|
|
|
|
|
|
|
|
},
|
|
getNew:function(){
|
|
this.getnoread()
|
|
this.getyhtodonum()
|
|
this.getzytodonum()
|
|
this.getpxqdnum()
|
|
this.getdknum() //待考
|
|
this.getgcnoreadnum()
|
|
this.getwsnoreadnum()//未遂未读
|
|
this.getjytodonum()
|
|
this.gettasknum()
|
|
this.getchecknum()//检查任务
|
|
this.getsbycnum()
|
|
this.getyhgznum()
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
},
|
|
getnoread: function () {
|
|
wx.request({
|
|
url: this.data.serverUrl + 'api/notice?a=noreadnum',
|
|
header: {
|
|
'content-type': 'application/json', // 默认值
|
|
'Cookie': getApp().globalData.sessionId,
|
|
},
|
|
data: {},
|
|
success: res => {
|
|
if (res.statusCode === 200) {
|
|
//console.log(res.data)
|
|
this.setData({
|
|
noread: res.data.noread,
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
getyhtodonum: function () {
|
|
var that = this
|
|
//获取隐患待办数目
|
|
wx.request({
|
|
url: this.data.serverUrl + 'troublehandle?a=todonum',
|
|
header: {
|
|
'content-type': 'application/json', // 默认值
|
|
'Cookie': getApp().globalData.sessionId,
|
|
},
|
|
data: {},
|
|
success: res => {
|
|
if (res.statusCode === 200) {
|
|
//console.log(res.data)
|
|
this.setData({
|
|
yhtodonum: res.data.todonum,
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
getzytodonum: function () {
|
|
var that = this
|
|
//获取作业待办数目
|
|
wx.request({
|
|
url: this.data.serverUrl + 'api/operation?a=todonum',
|
|
header: {
|
|
'content-type': 'application/json', // 默认值
|
|
'Cookie': getApp().globalData.sessionId,
|
|
},
|
|
data: {},
|
|
success: res => {
|
|
if (res.statusCode === 200) {
|
|
//console.log(res.data)
|
|
this.setData({
|
|
zytodonum: res.data.todonum,
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
getpxqdnum: function () {
|
|
var that = this
|
|
//获取待签到培训
|
|
wx.request({
|
|
url: this.data.serverUrl + 'pxhandle?a=dqdnum',
|
|
header: {
|
|
'content-type': 'application/json', // 默认值
|
|
'Cookie': getApp().globalData.sessionId,
|
|
},
|
|
data: {},
|
|
success: res => {
|
|
if (res.statusCode === 200) {
|
|
//console.log(res.data)
|
|
this.setData({
|
|
dqdnum: res.data.dqdnum,
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
getdknum: function () {
|
|
var that = this
|
|
//获取待考
|
|
wx.request({
|
|
url: this.data.serverUrl + 'api/examtest?a=dknum',
|
|
header: {
|
|
'content-type': 'application/json', // 默认值
|
|
'Cookie': getApp().globalData.sessionId,
|
|
},
|
|
data: {},
|
|
success: res => {
|
|
if (res.statusCode === 200) {
|
|
//console.log(res.data)
|
|
this.setData({
|
|
dknum: res.data.dknum,
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
getgcnoreadnum: function () {
|
|
var that = this
|
|
//获取待考
|
|
wx.request({
|
|
url: this.data.serverUrl + 'gchandle?a=noreadnum',
|
|
header: {
|
|
'content-type': 'application/json', // 默认值
|
|
'Cookie': getApp().globalData.sessionId,
|
|
},
|
|
data: {},
|
|
success: res => {
|
|
if (res.statusCode === 200) {
|
|
//console.log(res.data)
|
|
this.setData({
|
|
gcnoread: res.data.noread,
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
getwsnoreadnum: function () {
|
|
var that = this
|
|
//获取待考
|
|
wx.request({
|
|
url: this.data.serverUrl + 'api/miss?a=noreadnum',
|
|
header: {
|
|
'content-type': 'application/json', // 默认值
|
|
'Cookie': getApp().globalData.sessionId,
|
|
},
|
|
data: {},
|
|
success: res => {
|
|
if (res.statusCode === 200) {
|
|
//console.log(res.data)
|
|
this.setData({
|
|
wsnoread: res.data.noread,
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
getjytodonum: function () {
|
|
var that = this
|
|
//获取待考
|
|
wx.request({
|
|
url: this.data.serverUrl + 'api/suggest?a=todonum',
|
|
header: {
|
|
'content-type': 'application/json', // 默认值
|
|
'Cookie': getApp().globalData.sessionId,
|
|
},
|
|
data: {},
|
|
success: res => {
|
|
if (res.statusCode === 200) {
|
|
//console.log(res.data)
|
|
this.setData({
|
|
jytodonum: res.data.todonum,
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
gettasknum: function () {
|
|
var that = this
|
|
//获取待考
|
|
wx.request({
|
|
url: this.data.serverUrl + 'api/riskacttask?a=todonum2',
|
|
header: {
|
|
'content-type': 'application/json', // 默认值
|
|
'Cookie': getApp().globalData.sessionId,
|
|
},
|
|
data: {},
|
|
success: res => {
|
|
if (res.statusCode === 200) {
|
|
//console.log(res.data)
|
|
this.setData({
|
|
tasknum: res.data.todonum,
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
getchecknum: function () {
|
|
var that = this
|
|
//获取待考
|
|
wx.request({
|
|
url: this.data.serverUrl + 'api/checkproject?a=listself',
|
|
header: {
|
|
'content-type': 'application/json', // 默认值
|
|
'Cookie': getApp().globalData.sessionId,
|
|
},
|
|
data: {},
|
|
success: res => {
|
|
if (res.statusCode === 200) {
|
|
//console.log(res.data)
|
|
this.setData({
|
|
checknum: res.data.total,
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
getsbycnum: function () {
|
|
var that = this
|
|
//获取待办异常
|
|
wx.request({
|
|
url: this.data.serverUrl + 'api/inspectitem?a=listtodo',
|
|
header: {
|
|
'content-type': 'application/json', // 默认值
|
|
'Cookie': getApp().globalData.sessionId,
|
|
},
|
|
data: {},
|
|
success: res => {
|
|
if (res.statusCode === 200) {
|
|
//console.log(res.data)
|
|
this.setData({
|
|
sbtodonum: res.data.total,
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
getyhgznum: function () {
|
|
var that = this
|
|
//获取待办异常
|
|
wx.request({
|
|
url: this.data.serverUrl + 'api/troublefollowtask?a=mytodonum',
|
|
header: {
|
|
'content-type': 'application/json', // 默认值
|
|
'Cookie': getApp().globalData.sessionId,
|
|
},
|
|
data: {},
|
|
success: res => {
|
|
if (res.statusCode === 200) {
|
|
this.setData({
|
|
yhgznum: res.data.mytodonum,
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
taptest: function () {
|
|
if (getApp().globalData.userInfo.perms != undefined) {
|
|
if (getApp().globalData.userInfo.perms.indexOf(25) != -1) {//考试功能
|
|
wx.navigateTo({
|
|
url: '/pages/examtest/index',
|
|
})
|
|
} else {
|
|
wx.showModal({
|
|
content: '该功能如需开通,请查看公告或联系管理员!',
|
|
showCancel: false
|
|
})
|
|
}
|
|
} else {
|
|
wx.showModal({
|
|
content: '加载中,请稍后。。',
|
|
showCancel: false
|
|
})
|
|
}
|
|
},
|
|
tapexercise: function () {
|
|
if (this.data.isGjjt) { //练习功能
|
|
wx.showModal({
|
|
content: '本次活动该功能不便访问!',
|
|
showCancel: false
|
|
})
|
|
} else if (getApp().globalData.userInfo.perms != undefined) {
|
|
if (getApp().globalData.userInfo.perms.indexOf(25) != -1) {//考试功能
|
|
wx.navigateTo({
|
|
url: '/pages/exercise/index',
|
|
})
|
|
} else {
|
|
wx.showModal({
|
|
content: '该功能如需开通,请查看公告或联系管理员!',
|
|
showCancel: false
|
|
})
|
|
}
|
|
}
|
|
else {
|
|
wx.showModal({
|
|
content: '加载中,请稍后。。',
|
|
showCancel: false
|
|
})
|
|
}
|
|
},
|
|
tapinspect: function () {
|
|
if (getApp().globalData.userInfo.perms != undefined) {
|
|
if (getApp().globalData.userInfo.perms.indexOf(35) != -1) {//设备巡检
|
|
wx.navigateTo({
|
|
url: '/pages/inspect/index',
|
|
})
|
|
} else {
|
|
wx.showModal({
|
|
content: '该功能如需开通,请查看公告或联系管理员!',
|
|
showCancel: false
|
|
})
|
|
}
|
|
}
|
|
else {
|
|
wx.showModal({
|
|
content: '加载中,请稍后。。',
|
|
showCancel: false
|
|
})
|
|
}
|
|
},
|
|
|
|
}) |