You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
333 lines
7.4 KiB
JavaScript
333 lines
7.4 KiB
JavaScript
|
2 years ago
|
// pages/newIndex/index.js
|
||
|
|
const app = getApp();
|
||
|
|
Page({
|
||
|
|
/**
|
||
|
|
* 页面的初始数据
|
||
|
|
*/
|
||
|
|
data: {
|
||
|
|
isLogin: false,
|
||
|
|
isShow: false,
|
||
|
|
canShow: false,
|
||
|
|
roleOf41: false,
|
||
|
|
roleOf132: false,
|
||
|
|
managerRoleClassify: false,
|
||
|
|
topTips: false,
|
||
|
|
map: {
|
||
|
|
user40: "00",
|
||
|
|
user48: "00",
|
||
|
|
user50: "00",
|
||
|
|
numExp: "00",
|
||
|
|
num10: "00",
|
||
|
|
num100: "#",
|
||
|
|
num20: "00",
|
||
|
|
num25: "00",
|
||
|
|
num30: "00",
|
||
|
|
num40: "00",
|
||
|
|
num999: "00",
|
||
|
|
state: "00",
|
||
|
|
state2: "00",
|
||
|
|
state1: "00",
|
||
|
|
state3: "00",
|
||
|
|
},
|
||
|
|
},
|
||
|
|
toNoticeD: function (e) {
|
||
|
|
wx.navigateTo({
|
||
|
|
url: "/pages/noticeDetail/index?workOrderId=501",
|
||
|
|
});
|
||
|
|
},
|
||
|
|
getUserInfoBtn() {
|
||
|
|
app.getUserInfoBtn(this);
|
||
|
|
},
|
||
|
|
getUserInfo: function () {
|
||
|
|
var that = this;
|
||
|
|
wx.request({
|
||
|
|
url: app.globalData.ip + "/user/info",
|
||
|
|
data: {},
|
||
|
|
header: app.globalData.header,
|
||
|
|
method: "POST",
|
||
|
|
success: function (res) {
|
||
|
|
console.log(res);
|
||
|
|
if (res.data.status == 200) {
|
||
|
|
console.log(res.data.data);
|
||
|
|
app.globalData.userInfo = res.data.data.userInfo;
|
||
|
|
that.setData({
|
||
|
|
userInfo: res.data.data.userInfo,
|
||
|
|
});
|
||
|
|
} else if (res.data.status == 9999) {
|
||
|
|
//app.dialogNotLogin();
|
||
|
|
} else {
|
||
|
|
//app.showTips(that, res.data.msg);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
});
|
||
|
|
},
|
||
|
|
toCircle() {
|
||
|
|
wx.navigateTo({
|
||
|
|
url: "/pages/circle/index",
|
||
|
|
});
|
||
|
|
},
|
||
|
|
toAnnounce() {
|
||
|
|
wx.navigateTo({
|
||
|
|
url: "/pages/announce/index",
|
||
|
|
});
|
||
|
|
},
|
||
|
|
toAuto() {
|
||
|
|
wx.navigateTo({
|
||
|
|
url: "/pages/announceAuto/index",
|
||
|
|
});
|
||
|
|
},
|
||
|
|
toInform() {
|
||
|
|
wx.navigateTo({
|
||
|
|
url: "/pages/inform/index",
|
||
|
|
});
|
||
|
|
},
|
||
|
|
goProcess() {
|
||
|
|
wx.navigateTo({
|
||
|
|
url: "../myProcessNew/index?id=0&from=project",
|
||
|
|
});
|
||
|
|
},
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面加载
|
||
|
|
*/
|
||
|
|
onLoad(options) {
|
||
|
|
var that = this;
|
||
|
|
wx.showLoading({
|
||
|
|
title: "加载中...",
|
||
|
|
});
|
||
|
|
// that.getNum();
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
|
*/
|
||
|
|
onReady() {},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面显示
|
||
|
|
*/
|
||
|
|
getNum() {
|
||
|
|
var that = this;
|
||
|
|
|
||
|
|
wx.request({
|
||
|
|
url: app.globalData.ip + "/statistics/home",
|
||
|
|
method: "GET",
|
||
|
|
header: app.globalData.headers,
|
||
|
|
success: function (res) {
|
||
|
|
console.log(89);
|
||
|
|
console.log(res);
|
||
|
|
// wx.hideLoading({
|
||
|
|
// success: (res) => {},
|
||
|
|
// })
|
||
|
|
setTimeout(() => {
|
||
|
|
wx.hideLoading({
|
||
|
|
success: (res) => {},
|
||
|
|
});
|
||
|
|
that.setData({
|
||
|
|
canShow: true,
|
||
|
|
// isLogin:false
|
||
|
|
});
|
||
|
|
}, 100);
|
||
|
|
if (res.data.status != 200 || !app.globalData.isLogin) {
|
||
|
|
that.setData({
|
||
|
|
isShow: true,
|
||
|
|
// isLogin:false
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
that.setData({
|
||
|
|
// isShow:true,
|
||
|
|
// isLogin:true,
|
||
|
|
map: res.data.data ? res.data.data : "",
|
||
|
|
});
|
||
|
|
|
||
|
|
wx.setStorageSync("state1", res.data.data.state1);
|
||
|
|
console.log(wx.getStorageSync("state1Time"), new Date().getTime());
|
||
|
|
if (!app.isEmptyCheck(wx.getStorageSync("state1Time"))) {
|
||
|
|
if (that.isSameDay(wx.getStorageSync("state1Time"), new Date().getTime())) {
|
||
|
|
wx.setStorageSync("state1", 0);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
});
|
||
|
|
},
|
||
|
|
isSameDay(timeStampA, timeStampB) {
|
||
|
|
let dateA = new Date(timeStampA);
|
||
|
|
let dateB = new Date(timeStampB);
|
||
|
|
return dateA.setHours(0, 0, 0, 0) == dateB.setHours(0, 0, 0, 0);
|
||
|
|
},
|
||
|
|
onShow() {
|
||
|
|
let that = this;
|
||
|
|
// wx.showLoading({
|
||
|
|
// title: "加载中...",
|
||
|
|
// });
|
||
|
|
|
||
|
|
// wx.request({
|
||
|
|
// url: app.globalData.ip + "/checkLogin",
|
||
|
|
// method: "GET",
|
||
|
|
// header: app.globalData.headers,
|
||
|
|
// success: function (res) {
|
||
|
|
// console.log(res.data.status);
|
||
|
|
// },
|
||
|
|
|
||
|
|
// });
|
||
|
|
console.log(app.globalData);
|
||
|
|
|
||
|
|
console.log(app.globalData.isLogin);
|
||
|
|
|
||
|
|
if (app.globalData.isLogin) {
|
||
|
|
console.log(app.globalData.loginUserInfo);
|
||
|
|
|
||
|
|
this.setData({
|
||
|
|
isLogin: app.globalData.isLogin,
|
||
|
|
userId: app.globalData.userId,
|
||
|
|
userInfo: app.globalData.userInfo,
|
||
|
|
offlineManage: app.globalData.offlineManage,
|
||
|
|
roleOf41: app.globalData.roleOf41,
|
||
|
|
roleOf132: app.globalData.roleOf132,
|
||
|
|
managerRoleClassify: app.globalData.managerRoleClassify,
|
||
|
|
// isShow: true,
|
||
|
|
user: app.globalData.loginUserInfo,
|
||
|
|
});
|
||
|
|
// that.getWorkOrderHasNotRead();
|
||
|
|
//注释前
|
||
|
|
// wx.hideLoading()
|
||
|
|
console.log("=======================A");
|
||
|
|
console.log(app.globalData.userInfo);
|
||
|
|
console.log("=======================B");
|
||
|
|
if (!app.isEmptyCheck(app.globalData.user.imgSrc)) {
|
||
|
|
if (app.globalData.user.imgSrc != "" && app.globalData.user.imgSrc.startsWith("https://file.matripe.com")) {
|
||
|
|
// app.globalData.hasAva = true
|
||
|
|
this.setData({
|
||
|
|
hasAva: true,
|
||
|
|
topTips: false,
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
this.setData({
|
||
|
|
hasAva: false,
|
||
|
|
topTips: true,
|
||
|
|
});
|
||
|
|
// app.globalData.hasAva = false
|
||
|
|
}
|
||
|
|
}
|
||
|
|
that.getNum();
|
||
|
|
} else {
|
||
|
|
console.log(app.globalData.isLogin);
|
||
|
|
console.log("=======================进来了1");
|
||
|
|
// 由于 userLogin 是网络请求,可能会在 Page.onLoad 之后才返回
|
||
|
|
// 所以此处加入 callback 以防止这种情况
|
||
|
|
//app.userWechatAuth(999);
|
||
|
|
//注释前
|
||
|
|
// wx.hideLoading({
|
||
|
|
// success: (res) => {},
|
||
|
|
// })
|
||
|
|
|
||
|
|
app.userLoginCallback = (res) => {
|
||
|
|
//注释前
|
||
|
|
// wx.hideLoading()
|
||
|
|
console.log(app.globalData.isLogin);
|
||
|
|
console.log(app.globalData.roleOf41);
|
||
|
|
this.setData({
|
||
|
|
isLogin: app.globalData.isLogin,
|
||
|
|
userId: app.globalData.userId,
|
||
|
|
userInfo: app.globalData.userInfo,
|
||
|
|
offlineManage: app.globalData.offlineManage,
|
||
|
|
isShow: !app.globalData.isLogin,
|
||
|
|
roleOf41: app.globalData.roleOf41,
|
||
|
|
roleOf132: app.globalData.roleOf132,
|
||
|
|
managerRoleClassify: app.globalData.managerRoleClassify,
|
||
|
|
user: app.globalData.loginUserInfo,
|
||
|
|
});
|
||
|
|
|
||
|
|
if (app.globalData.isLogin) {
|
||
|
|
that.getNum();
|
||
|
|
// that.getWorkOrderHasNotRead();
|
||
|
|
console.log("=======================AA");
|
||
|
|
console.log(app.globalData);
|
||
|
|
console.log(app.globalData.userInfo);
|
||
|
|
console.log(app.globalData.loginUserInfo);
|
||
|
|
console.log("=======================BB");
|
||
|
|
//wx.hideLoading()
|
||
|
|
if (!app.isEmptyCheck(app.globalData.user.imgSrc)) {
|
||
|
|
if (app.globalData.user.imgSrc != "" && app.globalData.user.imgSrc.startsWith("https://file.matripe.com")) {
|
||
|
|
// app.globalData.hasAva = true
|
||
|
|
this.setData({
|
||
|
|
hasAva: true,
|
||
|
|
topTips: false,
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
this.setData({
|
||
|
|
hasAva: false,
|
||
|
|
topTips: true,
|
||
|
|
});
|
||
|
|
// app.globalData.hasAva = false
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
if (!app.isEmptyCheck(app.globalData.user.imgSrc)) {
|
||
|
|
if (app.globalData.user.imgSrc != "" && app.globalData.user.imgSrc.startsWith("https://file.matripe.com")) {
|
||
|
|
// app.globalData.hasAva = true
|
||
|
|
this.setData({
|
||
|
|
hasAva: true,
|
||
|
|
topTips: false,
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
this.setData({
|
||
|
|
hasAva: false,
|
||
|
|
topTips: true,
|
||
|
|
});
|
||
|
|
// app.globalData.hasAva = false
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
this.setData({
|
||
|
|
hasAva: false,
|
||
|
|
topTips: true,
|
||
|
|
});
|
||
|
|
// app.globalData.hasAva = false
|
||
|
|
}
|
||
|
|
// setTimeout(() => {
|
||
|
|
// that.setData({
|
||
|
|
// isShow: true
|
||
|
|
// })
|
||
|
|
|
||
|
|
// }, 100);
|
||
|
|
}
|
||
|
|
setTimeout(function () {
|
||
|
|
that.getNum();
|
||
|
|
}, 1000);
|
||
|
|
},
|
||
|
|
toPending: function () {
|
||
|
|
if (!app.globalData.isLogin) {
|
||
|
|
wx.navigateTo({
|
||
|
|
url: "/pages/login/index?path=newIndex",
|
||
|
|
});
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面隐藏
|
||
|
|
*/
|
||
|
|
onHide() {},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面卸载
|
||
|
|
*/
|
||
|
|
onUnload() {},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
|
*/
|
||
|
|
onPullDownRefresh() {},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面上拉触底事件的处理函数
|
||
|
|
*/
|
||
|
|
onReachBottom() {},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 用户点击右上角分享
|
||
|
|
*/
|
||
|
|
onShareAppMessage() {},
|
||
|
|
});
|