报名正则验证

master
zsk 2 years ago
parent 85793343fd
commit 615ed07b73

@ -2038,6 +2038,9 @@ button.bgBtn {
background-color: var(--color-ysd); background-color: var(--color-ysd);
line-height: 36px; line-height: 36px;
} }
button.bgBtn[disabled]{
background-color: #eee;
}
button.nobg_Btn { button.nobg_Btn {
color: var(--color-ysd); color: var(--color-ysd);
border: 1px solid var(--color-ysd); border: 1px solid var(--color-ysd);

@ -1,4 +1,5 @@
// components/recordBill/index.js // components/recordBill/index.js
const app = getApp();
Component({ Component({
data:{ data:{
// jobDetail:{} // jobDetail:{}
@ -32,10 +33,11 @@ Component({
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
idCardObj:{},
loading:false
}, },
ready () { ready () {
console.log(this.data.jobDetail); // console.log(this.data.jobDetail);
// this.setData({ // this.setData({
// jobDetail:this.data.jobDetail // jobDetail:this.data.jobDetail
// }) // })
@ -58,10 +60,119 @@ Component({
}) })
// this.triggerEvent("hidedrawer", eventDetail); // this.triggerEvent("hidedrawer", eventDetail);
}, },
submitModal(){ submitModal(e){
var that = this;
console.log('form发生了submit事件携带数据为', e.detail.value)
var formData = {};
var applyData = e.detail.value;
var nameReg = /^[\u4E00-\u9FA5]{2,10}(·[\u4E00-\u9FA5]{2,10}){0,2}$/;
if(nameReg.test(applyData.userName)){
// wx.showToast({
// icon: "none",
// title: '姓名正确',
// });
formData['userName'] = applyData.userName;
}else{
wx.showToast({
icon: "none",
title: '姓名不正确',
});
return
}
that.getIdCardInfo(applyData.idCard);
var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; //身份证
if(reg.test(applyData.idCard)){
// wx.showToast({
// icon: "none",
// title: '身份证号码正确',
// });
formData['idCard'] = applyData.idCard;
formData['sex'] = that.data.idCardObj.sexCode;
formData['age'] = that.data.idCardObj.age;
// console.log(this.getIdCardInfo(applyData.idCard));
}else{
wx.showToast({
icon: "none",
title: '身份证号码不正确',
});
return
}
const telReg = /^1[3456789]\d{9}$/
if(telReg.test(applyData.tel)){
formData['tel'] = applyData.tel;
}else{
wx.showToast({
icon: "none",
title: '电话号码不正确',
});
return
}
that.setData({
loading:true
})
console.log(this.data.jobDetail);
formData['agencyUserId'] = '';
formData['jobId'] = this.data.jobDetail.id;
wx.request({
url: app.globalData.ip + "/assistant/apply/handler/add",
data: formData,
header: app.globalData.header,
method: "POST",
success: function (res) {
console.log(res);
that.hideModal();
that.setData({
loading:false
})
wx.navigateTo({ wx.navigateTo({
url: '../../pages/returnMessage/index?type=success&msg=报名成功', url: '../../pages/returnMessage/index?type=success&msg=报名成功',
}) })
}, },
});
// wx.navigateTo({
// url: '../../pages/returnMessage/index?type=success&msg=报名成功',
// })
},
getIdCardInfo(idCard) {
var idCardObj = {};
//获取用户身份证号码
//获取性别
if (parseInt(idCard.substr(16, 1)) % 2 == 1) {
idCardObj.sexCode = '1' //男
} else {
idCardObj.sexCode = '2' //女
}
//获取出生年月日
var yearBirth = idCard.substring(6, 10);
var monthBirth = idCard.substring(10, 12);
var dayBirth = idCard.substring(12, 14);
var birthDate = yearBirth + "-" + monthBirth + "-" + dayBirth;
//获取当前年月日并计算年龄
var myDate = new Date();
var monthNow = myDate.getMonth() + 1;
var dayNow = myDate.getDay();
var age = myDate.getFullYear() - yearBirth;
if (monthNow < monthBirth || (monthNow == monthBirth && dayNow < dayBirth)) {
age--;
}
//得到年龄
idCardObj.birthDate = birthDate;
idCardObj.age = age;
this.setData({
idCardObj
})
//返回性别和年龄
// return idCardObj;
}
} }
}) })

