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.

477 lines
12 KiB
JavaScript

2 years ago
const app = getApp();
const mydate = new Date();
var dateUtil = require("../../utils/dateUtil.js");
var dateTimePicker = require("../../utils/dateTimePicker.js");
2 years ago
Component({
data: {
1 year ago
disabled: false,
idCardImageUrl: "",
idCardNum: "",
1 year ago
tel: '',
userName: '',
2 years ago
dateTime: "",
currentTime: dateUtil.formatDateYMD(mydate.toLocaleDateString()),
copyTime: dateUtil.formatDateYMD(mydate.toLocaleDateString()),
2 years ago
sex: 1,
2 years ago
ageArray: [],
ageIndex: -1,
2 years ago
morePeople: false,
recordList: [
{
id: 0,
name: '李红霞',
tel: 13488887125,
gender: '女',
checked: false
},
{
id: 1,
name: '张卫国',
tel: 13488887125,
gender: '男',
checked: false
},
{
id: 2,
name: '王丽丽',
tel: 13488887125,
gender: '男',
checked: false
},
{
id: 3,
name: '王丽丽',
tel: 13488887125,
gender: '男',
checked: false
},
{
id: 4,
name: '王丽丽',
tel: 13488887125,
gender: '男',
checked: false
},
]
},
properties: {
// 抽屉高度
height: {
type: String,
value: "",
},
drawerType: {
type: String,
value: "",
},
//抽屉显示隐藏
show: {
type: Boolean,
value: false
},
titleText: {
type: String,
value: ''
},
// 是否需要显示tabbar
hideTabbar: {
type: Boolean,
value: false
},
cancerShow: {
type: Boolean,
value: true
},
//
touchClose: {
type: Boolean,
value: true
},
2 years ago
info: {
type: Object,
1 year ago
value: {
},
2 years ago
}
},
ready () {
let that = this;
1 year ago
console.log('this.data.info', this.data.info);
console.log('app.globalData.loginUserInfo', app.globalData.loginUserInfo);
2 years ago
for (let i = 16; i < 70; i++) {
that.data.ageArray.push(i);
}
this.setData({
1 year ago
ageArray: that.data.ageArray,
info: that.data.info,
2 years ago
1 year ago
})
// 监听弹窗的显示与隐藏
Object.defineProperty(that.data, "show", {
enumerable: true,
configurable: true,
set (val) {
1 year ago
console.log('val',val); //打印设置好的值
1 year ago
if (val) {
1 year ago
console.log('app.globalData.loginUserInfo',app.globalData.loginUserInfo);
if (app.globalData.loginUserInfo.realName) {
that.setData({
tel: app.globalData.loginUserInfo.tel,
userName: app.globalData.loginUserInfo.user.realName,
idCardNum: app.globalData.loginUserInfo.user.idcard
})
}
1 year ago
}
},
});
2 years ago
let hour = new Date().getHours();
if (hour < 20 && hour >= 6) {
if (that.data.currentTime == that.data.copyTime) {
that.data.currentTime = that.data.currentTime + " " + (hour + 1) + ":00";
}
} else if (hour >= 20) {
if (that.data.currentTime == that.data.copyTime) {
that.data.currentTime = that.data.currentTime + " " + "19:30";
}
} else if (hour < 6) {
if (that.data.currentTime == that.data.copyTime) {
that.data.currentTime = that.data.currentTime + " " + "6:00";
}
}
this.setData({
currentTime: that.data.currentTime,
});
var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear, this.data.currentTime);
console.log(obj);
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] + "日";
}
2 years ago
2 years ago
this.setData({
dateTimeArray: obj.dateTimeArray,
dateTime: obj.dateTime,
});
2 years ago
},
methods: {
2 years ago
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]],
});
},
1 year ago
2 years ago
changeDateTimeColumn (e) {
console.log(e);
console.log(e.detail.value);
console.log(e.detail.column);
var arr = this.data.dateTime,
dateArr = this.data.dateTimeArray;
console.log(arr);
console.log(dateArr);
arr[e.detail.column] = e.detail.value;
console.log(dateArr[0][arr[0]], dateArr[1][arr[1]]);
1 year ago
2 years ago
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,
});
},
1 year ago
2 years ago
bindPickerChangeAge (e) {
this.setData({
ageIndex: e.detail.value,
["userInfo.age"]: parseInt(e.detail.value) + 16,
});
},
1 year ago
formSubmit (e) {
2 years ago
let that = this;
console.log(e.detail.value);
1 year ago
if (e.detail.value.userName == "") {
2 years ago
wx.showToast({
1 year ago
icon: "none",
title: "请输入姓名",
});
2 years ago
return;
}
1 year ago
if (e.detail.value.tel == "") {
2 years ago
wx.showToast({
1 year ago
icon: "none",
title: "请输入手机号",
});
2 years ago
return;
}
var reg = /^1[3|4|5|6|9|7|8][0-9]\d{8}$/;
1 year ago
if (reg.test(e.detail.value.tel) == false) {
2 years ago
wx.showToast({
1 year ago
icon: "none",
title: "请输入正确的手机号",
});
2 years ago
return;
}
1 year ago
// if (that.data.info.agencyOperation == 2) {
if (that.data.ageIndex == -1) {
wx.showToast({
icon: "none",
title: "请选择年龄",
});
return;
}
e.detail.value.age = parseInt(that.data.ageIndex) + 16;
e.detail.value.sex = that.data.sex;
// } else {
if (e.detail.value.idCard == "") {
wx.showToast({
icon: "none",
title: "请输入身份证号",
});
return;
2 years ago
}
1 year ago
var regIdCard = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
if (regIdCard.test(e.detail.value.idCard) == false) {
wx.showToast({
icon: "none",
title: "请输入正确的身份证号",
});
return;
}
e.detail.value.interviewTimeStr = that.data.currentTime;
// }
1 year ago
if (that.data.idCardImageUrl != "") {
2 years ago
e.detail.value.idCardImageUrl = that.data.idCardImageUrl
}
2 years ago
e.detail.value.jobId = that.data.info.id
that.setData({
1 year ago
disabled: true
})
2 years ago
console.log('form发生了submit事件携带数据为', e.detail.value)
wx.request({
url: app.globalData.ip + '/yishoudan/common/order/add',
data: e.detail.value,
header: app.globalData.headers,
method: "POST",
success: function (res) {
console.log(res);
if (res.data.status == 200) {
wx.showToast({
1 year ago
icon: "none",
2 years ago
title: "报名成功",
})
that.setData({
show: false,
1 year ago
ageIndex: -1,
disabled: false,
idCardNum: ""
2 years ago
})
2 years ago
wx.showTabBar({
animation: false,
success: (result) => {
},
fail: () => { },
complete: () => { }
});
1 year ago
2 years ago
} else {
that.setData({
1 year ago
disabled: false,
})
2 years ago
wx.showToast({
1 year ago
icon: "none",
2 years ago
title: res.data.msg,
})
}
}
})
},
1 year ago
2 years ago
/**
* 阻止滑动穿透
*
*
*/
modalMove () {
// console.log(this.data.color);
return false;
},
// 触摸开始事件
handletouchtart: function (event) {
this.data.lastX = event.touches[0].pageX;
this.data.lastY = event.touches[0].pageY;
},
filterTouchStart (event) {
this.handletouchtart(event);
},
filterTouchMove (event) {
let tx = this.handletouchmove(event);
if (this.data.touchClose) {
if (tx.ty > 100) {
this.hideLeft();
}
} else {
return false
}
},
/**
* 页面滑动事件监听
*
*
*/
handletouchmove: function (event) {
let that = this;
var currentX = event.touches[0].pageX;
var currentY = event.touches[0].pageY;
var tx = currentX - this.data.lastX;
var ty = currentY - this.data.lastY;
var text = "";
//左右方向滑动
if (Math.abs(tx) > Math.abs(ty)) {
return {
tx,
};
}
//上下方向滑动
else {
return {
ty,
};
}
},
hideLeft () {
// this.data.show = false
2 years ago
this.setData({
2 years ago
ageIndex: -1,
1 year ago
idCardNum: "",
2 years ago
})
2 years ago
var eventDetail = {
type: this.data.drawerType
};
this.triggerEvent("hidedrawer", eventDetail);
if (this.data.hideTabbar) {
setTimeout(() => {
this.getTabBar().setData({
isShow: true,
});
}, 200);
}
},
changeSex (e) {
this.setData({
sex: e.currentTarget.dataset.type
})
},
addPersion () {
wx.navigateTo({
url: '/pages/mine/vitaeList/index?type=add'
})
},
handlerMore () {
this.setData({
morePeople: !this.data.morePeople
})
2 years ago
},
chooseIdCard () {
var that = this;
console.log("ischoise");
wx.chooseMedia({
count: 1,
sizeType: ["original", "compressed"],
sourceType: ["album", "camera"],
success (res) {
console.log(res);
// debugger;
that.uploadIdcardImg(res);
},
});
},
uploadIdcardImg (imgPath) {
let that = this;
// tempFilePath可以作为img标签的src属性显示图片
let filePath;
console.log("22222222222222222");
console.log(imgPath);
if (imgPath.tempFiles[0].tempFilePath) {
filePath = imgPath.tempFiles[0].tempFilePath
} else {
filePath = imgPath;
}
1 year ago
2 years ago
console.log(filePath);
wx.showLoading({
title: "识别中...",
});
wx.uploadFile({
// url: app.globalData.ip + '/commons/idCardOcrRecognize',
url: app.globalData.ip + "/commons/idCardOcrRecognizeAndUploadToAliyunOss",
filePath,
name: "uploadFile",
header: app.globalData.headers,
success: function (res) {
console.log("9999999999");
console.log(res);
1 year ago
if (res.statusCode == 413) {
2 years ago
wx.showToast({
duration: 2000,
title: "身份证未识别",
icon: "none",
mask: true,
});
return
}
var idcard = JSON.parse(res.data);
console.log(idcard);
if (idcard.status == 200) {
that.setData({
1 year ago
idCardNum: idcard.data.num,
idCardImageUrl: idcard.data.idCardImageUrl
2 years ago
});
} else {
wx.showToast({
duration: 2000,
title: "身份证未识别",
icon: "none",
mask: true,
});
}
wx.hideLoading();
},
fail: function (res) {
console.log("99999999998");
console.log(res);
wx.hideLoading()
wx.showToast({
duration: 2000,
title: "身份证未识别",
icon: "none",
mask: true,
});
},
});
},
2 years ago
}
})