From a6b0cbffe6c22e1bcb1c119f900b2ab10a6f7326 Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Fri, 30 Apr 2021 15:17:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(app):=20=E4=B8=80=E9=94=AE=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E8=87=AA=E5=AE=9A=E4=B9=89=E7=99=BB=E9=99=86=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=82=B9=E5=87=BB=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app-plus/service/api/plugin/oauth.js | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/platforms/app-plus/service/api/plugin/oauth.js b/src/platforms/app-plus/service/api/plugin/oauth.js index b3ac6168a..4054682bc 100644 --- a/src/platforms/app-plus/service/api/plugin/oauth.js +++ b/src/platforms/app-plus/service/api/plugin/oauth.js @@ -31,7 +31,7 @@ export function login (params, callbackId) { authResult: authResult, errMsg: 'login:ok' }) - }, errorCallback, provider === 'apple' ? { scope: 'email' } : { univerifyStyle: params.univerifyStyle } || {}) + }, errorCallback, provider === 'apple' ? { scope: 'email' } : { univerifyStyle: univerifyButtonsClickHandling(params.univerifyStyle, errorCallback) } || {}) } // 先注销再登录 // apple登录logout之后无法重新触发获取email,fullname;一键登录无logout @@ -128,5 +128,28 @@ export function preLogin (params, callbackId) { } export function closeAuthView () { - getService('univerify').then(service => service.closeAuthView()) + return getService('univerify').then(service => service.closeAuthView()) +} + +/** + * 一键登录自定义登陆按钮点击处理 + */ +function univerifyButtonsClickHandling(univerifyStyle, errorCallback) { + if (univerifyStyle.buttons && + Object.prototype.toString.call(univerifyStyle.buttons.list) === '[object Array]' && + univerifyStyle.buttons.list.length > 0 + ) { + univerifyStyle.buttons.list.forEach((button, index) => { + univerifyStyle.buttons.list[index].onclick = function () { + closeAuthView().then(() => { + errorCallback({ + code: '30008', + message: '用户点击了自定义按钮', + index + }) + }) + } + }) + } + return univerifyStyle } -- GitLab