Commit f40c1a6e by 何为

修改签约身份证校验规则

parent d67f725c
......@@ -127,11 +127,14 @@ export function cardid (code) {
}
if (!validatenull(code)) {
console.log('=======')
console.log(code)
if (code.length === 18) {
if (!code || !/(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(code)) {
msg = '证件号码格式错误'
result = false
} else if (!city[code.substr(0, 2)]) {
msg = '地址编码错误'
result = false
} else {
// 18位身份证需要验证最后一位校验位
code = code.split('')
......@@ -151,15 +154,18 @@ export function cardid (code) {
console.log(sum % 11)
if (parity[sum % 11].toString() !== code[17]) {
msg = '证件号码校验位错误'
} else {
result = false
} else {
result = true
}
}
} else {
msg = '证件号码长度不为18位'
result = false
}
} else {
msg = '证件号码不能为空'
result = false
}
list.push(result)
list.push(msg)
......
......@@ -849,15 +849,17 @@ export default {
return false
}
const _baseIdCardFlag = this.BaseValidateIdCard()
if (_baseIdCardFlag == '不通过') {
this.error.idCard = '请输入有效的女性身份证号'
this.BaseValidate.idCardState = false
this.$toast({
message: '请输入有效的女性身份证号!',
position: 'center',
duration: 3000
})
return false
if(_baseIdCardFlag) {
if (_baseIdCardFlag.error == '不通过') {
this.error.idCard = _baseIdCardFlag.errorText
this.BaseValidate.idCardState = false
this.$toast({
message: _baseIdCardFlag.errorText,
position: 'center',
duration: 3000
})
return false
}
}
// 姓名字段校验
const _nameFlag = this.BaseForm.name
......@@ -961,24 +963,27 @@ export default {
this.saveSignInfoToCookie() // 储存用户签约录入信息
},
BaseValidateIdCard () { // 身份证验证
console.log(cardid(this.BaseForm.idCard)[0])
if (!cardid(this.BaseForm.idCard)[0]) {
this.error.idCard = '请输入有效的女性身份证号'
this.error.idCard = cardid(this.BaseForm.idCard)[1]
this.BaseValidate.idCardState = false
console.log('不通过')
let error = '不通过'
return error
let errorMsg = {}
errorMsg.error = '不通过'
errorMsg.errorText = this.error.idCard
return errorMsg
} else {
console.log(getSexByIdCard(this.BaseForm.idCard))
if (getSexByIdCard(this.BaseForm.idCard) === '2') {
this.BaseValidate.idCardState = true
} else {
this.BaseValidate.idCardState = false
this.error.idCard = '请输入有效的女性身份证号'
let errorMsg = {}
errorMsg.error = '不通过'
errorMsg.errorText = '请输入有效的女性身份证号'
return errorMsg
}
this.error.idCard = ''
console.log('通过')
let success = '通过'
this.getManualPriKey()
return success
}
if (this.pageType === 0) {
this.BaseFormIntoTab1()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment