468 lines
14 KiB
JavaScript
468 lines
14 KiB
JavaScript
|
const app = getApp()
|
|||
|
// pages/saft-education-user-bind/index.js
|
|||
|
Page({
|
|||
|
|
|||
|
/**
|
|||
|
* 页面的初始数据
|
|||
|
*/
|
|||
|
data: {
|
|||
|
loadShow:false,
|
|||
|
phoneNumber:"",
|
|||
|
cardId:"",
|
|||
|
companyName:"",
|
|||
|
typeWordName:"",
|
|||
|
userName:"",
|
|||
|
companyId:"",
|
|||
|
typeWord:"",
|
|||
|
manageSign:"",
|
|||
|
educationLevelList:[],
|
|||
|
educationLevel:'',
|
|||
|
emergencyName:'',
|
|||
|
emergencyPhone:'',
|
|||
|
szhprojectId:"",
|
|||
|
smzProjectId:"",
|
|||
|
cultureLevel:'',
|
|||
|
specialFlag:'',
|
|||
|
sex:'',
|
|||
|
idCardFront:'',
|
|||
|
//验证方式(1手机号,2身份证)
|
|||
|
authentication:"1",
|
|||
|
authenticationList:[
|
|||
|
{
|
|||
|
"id":"1",
|
|||
|
"text":'手机号'
|
|||
|
},
|
|||
|
{
|
|||
|
"id":"2",
|
|||
|
"text":'身份证'
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
/**
|
|||
|
*
|
|||
|
* @param {*} e
|
|||
|
*/
|
|||
|
onSelectAuthentication(e) {
|
|||
|
if(e.detail.id == "1") {
|
|||
|
this.setData({
|
|||
|
authentication: e.detail.id,
|
|||
|
cardId:"",
|
|||
|
phoneNumber:'',
|
|||
|
companyName:'',
|
|||
|
userName:'',
|
|||
|
emergencyName:'',
|
|||
|
emergencyPhone:'',
|
|||
|
manageSign:"",
|
|||
|
educationLevel:1,
|
|||
|
cultureLevel:'小学'
|
|||
|
})
|
|||
|
} else {
|
|||
|
this.setData({
|
|||
|
authentication: e.detail.id,
|
|||
|
cardId:'',
|
|||
|
phoneNumber:'',
|
|||
|
companyName:'',
|
|||
|
userName:'',
|
|||
|
emergencyName:'',
|
|||
|
emergencyPhone:'',
|
|||
|
manageSign:"",
|
|||
|
educationLevel:1,
|
|||
|
cultureLevel:'小学'
|
|||
|
})
|
|||
|
}
|
|||
|
console.log(this.data.educationLevel)
|
|||
|
},
|
|||
|
/**
|
|||
|
* 电话号码失去焦点
|
|||
|
*/
|
|||
|
inputPhoneNumber(e){
|
|||
|
let {value} = e.detail
|
|||
|
if(value >= 11){
|
|||
|
this.getUserInfo(value,'')
|
|||
|
}
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 身份证号失去焦点
|
|||
|
*/
|
|||
|
inputCardId(e){
|
|||
|
let {value} = e.detail
|
|||
|
if(value.length >= 18){
|
|||
|
this.getUserInfo('',value)
|
|||
|
}
|
|||
|
|
|||
|
},
|
|||
|
/**
|
|||
|
* 文化程度变化
|
|||
|
*/
|
|||
|
onSelectEducationLevel(e) {
|
|||
|
console.log(e)
|
|||
|
this.setData({
|
|||
|
educationLevel: e.detail.id,
|
|||
|
})
|
|||
|
},
|
|||
|
/**
|
|||
|
* 紧急联系人
|
|||
|
*/
|
|||
|
onEmergencyName(e) {
|
|||
|
this.setData({
|
|||
|
emergencyName: e.detail.value
|
|||
|
})
|
|||
|
},
|
|||
|
/**
|
|||
|
* 紧急联系人联系方式
|
|||
|
*/
|
|||
|
onEmergencyPhone(e) {
|
|||
|
this.setData({
|
|||
|
emergencyPhone: e.detail.value
|
|||
|
})
|
|||
|
},
|
|||
|
/**
|
|||
|
* 获取用户信息
|
|||
|
*/
|
|||
|
getUserInfo(phoneNumber ='',cardId = ''){
|
|||
|
let {smzProjectId} = this.data
|
|||
|
//获取当前扫码用户的openId
|
|||
|
let openId = wx.getStorageSync('openId')
|
|||
|
let that = this
|
|||
|
this.setData({
|
|||
|
loadShow:true
|
|||
|
})
|
|||
|
//获取用户在实名制用户信息
|
|||
|
wx.request({
|
|||
|
url: app.globalData.smzUrl+"/mkl/api/searchUserInfoList",
|
|||
|
method:"POST",
|
|||
|
data:{
|
|||
|
projectId:smzProjectId,
|
|||
|
isWork:1,
|
|||
|
idcardnum:cardId,
|
|||
|
userphone:phoneNumber
|
|||
|
},
|
|||
|
header: {
|
|||
|
'content-type': 'application/x-www-form-urlencoded' //修改此处即可
|
|||
|
},
|
|||
|
success(res){
|
|||
|
that.setData({
|
|||
|
loadShow:false
|
|||
|
})
|
|||
|
if(res.data.state != 'fails'){
|
|||
|
let userInfo = res.data.data
|
|||
|
if(!userInfo){
|
|||
|
app.toast("实名制系统查无此人,请确认系统录入或人员进场")
|
|||
|
return;
|
|||
|
}
|
|||
|
userInfo = userInfo[0]
|
|||
|
wx.request({
|
|||
|
url: app.globalData.szhUrl + "/business/saftEducationOpenIdMap/wxList",
|
|||
|
method:"post",
|
|||
|
data:{
|
|||
|
openId:openId
|
|||
|
},
|
|||
|
header: {
|
|||
|
'content-type': 'application/x-www-form-urlencoded' //修改此处即可
|
|||
|
},
|
|||
|
success(signTemp){
|
|||
|
let qrUrl = signTemp.data.rows.length <= 0 ? "":signTemp.data.rows[0].qrUrl
|
|||
|
let {name,userphone,idcardnum,teamid,uninName,worktypeid,workType,cultureLevel,specialFlag,sex,idcardimg} = userInfo
|
|||
|
that.setData({
|
|||
|
phoneNumber:userphone,
|
|||
|
cardId:idcardnum,
|
|||
|
companyName:uninName,
|
|||
|
typeWordName:workType,
|
|||
|
userName:name,
|
|||
|
companyId:teamid,
|
|||
|
typeWord:worktypeid,
|
|||
|
manageSign:qrUrl,
|
|||
|
cultureLevel:cultureLevel,
|
|||
|
specialFlag:specialFlag,
|
|||
|
sex:sex,
|
|||
|
idCardFront:idcardimg
|
|||
|
})
|
|||
|
|
|||
|
}
|
|||
|
})
|
|||
|
}else{
|
|||
|
app.toast('实名制系统查无此人,请确认系统录入或人员进场')
|
|||
|
// setTimeout(()=>{
|
|||
|
// wx.redirectTo({
|
|||
|
// url: '../gengduogongneng/gengduogongneng'
|
|||
|
// })
|
|||
|
// },2000)
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
bindInfo(){
|
|||
|
let that = this
|
|||
|
if(that.data.authentication == "1") {
|
|||
|
if(that.data.phoneNumber.length <= 0 || (that.data.manageSign.length <= 0 && that.data.manageSign !='')){
|
|||
|
app.toast("数据填写不完整");
|
|||
|
return;
|
|||
|
}
|
|||
|
} else {
|
|||
|
|
|||
|
if((that.data.manageSign.length <= 0 && that.data.manageSign !='') || that.data.cardId.length <=0){
|
|||
|
app.toast("数据填写不完整");
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
this.setData({
|
|||
|
loadShow:true
|
|||
|
})
|
|||
|
//获取当前扫码用户的openId
|
|||
|
let openId = wx.getStorageSync('openId')
|
|||
|
wx.uploadFile({
|
|||
|
//图片上传地址
|
|||
|
url: app.globalData.reqUrl+'/weixin/security/fileUpload',
|
|||
|
filePath: this.data.manageSign,
|
|||
|
name: 'file',
|
|||
|
header: {
|
|||
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
|
|||
|
},
|
|||
|
formData: { user: 'test' },
|
|||
|
success:resTemp => {
|
|||
|
wx.request({
|
|||
|
url: app.globalData.szhUrl + "/business/saftEducationOpenIdMap/list",
|
|||
|
method:"post",
|
|||
|
data:{
|
|||
|
openId
|
|||
|
},
|
|||
|
header: {
|
|||
|
'content-type': 'application/x-www-form-urlencoded' //修改此处即可
|
|||
|
},
|
|||
|
success(res){
|
|||
|
let dataFile = JSON.parse(resTemp.data);
|
|||
|
let data = res.data
|
|||
|
let {szhprojectId,phoneNumber,cardId,companyName,typeWordName,userName,companyId,typeWord,id,educationLevel,emergencyName,emergencyPhone,specialFlag,idCardFront,sex} = that.data
|
|||
|
phoneNumber = !phoneNumber ?'':phoneNumber
|
|||
|
//判断用户是否变绑定劳务公司
|
|||
|
if(data.code == '0' && data.rows.length > 0){
|
|||
|
wx.request({
|
|||
|
url: app.globalData.szhUrl + '/business/saftEducationOpenIdMap/edit',
|
|||
|
method:"post",
|
|||
|
data:{
|
|||
|
id,
|
|||
|
projectId:szhprojectId,
|
|||
|
openId,
|
|||
|
phoneNumber,
|
|||
|
cardId,
|
|||
|
companyName,
|
|||
|
typeWordName,
|
|||
|
userName,
|
|||
|
companyId,
|
|||
|
typeWord,
|
|||
|
signUrl:dataFile.url,
|
|||
|
educationLevel,
|
|||
|
emergencyName,
|
|||
|
emergencyPhone,
|
|||
|
specialFlag,
|
|||
|
idCardFront,
|
|||
|
sex
|
|||
|
},
|
|||
|
success(res){
|
|||
|
that.setData({
|
|||
|
loadShow:false
|
|||
|
})
|
|||
|
var firstWorkType = ''
|
|||
|
if(res.data.code == '0'){
|
|||
|
wx.navigateTo({
|
|||
|
url: '../Personnel-information-binding/index'
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
})
|
|||
|
}else{
|
|||
|
wx.request({
|
|||
|
url: app.globalData.szhUrl + '/business/saftEducationOpenIdMap/add',
|
|||
|
method:"post",
|
|||
|
data:{
|
|||
|
projectId:szhprojectId,
|
|||
|
openId,
|
|||
|
phoneNumber ,
|
|||
|
cardId,
|
|||
|
companyName,
|
|||
|
typeWordName,
|
|||
|
userName,
|
|||
|
companyId,
|
|||
|
typeWord,
|
|||
|
signUrl:dataFile.url,
|
|||
|
educationLevel,
|
|||
|
emergencyName,
|
|||
|
emergencyPhone,
|
|||
|
specialFlag,
|
|||
|
idCardFront,
|
|||
|
sex
|
|||
|
},
|
|||
|
header: {
|
|||
|
'content-type': 'application/x-www-form-urlencoded' //修改此处即可
|
|||
|
},
|
|||
|
success(res){
|
|||
|
that.setData({
|
|||
|
loadShow:false
|
|||
|
})
|
|||
|
if(res.data.code == '0'){
|
|||
|
wx.navigateTo({
|
|||
|
url: '../Personnel-information-binding/index'
|
|||
|
})
|
|||
|
}
|
|||
|
}
|
|||
|
})
|
|||
|
}
|
|||
|
}
|
|||
|
})
|
|||
|
}
|
|||
|
})
|
|||
|
|
|||
|
},
|
|||
|
resest(){
|
|||
|
this.setData({
|
|||
|
phoneNumber:"",
|
|||
|
cardId:"",
|
|||
|
companyName:"",
|
|||
|
typeWordName:"",
|
|||
|
userName:"",
|
|||
|
companyId:"",
|
|||
|
typeWord:"",
|
|||
|
manageSign:"",
|
|||
|
educationLevel:'1',
|
|||
|
emergencyName:'',
|
|||
|
emergencyPhone:''
|
|||
|
})
|
|||
|
this.getEducatuinLevelList()
|
|||
|
|
|||
|
},
|
|||
|
/**
|
|||
|
* 获取人员文化程度
|
|||
|
*/
|
|||
|
getEducatuinLevelList() {
|
|||
|
var that = this
|
|||
|
wx.request({
|
|||
|
url: app.globalData.szhUrl + '/system/dict/data/listData',
|
|||
|
method:"post",
|
|||
|
data:{
|
|||
|
dictType:"education_level"
|
|||
|
},
|
|||
|
header: {
|
|||
|
'content-type': 'application/x-www-form-urlencoded' //修改此处即可
|
|||
|
},
|
|||
|
success(res){
|
|||
|
var list = []
|
|||
|
if(res.data.code == 0) {
|
|||
|
if(res.data.rows.length > 0) {
|
|||
|
var data = res.data.rows;
|
|||
|
data.forEach(item => {
|
|||
|
var obj = {}
|
|||
|
obj.id = item.dictValue
|
|||
|
obj.text = item.dictLabel
|
|||
|
list.push(obj)
|
|||
|
});
|
|||
|
that.setData({
|
|||
|
educationLevelList:list
|
|||
|
})
|
|||
|
} else {
|
|||
|
that.setData({
|
|||
|
educationLevelList:[]
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
} else {
|
|||
|
that.setData({
|
|||
|
educationLevelList:[]
|
|||
|
})
|
|||
|
}
|
|||
|
console.log(that.data.educationLevelList)
|
|||
|
}
|
|||
|
})
|
|||
|
},
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面加载
|
|||
|
*/
|
|||
|
onLoad(options) {
|
|||
|
let {szhprojectId,smzProjectId} = options
|
|||
|
this.setData({
|
|||
|
szhprojectId,
|
|||
|
smzProjectId
|
|||
|
})
|
|||
|
this.getEducatuinLevelList()
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面初次渲染完成
|
|||
|
*/
|
|||
|
onReady() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面显示
|
|||
|
*/
|
|||
|
onShow() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面隐藏
|
|||
|
*/
|
|||
|
onHide() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面卸载
|
|||
|
*/
|
|||
|
onUnload() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 页面相关事件处理函数--监听用户下拉动作
|
|||
|
*/
|
|||
|
onPullDownRefresh() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 页面上拉触底事件的处理函数
|
|||
|
*/
|
|||
|
onReachBottom() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
|
|||
|
/**
|
|||
|
* 用户点击右上角分享
|
|||
|
*/
|
|||
|
onShareAppMessage() {
|
|||
|
|
|||
|
},
|
|||
|
goGCLB(){
|
|||
|
wx.redirectTo({
|
|||
|
url: '../gengduogongneng/gengduogongneng'
|
|||
|
})
|
|||
|
},
|
|||
|
/**
|
|||
|
* 签名
|
|||
|
* @param {} e
|
|||
|
*/
|
|||
|
sign(e){
|
|||
|
let tempFilePath = e.detail
|
|||
|
this.data.manageSign = tempFilePath
|
|||
|
},
|
|||
|
changePage(e){
|
|||
|
if(e.detail){
|
|||
|
this.setData({
|
|||
|
overflow:'aotu'
|
|||
|
})
|
|||
|
}else{
|
|||
|
this.setData({
|
|||
|
overflow:'hidden'
|
|||
|
})
|
|||
|
}
|
|||
|
},
|
|||
|
})
|