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

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

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