jhwxapp/miniprogram/pageage/lw-index/lw-index.js

151 lines
3.1 KiB
JavaScript
Raw Normal View History

2023-08-10 01:21:29 +08:00
// pages/lw-index/lw-index.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
show: false,
projectId:'',
projectName:'' ,
loginName:'',
userName:'',
loadShow:false,
remark:''
},
onClickShow() {
this.setData({ loadShow: true });
},
onClickHide() {
this.setData({ loadShow: false });
},
showPopup() {
this.setData({ show: true });
},
onClose() {
this.setData({ show: false });
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this;
//获取缓存数据
wx.getStorage({
key: 'userinfo',
success:function(res){
that.setData({
remark:res.data.remark,
loginName:res.data.loginName,
userName:res.data.userName,
projectId:app.globalData.projectId,
projectName:app.globalData.projectName,
})
}
})
},
/**
* 人脸照片识别
* file 图片地址
* type == "" 人脸图片
*/
selectIDCardInfo:function(file,projectId){
var that = this;
that.onClickShow();
wx.uploadFile({
url: app.globalData.reqUrl+'/weixin/labour/selectUserInfoDiscern',
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
filePath: file[0],
name: 'file',
formData: {'projectId':projectId},
method:"post",
success:function(res){
that.onClickHide();
var json = JSON.parse(res.data);
if(json.code == '200'){
wx.redirectTo({
url: '../lw-gerenxinxi/lw-gerenxinxi?register=1'+'&userInfo='+encodeURIComponent(JSON.stringify(json.data)),
})
}else if(json.code == '400'){
wx.redirectTo({
url: '../lw-gerenxinxi/lw-gerenxinxi?register=2'+'&pathUrl='+encodeURIComponent(json.data),
})
}else{
app.toast(json.msg);
}
},
})
},
/**
* 跳转到考勤打卡
*/
KQDK:function(){
var _this = this;
var Type = _this.data.sourceType
wx.chooseImage({
count: 1, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: Type, // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
// 返回选定照片的本地文件路径列表tempFilePath可以作为img标签的src属性显示图片
_this.selectIDCardInfo(res.tempFilePaths,app.globalData.projectId);
}
})
},
/**
* 跳转到报表查询
*/
BBCX:function(){
wx.redirectTo({
url: '../lw-baobiaochaxun/lw-baobiaochaxun',
})
},
/**
* 跳转信息录入
*/
XXLR:function(){
wx.redirectTo({
url: '../lw-jibenxinxi/lw-jibenxinxi',
})
},
/**
* 返回更多功能
*/
goBack:function(){
wx.redirectTo({
url: '../../pages/gengduogongneng/gengduogongneng'
})
},
/**
* 退出登录
*/
TCDL:function(){
wx.clearStorageSync();
wx.setStorageSync('isReload', "1")
wx.redirectTo({
url: '../login/login',
})
},
})