diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000000000000000000000000000000000000..c6c8b3621938a4691225a870a59bf382af1883dd
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,9 @@
+root = true
+
+[*]
+indent_style = space
+indent_size = 2
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
index 0000000000000000000000000000000000000000..66a93bb202b6a569a9fb8dc4c7912194ef77274e
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,3 @@
+module.exports = {
+ extends: "standard",
+};
diff --git a/manifest.json b/manifest.json
index bc2c62e8ffd415c1d5bc2c0d3e0947ec52b00b07..5865476dc1512df0c9b05594400710d0a89648ab 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,10 +1,14 @@
{
"name" : "hello uni-id-pages",
- "appid" : "__UNI__17D54C2",
+ "appid" : "__UNI__1108543",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
- "uni-app-x" : {},
+ "uni-app-x" : {
+ "modules" : {
+ "FacialRecognitionVerify" : {}
+ }
+ },
/* 快应用特有相关 */
"quickapp" : {},
/* 小程序特有相关 */
diff --git a/uni_modules/uni-id-pages-x/config.uts b/uni_modules/uni-id-pages-x/config.uts
index 8e55ebb569f52a386e69125068d4a72e643ec663..5f91a06be42f54792d9ef2842420b5de4b7bb169 100644
--- a/uni_modules/uni-id-pages-x/config.uts
+++ b/uni_modules/uni-id-pages-x/config.uts
@@ -3,13 +3,13 @@ export default {
"agreements":{
"serviceUrl": "https://uniapp.dcloud.io/", // 用户服务协议链接
"privacyUrl": "https://uniapp.dcloud.io/", // 隐私政策条款链接
- /*
+ /*
* 哪些场景下显示
* 1. register注册(包括登录并注册,如:短信验证码登录,一键登录)
* 2. login登录(如:用户名密码登录,短信验证码登录)
*/
"scopeList": [
- "register","login"
+ "register","login","realNameVerify"
]
},
"needLogin":[
diff --git a/uni_modules/uni-id-pages-x/lib/check-id-card.uts b/uni_modules/uni-id-pages-x/lib/check-id-card.uts
new file mode 100644
index 0000000000000000000000000000000000000000..6e379344daae8f8237c8b87dcd184a944cecb1cd
--- /dev/null
+++ b/uni_modules/uni-id-pages-x/lib/check-id-card.uts
@@ -0,0 +1,16 @@
+function checkIdCard (idCardNumber: string): boolean {
+ if (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]
+ const code = idCardNumber.substring(17)
+
+ let sum = 0
+ for (let i = 0; i < 17; i++) {
+ sum += parseInt(idCardNumber.charAt(i)) * coefficient[i]
+ }
+
+ return checkCode[sum % 11].toString() == code.toLowerCase()
+}
+
+export default checkIdCard
diff --git a/uni_modules/uni-id-pages-x/pages/userinfo/realnameAuth/realnameAuth.uvue b/uni_modules/uni-id-pages-x/pages/userinfo/realnameAuth/realnameAuth.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..08d3975195e78055dcc396a833aa2e99c93a19eb
--- /dev/null
+++ b/uni_modules/uni-id-pages-x/pages/userinfo/realnameAuth/realnameAuth.uvue
@@ -0,0 +1,345 @@
+
+
+
+
+
+ 姓名
+
+ {{realnameInfo['realName']}}
+
+
+
+ 身份证号码
+
+ {{realnameInfo['identity']}}
+
+
+
+
+
+
+
+
+
+
+
+ {{verifyFailTitle}}
+
+
+ {{verifyFailContent}}
+
+
+
+ 请在控制台查看详细错误(此提示仅在开发环境展示)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/uni-id-pages-x/pages/userinfo/userinfo.uvue b/uni_modules/uni-id-pages-x/pages/userinfo/userinfo.uvue
index fac0a558aa243be2ca910bb7f0cba5ea4a5ad066..f28d5e581c9864872524cdf8784e73e5cd982e20 100644
--- a/uni_modules/uni-id-pages-x/pages/userinfo/userinfo.uvue
+++ b/uni_modules/uni-id-pages-x/pages/userinfo/userinfo.uvue
@@ -1,181 +1,208 @@
-
-
-
- 头像
-
-
-
- 昵称
-
- 未登录
- {{userInfo['nickname']}}
- 未设置
-
-
-
-
- 手机号码
-
- {{userInfo['mobile']}}
- 未绑定
-
-
-
-
-
-
- 注销账号
-
-
-
- 退出登录
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 头像
+
+
+
+ 昵称
+
+ 未登录
+ {{userInfo['nickname']}}
+
+ 未设置
+
+
+
+
+ 手机号码
+
+ {{userInfo['mobile']}}
+ 未绑定
+
+
+
+
+
+
+
+ 实名认证
+
+ 已认证
+ 未认证
+
+
+
+
+
+
+ 注销账号
+
+
+
+ 退出登录
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
+ .uni-content {
+ width: 750rpx;
+ background-color: #f5f5f5;
+ flex: 1;
+ }
+
+ .avatar {
+ border: 1px solid #000;
+ align-items: center;
+ }
+
+ .list {
+ position: relative;
+ background-color: #fff;
+ margin-top: 15px;
+ }
+
+ .mask {
+ position: absolute;
+ width: 750rpx;
+ height: 100%;
+ }
+
+ .list .item {
+ border-bottom: 1px solid #f5f5f5;
+ flex-direction: row;
+ align-items: center;
+ padding: 15px 15px;
+ }
+
+ .list .item.deactivate {
+ margin-top: 20px;
+ border-top: 0.1px solid #EEE;
+ }
+
+ .list .item .title {
+ font-size: 14px;
+ flex: 1;
+ color: #333;
+ }
+
+ .list .item .content {
+ flex-direction: row;
+ justify-content: center;
+ align-items: center;
+ }
+
+ .list .item .content .value {
+ color: #999;
+ font-size: 12px;
+ }
+
+ .list .item .content .unset {
+ color: #aaa;
+ font-size: 12px;
+ }
+
+ .link-icon {
+ margin-left: 5px;
+ width: 13px;
+ }
+
+ .btn-list {
+ margin-top: 30px;
+ padding: 30px 150rpx;
+ }
+
+ .logout {
+ color: #888;
+ border-style: none;
+ }
+
diff --git a/uni_modules/uni-id-pages-x/static/face-verify-icon.png b/uni_modules/uni-id-pages-x/static/face-verify-icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..f4eb23905d719034bdb45e98ddb2bcb96924686c
Binary files /dev/null and b/uni_modules/uni-id-pages-x/static/face-verify-icon.png differ
diff --git a/uni_modules/uni-id-pages-x/store.uts b/uni_modules/uni-id-pages-x/store.uts
index 7ec892fde6a67b3ca5815acc778b058cac2fc52b..3d1c49066e70d341a24400228324f67ed3ccd28e 100644
--- a/uni_modules/uni-id-pages-x/store.uts
+++ b/uni_modules/uni-id-pages-x/store.uts
@@ -1,71 +1,81 @@
export type State = {
- pendingAgreements : boolean,
- isLogin : boolean,
- userInfo : UTSJSONObject
+ pendingAgreements: boolean,
+ isLogin: boolean,
+ userInfo: UTSJSONObject
}
// 实例化为state
export const state = reactive({
- pendingAgreements: false,
- userInfo: {
- "_id": null,
- "avatar_file": null,
- "nickname": null,
- "mobile": null,
- } as UTSJSONObject,
- isLogin: false
+ pendingAgreements: false,
+ userInfo: {
+ "_id": null,
+ "avatar_file": null,
+ "nickname": null,
+ "mobile": null,
+ } as UTSJSONObject,
+ isLogin: false
} as State)
-
function initState() {
- try {
- let userInfo = uni.getStorageSync('uni-id-pages-x-userInfo')
- if (userInfo instanceof UTSJSONObject) {
- state.userInfo = userInfo
- // console.log('init userInfo',userInfo);
- }
- } catch (e) {
- console.error('init userInfo error', e);
- }
- state.isLogin = uniCloud.getCurrentUserInfo().tokenExpired > Date.now()
+ try {
+ let userInfo = uni.getStorageSync('uni-id-pages-x-userInfo')
+ if (userInfo instanceof UTSJSONObject) {
+ state.userInfo = userInfo
+ // console.log('init userInfo',userInfo);
+ }
+ } catch (e) {
+ console.error('init userInfo error', e);
+ }
+ state.isLogin = uniCloud.getCurrentUserInfo().tokenExpired > Date.now()
};
initState()
type Mutations = {
- updateUserInfo(param : null | UTSJSONObject) : void
+ updateUserInfo(param: null | UTSJSONObject): void
}
export const mutations = {
- updateUserInfo(param : null | UTSJSONObject) {
- // console.log('updateUserInfo', param); // param为 null 时从云端获取数据更新,为UTSJSONObject时直接根据传入的值来更新
- function afterUpdateUserInfo() {
- // console.log('afterUpdateUserInfo', state.userInfo);
- uni.setStorageSync('uni-id-pages-x-userInfo', state.userInfo)
- }
- if (param == null) {
- const db = uniCloud.databaseForJQL()
- const user_id = uniCloud.getCurrentUserInfo().uid
- // console.log('user_id', user_id);
- if (user_id != null) {
- db.collection('uni-id-users')
- .doc(user_id)
- .field('_id,username,nickname,avatar_file,mobile')
- .get()
- .then(res => {
- // console.log("get cloud userinfo", res);
- state.userInfo = res.data[0]
- afterUpdateUserInfo()
- })
- .catch((err : any | null) => {
- const error = err as UniCloudError
- console.error(error.errMsg, '错误')
- })
- }
- } else {
- param.toMap().forEach((value, key) => {
- // console.log("updateUserInfo.", key, value)
- state.userInfo.set(key, value)
- })
- afterUpdateUserInfo()
- }
- }
-} as Mutations;
\ No newline at end of file
+ updateUserInfo(param: null | UTSJSONObject) {
+ // console.log('updateUserInfo', param); // param为 null 时从云端获取数据更新,为UTSJSONObject时直接根据传入的值来更新
+ function afterUpdateUserInfo() {
+ // console.log('afterUpdateUserInfo', state.userInfo);
+ uni.setStorageSync('uni-id-pages-x-userInfo', state.userInfo)
+ }
+
+ if (param == null) {
+ const db = uniCloud.databaseForJQL()
+ const user_id = uniCloud.getCurrentUserInfo().uid
+ // console.log('user_id', user_id);
+ if (user_id != null) {
+ db.collection('uni-id-users')
+ .doc(user_id)
+ .field('_id,username,nickname,avatar_file,mobile')
+ .get()
+ .then(res => {
+ const uniIdCo = uniCloud.importObject('uni-id-co', {
+ customUI: true
+ })
+
+ uniIdCo
+ .getRealNameInfo()
+ .then((realNameInfo) => {
+ state.userInfo = Object.assign(res.data[0], {
+ realNameInfo
+ })
+
+ afterUpdateUserInfo()
+ })
+ })
+ .catch((err: any | null) => {
+ const error = err as UniCloudError
+ console.error(error.errMsg, '错误')
+ })
+ }
+ } else {
+ param.toMap().forEach((value, key) => {
+ // console.log("updateUserInfo.", key, value)
+ state.userInfo.set(key, value)
+ })
+ afterUpdateUserInfo()
+ }
+ }
+} as Mutations;
diff --git a/uni_modules/uni-id-pages-x/uniCloud/cloudfunctions/uni-id-co/module/facial-recognition-verify/get-certify-id.js b/uni_modules/uni-id-pages-x/uniCloud/cloudfunctions/uni-id-co/module/facial-recognition-verify/get-certify-id.js
index 221b74cf80cfff17376ef1e7f616929291b9275a..5b9d1d9e268b8ece31346c3dc9649de5f292fd9c 100644
--- a/uni_modules/uni-id-pages-x/uniCloud/cloudfunctions/uni-id-co/module/facial-recognition-verify/get-certify-id.js
+++ b/uni_modules/uni-id-pages-x/uniCloud/cloudfunctions/uni-id-co/module/facial-recognition-verify/get-certify-id.js
@@ -45,11 +45,9 @@ module.exports = async function (params) {
// 查询已经使用同一个身份证认证的账号数量,如果超过限制则不能认证
const idCardAccount = await userCollection.where({
- realname_auth: {
- type: 0, // 用户认证状态是个人
- auth_status: REAL_NAME_STATUS.CERTIFIED, // 认证状态为已认证
- identity: idCard // 身份证号码和传入参数的身份证号码相同
- }
+ 'realname_auth.type': 0,
+ 'realname_auth.auth_status': REAL_NAME_STATUS.CERTIFIED,
+ 'realname_auth.identity': idCard
}).get()
if (idCardAccount.data.length >= idCardCertifyLimit) {
throw {