From 14112b415af7134618788fbe401e2dfaf0b2a7ce Mon Sep 17 00:00:00 2001 From: chenruilong Date: Wed, 8 Feb 2023 11:41:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=20=E5=AE=9E=E5=90=8D?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E9=A1=B5=E9=9D=A2=E4=B8=8E=E4=BA=BA=E8=84=B8?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uni-id-pages/common/check-id-card.js | 14 + uni_modules/uni-id-pages/common/store.js | 15 +- uni_modules/uni-id-pages/config.js | 90 +++--- .../userinfo/face-verify/face-verify-icon.svg | 1 + .../userinfo/face-verify/face-verify.vue | 301 ++++++++++++++++++ .../realname-verify/realname-verify.vue | 130 ++++++++ .../uni-id-pages/pages/userinfo/userinfo.vue | 28 +- uni_modules/uni-id-pages/pages_init.json | 12 + 8 files changed, 536 insertions(+), 55 deletions(-) create mode 100644 uni_modules/uni-id-pages/common/check-id-card.js create mode 100644 uni_modules/uni-id-pages/pages/userinfo/face-verify/face-verify-icon.svg create mode 100644 uni_modules/uni-id-pages/pages/userinfo/face-verify/face-verify.vue create mode 100644 uni_modules/uni-id-pages/pages/userinfo/realname-verify/realname-verify.vue diff --git a/uni_modules/uni-id-pages/common/check-id-card.js b/uni_modules/uni-id-pages/common/check-id-card.js new file mode 100644 index 0000000..c01ea18 --- /dev/null +++ b/uni_modules/uni-id-pages/common/check-id-card.js @@ -0,0 +1,14 @@ +export default function checkIdCard (idCardNumber) { + if (!idCardNumber) 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] + const code = idCardNumber.substring(17) + + let sum = 0 + for (let i = 0; i < 17; i++) { + sum += Number(idCardNumber.charAt(i)) * coefficient[i] + } + + return checkCode[sum % 11].toString() === code.toLowerCase() +} \ No newline at end of file diff --git a/uni_modules/uni-id-pages/common/store.js b/uni_modules/uni-id-pages/common/store.js index 98966d0..30510bf 100644 --- a/uni_modules/uni-id-pages/common/store.js +++ b/uni_modules/uni-id-pages/common/store.js @@ -37,12 +37,21 @@ export const mutations = { }) } else { + const uniIdCo = uniCloud.importObject("uni-id-co", { + customUI: true + }) try { let res = await usersTable.where("'_id' == $cloudEnv_uid") - .field('mobile,nickname,username,email,avatar_file') - .get() + .field('mobile,nickname,username,email,avatar_file') + .get() + + const realNameRes = await uniIdCo.getRealNameInfo() + // console.log('fromDbData',res.result.data); - this.setUserInfo(res.result.data[0]) + this.setUserInfo({ + ...res.result.data[0], + realNameAuth: realNameRes + }) } catch (e) { this.setUserInfo({},{cover:true}) console.error(e.message, e.errCode); diff --git a/uni_modules/uni-id-pages/config.js b/uni_modules/uni-id-pages/config.js index b03a2bf..e847774 100644 --- a/uni_modules/uni-id-pages/config.js +++ b/uni_modules/uni-id-pages/config.js @@ -1,50 +1,50 @@ export default { - //调试模式 - "debug": false, - /* + // 调试模式 + debug: false, + /* 登录类型 未列举到的或运行环境不支持的,将被自动隐藏。 如果需要在不同平台有不同的配置,直接用条件编译即可 */ - "isAdmin": false, // 区分管理端与用户端 - "loginTypes": [ - // "qq", - // "xiaomi", - // "sinaweibo", - // "taobao", - // "facebook", - // "google", - // "alipay", - // "douyin", + isAdmin: false, // 区分管理端与用户端 + loginTypes: [ + // "qq", + // "xiaomi", + // "sinaweibo", + // "taobao", + // "facebook", + // "google", + // "alipay", + // "douyin", - // #ifdef APP - "univerify", - // #endif - "weixin", - "username", - // #ifdef APP - "apple", - // #endif - "smsCode" - ], - //政策协议 - "agreements": { - "serviceUrl": "https://xxx", //用户服务协议链接 - "privacyUrl": "https://xxx", //隐私政策条款链接 - // 哪些场景下显示,1.注册(包括登录并注册,如:微信登录、苹果登录、短信验证码登录)、2.登录(如:用户名密码登录) - "scope": [ - 'register', 'login' - ] - }, - // 提供各类服务接入(如微信登录服务)的应用id - "appid": { - "weixin": { - // 微信公众号的appid,来源:登录微信公众号(https://mp.weixin.qq.com)-> 设置与开发 -> 基本配置 -> 公众号开发信息 -> AppID - "h5": "xxxxxx", - // 微信开放平台的appid,来源:登录微信开放平台(https://open.weixin.qq.com) -> 管理中心 -> 网站应用 -> 选择对应的应用名称,点击查看 -> AppID - "web": "xxxxxx" - } - }, - /** + // #ifdef APP + 'univerify', + // #endif + 'weixin', + 'username', + // #ifdef APP + 'apple', + // #endif + 'smsCode' + ], + // 政策协议 + agreements: { + serviceUrl: 'https://xxx', // 用户服务协议链接 + privacyUrl: 'https://xxx', // 隐私政策条款链接 + // 哪些场景下显示,1.注册(包括登录并注册,如:微信登录、苹果登录、短信验证码登录)、2.登录(如:用户名密码登录) + scope: [ + 'register', 'login', 'realNameVerify' + ] + }, + // 提供各类服务接入(如微信登录服务)的应用id + appid: { + weixin: { + // 微信公众号的appid,来源:登录微信公众号(https://mp.weixin.qq.com)-> 设置与开发 -> 基本配置 -> 公众号开发信息 -> AppID + h5: 'xxxxxx', + // 微信开放平台的appid,来源:登录微信开放平台(https://open.weixin.qq.com) -> 管理中心 -> 网站应用 -> 选择对应的应用名称,点击查看 -> AppID + web: 'xxxxxx' + } + }, + /** * 密码强度 * super(超强:密码必须包含大小写字母、数字和特殊符号,长度范围:8-16位之间) * strong(强: 密密码必须包含字母、数字和特殊符号,长度范围:8-16位之间) @@ -52,8 +52,8 @@ export default { * weak(弱:密码必须包含字母和数字,长度范围:6-16位之间) * 为空或false则不验证密码强度 */ - "passwordStrength":"medium", - /** + passwordStrength: 'medium', + /** * 登录后允许用户设置密码(只针对未设置密码得用户) * 开启此功能将 setPasswordAfterLogin 设置为 true 即可 * "setPasswordAfterLogin": false @@ -63,5 +63,5 @@ export default { * "allowSkip": true * } * */ - "setPasswordAfterLogin": false + setPasswordAfterLogin: false } diff --git a/uni_modules/uni-id-pages/pages/userinfo/face-verify/face-verify-icon.svg b/uni_modules/uni-id-pages/pages/userinfo/face-verify/face-verify-icon.svg new file mode 100644 index 0000000..6eb1749 --- /dev/null +++ b/uni_modules/uni-id-pages/pages/userinfo/face-verify/face-verify-icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/uni_modules/uni-id-pages/pages/userinfo/face-verify/face-verify.vue b/uni_modules/uni-id-pages/pages/userinfo/face-verify/face-verify.vue new file mode 100644 index 0000000..06d53b6 --- /dev/null +++ b/uni_modules/uni-id-pages/pages/userinfo/face-verify/face-verify.vue @@ -0,0 +1,301 @@ + + + + + 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 new file mode 100644 index 0000000..22da398 --- /dev/null +++ b/uni_modules/uni-id-pages/pages/userinfo/realname-verify/realname-verify.vue @@ -0,0 +1,130 @@ + + + + + diff --git a/uni_modules/uni-id-pages/pages/userinfo/userinfo.vue b/uni_modules/uni-id-pages/pages/userinfo/userinfo.vue index 36b34b1..58dc45e 100644 --- a/uni_modules/uni-id-pages/pages/userinfo/userinfo.vue +++ b/uni_modules/uni-id-pages/pages/userinfo/userinfo.vue @@ -11,12 +11,19 @@ + + + + + + + @@ -30,9 +37,7 @@