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.
398 lines
12 KiB
JavaScript
398 lines
12 KiB
JavaScript
const app = getApp();
|
|
Page({
|
|
data: {
|
|
userId: -1,
|
|
offlineManage: false,
|
|
userInfo: {},
|
|
isShow:false,
|
|
isLogin: false,
|
|
//
|
|
firstLoad: true, //页面第一次加载
|
|
workOrderHasNotRead: 0,
|
|
user: {},
|
|
},
|
|
onLoad: function() {
|
|
wx.showLoading({
|
|
title: '加载中...',
|
|
})
|
|
// that.checkWXHasUpdate();
|
|
|
|
},
|
|
onShow: function() {
|
|
|
|
|
|
|
|
var that = this;
|
|
|
|
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,
|
|
isShow:true,
|
|
user: app.globalData.loginUserInfo,
|
|
});
|
|
that.getWorkOrderHasNotRead();
|
|
wx.hideLoading()
|
|
console.log('=======================A');
|
|
console.log(app.globalData.userInfo);
|
|
console.log('=======================B');
|
|
} else {
|
|
|
|
console.log('=======================进来了1');
|
|
// 由于 userLogin 是网络请求,可能会在 Page.onLoad 之后才返回
|
|
// 所以此处加入 callback 以防止这种情况
|
|
//app.userWechatAuth(999);
|
|
app.userLoginCallback = res => {
|
|
this.setData({
|
|
isLogin: app.globalData.isLogin,
|
|
userId: app.globalData.userId,
|
|
userInfo: app.globalData.userInfo,
|
|
offlineManage: app.globalData.offlineManage,
|
|
isShow:true,
|
|
user: app.globalData.loginUserInfo,
|
|
});
|
|
that.getWorkOrderHasNotRead();
|
|
console.log('=======================AA');
|
|
console.log(app.globalData.userInfo);
|
|
console.log(app.globalData.loginUserInfo);
|
|
console.log('=======================BB');
|
|
//wx.hideLoading()
|
|
|
|
}
|
|
setTimeout(() => {
|
|
that.setData({
|
|
isShow:true
|
|
})
|
|
wx.hideLoading()
|
|
}, 1500);
|
|
}
|
|
|
|
|
|
this.setData({
|
|
receive: "立即领取",
|
|
see: "立即查看",
|
|
current: 0
|
|
});
|
|
try {
|
|
// this.getUserInfo();
|
|
//这一段的作用:用户扫码进入面试登记表页面,跳转到授权页面,会记录从哪个页面跳转过来的,如果此时没有授权,然后退出了,这个时候再进首页然后进入授权页面,就会出现授权之后跳转到记录的页面。
|
|
//现在只要进入首页,所有授权前记录的跳转页面都清空
|
|
// wx.removeStorageSync('comeFromPage');
|
|
|
|
} catch (e) {
|
|
console.log("用户进入首页,删除缓存的其它页面跳转路径出错");
|
|
}
|
|
|
|
// this.data.firstLoad = false;
|
|
},
|
|
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);
|
|
}
|
|
|
|
}
|
|
})
|
|
},
|
|
getWorkOrderHasNotRead: function() {
|
|
var that = this;
|
|
wx.request({
|
|
url: app.globalData.ip + '/workorder/getWorkOrderHasNotRead',
|
|
data: {},
|
|
header: app.globalData.header,
|
|
method: "GET",
|
|
success: function(res) {
|
|
console.log(res);
|
|
if (res.data.status == 200) {
|
|
console.log(res.data.data);
|
|
that.setData({
|
|
workOrderHasNotRead: res.data.data
|
|
});
|
|
} else if (res.data.status == 9999) {
|
|
//app.dialogNotLogin();
|
|
} else {
|
|
//app.showTips(that, res.data.msg);
|
|
}
|
|
|
|
}
|
|
})
|
|
},
|
|
myProcess:function(){
|
|
wx.navigateTo({
|
|
url: '/pages/myProcess/index',
|
|
})
|
|
|
|
},
|
|
myProcessNew:function(e){
|
|
var name = e.currentTarget.dataset.name;
|
|
wx.navigateTo({
|
|
url: '/pages/myProcessNew/index?from='+name,
|
|
})
|
|
|
|
},
|
|
|
|
toEnrollInfo:function(){
|
|
if(app.globalData.isLogin) {
|
|
wx.removeStorageSync('tempUserInfo');
|
|
wx.removeStorageSync('idInfo');
|
|
wx.removeStorageSync('src');
|
|
|
|
wx.navigateTo({
|
|
url: '/pages/enrollInfo/index',
|
|
})
|
|
} else {
|
|
wx.navigateTo({
|
|
url: '/pages/login/index?path=enrollInfo',
|
|
})
|
|
}
|
|
|
|
|
|
},
|
|
goIndexMe: function() {
|
|
wx.navigateTo({
|
|
url: '/pages/indexMe/indexMe',
|
|
})
|
|
},
|
|
toTowns: function() {
|
|
wx.navigateTo({
|
|
url: '/pages/townsman/index',
|
|
})
|
|
},
|
|
toNotice: function(e) {
|
|
var str = e.currentTarget.dataset.id
|
|
console.log(str)
|
|
wx.navigateTo({
|
|
url: '/pages/normalNotice/index?type='+str,
|
|
})
|
|
},
|
|
|
|
toNoticeD: function(e) {
|
|
wx.navigateTo({
|
|
url:'/pages/noticeDetail/index?workOrderId=501'
|
|
})
|
|
},
|
|
toTownsNoJob: function() {
|
|
wx.navigateTo({
|
|
url: '/pages/townsmanNoJob/index',
|
|
})
|
|
},
|
|
toAgentData:function(){
|
|
wx.navigateTo({
|
|
url: '/pages/agentData/index',
|
|
})
|
|
},
|
|
goWechatAuthNew: function() {
|
|
// wx.navigateTo({
|
|
// // url: '../login/index'
|
|
// url: '/pages/wechatAuthNew/index?type=6',
|
|
// })
|
|
app.userWechatAuth(6);
|
|
},
|
|
goToSwitchUser: function() {
|
|
wx.navigateTo({
|
|
url: '/pages/switchUser/index',
|
|
})
|
|
},
|
|
toPending: function() {
|
|
if (!app.globalData.isLogin) {
|
|
wx.navigateTo({
|
|
url: '/pages/login/index',
|
|
})
|
|
return;
|
|
}
|
|
wx.navigateTo({
|
|
url: '/pages/pending/index',
|
|
})
|
|
// if (app.globalData.isLogin) {
|
|
// if (app.isEmptyCheck(this.data.userInfo.tel)) {
|
|
// wx.navigateTo({
|
|
// url: '/pages/wechatAuthNew/index?type=3',
|
|
// })
|
|
// } else {
|
|
// wx.navigateTo({
|
|
// url: '/pages/user/healthCard/index',
|
|
// })
|
|
// }
|
|
// } else {
|
|
// app.userWechatAuth(3);
|
|
// }
|
|
|
|
},
|
|
toProcessed: function() {
|
|
if (!app.globalData.isLogin) {
|
|
wx.navigateTo({
|
|
url: '/pages/login/index',
|
|
})
|
|
return;
|
|
}
|
|
wx.navigateTo({
|
|
url: '/pages/processed/index',
|
|
})
|
|
|
|
// if (app.globalData.isLogin) {
|
|
// if (app.isEmptyCheck(this.data.userInfo.tel)) {
|
|
// wx.navigateTo({
|
|
// url: '/pages/wechatAuthNew/index?type=2',
|
|
// })
|
|
// } else {
|
|
// wx.navigateTo({
|
|
// url: '/pages/realNameAuth/registerAuth/authName/index',
|
|
// })
|
|
// }
|
|
// } else {
|
|
// app.userWechatAuth(2);
|
|
// }
|
|
|
|
},
|
|
toIntvRecord: function() {
|
|
|
|
if (app.globalData.isLogin) {
|
|
if (app.isEmptyCheck(this.data.userInfo.tel)) {
|
|
wx.navigateTo({
|
|
// url: '../login/index'
|
|
url: '/pages/wechatAuthNew/index?type=1',
|
|
})
|
|
} else {
|
|
wx.navigateTo({
|
|
url: '/pages/intvRecord/index',
|
|
})
|
|
}
|
|
} else {
|
|
//登录失败,重新登录
|
|
app.userWechatAuth(1);
|
|
}
|
|
|
|
},
|
|
openMiniApp: function() {
|
|
console.log('aaa');
|
|
if (app.globalData.appInfo.DGXCX_SHOW_CLOCK_APP == 0) {
|
|
wx.navigateToMiniProgram({
|
|
appId: 'wx5836990071485748',
|
|
path: 'pages/clockIn/index',
|
|
extarData: {
|
|
open: 'happy'
|
|
},
|
|
envVersion: 'release',
|
|
success(res) {
|
|
// 打开成功
|
|
console.log(res);
|
|
},
|
|
fail(res) {
|
|
console.log(res);
|
|
}
|
|
})
|
|
} else if (app.globalData.appInfo.DGXCX_SHOW_CLOCK_APP == 1) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '打卡小程序维护中',
|
|
showCancel: false,
|
|
confirmColor: "#e60012",
|
|
confirmText: '知道了',
|
|
success: function(res) {}
|
|
})
|
|
} else if (app.globalData.appInfo.DGXCX_SHOW_CLOCK_APP == 2) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '考勤打卡请到咱们公司的打卡小程序',
|
|
showCancel: false,
|
|
confirmColor: "#e60012",
|
|
confirmText: '知道了',
|
|
success: function(res) {}
|
|
})
|
|
}
|
|
},
|
|
checkWXHasUpdate: function() { //检查小程序是否有新版本
|
|
var updateManager = wx.getUpdateManager();
|
|
//检查是否存在新版本
|
|
updateManager.onCheckForUpdate(function(res) {
|
|
// 请求完新版本信息的回调
|
|
console.log("是否有新版本:" + res.hasUpdate);
|
|
if (res.hasUpdate) { //如果有新版本
|
|
// 小程序有新版本,会主动触发下载操作(无需开发者触发)
|
|
updateManager.onUpdateReady(function() { //当新版本下载完成,会进行回调
|
|
wx.showModal({
|
|
title: '更新提示',
|
|
content: '新版本已经准备好,单击确定重启应用',
|
|
showCancel: false,
|
|
success: function(res) {
|
|
if (res.confirm) {
|
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
updateManager.applyUpdate();
|
|
}
|
|
}
|
|
})
|
|
})
|
|
// 小程序有新版本,会主动触发下载操作(无需开发者触发)
|
|
updateManager.onUpdateFailed(function() { //当新版本下载失败,会进行回调
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '检查到有新版本,但下载失败,请检查网络设置',
|
|
showCancel: false,
|
|
})
|
|
})
|
|
}
|
|
});
|
|
},
|
|
closeNotice: function() {
|
|
console.log(1);
|
|
this.setData({
|
|
isShow: false
|
|
})
|
|
},
|
|
toMyAgent:function(){
|
|
wx.navigateTo({
|
|
url: '/pages/myAgentNew/index',
|
|
})
|
|
|
|
},
|
|
tocreatAgent:function(){
|
|
wx.navigateTo({
|
|
url: '/pages/creatAgent/index',
|
|
})
|
|
|
|
},
|
|
|
|
goGoodJob:function(e){
|
|
console.log(e)
|
|
wx.navigateToMiniProgram({
|
|
appId: 'wxb1f7c694803f6f00', //appid
|
|
path: '/pages/creatAgent/index?fromMiniApp=1&pmdUserId=' + app.globalData.userId,//path
|
|
extraData: { //参数
|
|
agencyUserId: app.globalData.userId
|
|
},
|
|
envVersion: 'release', //develop 开发版 trial 体验版 release 正式版
|
|
success(res) {
|
|
console.log('成功')
|
|
// 打开成功
|
|
}
|
|
})
|
|
|
|
},
|
|
toHelpSignUp:function(){
|
|
wx.navigateTo({
|
|
url: '/pages/helpSignUp/index',
|
|
})
|
|
},
|
|
}) |