Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello_uni-id-pages
提交
8bb3416f
H
hello_uni-id-pages
项目概览
DCloud
/
hello_uni-id-pages
通知
1051
Star
31
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8bb3416f
编写于
7月 27, 2022
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: getH5WeixinConfig
上级
71dc39a3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
75 addition
and
6 deletion
+75
-6
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/utils.js
...d-pages/uniCloud/cloudfunctions/uni-id-co/common/utils.js
+10
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js
...i-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js
+9
-2
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/dev/get-supported-login-type.js
...unctions/uni-id-co/module/dev/get-supported-login-type.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin.js
.../cloudfunctions/uni-id-co/module/login/login-by-weixin.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/get-h5-weixin-config.js
...dfunctions/uni-id-co/module/utils/get-h5-weixin-config.js
+52
-0
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/index.js
...s/uniCloud/cloudfunctions/uni-id-co/module/utils/index.js
+2
-1
未找到文件。
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/utils.js
浏览文件 @
8bb3416f
...
...
@@ -163,6 +163,14 @@ function coverMobile (mobile) {
return
mobile
.
slice
(
0
,
3
)
+
'
****
'
+
mobile
.
slice
(
7
)
}
function
getNonceStr
(
length
=
16
)
{
let
str
=
''
while
(
str
.
length
<
length
)
{
str
+=
Math
.
random
().
toString
(
32
).
substring
(
2
)
}
return
str
.
substring
(
0
,
length
)
}
module
.
exports
=
{
getType
,
isValidString
,
...
...
@@ -177,5 +185,6 @@ module.exports = {
snake2camelJson
,
getExtension
,
getVerifyCode
,
coverMobile
coverMobile
,
getNonceStr
}
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js
浏览文件 @
8bb3416f
...
...
@@ -54,7 +54,8 @@ const {
}
=
require
(
'
./module/verify/index
'
)
const
{
refreshToken
,
setPushCid
setPushCid
,
getH5WeixinConfig
}
=
require
(
'
./module/utils/index
'
)
const
{
getInvitedUser
,
...
...
@@ -480,5 +481,11 @@ module.exports = {
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#get-supported-login-type
* @returns
*/
getSupportedLoginType
getSupportedLoginType
,
/**
* 获取微信公众号config参数
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#get-h5-weixin-config
* @returns
*/
getH5WeixinConfig
}
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/dev/get-supported-login-type.js
浏览文件 @
8bb3416f
...
...
@@ -50,7 +50,7 @@ const loginTypeTester = {
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#get-supported-login-type
* @returns
*/
module
.
exports
=
function
()
{
module
.
exports
=
async
function
()
{
const
supportedLoginType
=
[
'
username-password
'
,
'
mobile-password
'
,
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin.js
浏览文件 @
8bb3416f
...
...
@@ -88,7 +88,7 @@ module.exports = async function (params = {}) {
wx_unionid
:
unionid
}
})
const
extraData
=
{}
const
extraData
=
{
}
if
(
type
===
'
register
'
&&
weixinPlatform
!==
'
mp
'
)
{
const
{
nickname
,
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/get-h5-weixin-config.js
0 → 100644
浏览文件 @
8bb3416f
const
{
getWeixinPlatform
}
=
require
(
'
../../lib/utils/weixin
'
)
const
{
getNonceStr
}
=
require
(
'
../../common/utils
'
)
const
{
createHash
}
=
require
(
'
crypto
'
)
/**
* 获取微信公众号config参数
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#get-h5-weixin-config
* @returns
*/
module
.
exports
=
async
function
(
params
)
{
const
schema
=
{
url
:
'
string
'
}
this
.
middleware
.
validate
(
params
,
schema
)
const
{
url
}
=
params
const
oauthConfig
=
this
.
configUtils
.
getOauthConfig
({
provider
:
'
weixin
'
})
const
bridge
=
require
(
'
uni-open-bridge-common
'
)
const
{
appId
}
=
this
.
getClientInfo
()
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
ticket
=
await
bridge
.
getWeixinTicket
({
appId
,
platform
:
weixinPlatform
})
const
signContent
=
{
jsapi_ticket
:
ticket
,
noncestr
:
getNonceStr
(),
timestamp
:
Math
.
floor
(
Date
.
now
()
/
1000
)
+
''
,
url
:
url
.
split
(
'
#
'
)[
0
]
}
const
signStr
=
Object
.
keys
(
signContent
).
sort
().
reduce
(
function
(
str
,
key
)
{
return
str
+
key
+
'
=
'
+
signContent
[
key
]
+
'
&
'
},
''
).
replace
(
/&$/
,
''
)
const
signature
=
createHash
(
'
sha1
'
).
update
(
signStr
,
'
utf8
'
).
digest
(
'
hex
'
)
return
{
appId
:
oauthConfig
.
appid
,
// 公众号的唯一标识
timestamp
:
signContent
.
timestamp
,
// 生成签名的时间戳
nonceStr
:
signContent
.
noncestr
,
// 生成签名的随机串
signature
// 签名
}
}
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/index.js
浏览文件 @
8bb3416f
module
.
exports
=
{
refreshToken
:
require
(
'
./refresh-token
'
),
setPushCid
:
require
(
'
./set-push-cid
'
)
setPushCid
:
require
(
'
./set-push-cid
'
),
getH5WeixinConfig
:
require
(
'
./get-h5-weixin-config
'
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录