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.

496 lines
12 KiB
JavaScript

2 years ago
// pages/enrollInfo/index.js
const app = getApp();
var dateTimePicker = require('../../utils/dateTimePicker.js');
var dateUtil = require('../../utils/dateUtil.js');
const mydate = new Date();
Page({
/**
* 页面的初始数据
*/
data: {
uploadID: true,
idInfo: {},
index: -1,
agentArray: [],
jobIndex: -1,
jobArray: [{
id: 1,
name: 'GG'
}],
storeIndex: -1,
storeArray: [{
id: 1,
name: 'GG'
}],
dateTimeArray1: null,
dateTime1: null,
startYear: 2022,
endYear: 2024,
currentTime: dateUtil.formatDateYMD(mydate.toLocaleDateString()) + ' ' + '12:00',
searchListShow: false,
searchListShowA:false,
searchKeys: '',
searchKeysA: '',
inputShowed: false,
inputVal: "",
inputShowedA: false,
inputValA: "",
storeId: '',
agentId:'',
storeJobId: '',
policy: '',
loading: false
},
showInput: function () {
this.setData({
inputShowed: true
});
},
hideInput: function () {
this.setData({
inputVal: "",
inputShowed: false
});
},
clearInput: function () {
this.setData({
inputVal: ""
});
},
setValue: function (e) {
let str = e.currentTarget.dataset.name
let storeId = e.currentTarget.dataset.id
console.log(storeId);
this.setData({
inputVal: str,
storeId: storeId,
searchListShow: false
});
this.getJobList(storeId);
},
inputTyping: function (e) {
this.setData({
inputVal: e.detail.value
});
if (e.detail.value.length > 0) {
this.setData({
searchListShow: true
});
this.getStoreList(e.detail.value);
} else {
this.setData({
searchListShow: false
});
}
},
getStoreList: function (searchKeys) {
console.log(searchKeys);
var that = this;
that.data.searchKeys = searchKeys;
// 60秒后重新获取验证码
wx.request({
url: app.globalData.ip + '/store/getAllStoreAliasName',
data: {
keys: searchKeys,
},
header: app.globalData.header,
method: "GET",
success: function (res) {
console.log(res);
if (res.data.status == 200) {
that.setData({
storeArray: res.data.data
});
}
},
fail: function (res) {
}
})
},
setValueA: function (e) {
let str = e.currentTarget.dataset.name
this.setData({
inputValA: str,
searchListShowA: false,
agentId:e.currentTarget.dataset.id
});
this.getAgencyList(str);
},
inputTypingA: function (e) {
this.setData({
inputValA: e.detail.value
});
if (e.detail.value.length > 0) {
this.setData({
searchListShowA: true
});
this.getAgencyList(e.detail.value);
} else {
this.setData({
searchListShowA: false
});
}
},
getAgencyList: function (searchKeys) {
var that = this;
that.data.searchKeysA = searchKeys;
// 60秒后重新获取验证码
wx.request({
url: app.globalData.ip + '/agency/getByPmdUserId',
data: {
agencyName: searchKeys,
// pmdUserId: 101125
},
header: app.globalData.header,
method: "GET",
success: function (res) {
console.log(res);
if (res.data.status == 200) {
that.setData({
agentArray: res.data.data
});
}
},
fail: function (res) {
}
})
},
getJobList: function (storeId) {
var that = this;
// 60秒后重新获取验证码
wx.request({
url: app.globalData.ip + '/store/job/getJobNameByStoreId',
data: {
storeId: storeId,
},
header: app.globalData.header,
method: "GET",
success: function (res) {
console.log(res);
if (res.data.status == 200) {
that.setData({
jobArray: res.data.data
});
}
},
fail: function (res) {
}
})
},
getPolicyByStoreJobId: function (storeJobId) {
var that = this;
// 60秒后重新获取验证码
wx.request({
url: app.globalData.ip + '/store/job/getPolicyByStoreJobId',
data: {
storeJobId: storeJobId,
},
header: app.globalData.header,
method: "GET",
success: function (res) {
console.log(res);
if (res.data.status == 200) {
that.setData({
policy: res.data.data
});
}
},
fail: function (res) {
}
})
},
bindPickerChange: function (e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.setData({
index: e.detail.value
})
},
bindPickerChangeJob: function (e) {
var that = this;
console.log('picker发送选择改变携带值为', e.detail.value)
var storeJobId = that.data.jobArray[e.detail.value].id;
console.log(storeJobId)
that.getPolicyByStoreJobId(storeJobId);
this.setData({
jobIndex: e.detail.value
})
},
bindPickerChangeStore: function (e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.setData({
storeIndex: e.detail.value
})
},
chooseIdCard() {
var that = this;
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
console.log(res.tempFilePaths[0]);
const tempFilePaths = res.tempFilePaths;
wx.uploadFile({
url: app.globalData.ip + '/commons/idCardOcrRecognize',
filePath: res.tempFilePaths[0],
name: 'uploadFile',
header: app.globalData.header,
success: function (res) {
console.log(JSON.parse(res.data));
var idcard = JSON.parse(res.data);
if (idcard.status == 200) {
console.log(200);
that.setData({
idInfo: idcard.data,
// uploadID:false
})
wx.setStorage({
key: "idInfo",
data: idcard,
success: function () {
wx.navigateTo({
url: '/pages/newEnroll/index',
})
},
})
wx.setStorage({
key: "src",
data: tempFilePaths[0],
})
} else {
wx.showToast({
duration: 2000,
title: '身份证未识别',
icon: 'none',
mask: true
})
setTimeout(function () {
wx.navigateTo({
url: '/pages/newEnroll/index',
})
}, 2000)
// console.log(1);
//app.showTips(that, res.data.msg);
}
},
fail: function (res) {
console.log(res);
}
})
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
var that = this;
//登录=================================start
if (app.globalData.isLogin) {
that.getByPmdUserId();
} else {
// 由于 userLogin 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userLoginCallback = res => {
that.getByPmdUserId();
}
}
var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear, this.data.currentTime);
console.log(obj.dateTimeArray);
this.setData({
dateTimeArray: obj.dateTimeArray,
dateTime: obj.dateTime
});
},
onShow() {
var that = this;
if (app.isNotEmptyCheck(wx.getStorageSync("tempUserInfo"))) {
console.log(wx.getStorageSync("tempUserInfo"));
that.setData({
uploadID: false,
idInfo: wx.getStorageSync("tempUserInfo")
})
}
},
pickerTap: function (e) {
var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear, this.data.currentTime);
console.log(obj.dateTimeArray);
for (let index = 0; index < obj.dateTimeArray[0].length; index++) {
obj.dateTimeArray[0][index] = obj.dateTimeArray[0][index] + "年"
}
for (let index = 0; index < obj.dateTimeArray[1].length; index++) {
obj.dateTimeArray[1][index] = obj.dateTimeArray[1][index] + "月"
}
for (let index = 0; index < obj.dateTimeArray[2].length; index++) {
obj.dateTimeArray[2][index] = obj.dateTimeArray[2][index] + "日"
}
this.setData({
dateTimeArray: obj.dateTimeArray,
dateTime: obj.dateTime
});
},
changeDateTime(e) {
var dateTimeArray = this.data.dateTimeArray,
dateTime = e.detail.value;
this.setData({
// dateTime: e.detail.value,
currentTime: dateTimeArray[0][dateTime[0]].replace("年",'') + '-' + dateTimeArray[1][dateTime[1]].replace("月",'') + '-' + dateTimeArray[2][dateTime[2]].replace("日",'') + ' ' + dateTimeArray[3][dateTime[3]]
});
console.log(this.data.dateTimeArray)
},
changeDateTimeColumn(e) {
var arr = this.data.dateTime,
dateArr = this.data.dateTimeArray;
arr[e.detail.column] = e.detail.value;
dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]);
for (let index = 0; index < dateArr[2].length; index++) {
dateArr[2][index] = dateArr[2][index] + "日"
}
// .replace("年",'').replace("月",'').replace("日",'')
this.setData({
dateTimeArray: dateArr,
dateTime: arr
});
},
goNewEnroll() {
wx.navigateTo({
url: '/pages/newEnroll/index',
})
},
getByPmdUserId() {
var that = this;
wx.request({
url: app.globalData.ip + '/agency/getByPmdUserId',
header: app.globalData.header,
data: {
// pmdUserId: 101125
},
method: "POST",
success: function (res) {
console.log(res)
that.setData({
agentArray: res.data.data
})
}
})
},
formSubmit: function (e) {
var that = this;
that.setData({
loading: true
})
// if (that.data.index == -1) {
// wx.showToast({
// duration: 2000,
// title: '请选择代理',
// icon: 'none',
// mask: true
// })
// that.setData({
// loading: false
// })
// } else
if (that.data.jobIndex == -1) {
wx.showToast({
duration: 2000,
title: '请选择岗位',
icon: 'none',
mask: true
})
that.setData({
loading: false
})
} else {
var paramData = {};
paramData['userName'] = that.data.idInfo.userName;
paramData['sex'] = that.data.idInfo.sex;
paramData['age'] = that.data.idInfo.age;
paramData['nation'] = that.data.idInfo.nation;
paramData['idCard'] = that.data.idInfo.idCard;
paramData['tel'] = that.data.idInfo.tel;
paramData['idCardImageUrl'] = that.data.idInfo.idCardImageUrl;
paramData['address'] = that.data.idInfo.address;
paramData['agencyId'] = that.data.agentId;
paramData['storeJobId'] = that.data.jobArray[that.data.jobIndex].id;
paramData['policy'] = that.data.policy;
paramData['interviewTime'] = that.data.currentTime;
wx.request({
url: app.globalData.ip + '/user/apply/order/addByAgency',
header: app.globalData.header,
data: paramData,
method: "POST",
success: function (res) {
console.log(res);
wx.showToast({
duration: 2000,
title: '提交成功',
icon: 'none',
mask: true
})
wx.removeStorageSync('tempUserInfo');
wx.removeStorageSync('idInfo');
wx.removeStorageSync('src');
wx.switchTab({
url: '/pages/stationReach/index',
})
}
})
}
},
})