Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello_uni-id-pages
提交
21b2a433
H
hello_uni-id-pages
项目概览
DCloud
/
hello_uni-id-pages
通知
1058
Star
33
Fork
43
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
2
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello_uni-id-pages
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
21b2a433
编写于
12月 20, 2024
作者:
C
chenruilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 华为元服务登录
上级
396d84c6
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
242 addition
and
67 deletion
+242
-67
pages/index/index.vue
pages/index/index.vue
+3
-0
uni_modules/uni-captcha/components/uni-captcha/uni-captcha.vue
...odules/uni-captcha/components/uni-captcha/uni-captcha.vue
+1
-1
uni_modules/uni-id-pages/changelog.md
uni_modules/uni-id-pages/changelog.md
+4
-2
uni_modules/uni-id-pages/components/uni-id-pages-agreements/uni-id-pages-agreements.vue
...nents/uni-id-pages-agreements/uni-id-pages-agreements.vue
+18
-8
uni_modules/uni-id-pages/components/uni-id-pages-fab-login/uni-id-pages-fab-login.vue
...ponents/uni-id-pages-fab-login/uni-id-pages-fab-login.vue
+31
-12
uni_modules/uni-id-pages/config.js
uni_modules/uni-id-pages/config.js
+7
-1
uni_modules/uni-id-pages/package.json
uni_modules/uni-id-pages/package.json
+1
-1
uni_modules/uni-id-pages/pages/login/login-withoutpwd.vue
uni_modules/uni-id-pages/pages/login/login-withoutpwd.vue
+29
-8
uni_modules/uni-id-pages/pages/login/login-withpwd.vue
uni_modules/uni-id-pages/pages/login/login-withpwd.vue
+2
-2
uni_modules/uni-id-pages/static/login/apple.png
uni_modules/uni-id-pages/static/login/apple.png
+0
-0
uni_modules/uni-id-pages/static/login/huawei-mobile.png
uni_modules/uni-id-pages/static/login/huawei-mobile.png
+0
-0
uni_modules/uni-id-pages/static/login/huawei.png
uni_modules/uni-id-pages/static/login/huawei.png
+0
-0
uni_modules/uni-id-pages/static/login/uni-fab-login/apple.png
...modules/uni-id-pages/static/login/uni-fab-login/apple.png
+0
-0
uni_modules/uni-id-pages/static/login/uni-fab-login/huawei.png
...odules/uni-id-pages/static/login/uni-fab-login/huawei.png
+0
-0
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js
...i-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js
+11
-3
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/huawei.js
...ges/uniCloud/cloudfunctions/uni-id-co/lib/utils/huawei.js
+16
-0
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/index.js
...s/uniCloud/cloudfunctions/uni-id-co/module/login/index.js
+2
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-huawei.js
.../cloudfunctions/uni-id-co/module/login/login-by-huawei.js
+55
-26
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-mobile-by-huawei.js
...unctions/uni-id-co/module/relate/bind-mobile-by-huawei.js
+57
-0
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/index.js
.../uniCloud/cloudfunctions/uni-id-co/module/relate/index.js
+4
-1
uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue
...ni-popup/components/uni-popup-dialog/uni-popup-dialog.vue
+1
-1
未找到文件。
pages/index/index.vue
浏览文件 @
21b2a433
...
...
@@ -34,6 +34,9 @@
},
{
"
value
"
:
"
huawei
"
,
"
text
"
:
"
华为登录
"
},
{
"
value
"
:
"
huaweiMobile
"
,
"
text
"
:
"
华为账号一键登录
"
}]
}
},
...
...
uni_modules/uni-captcha/components/uni-captcha/uni-captcha.vue
浏览文件 @
21b2a433
...
...
@@ -6,7 +6,7 @@
mode="widthFix">
</image>
</view>
<input
@
blur=
"focusCaptchaInput = false"
:focus=
"focusCaptchaInput"
type=
"text"
class=
"captcha"
:inputBorder=
"false"
maxlength=
"4"
v-model=
"val"
placeholder=
"请输入验证码"
>
:inputBorder=
"false"
maxlength=
"4"
v-model=
"val"
placeholder=
"请输入验证码"
>
</input>
</view>
</
template
>
...
...
uni_modules/uni-id-pages/changelog.md
浏览文件 @
21b2a433
## 1.1.23(2024-11-05)
-
uni-id-co 修复 没有配置敏感信息解密密钥时导致登录报错的问题
## 1.1.24(2024-12-20)
-
新增 支持华为元服务登录
## 1.1.23(2024-11-05)
-
uni-id-co 修复 没有配置敏感信息解密密钥时导致登录报错的问题
## 1.1.22(2024-09-13)
-
注册登录时去除字符串两端的空白字符
-
删除static目录下重复资源
...
...
uni_modules/uni-id-pages/components/uni-id-pages-agreements/uni-id-pages-agreements.vue
浏览文件 @
21b2a433
...
...
@@ -33,7 +33,7 @@
import
config
from
'
@/uni_modules/uni-id-pages/config.js
'
let
retryFun
=
()
=>
console
.
log
(
'
为定义
'
)
/**
* uni-id-pages-agreements
* uni-id-pages-agreements
* @description 用户服务协议和隐私政策条款组件
* @property {String,Boolean} scope = [register|login] 作用于哪种场景如:register 注册(包括登录并注册,如:微信登录、苹果登录、短信验证码登录)、login 登录。默认值为:register
*/
...
...
@@ -74,12 +74,22 @@
popup
(
Fun
){
this
.
needPopupAgreements
=
true
// this.needAgreements = true
//::TODO 鸿蒙元服务暂不支持 createAnimation,等支持后再打开
// #ifdef MP-HARMONY
return
uni
.
showModal
({
title
:
"
提示
"
,
content
:
`请先阅读并同意
${
this
.
agreements
.
map
(
item
=>
`“
${
item
.
title
}
”`
).
join
(
'
和
'
)}
`
,
})
// #endif
// #ifndef MP-HARMONY
this
.
$nextTick
(()
=>
{
if
(
Fun
){
retryFun
=
Fun
}
this
.
$refs
.
popupAgreement
.
open
()
})
// #endif
},
navigateTo
({
url
,
...
...
@@ -100,7 +110,7 @@
this
.
$emit
(
'
setAgree
'
,
this
.
isAgree
)
}
},
created
()
{
created
()
{
this
.
needAgreements
=
(
config
?.
agreements
?.
scope
||
[]).
includes
(
this
.
scope
)
},
data
()
{
...
...
@@ -145,7 +155,7 @@
color
:
#04498c
;
cursor
:
pointer
;
}
.
checkbox-box
:
:
v-deep
.
uni-checkbox-input
{
border-radius
:
100%
;
}
...
...
@@ -155,13 +165,13 @@
color
:
#FFFFFF
!
important
;
background-color
:
$uni-color-primary
;
}
.content
{
flex-wrap
:
wrap
;
flex-direction
:
row
;
}
.
root
:
:
v-deep
.
uni-popup__error
{
color
:
#333333
;
}
.
root
:
:
v-deep
.
uni-popup__error
{
color
:
#333333
;
}
</
style
>
uni_modules/uni-id-pages/components/uni-id-pages-fab-login/uni-id-pages-fab-login.vue
浏览文件 @
21b2a433
...
...
@@ -62,22 +62,29 @@
"
text
"
:
"
微信登录
"
,
"
logo
"
:
"
/uni_modules/uni-id-pages/static/login/uni-fab-login/weixin.png
"
,
},
{
"
id
"
:
"
huawei
"
,
"
text
"
:
"
华为登录
"
,
"
logo
"
:
"
/uni_modules/uni-id-pages/static/login/uni-fab-login/huawei.png
"
,
"
path
"
:
"
/uni_modules/uni-id-pages/pages/login/login-withoutpwd?type=huawei
"
},
{
"
id
"
:
"
huaweiMobile
"
,
"
text
"
:
"
华为账号一键登录
"
,
"
logo
"
:
"
/uni_modules/uni-id-pages/static/login/uni-fab-login/huawei.png
"
,
"
path
"
:
"
/uni_modules/uni-id-pages/pages/login/login-withoutpwd?type=huaweiMobile
"
},
// #ifndef MP-WEIXIN
{
"
id
"
:
"
apple
"
,
"
text
"
:
"
苹果登录
"
,
"
logo
"
:
"
/uni_modules/uni-id-pages/static/
app/
uni-fab-login/apple.png
"
,
"
logo
"
:
"
/uni_modules/uni-id-pages/static/uni-fab-login/apple.png
"
,
},
{
"
id
"
:
"
univerify
"
,
"
text
"
:
"
一键登录
"
,
"
logo
"
:
"
/uni_modules/uni-id-pages/static/app/uni-fab-login/univerify.png
"
,
},
{
"
id
"
:
"
huawei
"
,
"
text
"
:
"
华为登录
"
,
"
logo
"
:
"
/uni_modules/uni-id-pages/static/app/uni-fab-login/univerify.png
"
,
},
{
"
id
"
:
"
taobao
"
,
"
text
"
:
"
淘宝登录
"
,
//暂未提供该登录方式的接口示例
...
...
@@ -207,7 +214,7 @@
return
'
/
'
+
pages
[
pages
.
length
-
n
].
route
},
toPage
(
path
,
index
=
0
)
{
//
console.log('比较', this.getRoute(1),this.getRoute(2), path)
console
.
log
(
'
比较
'
,
this
.
getRoute
(
1
),
this
.
getRoute
(
2
),
path
)
if
(
this
.
getRoute
(
1
)
==
path
.
split
(
'
?
'
)[
0
]
&&
this
.
getRoute
(
1
)
==
'
/uni_modules/uni-id-pages/pages/login/login-withoutpwd
'
)
{
//如果要被打开的页面已经打开,且这个页面是 /uni_modules/uni-id-pages/pages/index/index 则把类型参数传给他
...
...
@@ -238,7 +245,7 @@
}
},
async
login_before
(
type
,
navigateBack
=
true
,
options
=
{})
{
console
.
log
(
type
);
console
.
log
(
type
,
options
);
//提示空实现
if
([
"
qq
"
,
"
xiaomi
"
,
...
...
@@ -256,15 +263,17 @@
});
}
console
.
log
(
'
检查当前环境是否支持这种登录方式
'
)
//检查当前环境是否支持这种登录方式
// #ifdef APP
let
isAppExist
=
true
await
new
Promise
((
callback
)
=>
{
console
.
log
(
'
uni.getProvider
'
,
uni
.
getProvider
)
uni
.
getProvider
({
service
:
'
oauth
'
,
success
:
(
res
)
=>
{
const
provider
=
res
.
providers
.
find
(
item
=>
item
.
id
===
type
)
console
.
log
(
'
res
'
,
res
)
if
(
provider
)
{
isAppExist
=
provider
?.
isAppExist
??
true
callback
()
...
...
@@ -282,6 +291,7 @@
})
})
// #endif
if
(
// #ifdef APP
!
isAppExist
...
...
@@ -347,7 +357,11 @@
}
}
// #endif
console
.
log
(
'
login ----
'
)
uni
.
showLoading
({
// #ifdef MP-HARMONY
title
:
"
正在登录
"
,
// #endif
mask
:
true
})
...
...
@@ -425,7 +439,7 @@
})
}
if
(
type
===
'
weixinMobile
'
)
{
if
(
type
===
'
weixinMobile
'
||
type
===
'
huaweiMobile
'
)
{
return
this
.
login
({
phoneCode
:
options
.
phoneNumberCode
},
type
)
...
...
@@ -451,7 +465,12 @@
}
:
e
.
authResult
,
type
)
},
fail
:
async
(
err
)
=>
{
console
.
log
(
JSON
.
stringify
(
err
));
console
.
error
(
JSON
.
stringify
(
err
));
uni
.
showModal
({
content
:
`登录失败; code:
${
err
.
errCode
||
-
1
}
`
,
confirmText
:
"
知道了
"
,
showCancel
:
false
});
uni
.
hideLoading
()
}
})
...
...
@@ -570,6 +589,6 @@
margin-top
:
6px
;
color
:
#999
;
font-size
:
10px
;
width
:
7
0px
;
width
:
8
0px
;
}
</
style
>
uni_modules/uni-id-pages/config.js
浏览文件 @
21b2a433
...
...
@@ -19,12 +19,18 @@ export default {
// #ifdef APP
'
univerify
'
,
// #endif
// #ifndef MP-HARMONY
'
weixin
'
,
// #endif
'
username
'
,
// #ifdef APP
'
apple
'
,
// #endif
'
smsCode
'
'
smsCode
'
,
// #ifdef APP-HARMONY || MP-HARMONY
'
huawei
'
,
'
huaweiMobile
'
// #endif
],
// 政策协议
agreements
:
{
...
...
uni_modules/uni-id-pages/package.json
浏览文件 @
21b2a433
{
"id"
:
"uni-id-pages"
,
"displayName"
:
"uni-id-pages"
,
"version"
:
"1.1.2
3
"
,
"version"
:
"1.1.2
4
"
,
"description"
:
"云端一体简单、统一、可扩展的用户中心页面模版"
,
"keywords"
:
[
"用户管理"
,
...
...
uni_modules/uni-id-pages/pages/login/login-withoutpwd.vue
浏览文件 @
21b2a433
...
...
@@ -7,13 +7,20 @@
<!-- 顶部文字 -->
<text
class=
"title"
>
请选择登录方式
</text>
<!-- 快捷登录框 当url带参数时有效 -->
<template
v-if=
"['apple','weixin', 'weixinMobile', 'huawei'].includes(type)"
>
<template
v-if=
"['apple','weixin', 'weixinMobile', 'huawei'
, 'huaweiMobile'
].includes(type)"
>
<text
class=
"tip"
>
将根据第三方账号服务平台的授权范围获取你的信息
</text>
<view
class=
"quickLogin"
>
<image
v-if=
"type !== 'weixinMobile'"
@
click=
"quickLogin"
:src=
"imgSrc"
mode=
"widthFix"
<image
v-if=
"type !== 'weixinMobile'
&& type !== 'huaweiMobile'
"
@
click=
"quickLogin"
:src=
"imgSrc"
mode=
"widthFix"
class=
"quickLoginBtn"
></image>
<button
v-else
type=
"primary"
open-type=
"getPhoneNumber"
@
getphonenumber=
"quickLogin"
class=
"uni-btn"
>
微信授权手机号登录
</button>
<view
v-else
style=
"position: relative"
>
<button
v-if=
"type ==='weixinMobile'"
type=
"primary"
open-type=
"getPhoneNumber"
@
getphonenumber=
"quickLogin"
class=
"uni-btn"
>
微信授权手机号登录
</button>
<button
v-if=
"type === 'huaweiMobile'"
open-type=
"getPhoneNumber"
@
getphonenumber=
"quickLogin"
class=
"quickLoginBtn"
style=
"padding: 0; display: flex"
>
<image
:src=
"imgSrc"
mode=
"widthFix"
></image>
</button>
<view
v-if=
"this.needAgreements && !this.agree"
class=
"mobile-login-agreement-layer"
@
click=
"showAgreementModal"
></view>
</view>
<uni-id-pages-agreements
scope=
"register"
ref=
"agreements"
></uni-id-pages-agreements>
</view>
</
template
>
...
...
@@ -57,7 +64,8 @@
const
images
=
{
weixin
:
'
/uni_modules/uni-id-pages/static/login/weixin.png
'
,
apple
:
'
/uni_modules/uni-id-pages/static/app/apple.png
'
,
huawei
:
'
/uni_modules/uni-id-pages/static/app/huawei.png
'
huawei
:
'
/uni_modules/uni-id-pages/static/login/huawei.png
'
,
huaweiMobile
:
'
/uni_modules/uni-id-pages/static/login/huawei-mobile.png
'
,
}
return
images
[
this
.
type
]
}
...
...
@@ -73,7 +81,7 @@
}
this
.
$nextTick
(()
=>
{
//关闭重复显示的登录快捷方式
if
([
'
weixin
'
,
'
apple
'
].
includes
(
type
))
{
if
([
'
weixin
'
,
'
apple
'
,
'
huawei
'
,
'
huaweiMobile
'
].
includes
(
type
))
{
this
.
$refs
.
uniFabLogin
.
servicesList
=
this
.
$refs
.
uniFabLogin
.
servicesList
.
filter
(
item
=>
item
.
id
!=
type
)
}
...
...
@@ -133,14 +141,17 @@
"
top
"
:
0
})
},
showAgreementModal
()
{
this
.
$refs
.
agreements
.
popup
()
},
quickLogin
(
e
)
{
let
options
=
{}
console
.
log
(
e
)
if
(
e
.
detail
?.
code
)
{
options
.
phoneNumberCode
=
e
.
detail
.
code
}
if
(
this
.
type
===
'
weixinMobile
'
&&
!
e
.
detail
?.
code
)
return
if
(
(
this
.
type
===
'
weixinMobile
'
||
this
.
type
===
'
huaweiMobile
'
)
&&
!
e
.
detail
?.
code
)
return
this
.
$refs
.
uniFabLogin
.
login_before
(
this
.
type
,
true
,
options
)
},
...
...
@@ -187,6 +198,13 @@
}
}
.mobile-login-agreement-layer
{
position
:
absolute
;
top
:
0
;
left
:
0
;
width
:
100%
;
height
:
100%
;
}
.uni-content
,
.quickLogin
{
/* #ifndef APP-NVUE */
...
...
@@ -242,6 +260,9 @@
.quickLoginBtn
{
margin
:
20px
0
;
width
:
450rpx
;
background-color
:
transparent
;
border
:
none
;
box-shadow
:
none
;
/* #ifndef APP-NVUE */
max-width
:
230px
;
/* #endif */
...
...
uni_modules/uni-id-pages/pages/login/login-withpwd.vue
浏览文件 @
21b2a433
...
...
@@ -12,8 +12,8 @@
:inputBorder=
"false"
v-model=
"username"
placeholder=
"请输入手机号/用户名/邮箱"
trim=
"all"
/>
</uni-forms-item>
<uni-forms-item
name=
"password"
>
<uni-easyinput
:focus=
"focusPassword"
@
blur=
"focusPassword = false"
class=
"input-box"
clearable
type=
"password"
:inputBorder=
"false"
v-model=
"password"
placeholder=
"请输入密码"
trim=
"all"
/>
<uni-easyinput
:focus=
"focusPassword"
@
blur=
"focusPassword = false"
class=
"input-box"
clearable
type=
"password"
:inputBorder=
"false"
v-model=
"password"
placeholder=
"请输入密码"
trim=
"all"
/>
</uni-forms-item>
</uni-forms>
<uni-captcha
v-if=
"needCaptcha"
focus
ref=
"captcha"
scene=
"login-by-pwd"
v-model=
"captcha"
/>
...
...
uni_modules/uni-id-pages/static/login/apple.png
0 → 100644
浏览文件 @
21b2a433
10.0 KB
uni_modules/uni-id-pages/static/login/huawei-mobile.png
0 → 100644
浏览文件 @
21b2a433
13.8 KB
uni_modules/uni-id-pages/static/
app
/huawei.png
→
uni_modules/uni-id-pages/static/
login
/huawei.png
浏览文件 @
21b2a433
文件已移动
uni_modules/uni-id-pages/static/login/uni-fab-login/apple.png
0 → 100644
浏览文件 @
21b2a433
3.2 KB
uni_modules/uni-id-pages/static/login/uni-fab-login/huawei.png
0 → 100644
浏览文件 @
21b2a433
7.6 KB
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js
浏览文件 @
21b2a433
...
...
@@ -34,7 +34,8 @@ const {
loginByQQ
,
loginByApple
,
loginByWeixinMobile
,
loginByHuawei
loginByHuawei
,
loginByHuaweiMobile
}
=
require
(
'
./module/login/index
'
)
const
{
logout
...
...
@@ -50,7 +51,10 @@ const {
unbindWeixin
,
unbindAlipay
,
unbindQQ
,
unbindApple
unbindApple
,
bindHuawei
,
unbindHuawei
,
bindMobileByHuawei
}
=
require
(
'
./module/relate/index
'
)
const
{
setPwd
,
...
...
@@ -419,6 +423,7 @@ module.exports = {
loginByApple
,
loginByWeixinMobile
,
loginByHuawei
,
loginByHuaweiMobile
,
/**
* 用户退出登录
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#logout
...
...
@@ -694,5 +699,8 @@ module.exports = {
* @param {Boolean} params.decryptData 是否解密数据
* @returns
*/
getRealNameInfo
getRealNameInfo
,
bindHuawei
,
unbindHuawei
,
bindMobileByHuawei
}
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/huawei.js
0 → 100644
浏览文件 @
21b2a433
function
getHuaweiPlatform
()
{
const
platform
=
this
.
clientPlatform
switch
(
platform
)
{
case
'
app
'
:
case
'
app-harmony
'
:
return
'
app-harmony
'
case
'
mp-harmony
'
:
return
'
mp-harmony
'
default
:
throw
new
Error
(
'
Unsupported weixin platform
'
)
}
}
module
.
exports
=
{
getHuaweiPlatform
}
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/index.js
浏览文件 @
21b2a433
...
...
@@ -17,5 +17,6 @@ module.exports = {
loginByFacebook
:
require
(
'
./login-by-facebook
'
),
loginByGoogle
:
require
(
'
./login-by-google
'
),
loginByWeixinMobile
:
require
(
'
./login-by-weixin-mobile
'
),
loginByHuawei
:
require
(
'
./login-by-huawei
'
)
loginByHuawei
:
require
(
'
./login-by-huawei
'
),
loginByHuaweiMobile
:
require
(
'
./login-by-huawei
'
)
}
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-huawei.js
浏览文件 @
21b2a433
...
...
@@ -9,10 +9,8 @@ const {
postUnifiedLogin
}
=
require
(
'
../../lib/utils/unified-login
'
)
const
{
generateWeixinCache
,
getWeixinPlatform
,
saveWeixinUserKey
,
}
=
require
(
'
../../lib/utils/weixin
'
)
getHuaweiPlatform
,
}
=
require
(
'
../../lib/utils/huawei
'
)
const
{
LOG_TYPE
}
=
require
(
'
../../common/constants
'
)
...
...
@@ -21,33 +19,59 @@ const {initHuawei} = require("../../lib/third-party");
/**
* 华为登录
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#login-by-
weixin
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#login-by-
huawei
* @param {Object} params
* @param {String} params.code
微信
登录返回的code
* @param {String} params.code
华为
登录返回的code
* @param {String} params.inviteCode 邀请码
* @returns
*/
module
.
exports
=
async
function
(
params
=
{})
{
const
schema
=
{
code
:
'
string
'
,
code
:
{
type
:
'
string
'
,
required
:
false
},
phoneCode
:
{
type
:
'
string
'
,
required
:
false
},
inviteCode
:
{
type
:
'
string
'
,
required
:
false
}
}
this
.
middleware
.
validate
(
params
,
schema
)
const
{
code
,
inviteCode
}
=
params
if
(
!
params
.
code
&&
!
params
.
phoneCode
)
{
throw
{
errCode
:
ERROR
.
PARAM_REQUIRED
,
errMsgValue
:
{
param
:
'
code or phoneCode
'
}
}
}
const
{
appId
}
=
this
.
getUniversalClientInfo
()
const
huaweiPlatform
=
getHuaweiPlatform
.
call
(
this
)
const
code
=
params
.
code
||
params
.
phoneCode
const
huaweiApi
=
initHuawei
.
call
(
this
)
let
acc
ountResult
let
acc
essToken
try
{
const
{
accessToken
}
=
await
huaweiApi
.
getUserAccessToken
(
code
)
accountResult
=
await
huaweiApi
.
getAccessTokenInfo
(
accessToken
)
accountResult
.
accessToken
=
accessToken
const
res
=
await
huaweiApi
.
getUserAccessToken
(
code
)
if
(
res
.
errCode
!==
0
)
{
console
.
error
(
res
)
throw
new
Error
(
res
.
errMsg
)
}
accessToken
=
res
.
accessToken
}
catch
(
error
)
{
console
.
error
(
error
)
await
this
.
middleware
.
uniIdLog
({
...
...
@@ -60,33 +84,39 @@ module.exports = async function (params = {}) {
}
const
{
openId
,
unionId
,
accessToken
}
=
accountResult
openID
:
openId
,
unionID
:
unionId
,
purePhoneNumber
:
mobile
,
displayName
:
nickname
,
headPictureURL
:
avatar
,
}
=
await
huaweiApi
.
getUserInfo
(
accessToken
)
const
{
type
,
user
}
=
await
preUnifiedLogin
.
call
(
this
,
{
user
:
{
huawei_openid
:
openId
,
huawei_unionid
:
unionId
huawei_openid
:
{
[
huaweiPlatform
]:
openId
},
huawei_unionid
:
unionId
,
mobile
}
})
const
extraData
=
{
huawei_openid
:
openId
,
huawei_openid
:
{
[
`
${
huaweiPlatform
}
_
${
appId
}
`
]:
openId
},
huawei_unionid
:
unionId
}
if
(
mobile
)
{
extraData
.
mobile
=
mobile
extraData
.
mobile_confirmed
=
1
}
if
(
type
===
'
register
'
)
{
const
res
=
await
huaweiApi
.
getUserInfo
(
accessToken
)
console
.
log
(
'
userinfo
'
,
res
)
const
{
displayName
:
nickname
,
headPictureURL
:
avatar
}
=
res
if
(
avatar
)
{
// eslint-disable-next-line n/no-deprecated-api
const
avatarPath
=
url
.
parse
(
avatar
).
pathname
...
...
@@ -112,7 +142,6 @@ module.exports = async function (params = {}) {
url
:
fileID
}
}
extraData
.
nickname
=
nickname
}
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-mobile-by-huawei.js
0 → 100644
浏览文件 @
21b2a433
const
{
preBind
,
postBind
}
=
require
(
'
../../lib/utils/relate
'
)
const
{
LOG_TYPE
}
=
require
(
'
../../common/constants
'
)
const
{
decryptWeixinData
,
getWeixinCache
,
getWeixinAccessToken
}
=
require
(
'
../../lib/utils/weixin
'
)
const
{
initWeixin
}
=
require
(
'
../../lib/third-party
'
)
const
{
ERROR
}
=
require
(
'
../../common/error
'
)
const
{
initHuawei
}
=
require
(
"
../../lib/third-party
"
);
/**
* 通过华为账号一键登录绑定手机号
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#bind-mobile-by-huawei
* @param {Object} params
* @param {String} params.code 华为账号一键登录获取手机号返回的code
* @returns
*/
module
.
exports
=
async
function
(
params
=
{})
{
const
schema
=
{
code
:
"
string
"
}
const
{
code
}
=
params
this
.
middleware
.
validate
(
params
,
schema
)
const
huaweiApi
=
initHuawei
.
call
(
this
)
const
uid
=
this
.
authInfo
.
uid
const
{
accessToken
}
=
await
huaweiApi
.
getUserAccessToken
(
code
)
const
res
=
await
huaweiApi
.
getUserInfo
(
accessToken
)
const
mobile
=
res
.
purePhoneNumber
const
bindAccount
=
{
mobile
}
await
preBind
.
call
(
this
,
{
uid
,
bindAccount
,
logType
:
LOG_TYPE
.
BIND_MOBILE
})
await
postBind
.
call
(
this
,
{
uid
,
bindAccount
,
extraData
:
{
mobile_confirmed
:
1
},
logType
:
LOG_TYPE
.
BIND_MOBILE
})
return
{
errCode
:
0
}
}
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/index.js
浏览文件 @
21b2a433
...
...
@@ -9,5 +9,8 @@ module.exports = {
unbindWeixin
:
require
(
'
./unbind-weixin
'
),
unbindAlipay
:
require
(
'
./unbind-alipay
'
),
unbindQQ
:
require
(
'
./unbind-qq
'
),
unbindApple
:
require
(
'
./unbind-apple
'
)
unbindApple
:
require
(
'
./unbind-apple
'
),
bindHuawei
:
require
(
'
./bind-huawei
'
),
unbindHuawei
:
require
(
'
./unbind-huawei
'
),
bindMobileByHuawei
:
require
(
'
./bind-mobile-by-huawei
'
),
}
uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue
浏览文件 @
21b2a433
...
...
@@ -10,7 +10,7 @@
</view>
<view
v-else
class=
"uni-dialog-content"
>
<slot>
<input
class=
"uni-dialog-input"
v-model=
"val"
:type=
"inputType"
:placeholder=
"placeholderText"
:focus=
"focus"
>
<input
class=
"uni-dialog-input"
v-model=
"val"
:type=
"inputType"
:placeholder=
"placeholderText"
:focus=
"focus"
></input
>
</slot>
</view>
<view
class=
"uni-dialog-button-group"
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录