提交 94af3af7 编写于 作者: C chenruilong

fix(uni-id-co): 实人认证检测身份证号逻辑

上级 e8658d6f
{
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "uni-app"
}
},
{
"path": "uni_modules/uni-id-pages/pages/userinfo/deactivate/deactivate",
"style": {
"navigationBarTitleText": "注销账号"
}
},
{
"path": "uni_modules/uni-id-pages/pages/userinfo/userinfo",
"style": {
"navigationBarTitleText": "个人资料"
}
},
{
"path": "uni_modules/uni-id-pages/pages/userinfo/bind-mobile/bind-mobile",
"style": {
"navigationBarTitleText": "绑定手机号码"
}
},
// #ifndef MP-WEIXIN
{
"path": "uni_modules/uni-id-pages/pages/userinfo/cropImage/cropImage",
"style": {
"navigationBarTitleText": ""
}
},
// #endif
{
"path": "uni_modules/uni-id-pages/pages/login/login-withoutpwd",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "uni_modules/uni-id-pages/pages/login/login-withpwd",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "uni_modules/uni-id-pages/pages/login/login-smscode",
"style": {
"navigationBarTitleText": "手机验证码登录"
}
},
{
"path": "uni_modules/uni-id-pages/pages/register/register",
"style": {
"navigationBarTitleText": "注册"
}
},
// #ifndef MP-WEIXIN
{
"path": "uni_modules/uni-id-pages/pages/register/register-admin",
"style": {
"navigationBarTitleText": "注册管理员账号",
"enablePullDownRefresh": false
}
},
// #endif
{
"path": "uni_modules/uni-id-pages/pages/register/register-by-email",
"style": {
"navigationBarTitleText": "邮箱验证码注册"
}
},
{
"path": "uni_modules/uni-id-pages/pages/retrieve/retrieve",
"style": {
"navigationBarTitleText": "重置密码"
}
},
{
"path": "uni_modules/uni-id-pages/pages/retrieve/retrieve-by-email",
"style": {
"navigationBarTitleText": "通过邮箱重置密码"
}
},
{
"path": "uni_modules/uni-id-pages/pages/common/webview/webview",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}, {
"path": "uni_modules/uni-id-pages/pages/userinfo/change_pwd/change_pwd",
"style": {
"navigationBarTitleText": "修改密码",
"enablePullDownRefresh": false
}
},{
"path": "uni_modules/uni-id-pages/pages/userinfo/set-pwd/set-pwd",
"style": {
"navigationBarTitleText": "设置密码",
"enablePullDownRefresh": false
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#FFF",
"backgroundColor": "#F8F8F8"
/* #ifdef H5 */
,"navigationStyle": "custom"
/* #endif */
},
"condition": { //模式配置,仅开发期间生效
"current": 0, //当前激活的模式(list 的索引项)
"list": [{
"name": "", //模式名称
"path": "", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到
}]
},
"uniIdRouter": {
"loginPage": "uni_modules/uni-id-pages/pages/login/login-withoutpwd",
"needLogin": [
"uni_modules/uni-id-pages/pages/userinfo/userinfo"
],
"resToLogin": true
}
"pages": [
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "uni-app"
}
},
{
"path": "uni_modules/uni-id-pages/pages/userinfo/deactivate/deactivate",
"style": {
"navigationBarTitleText": "注销账号"
}
},
{
"path": "uni_modules/uni-id-pages/pages/userinfo/userinfo",
"style": {
"navigationBarTitleText": "个人资料"
}
},
{
"path": "uni_modules/uni-id-pages/pages/userinfo/bind-mobile/bind-mobile",
"style": {
"navigationBarTitleText": "绑定手机号码"
}
},
// #ifndef MP-WEIXIN
{
"path": "uni_modules/uni-id-pages/pages/userinfo/cropImage/cropImage",
"style": {
"navigationBarTitleText": ""
}
},
// #endif
{
"path": "uni_modules/uni-id-pages/pages/login/login-withoutpwd",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "uni_modules/uni-id-pages/pages/login/login-withpwd",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "uni_modules/uni-id-pages/pages/login/login-smscode",
"style": {
"navigationBarTitleText": "手机验证码登录"
}
},
{
"path": "uni_modules/uni-id-pages/pages/register/register",
"style": {
"navigationBarTitleText": "注册"
}
},
// #ifndef MP-WEIXIN
{
"path": "uni_modules/uni-id-pages/pages/register/register-admin",
"style": {
"navigationBarTitleText": "注册管理员账号",
"enablePullDownRefresh": false
}
},
// #endif
{
"path": "uni_modules/uni-id-pages/pages/register/register-by-email",
"style": {
"navigationBarTitleText": "邮箱验证码注册"
}
},
{
"path": "uni_modules/uni-id-pages/pages/retrieve/retrieve",
"style": {
"navigationBarTitleText": "重置密码"
}
},
{
"path": "uni_modules/uni-id-pages/pages/retrieve/retrieve-by-email",
"style": {
"navigationBarTitleText": "通过邮箱重置密码"
}
},
{
"path": "uni_modules/uni-id-pages/pages/common/webview/webview",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "uni_modules/uni-id-pages/pages/userinfo/change_pwd/change_pwd",
"style": {
"navigationBarTitleText": "修改密码",
"enablePullDownRefresh": false
}
},
{
"path": "uni_modules/uni-id-pages/pages/userinfo/set-pwd/set-pwd",
"style": {
"navigationBarTitleText": "设置密码",
"enablePullDownRefresh": false
}
},
{
"path": "uni_modules/uni-id-pages/pages/userinfo/realname-verify/realname-verify",
"style": {
"navigationBarTitleText": "实名认证",
"enablePullDownRefresh": false
}
},
{
"path": "uni_modules/uni-id-pages/pages/userinfo/face-verify/face-verify",
"style": {
"navigationBarTitleText": "人脸识别验证",
"enablePullDownRefresh": false
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#FFF",
"backgroundColor": "#F8F8F8"
/* #ifdef H5 */,
"navigationStyle": "custom"
/* #endif */
},
"condition": {
//模式配置,仅开发期间生效
"current": 0,
//当前激活的模式(list 的索引项)
"list": [
{
"name": "",
//模式名称
"path": "",
//启动页面,必选
"query": ""
//启动参数,在页面的onLoad函数里面得到
}
]
},
"uniIdRouter": {
"loginPage": "uni_modules/uni-id-pages/pages/login/login-withoutpwd",
"needLogin": [
"uni_modules/uni-id-pages/pages/userinfo/userinfo"
],
"resToLogin": true
}
}
export default function checkIdCard (idCardNumber) {
if (!idCardNumber) return false
if (!idCardNumber || typeof idCardNumber !== 'string' || idCardNumber.length !== 18) return false
const coefficient = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
const checkCode = [1, 0, 'x', 9, 8, 7, 6, 5, 4, 3, 2]
......@@ -11,4 +11,4 @@ export default function checkIdCard (idCardNumber) {
}
return checkCode[sum % 11].toString() === code.toLowerCase()
}
\ No newline at end of file
}
......@@ -79,7 +79,11 @@ export default {
return
}
if (!/^[\u4e00-\u9fa5]+$/.test(this.realName)) {
if (
typeof this.realName !== 'string' ||
this.realName.length < 2 ||
!/^[\u4e00-\u9fa5]{1,10}(·?[\u4e00-\u9fa5]{1,10}){0,5}$/.test(this.realName)
) {
uni.showToast({
title: "姓名只能是汉字",
icon: "none"
......
......@@ -195,7 +195,7 @@ function isMatchUserApp (userAppList, matchAppList) {
}
function checkIdCard (idCardNumber) {
if (!idCardNumber || typeof idCardNumber !== 'string') return false
if (!idCardNumber || typeof idCardNumber !== 'string' || idCardNumber.length !== 18) return false
const coefficient = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
const checkCode = [1, 0, 'x', 9, 8, 7, 6, 5, 4, 3, 2]
......@@ -231,14 +231,11 @@ function dataDesensitization (value = '', options = {}) {
return first + star + last
}
function getCurrentDate () {
const date = new Date()
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
return new Date(`${year}/${month}/${day}`)
function getCurrentDateTimestamp (date = Date.now(), targetTimezone = 8) {
const oneHour = 60 * 60 * 1000
return parseInt((date + targetTimezone * oneHour) / (24 * oneHour)) * (24 * oneHour) - targetTimezone * oneHour
}
module.exports = {
getType,
isValidString,
......@@ -259,5 +256,5 @@ module.exports = {
checkIdCard,
catchAwait,
dataDesensitization,
getCurrentDate
getCurrentDateTimestamp
}
const { userCollection, REAL_NAME_STATUS, frvLogsCollection, dbCmd } = require('../../common/constants')
const { ERROR } = require('../../common/error')
const { encryptData } = require('../../common/sensitive-aes-cipher')
const { getCurrentDate } = require('../../common/utils')
const { getCurrentDateTimestamp } = require('../../common/utils')
/**
* 获取认证ID
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#get-frv-certify-id
......@@ -63,7 +62,7 @@ module.exports = async function (params) {
// 用户发起了人脸识别但未刷脸并且 certifyId 还在有效期内就还可以用上次的 certifyId
if (frvLogs.data.length) {
const record = frvLogs.data[0]
if (realName === record.real_name && idCard === record.identity) {
if (record.certify_id) {
return {
certifyId: record.certify_id
}
......@@ -72,7 +71,7 @@ module.exports = async function (params) {
const userFrvLogs = await frvLogsCollection.where({
user_id: uid,
created_date: dbCmd.gt(getCurrentDate().getTime())
created_date: dbCmd.gt(getCurrentDateTimestamp())
}).get()
// 限制用户每日认证次数
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册