|
|
|
@ -14,7 +14,7 @@ |
|
|
|
<view class="form-card"> |
|
|
|
<!-- 姓名 --> |
|
|
|
<view class="form-item"> |
|
|
|
<uni-icons class="form-icon" custom-prefix="iconfont" type="icon-user" size="24"></uni-icons> |
|
|
|
<uni-icons class="form-icon" custom-prefix="iconfont" type="icon-xingming" size="22"></uni-icons> |
|
|
|
<input |
|
|
|
class="input" |
|
|
|
placeholder="请输入真实姓名" |
|
|
|
@ -25,7 +25,7 @@ |
|
|
|
|
|
|
|
<!-- 身份证号 --> |
|
|
|
<view class="form-item"> |
|
|
|
<uni-icons class="form-icon" custom-prefix="iconfont" type="icon-shenfen" size="24"></uni-icons> |
|
|
|
<uni-icons class="form-icon" custom-prefix="iconfont" type="icon-duzhezheng" size="24"></uni-icons> |
|
|
|
<input |
|
|
|
class="input" |
|
|
|
placeholder="请输入18位身份证号" |
|
|
|
@ -167,20 +167,35 @@ export default { |
|
|
|
this.showConfirmPwd = !this.showConfirmPwd; |
|
|
|
}, |
|
|
|
|
|
|
|
// 身份证验证(完整版) |
|
|
|
// 身份证验证(支持15位和18位,自动去除空格和连字符) |
|
|
|
validateIdCard(idCard) { |
|
|
|
const reg = /^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/; |
|
|
|
if (!reg.test(idCard)) return false; |
|
|
|
if (!idCard) return false; |
|
|
|
|
|
|
|
// 去除空格和连字符 |
|
|
|
idCard = idCard.replace(/[\s-]/g, ''); |
|
|
|
|
|
|
|
// 15位身份证格式验证 |
|
|
|
const idCard15Reg = /^[1-9]\d{5}\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}$/; |
|
|
|
|
|
|
|
// 18位身份证格式验证 |
|
|
|
const idCard18Reg = /^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/; |
|
|
|
|
|
|
|
// 15位身份证直接验证格式 |
|
|
|
if (idCard.length === 15) { |
|
|
|
return idCard15Reg.test(idCard); |
|
|
|
} |
|
|
|
|
|
|
|
// 18位身份证需要验证格式、日期和校验码 |
|
|
|
if (idCard.length !== 18 || !idCard18Reg.test(idCard)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
// 验证日期有效性(宽松模式:跳过校验码验证) |
|
|
|
const year = +idCard.substring(6, 10); |
|
|
|
const month = +idCard.substring(10, 12); |
|
|
|
const day = +idCard.substring(12, 14); |
|
|
|
const date = new Date(year, month - 1, day); |
|
|
|
if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) return false; |
|
|
|
const weights = [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]; |
|
|
|
const codes = ['1','0','X','9','8','7','6','5','4','3','2']; |
|
|
|
let sum = 0; |
|
|
|
for (let i=0;i<17;i++) sum += +idCard[i] * weights[i]; |
|
|
|
return idCard[17].toUpperCase() === codes[sum % 11]; |
|
|
|
return date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day; |
|
|
|
}, |
|
|
|
|
|
|
|
// 手机号验证 |
|
|
|
@ -254,8 +269,8 @@ export default { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
uni.showToast({ title: '后续流程正在研发中~', icon: 'none' }); |
|
|
|
// setTimeout(() => uni.navigateBack(), 1500); |
|
|
|
uni.showToast({ title: '后续流程正在研发中,请稍后试用~', icon: 'none' }); |
|
|
|
setTimeout(() => uni.navigateBack(), 1500); |
|
|
|
|
|
|
|
// 提交(trim 后再发) |
|
|
|
// const res = await uni.request({ |
|
|
|
|