@ -1,4 +1,5 @@
<!-- wx:if="{{recordBillShow}}" --> <!-- wx:if="{{recordBillShow}}" -->
<form catchsubmit="submitModal" catchreset="formReset">
<view class="leftBox" hover-class="none" hover-stop-propagation="false"> <view class="leftBox" hover-class="none" hover-stop-propagation="false">
<view class="mask" wx:if="{{show}}" catchtouchmove="modalMove" bindtap="hideModal"></view> <view class="mask" wx:if="{{show}}" catchtouchmove="modalMove" bindtap="hideModal"></view>
<view class="hideBox {{show ? 'leftShow':''}}" > <view class="hideBox {{show ? 'leftShow':''}}" >
@ -28,7 +29,7 @@
</view> </view>
<view class="fw500 f15 fss por billInput"> <view class="fw500 f15 fss por billInput">
<view class> <view class>
<input class="weui-input" type="text" name="userName" data-type="name" value="{{userInfo.name}}" placeholder="手动输入或拍照自动识别" /> <input class="weui-input" type="text" name="idCard" data-type="name" value="{{userInfo.idCard}}" placeholder="手动输入或拍照自动识别" />
</view> </view>
<i class="iconfont icon-paizhao1 poa c9" style="right:12px;font-size: 30px;"></i> <i class="iconfont icon-paizhao1 poa c9" style="right:12px;font-size: 30px;"></i>
</view> </view>
@ -39,7 +40,7 @@
</view> </view>
<view class="fw500 f15 fss por billInput"> <view class="fw500 f15 fss por billInput">
<view class> <view class>
<input class="weui-input" type="text" name="userName" data-type="name" value="{{userInfo.name}}" placeholder="请输入联系电话" /> <input class="weui-input" type="text" name="tel" data-type="name" value="{{userInfo.tel}}" placeholder="请输入联系电话" />
</view> </view>
</view> </view>
</view> </view>
@ -47,7 +48,8 @@
</view> </view>
<view class="fsa pl32 pr32 mb24" hover-class="none" hover-stop-propagation="false"> <view class="fsa pl32 pr32 mb24" hover-class="none" hover-stop-propagation="false">
<button class="nobg_Btn normalBtn36 mr16" style type role="button" hover-class="thover" bindtap='hideModal'>我再想想</button> <button class="nobg_Btn normalBtn36 mr16" style type role="button" hover-class="thover" bindtap='hideModal'>我再想想</button>
<button class="bgBtn normalBtn36" style type="primary" hover-class="thover" bindtap="submitModal">确认报名</button> <button class="bgBtn normalBtn36" style type="primary" hover-class="thover" disabled="{{loading}}" loading="{{loading}}" formType="submit">确认报名</button>
</view> </view>
</view> </view>
</view> </view>
</form>

@ -474,7 +474,8 @@ Page({
if(that.data.from == 'shoucang'){ if(that.data.from == 'shoucang'){
url = '/assistant/job/collect/list' url = '/assistant/job/collect/list'
}else if(that.data.from == 'baoming'){ }else if(that.data.from == 'baoming'){
url = '/assistant/mine/info' url = '/assistant/mine/getApplys'
that.data.storeJobListSearchForm = {}
} }
@ -486,9 +487,27 @@ Page({
success: function (res) { success: function (res) {
console.log("职位列表↓↓↓↓"); console.log("职位列表↓↓↓↓");
console.log(res); console.log(res);
if(that.data.from == 'baoming'){ if(that.data.from == 'baoming'){ //我的报名
res.data.data.recordList = res.data.data.pageBean.recordList if (res.data.data.list == null || res.data.data.list.length == 0 || res.data.data.list.length < that.data.storeJobListSearchForm.pageSize) {
var jobListTemp = commonUtil.disposeJobListData(res.data.data.list);
that.data.recordList = that.data.recordList.concat(jobListTemp);
that.setData({
recordList: that.data.recordList,
hasMoreData: false,
isTrigger: false,
});
} else {
var jobListTemp = commonUtil.disposeJobListData(res.data.data.list);
that.data.recordList = that.data.recordList.concat(jobListTemp);
that.setData({
recordList: that.data.recordList,
hasMoreData: true,
isTrigger: false,
});
} }
}else{ //我的收藏
that.setData({ that.setData({
totalPage: res.data.data.pageBean.pageCount, totalPage: res.data.data.pageBean.pageCount,
currPage: res.data.data.pageBean.currentPage, currPage: res.data.data.pageBean.currentPage,
@ -518,6 +537,8 @@ Page({
isTrigger: false, isTrigger: false,
}); });
} }
}
wx.hideLoading({ wx.hideLoading({
success: (res) => {}, success: (res) => {},

@ -744,4 +744,10 @@ Page({
share(){ share(){
this.onShareAppMessage() this.onShareAppMessage()
}, },
goNewEnroll (e) {
let that = this;
this.setData({
recordBillShow: true
})
}
}); });

@ -1,3 +1,6 @@
page{
background-color: #fff;
}
.container{ .container{
display: flex; display: flex;
flex-direction: column; flex-direction: column;

Loading…
Cancel
Save