From 8d08d56a211d7f959ace735d8a7aea92bd6420ad Mon Sep 17 00:00:00 2001 From: linju Date: Fri, 24 Jun 2022 10:56:33 +0800 Subject: [PATCH] 1.0.0 --- changelog.md | 2 - package.json | 84 ----------- .../common/uni-id-common/index.js | 2 +- uni_modules/uni-id-pages/changelog.md | 2 - .../uni-id-pages-fab-login.vue | 140 +++++++++--------- uni_modules/uni-id-pages/config.js | 24 +-- uni_modules/uni-id-pages/init.js | 14 +- uni_modules/uni-id-pages/package.json | 2 +- .../pages/login/login-smscode.vue | 2 +- .../pages/login/login-withoutpwd.vue | 2 +- .../pages/login/login-withpwd.vue | 2 +- 11 files changed, 94 insertions(+), 182 deletions(-) delete mode 100644 changelog.md diff --git a/changelog.md b/changelog.md deleted file mode 100644 index f3ff795..0000000 --- a/changelog.md +++ /dev/null @@ -1,2 +0,0 @@ -## 1.0.0(2022-05-10) -1.0版发布 diff --git a/package.json b/package.json index 2f5a825..2c63c08 100644 --- a/package.json +++ b/package.json @@ -1,86 +1,2 @@ { - "id": "uni-id-pages", - "displayName": "hello uni-id-pages", - "version": "1.0.0", - "description": "云端一体简单、统一、可扩展的用户中心页面模版", - "keywords": [ - "uniid", - "uni-id", - "用户管理", - "用户中心", - "短信验证码", - "登录模版" - ], - "repository": "", - "engines": { - "HBuilderX": "^3.2.6" - }, - "dcloudext": { - "category": [ - "uniCloud", - "云端一体项目模板" - ], - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "无", - "permissions": "无" - }, - "npmurl": "" - }, - "uni_modules": { - "dependencies": [], - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "y", - "aliyun": "y" - }, - "client": { - "App": { - "app-vue": "y", - "app-nvue": "y" - }, - "H5-mobile": { - "Safari": "u", - "Android Browser": "u", - "微信浏览器(Android)": "u", - "QQ浏览器(Android)": "u" - }, - "H5-pc": { - "Chrome": "y", - "IE": "n", - "Edge": "u", - "Firefox": "u", - "Safari": "u" - }, - "小程序": { - "微信": "y", - "阿里": "u", - "百度": "u", - "字节跳动": "u", - "QQ": "u" - }, - "快应用": { - "华为": "u", - "联盟": "u" - }, - "Vue": { - "vue2": "y", - "vue3": "u" - } - } - } - }, - "dependencies": {} } diff --git a/uni_modules/uni-id-common/uniCloud/cloudfunctions/common/uni-id-common/index.js b/uni_modules/uni-id-common/uniCloud/cloudfunctions/common/uni-id-common/index.js index cc7f29f..b04313a 100644 --- a/uni_modules/uni-id-common/uniCloud/cloudfunctions/common/uni-id-common/index.js +++ b/uni_modules/uni-id-common/uniCloud/cloudfunctions/common/uni-id-common/index.js @@ -1 +1 @@ -"use strict";var e,n=(e=require("crypto"))&&"object"==typeof e&&"default"in e?e.default:e;const t={TOKEN_EXPIRED:"uni-id-token-expired",CHECK_TOKEN_FAILED:"uni-id-check-token-failed",PARAM_REQUIRED:"uni-id-param-required",ACCOUNT_EXISTS:"uni-id-account-exists",ACCOUNT_NOT_EXISTS:"uni-id-account-not-exists",ACCOUNT_CONFLICT:"uni-id-account-conflict",ACCOUNT_BANNED:"uni-id-account-banned",ACCOUNT_AUDITING:"uni-id-account-auditing",ACCOUNT_AUDIT_FAILED:"uni-id-account-audit-failed",ACCOUNT_CLOSED:"uni-id-account-closed"};function i(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}const r={"uni-id-token-expired":30203,"uni-id-check-token-failed":30202};function o(e){const{errCode:n,errMsgValue:t}=e;e.errMsg=this._t(n,t),n in r&&(e.code=r[n])}function c(e){return"object"===(i=e,Object.prototype.toString.call(i).slice(8,-1).toLowerCase())&&e.errCode&&(n=e.errCode,Object.values(t).includes(n))&&!!e.errCode;var n,i}let s={"zh-Hans":{"uni-id-token-expired":"登陆状态失效,token已过期","uni-id-check-token-failed":"token校验未通过","uni-id-param-required":"缺少参数: {param}","uni-id-account-exists":"此账号已注册","uni-id-account-not-exists":"此账号未注册","uni-id-account-conflict":"用户账号冲突","uni-id-account-banned":"从账号已封禁","uni-id-account-auditing":"此账号正在审核中","uni-id-account-audit-failed":"此账号审核失败","uni-id-account-closed":"此账号已注销"},en:{"uni-id-token-expired":"The login status is invalid, token has expired","uni-id-check-token-failed":"Check token failed","uni-id-param-required":"Parameter required: {param}","uni-id-account-exists":"Account exists","uni-id-account-not-exists":"Account does not exists","uni-id-account-conflict":"User account conflict","uni-id-account-banned":"Account has been banned","uni-id-account-auditing":"Account audit in progress","uni-id-account-audit-failed":"Account audit failed","uni-id-account-closed":"Account has been closed"}};try{const e=require.resolve("uni-config-center/uni-id/lang/index.js");s=function(e,n){const t=Object.keys(e);t.push(...Object.keys(n));const i={};for(let r=0;ri)throw new Error("Config error, tokenExpiresThreshold should be less than tokenExpiresIn");let o;try{o=p(e,n)}catch(e){if("TokenExpiredError"===e.name)throw{errCode:t.TOKEN_EXPIRED};throw{errCode:t.CHECK_TOKEN_FAILED}}return o}async function k(e){const n=e.uid,i=(await E.doc(n).get()).data[0];if(!i)throw{errCode:t.CHECK_TOKEN_FAILED};if(i.valid_token_date&&i.valid_token_date>1e3*e.iat)throw{errCode:t.TOKEN_EXPIRED};const{role:r,permission:o}=await w(i);return T.call(this,{uid:n,role:r,permission:o})}async function w(e){if(!e)throw{errCode:t.ACCOUNT_NOT_EXISTS};!function(e){switch(e.status){case void 0:case 0:break;case 1:throw{errCode:t.ACCOUNT_BANNED};case 2:throw{errCode:t.ACCOUNT_AUDITING};case 3:throw{errCode:t.ACCOUNT_AUDIT_FAILED};case 4:throw{errCode:t.ACCOUNT_CLOSED}}}(e);const n=e.role||[];if(0===n.length)return{role:[],permission:[]};if(n.includes("admin"))return{role:["admin"],permission:[]};const i=await I.where({role_id:C.in(n)});var r;return{role:n,permission:(r=i.data.reduce((e,n)=>{n.permission&&e.push(...n.permission)},[]),Array.from(new Set(r)))}}async function m({uid:e,signContent:n,tokenSecret:t,tokenExpiresIn:i}={}){const r=Date.now(),o=h(n,t,{expiresIn:i});return await E.doc(e).update({last_login_ip:this._clientInfo.clientIP,last_login_date:r}),{token:o,tokenExpired:r+1e3*i}}async function T({uid:e,role:n,permission:i}={}){const{tokenSecret:r,tokenExpiresIn:o,tokenExpiresThreshold:c}=this._getConfig();if(!e)throw{errCode:t.PARAM_REQUIRED,errMsgValue:{param:"uid"}};if(c>o)throw new Error("Config error, tokenExpiresThreshold should be less than tokenExpiresIn");if(!n||!i){const t=(await E.doc(e).get()).data[0],r=await w(t);n=r.role,i=r.permission}if(!this.interceptorMap.has("customToken"))return m.call(this,{uid:e,signContent:{uid:e,role:n,permission:i},tokenSecret:r,tokenExpiresIn:o});const s=this.interceptorMap.get("customToken");if("function"==typeof s)throw new Error("Invalid custom token file");const a=await s({uid:e,role:n,permission:i});return m.call(this,{uid:e,signContent:a,tokenSecret:r,tokenExpiresIn:o})}var x=Object.freeze({__proto__:null,checkToken:async function(e,{autoRefresh:n=!0}={}){const t=await _.call(this,e),{tokenExpiresThreshold:i}=this._getConfig();if(!i||!n)return{code:0,errCode:0,...t};const r=Date.now();let o={};return 1e3*t.exp-r<1e3*i&&(o=await k.call(this,t)),{code:0,errCode:0,...t,...o}},createToken:async function({uid:e,role:n,permission:t}={}){return T.call(this,{uid:e,role:n,permission:t})},refreshToken:async function({token:e}={}){const n=await _.call(this,e);return{errCode:0,...await k.call(this,n)}}});const A=require("uni-config-center")({pluginId:"uni-id"});class O{constructor({context:e,clientInfo:n,config:t}={}){this._clientInfo=e?function(e){return{appId:e.APPID,platform:e.PLATFORM,locale:e.LOCALE,clientIP:e.CLIENTIP,deviceId:e.DEVICEID}}(e):n,this.config=t||this._getOriginConfig(),this.interceptorMap=new Map,A.hasFile("custom-token.js")&&this.setInterceptor("customToken",require(A.resolve("custom-token.js"))),this._i18n=uniCloud.initI18n({locale:this._clientInfo.locale,fallbackLocale:"zh-Hans",messages:a})}_t(...e){return this._i18n.t(...e)}_getOriginConfig(){if(A.hasFile("config.json")){let e;try{e=A.config()}catch(e){throw new Error("Invalid uni-id config file\n"+e.messages)}return Array.isArray(e)?e:e[0]?Object.values(e):e}throw new Error("Invalid uni-id config file")}_getAppConfig(){const e=this._getOriginConfig();return Array.isArray(e)?e.find(e=>e.dcloudAppid===this.clientInfo.appId)||e.find(e=>e.isDefaultConfig):e}_getPlatformConfig(){const e=this._getAppConfig();"app-plus"===this._clientInfo.platform&&(this._clientInfo.platform="app"),"h5"===this._clientInfo.platform&&(this._clientInfo.platform="web");const n=Object.assign({tokenExpiresIn:7200,tokenExpiresThreshold:1200,passwordErrorLimit:6,passwordErrorRetryTime:3600},e,e[this._clientInfo.platform]);return["tokenSecret","tokenExpiresIn"].forEach(e=>{if(!n||!n[e])throw new Error(`Config parameter missing, ${e} is required`)}),n}_getConfig(){return this._getPlatformConfig()}}for(const e in x)O.prototype[e]=x[e];function y(e){const n=new O(e);return new Proxy(n,{get(e,n){if(n in e&&0!==n.indexOf("_")){if("function"==typeof e[n])return(t=e[n],function(){let e;try{e=t.apply(this,arguments)}catch(e){if(c(e))return o.call(this,e),e;throw e}return i(e)?e.then(e=>(c(e)&&o.call(this,e),e),e=>{if(c(e))return o.call(this,e),e;throw e}):(c(e)&&o.call(this,e),e)}).bind(e);if("context"!==n&&"config"!==n)return e[n]}var t}})}O.prototype.createInstance=y;const N={createInstance:y};module.exports=N; +"use strict";var e,n=(e=require("crypto"))&&"object"==typeof e&&"default"in e?e.default:e;const t={TOKEN_EXPIRED:"uni-id-token-expired",CHECK_TOKEN_FAILED:"uni-id-check-token-failed",PARAM_REQUIRED:"uni-id-param-required",ACCOUNT_EXISTS:"uni-id-account-exists",ACCOUNT_NOT_EXISTS:"uni-id-account-not-exists",ACCOUNT_CONFLICT:"uni-id-account-conflict",ACCOUNT_BANNED:"uni-id-account-banned",ACCOUNT_AUDITING:"uni-id-account-auditing",ACCOUNT_AUDIT_FAILED:"uni-id-account-audit-failed",ACCOUNT_CLOSED:"uni-id-account-closed"};function i(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}const r={"uni-id-token-expired":30203,"uni-id-check-token-failed":30202};function o(e){const{errCode:n,errMsgValue:t}=e;e.errMsg=this._t(n,t),n in r&&(e.code=r[n])}function c(e){return"object"===(i=e,Object.prototype.toString.call(i).slice(8,-1).toLowerCase())&&e.errCode&&(n=e.errCode,Object.values(t).includes(n))&&!!e.errCode;var n,i}let s={"zh-Hans":{"uni-id-token-expired":"登录状态失效,token已过期","uni-id-check-token-failed":"token校验未通过","uni-id-param-required":"缺少参数: {param}","uni-id-account-exists":"此账号已注册","uni-id-account-not-exists":"此账号未注册","uni-id-account-conflict":"用户账号冲突","uni-id-account-banned":"从账号已封禁","uni-id-account-auditing":"此账号正在审核中","uni-id-account-audit-failed":"此账号审核失败","uni-id-account-closed":"此账号已注销"},en:{"uni-id-token-expired":"The login status is invalid, token has expired","uni-id-check-token-failed":"Check token failed","uni-id-param-required":"Parameter required: {param}","uni-id-account-exists":"Account exists","uni-id-account-not-exists":"Account does not exists","uni-id-account-conflict":"User account conflict","uni-id-account-banned":"Account has been banned","uni-id-account-auditing":"Account audit in progress","uni-id-account-audit-failed":"Account audit failed","uni-id-account-closed":"Account has been closed"}};try{const e=require.resolve("uni-config-center/uni-id/lang/index.js");s=function(e,n){const t=Object.keys(e);t.push(...Object.keys(n));const i={};for(let r=0;ri)throw new Error("Config error, tokenExpiresThreshold should be less than tokenExpiresIn");let o;try{o=p(e,n)}catch(e){if("TokenExpiredError"===e.name)throw{errCode:t.TOKEN_EXPIRED};throw{errCode:t.CHECK_TOKEN_FAILED}}return o}async function k(e){const n=e.uid,i=(await E.doc(n).get()).data[0];if(!i)throw{errCode:t.CHECK_TOKEN_FAILED};if(i.valid_token_date&&i.valid_token_date>1e3*e.iat)throw{errCode:t.TOKEN_EXPIRED};const{role:r,permission:o}=await w(i);return T.call(this,{uid:n,role:r,permission:o})}async function w(e){if(!e)throw{errCode:t.ACCOUNT_NOT_EXISTS};!function(e){switch(e.status){case void 0:case 0:break;case 1:throw{errCode:t.ACCOUNT_BANNED};case 2:throw{errCode:t.ACCOUNT_AUDITING};case 3:throw{errCode:t.ACCOUNT_AUDIT_FAILED};case 4:throw{errCode:t.ACCOUNT_CLOSED}}}(e);const n=e.role||[];if(0===n.length)return{role:[],permission:[]};if(n.includes("admin"))return{role:["admin"],permission:[]};const i=await I.where({role_id:C.in(n)});var r;return{role:n,permission:(r=i.data.reduce((e,n)=>{n.permission&&e.push(...n.permission)},[]),Array.from(new Set(r)))}}async function m({uid:e,signContent:n,tokenSecret:t,tokenExpiresIn:i}={}){const r=Date.now(),o=h(n,t,{expiresIn:i});return await E.doc(e).update({last_login_ip:this._clientInfo.clientIP,last_login_date:r}),{token:o,tokenExpired:r+1e3*i}}async function T({uid:e,role:n,permission:i}={}){const{tokenSecret:r,tokenExpiresIn:o,tokenExpiresThreshold:c}=this._getConfig();if(!e)throw{errCode:t.PARAM_REQUIRED,errMsgValue:{param:"uid"}};if(c>o)throw new Error("Config error, tokenExpiresThreshold should be less than tokenExpiresIn");if(!n||!i){const t=(await E.doc(e).get()).data[0],r=await w(t);n=r.role,i=r.permission}if(!this.interceptorMap.has("customToken"))return m.call(this,{uid:e,signContent:{uid:e,role:n,permission:i},tokenSecret:r,tokenExpiresIn:o});const s=this.interceptorMap.get("customToken");if("function"==typeof s)throw new Error("Invalid custom token file");const a=await s({uid:e,role:n,permission:i});return m.call(this,{uid:e,signContent:a,tokenSecret:r,tokenExpiresIn:o})}var x=Object.freeze({__proto__:null,checkToken:async function(e,{autoRefresh:n=!0}={}){const t=await _.call(this,e),{tokenExpiresThreshold:i}=this._getConfig();if(!i||!n)return{code:0,errCode:0,...t};const r=Date.now();let o={};return 1e3*t.exp-r<1e3*i&&(o=await k.call(this,t)),{code:0,errCode:0,...t,...o}},createToken:async function({uid:e,role:n,permission:t}={}){return T.call(this,{uid:e,role:n,permission:t})},refreshToken:async function({token:e}={}){const n=await _.call(this,e);return{errCode:0,...await k.call(this,n)}}});const A=require("uni-config-center")({pluginId:"uni-id"});class O{constructor({context:e,clientInfo:n,config:t}={}){this._clientInfo=e?function(e){return{appId:e.APPID,platform:e.PLATFORM,locale:e.LOCALE,clientIP:e.CLIENTIP,deviceId:e.DEVICEID}}(e):n,this.config=t||this._getOriginConfig(),this.interceptorMap=new Map,A.hasFile("custom-token.js")&&this.setInterceptor("customToken",require(A.resolve("custom-token.js"))),this._i18n=uniCloud.initI18n({locale:this._clientInfo.locale,fallbackLocale:"zh-Hans",messages:a})}_t(...e){return this._i18n.t(...e)}_getOriginConfig(){if(A.hasFile("config.json")){let e;try{e=A.config()}catch(e){throw new Error("Invalid uni-id config file\n"+e.messages)}return Array.isArray(e)?e:e[0]?Object.values(e):e}throw new Error("Invalid uni-id config file")}_getAppConfig(){const e=this._getOriginConfig();return Array.isArray(e)?e.find(e=>e.dcloudAppid===this.clientInfo.appId)||e.find(e=>e.isDefaultConfig):e}_getPlatformConfig(){const e=this._getAppConfig();"app-plus"===this._clientInfo.platform&&(this._clientInfo.platform="app"),"h5"===this._clientInfo.platform&&(this._clientInfo.platform="web");const n=Object.assign({tokenExpiresIn:7200,tokenExpiresThreshold:1200,passwordErrorLimit:6,passwordErrorRetryTime:3600},e,e[this._clientInfo.platform]);return["tokenSecret","tokenExpiresIn"].forEach(e=>{if(!n||!n[e])throw new Error(`Config parameter missing, ${e} is required`)}),n}_getConfig(){return this._getPlatformConfig()}}for(const e in x)O.prototype[e]=x[e];function y(e){const n=new O(e);return new Proxy(n,{get(e,n){if(n in e&&0!==n.indexOf("_")){if("function"==typeof e[n])return(t=e[n],function(){let e;try{e=t.apply(this,arguments)}catch(e){if(c(e))return o.call(this,e),e;throw e}return i(e)?e.then(e=>(c(e)&&o.call(this,e),e),e=>{if(c(e))return o.call(this,e),e;throw e}):(c(e)&&o.call(this,e),e)}).bind(e);if("context"!==n&&"config"!==n)return e[n]}var t}})}O.prototype.createInstance=y;const N={createInstance:y};module.exports=N; diff --git a/uni_modules/uni-id-pages/changelog.md b/uni_modules/uni-id-pages/changelog.md index 5eb378a..fdafabb 100644 --- a/uni_modules/uni-id-pages/changelog.md +++ b/uni_modules/uni-id-pages/changelog.md @@ -1,4 +1,2 @@ -## 1.0.1(2022-06-23) -新增,应用[pages_init](https://uniapp.dcloud.io/plugin/publish.html#pages-init)当导入插件到项目工程时,自动合并本插件的页面路由到项目的pages.json ## 1.0.0(2022-06-23) 正式版 diff --git a/uni_modules/uni-id-pages/components/uni-id-pages-fab-login/uni-id-pages-fab-login.vue b/uni_modules/uni-id-pages/components/uni-id-pages-fab-login/uni-id-pages-fab-login.vue index 00dd262..23becee 100644 --- a/uni_modules/uni-id-pages/components/uni-id-pages-fab-login/uni-id-pages-fab-login.vue +++ b/uni_modules/uni-id-pages/components/uni-id-pages-fab-login/uni-id-pages-fab-login.vue @@ -141,17 +141,17 @@ let servicesList = this.servicesList let loginTypes = config.loginTypes - servicesList = servicesList.filter(item => { + servicesList = servicesList.filter(item => { // #ifndef APP - //非app端去掉apple登陆 + //非app端去掉apple登录 if (item.id == 'apple') { return false } - // #endif + // #endif // #ifdef APP - //去掉非ios系统上的apple登陆 + //去掉非ios系统上的apple登录 if (item.id == 'apple' && uni.getSystemInfoSync().osName != 'ios') { return false } @@ -220,9 +220,9 @@ console.log('出乎意料的情况,path:' + path); } }, - async login_before(type, navigateBack = true) { - console.log(type); - + async login_before(type, navigateBack = true) { + console.log(type); + //提示空实现 if (["qq", "xiaomi", @@ -231,56 +231,56 @@ "facebook", "google", "alipay", - "douyin", - //H5端没有支持微信登陆 - // #ifdef H5 - "weixin" + "douyin", + //H5端没有支持微信登录 + // #ifdef H5 + "weixin" // #endif ].includes(type)) { return uni.showToast({ - title: '该登陆方式暂未实现,欢迎提交pr', + title: '该登录方式暂未实现,欢迎提交pr', icon: 'none' }); - } - + } + //检查当前环境是否支持这种登录方式 // #ifdef APP - let isAppExist = true - await new Promise((callback) => { - plus.oauth.getServices(oauthServices => { - let index = oauthServices.findIndex(e => e.id == type) - if(index != -1){ - isAppExist = oauthServices[index].nativeClient - callback() - }else{ - return uni.showToast({ - title: '当前设备不支持此登录,请选择其他登录方式', - icon: 'none' - }); - } - }, err => { - throw new Error('获取服务供应商失败:' + JSON.stringify(err)) - }) + let isAppExist = true + await new Promise((callback) => { + plus.oauth.getServices(oauthServices => { + let index = oauthServices.findIndex(e => e.id == type) + if(index != -1){ + isAppExist = oauthServices[index].nativeClient + callback() + }else{ + return uni.showToast({ + title: '当前设备不支持此登录,请选择其他登录方式', + icon: 'none' + }); + } + }, err => { + throw new Error('获取服务供应商失败:' + JSON.stringify(err)) + }) }) - // #endif - - if ( - // #ifdef APP - !isAppExist - // #endif - - //非app端使用了,app特有登录方式 - // #ifndef APP - ["univerify","apple"].includes(type) - // #endif - - ) { - return uni.showToast({ - title: '当前设备不支持此登录,请选择其他登录方式', - icon: 'none' - }); - } - + // #endif + + if ( + // #ifdef APP + !isAppExist + // #endif + + //非app端使用了,app特有登录方式 + // #ifndef APP + ["univerify","apple"].includes(type) + // #endif + + ) { + return uni.showToast({ + title: '当前设备不支持此登录,请选择其他登录方式', + icon: 'none' + }); + } + //判断是否需要弹出隐私协议授权框 console.log(type, this.agree); let needAgreements = config.agreements.scope.includes('register') @@ -361,8 +361,8 @@ uni.login({ "provider": type, "onlyAuthorize": true, - // #ifdef APP - "univerifyStyle": this.univerifyStyle, + // #ifdef APP + "univerifyStyle": this.univerifyStyle, // #endif success: async e => { console.log(e); @@ -370,7 +370,7 @@ let res = await this.getUserInfo({ provider: "apple" }) - Object.assign(e.authResult, res.userInfo) + Object.assign(e.authResult, res.userInfo) uni.hideLoading() } this.login(type == 'weixin' ? { @@ -378,7 +378,7 @@ } : e.authResult, type) }, fail: async (err) => { - console.log(err); + console.log(err); uni.hideLoading() } }) @@ -390,17 +390,17 @@ }); //toLowerCase let action = 'loginBy' + type.trim().toLowerCase().replace(type[0], type[0].toUpperCase()) - const uniIdCo = uniCloud.importObject("uni-id-co",{ - customUI:true + const uniIdCo = uniCloud.importObject("uni-id-co",{ + customUI:true }) uniIdCo[action](params).then(result => { - console.log("login-result", result); - uni.showToast({ - title: '登陆成功', - icon: 'none' + console.log("login-result", result); + uni.showToast({ + title: '登录成功', + icon: 'none' }); - // #ifdef MP-WEIXIN - //如果是微信小程序端的微信登陆,且为首次登陆,就弹出获取微信昵称+头像用于绑定资料 + // #ifdef MP-WEIXIN + //如果是微信小程序端的微信登录,且为首次登录,就弹出获取微信昵称+头像用于绑定资料 if (type == 'weixin' && result.type == "register") { loginSuccess({ ...result, @@ -411,19 +411,19 @@ } // #endif loginSuccess(result) - }) + }) .catch(e=>{ - console.log(e); - uni.showModal({ - content: e.message, - confirmText:"知道了", - showCancel: false + console.log(e); + uni.showModal({ + content: e.message, + confirmText:"知道了", + showCancel: false }); - }) + }) .finally(e => { if (type == 'univerify') { uni.closeAuthView() - } + } uni.hideLoading() }) }, @@ -511,4 +511,4 @@ font-size: 10px; width: 70px; } - + diff --git a/uni_modules/uni-id-pages/config.js b/uni_modules/uni-id-pages/config.js index 9eef67c..33e954a 100644 --- a/uni_modules/uni-id-pages/config.js +++ b/uni_modules/uni-id-pages/config.js @@ -5,16 +5,16 @@ export default { 登录类型 未列举到的或运行环境不支持的,将被自动隐藏。 如果需要在不同平台有不同的配置,直接用条件编译即可 */ - "loginTypes": [ - // "qq", - // "xiaomi", - // "sinaweibo", - // "taobao", - // "facebook", - // "google", - // "alipay", - // "douyin", - + "loginTypes": [ + // "qq", + // "xiaomi", + // "sinaweibo", + // "taobao", + // "facebook", + // "google", + // "alipay", + // "douyin", + // #ifdef APP "univerify", // #endif @@ -31,7 +31,7 @@ export default { "agreements": { "serviceUrl": "https://xxx", //用户服务协议链接 "privacyUrl": "https://xxx", //隐私政策条款链接 - // 哪些场景下显示,1.注册(包括登录并注册,如:微信登录、苹果登录、短信验证码登录)、2.登录(如:用户名密码登陆) + // 哪些场景下显示,1.注册(包括登录并注册,如:微信登录、苹果登录、短信验证码登录)、2.登录(如:用户名密码登录) "scope": ['register', 'login'] } -} +} diff --git a/uni_modules/uni-id-pages/init.js b/uni_modules/uni-id-pages/init.js index 65c41cb..1bd96e2 100644 --- a/uni_modules/uni-id-pages/init.js +++ b/uni_modules/uni-id-pages/init.js @@ -15,12 +15,12 @@ export default async function() { // 有打开调试模式的情况下 if (debug) { // 1. 检查本地uni-id-pages中配置的登录方式,服务器端是否已经配置正确。否则提醒并引导去配置 - //调用云对象,获取服务端已正确配置的登陆方式 + //调用云对象,获取服务端已正确配置的登录方式 let { supportedLoginType } = await uniIdCo.getSupportedLoginType() console.log("supportedLoginType: " + JSON.stringify(supportedLoginType)); - //登陆方式,服务端和客户端的映射关系 + //登录方式,服务端和客户端的映射关系 let data = { smsCode: 'mobile-code', univerify: 'univerify', @@ -32,10 +32,10 @@ export default async function() { taobao: 'taobao', facebook: 'facebook', google: 'google', - alipay: 'alipay', + alipay: 'alipay', apple:"apple" } - //遍历客户端配置的登陆方式,与服务端比对。并在错误时抛出错误提示 + //遍历客户端配置的登录方式,与服务端比对。并在错误时抛出错误提示 let list = loginTypes.filter(type => !supportedLoginType.includes(data[type])) if (list.length) { console.error( @@ -45,7 +45,7 @@ export default async function() { } // #ifdef APP-PLUS - //如果uni-id-pages配置的登陆功能有一键登录,有则执行预登录(异步) + //如果uni-id-pages配置的登录功能有一键登录,有则执行预登录(异步) if (loginTypes.includes('univerify')) { uni.preLogin({ provider: 'univerify', @@ -71,5 +71,5 @@ export default async function() { }); } // 解绑clientDB错误事件 - //db.off('error', onDBError) -} + //db.off('error', onDBError) +} diff --git a/uni_modules/uni-id-pages/package.json b/uni_modules/uni-id-pages/package.json index 23eb7c3..a37fb3a 100644 --- a/uni_modules/uni-id-pages/package.json +++ b/uni_modules/uni-id-pages/package.json @@ -1,7 +1,7 @@ { "id": "uni-id-pages", "displayName": "uni-id-pages", - "version": "1.0.1", + "version": "1.0.0", "description": "云端一体简单、统一、可扩展的用户中心页面模版", "keywords": [ "用户管理", diff --git a/uni_modules/uni-id-pages/pages/login/login-smscode.vue b/uni_modules/uni-id-pages/pages/login/login-smscode.vue index 9980ea4..b0ca3d0 100644 --- a/uni_modules/uni-id-pages/pages/login/login-smscode.vue +++ b/uni_modules/uni-id-pages/pages/login/login-smscode.vue @@ -1,4 +1,4 @@ - +