Commit f40c1a6e by 何为

修改签约身份证校验规则

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