From 94af3af74b421ceaa6a59906d59a29baf7dc010b Mon Sep 17 00:00:00 2001 From: chenruilong Date: Fri, 10 Feb 2023 14:42:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(uni-id-co):=20=E5=AE=9E=E4=BA=BA=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E6=A3=80=E6=B5=8B=E8=BA=AB=E4=BB=BD=E8=AF=81=E5=8F=B7?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 280 ++++++++++-------- .../uni-id-pages/common/check-id-card.js | 4 +- .../realname-verify/realname-verify.vue | 6 +- .../cloudfunctions/uni-id-co/common/utils.js | 15 +- .../get-certify-id.js | 7 +- 5 files changed, 168 insertions(+), 144 deletions(-) diff --git a/pages.json b/pages.json index 6563c18..ac91f72 100644 --- a/pages.json +++ b/pages.json @@ -1,130 +1,154 @@ { - "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 + } } diff --git a/uni_modules/uni-id-pages/common/check-id-card.js b/uni_modules/uni-id-pages/common/check-id-card.js index c01ea18..cba63f9 100644 --- a/uni_modules/uni-id-pages/common/check-id-card.js +++ b/uni_modules/uni-id-pages/common/check-id-card.js @@ -1,5 +1,5 @@ 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 +} diff --git a/uni_modules/uni-id-pages/pages/userinfo/realname-verify/realname-verify.vue b/uni_modules/uni-id-pages/pages/userinfo/realname-verify/realname-verify.vue index 22da398..e73619a 100644 --- a/uni_modules/uni-id-pages/pages/userinfo/realname-verify/realname-verify.vue +++ b/uni_modules/uni-id-pages/pages/userinfo/realname-verify/realname-verify.vue @@ -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" diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/utils.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/utils.js index 333cb6e..58d6a1f 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/utils.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/utils.js @@ -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 } diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/facial-recognition-verify/get-certify-id.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/facial-recognition-verify/get-certify-id.js index 1b4866c..0221024 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/facial-recognition-verify/get-certify-id.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/facial-recognition-verify/get-certify-id.js @@ -1,8 +1,7 @@ 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() // 限制用户每日认证次数 -- GitLab