Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
德宏大魔王
uni-starter
提交
721bf925
U
uni-starter
项目概览
德宏大魔王
/
uni-starter
与 Fork 源项目一致
Fork自
DCloud / uni-starter
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-starter
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
721bf925
编写于
11月 14, 2022
作者:
study夏羽
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新依赖插件
上级
edf7f391
变更
56
展开全部
隐藏空白更改
内联
并排
Showing
56 changed file
with
1356 addition
and
860 deletion
+1356
-860
uni_modules/uni-captcha/components/uni-captcha/uni-captcha.vue
...odules/uni-captcha/components/uni-captcha/uni-captcha.vue
+8
-11
uni_modules/uni-captcha/readme.md
uni_modules/uni-captcha/readme.md
+1
-1
uni_modules/uni-config-center/changelog.md
uni_modules/uni-config-center/changelog.md
+2
-0
uni_modules/uni-config-center/package.json
uni_modules/uni-config-center/package.json
+9
-8
uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/index.js
...uniCloud/cloudfunctions/common/uni-config-center/index.js
+1
-1
uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/package.json
...loud/cloudfunctions/common/uni-config-center/package.json
+1
-1
uni_modules/uni-easyinput/changelog.md
uni_modules/uni-easyinput/changelog.md
+49
-15
uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue
.../uni-easyinput/components/uni-easyinput/uni-easyinput.vue
+595
-562
uni_modules/uni-easyinput/package.json
uni_modules/uni-easyinput/package.json
+1
-1
uni_modules/uni-id-pages/changelog.md
uni_modules/uni-id-pages/changelog.md
+12
-2
uni_modules/uni-id-pages/init.js
uni_modules/uni-id-pages/init.js
+6
-7
uni_modules/uni-id-pages/package.json
uni_modules/uni-id-pages/package.json
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/constants.js
...ges/uniCloud/cloudfunctions/uni-id-co/common/constants.js
+3
-0
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js
...d-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js
+2
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/universal.js
...ges/uniCloud/cloudfunctions/uni-id-co/common/universal.js
+47
-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
+12
-3
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js
...uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js
+2
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js
...d-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js
+2
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/captcha.js
...es/uniCloud/cloudfunctions/uni-id-co/lib/utils/captcha.js
+2
-2
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/login.js
...ages/uniCloud/cloudfunctions/uni-id-co/lib/utils/login.js
+6
-6
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/logout.js
...ges/uniCloud/cloudfunctions/uni-id-co/lib/utils/logout.js
+3
-3
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/password.js
...s/uniCloud/cloudfunctions/uni-id-co/lib/utils/password.js
+213
-68
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/qq.js
...d-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/qq.js
+12
-12
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js
...s/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js
+9
-8
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js
...ges/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/unified-login.js
...Cloud/cloudfunctions/uni-id-co/lib/utils/unified-login.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/univerify.js
.../uniCloud/cloudfunctions/uni-id-co/lib/utils/univerify.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/utils.js
...ages/uniCloud/cloudfunctions/uni-id-co/lib/utils/utils.js
+18
-0
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/verify-code.js
...niCloud/cloudfunctions/uni-id-co/lib/utils/verify-code.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/weixin.js
...ges/uniCloud/cloudfunctions/uni-id-co/lib/utils/weixin.js
+42
-6
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/auth.js
...ages/uniCloud/cloudfunctions/uni-id-co/middleware/auth.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/uni-id-log.js
...niCloud/cloudfunctions/uni-id-co/middleware/uni-id-log.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js
...dfunctions/uni-id-co/module/account/reset-pwd-by-email.js
+2
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js
...oudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js
+2
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/update-pwd.js
...oud/cloudfunctions/uni-id-co/module/account/update-pwd.js
+4
-2
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/add-user.js
...niCloud/cloudfunctions/uni-id-co/module/admin/add-user.js
+1
-0
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/update-user.js
...loud/cloudfunctions/uni-id-co/module/admin/update-user.js
+1
-0
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-qq.js
...loud/cloudfunctions/uni-id-co/module/login/login-by-qq.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin-mobile.js
...unctions/uni-id-co/module/login/login-by-weixin-mobile.js
+1
-4
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
+18
-3
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/register/register-admin.js
...loudfunctions/uni-id-co/module/register/register-admin.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-qq.js
...niCloud/cloudfunctions/uni-id-co/module/relate/bind-qq.js
+2
-2
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-weixin.js
...oud/cloudfunctions/uni-id-co/module/relate/bind-weixin.js
+2
-2
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/unbind-qq.js
...Cloud/cloudfunctions/uni-id-co/module/relate/unbind-qq.js
+1
-1
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/module/utils/refresh-token.js
...ud/cloudfunctions/uni-id-co/module/utils/refresh-token.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/secure-network-handshake-by-weixin.js
...-id-co/module/utils/secure-network-handshake-by-weixin.js
+73
-0
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/set-push-cid.js
...oud/cloudfunctions/uni-id-co/module/utils/set-push-cid.js
+2
-2
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/create-captcha.js
.../cloudfunctions/uni-id-co/module/verify/create-captcha.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/refresh-captcha.js
...cloudfunctions/uni-id-co/module/verify/refresh-captcha.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json
...i-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json
+6
-2
uni_modules/uni-list/changelog.md
uni_modules/uni-list/changelog.md
+4
-0
uni_modules/uni-list/components/uni-list-chat/uni-list-chat.vue
...dules/uni-list/components/uni-list-chat/uni-list-chat.vue
+17
-4
uni_modules/uni-list/components/uni-list-item/uni-list-item.vue
...dules/uni-list/components/uni-list-item/uni-list-item.vue
+42
-9
uni_modules/uni-list/components/uni-list/uni-list.vue
uni_modules/uni-list/components/uni-list/uni-list.vue
+102
-87
uni_modules/uni-list/package.json
uni_modules/uni-list/package.json
+4
-7
未找到文件。
uni_modules/uni-captcha/components/uni-captcha/uni-captcha.vue
浏览文件 @
721bf925
...
@@ -47,6 +47,13 @@
...
@@ -47,6 +47,13 @@
}
}
}
}
},
},
data
()
{
return
{
focusCaptchaInput
:
false
,
captchaBase64
:
""
,
loging
:
false
};
},
watch
:
{
watch
:
{
scene
:
{
scene
:
{
handler
(
scene
)
{
handler
(
scene
)
{
...
@@ -113,16 +120,6 @@
...
@@ -113,16 +120,6 @@
background-color
:
#FEFAE7
;
background-color
:
#FEFAE7
;
}
}
.captcha
{
height
:
44px
;
line-height
:
44px
;
}
.captcha-img-box
{
position
:
relative
;
background-color
:
#FEFAE7
;
}
.captcha
{
.captcha
{
background-color
:
#F8F8F8
;
background-color
:
#F8F8F8
;
font-size
:
14px
;
font-size
:
14px
;
...
@@ -167,4 +164,4 @@
...
@@ -167,4 +164,4 @@
transform
:
rotate
(
360deg
)
transform
:
rotate
(
360deg
)
}
}
}
}
</
style
>
</
style
>
\ No newline at end of file
uni_modules/uni-captcha/readme.md
浏览文件 @
721bf925
<h2>
<h2>
文档已移至
<a
href=
"https://uniapp.dcloud.io/uniCloud/uni-captcha.html"
target=
"_blank"
>
uni-captcha文档
</a>
文档已移至
<a
href=
"https://uniapp.dcloud.io/uniCloud/uni-captcha.html"
target=
"_blank"
>
uni-captcha文档
</a>
</h2>
</h2>
\ No newline at end of file
uni_modules/uni-config-center/changelog.md
浏览文件 @
721bf925
## 0.0.3(2022-11-11)
-
修复 config 方法获取根节点为数组格式配置时错误的转化为了对象的Bug
## 0.0.2(2021-04-16)
## 0.0.2(2021-04-16)
-
修改插件package信息
-
修改插件package信息
## 0.0.1(2021-03-15)
## 0.0.1(2021-03-15)
...
...
uni_modules/uni-config-center/package.json
浏览文件 @
721bf925
{
{
"id"
:
"uni-config-center"
,
"id"
:
"uni-config-center"
,
"displayName"
:
"uni-config-center"
,
"displayName"
:
"uni-config-center"
,
"version"
:
"0.0.
2
"
,
"version"
:
"0.0.
3
"
,
"description"
:
"uniCloud 配置中心"
,
"description"
:
"uniCloud 配置中心"
,
"keywords"
:
[
"keywords"
:
[
"配置"
,
"配置"
,
...
@@ -11,11 +11,7 @@
...
@@ -11,11 +11,7 @@
"engines"
:
{
"engines"
:
{
"HBuilderX"
:
"^3.1.0"
"HBuilderX"
:
"^3.1.0"
},
},
"dcloudext"
:
{
"dcloudext"
:
{
"category"
:
[
"uniCloud"
,
"云函数模板"
],
"sale"
:
{
"sale"
:
{
"regular"
:
{
"regular"
:
{
"price"
:
"0.00"
"price"
:
"0.00"
...
@@ -32,7 +28,8 @@
...
@@ -32,7 +28,8 @@
"data"
:
"无"
,
"data"
:
"无"
,
"permissions"
:
"无"
"permissions"
:
"无"
},
},
"npmurl"
:
""
"npmurl"
:
""
,
"type"
:
"unicloud-template-function"
},
},
"directories"
:
{
"directories"
:
{
"example"
:
"../../../scripts/dist"
"example"
:
"../../../scripts/dist"
...
@@ -73,8 +70,12 @@
...
@@ -73,8 +70,12 @@
"快应用"
:
{
"快应用"
:
{
"华为"
:
"u"
,
"华为"
:
"u"
,
"联盟"
:
"u"
"联盟"
:
"u"
},
"Vue"
:
{
"vue2"
:
"y"
,
"vue3"
:
"u"
}
}
}
}
}
}
}
}
}
}
uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/index.js
浏览文件 @
721bf925
此差异已折叠。
点击以展开。
uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/package.json
浏览文件 @
721bf925
{
{
"name"
:
"uni-config-center"
,
"name"
:
"uni-config-center"
,
"version"
:
"0.0.
2
"
,
"version"
:
"0.0.
3
"
,
"description"
:
"配置中心"
,
"description"
:
"配置中心"
,
"main"
:
"index.js"
,
"main"
:
"index.js"
,
"keywords"
:
[],
"keywords"
:
[],
...
...
uni_modules/uni-easyinput/changelog.md
浏览文件 @
721bf925
## 1.1.3(2022-09-22)
## 1.1.4(2022-10-27)
-
修复,引入 uni.scss 引入默认主题色报错的问题
-
修复 props 中背景颜色无默认值的bug
## 1.1.2(2022-09-22)
-
增加主题色 primaryColor 配置选项
## 1.1.1(2022-09-19)
-
修复,输入后回车,change 事件触发两次,
[
详情
](
https://ask.dcloud.net.cn/question/152149
)
## 1.1.0(2022-06-30)
## 1.1.0(2022-06-30)
-
新增 在 uni-forms 1.4.0 中使用可以在 blur 时校验内容
-
新增 在 uni-forms 1.4.0 中使用可以在 blur 时校验内容
-
新增 clear 事件,点击右侧叉号图标触发
-
新增 clear 事件,点击右侧叉号图标触发
-
新增 change 事件 ,仅在输入框失去焦点或用户按下回车时触发
-
新增 change 事件 ,仅在输入框失去焦点或用户按下回车时触发
-
优化 组件样式,组件获取焦点时高亮显示,图标颜色调整等
-
优化 组件样式,组件获取焦点时高亮显示,图标颜色调整等
-
## 1.0.5(2022-06-07)
## 1.0.5(2022-06-07)
-
优化 clearable 显示策略
-
优化 clearable 显示策略
## 1.0.4(2022-06-07)
## 1.0.4(2022-06-07)
-
优化 clearable 显示策略
-
优化 clearable 显示策略
## 1.0.3(2022-05-20)
## 1.0.3(2022-05-20)
-
修复 关闭图标某些情况下无法取消的bug
-
修复 关闭图标某些情况下无法取消的 bug
## 1.0.2(2022-04-12)
## 1.0.2(2022-04-12)
-
修复 默认值不生效的bug
-
修复 默认值不生效的 bug
## 1.0.1(2022-04-02)
## 1.0.1(2022-04-02)
-
修复 value不能为0的bug
-
修复 value 不能为 0 的 bug
## 1.0.0(2021-11-19)
## 1.0.0(2021-11-19)
-
优化 组件UI,并提供设计资源,详见:
[
https://uniapp.dcloud.io/component/uniui/resource
](
https://uniapp.dcloud.io/component/uniui/resource
)
-
优化 组件 UI,并提供设计资源,详见:
[
https://uniapp.dcloud.io/component/uniui/resource
](
https://uniapp.dcloud.io/component/uniui/resource
)
-
文档迁移,详见:
[
https://uniapp.dcloud.io/component/uniui/uni-easyinput
](
https://uniapp.dcloud.io/component/uniui/uni-easyinput
)
-
文档迁移,详见:
[
https://uniapp.dcloud.io/component/uniui/uni-easyinput
](
https://uniapp.dcloud.io/component/uniui/uni-easyinput
)
## 0.1.4(2021-08-20)
## 0.1.4(2021-08-20)
-
修复 在 uni-forms 的动态表单中默认值校验不通过的 bug
-
修复 在 uni-forms 的动态表单中默认值校验不通过的 bug
## 0.1.3(2021-08-11)
## 0.1.3(2021-08-11)
-
修复 在 uni-forms 中重置表单,错误信息无法清除的问题
-
修复 在 uni-forms 中重置表单,错误信息无法清除的问题
## 0.1.2(2021-07-30)
## 0.1.2(2021-07-30)
-
优化 vue3下事件警告的问题
-
优化 vue3 下事件警告的问题
## 0.1.1
## 0.1.1
-
优化 errorMessage 属性支持 Boolean 类型
-
优化 errorMessage 属性支持 Boolean 类型
## 0.1.0(2021-07-13)
## 0.1.0(2021-07-13)
-
组件兼容 vue3,如何创建vue3项目,详见
[
uni-app 项目支持 vue3 介绍
](
https://ask.dcloud.net.cn/article/37834
)
-
组件兼容 vue3,如何创建 vue3 项目,详见
[
uni-app 项目支持 vue3 介绍
](
https://ask.dcloud.net.cn/article/37834
)
## 0.0.16(2021-06-29)
## 0.0.16(2021-06-29)
-
修复 confirmType 属性(仅 type="text" 生效)导致多行文本框无法换行的 bug
-
修复 confirmType 属性(仅 type="text" 生效)导致多行文本框无法换行的 bug
## 0.0.15(2021-06-21)
## 0.0.15(2021-06-21)
-
修复 passwordIcon 属性拼写错误的 bug
-
修复 passwordIcon 属性拼写错误的 bug
## 0.0.14(2021-06-18)
## 0.0.14(2021-06-18)
-
新增 passwordIcon 属性,当type=password时是否显示小眼睛图标
-
新增 passwordIcon 属性,当 type=password 时是否显示小眼睛图标
-
修复 confirmType 属性不生效的问题
-
修复 confirmType 属性不生效的问题
## 0.0.13(2021-06-04)
## 0.0.13(2021-06-04)
-
修复 disabled 状态可清出内容的 bug
-
修复 disabled 状态可清出内容的 bug
## 0.0.12(2021-05-12)
## 0.0.12(2021-05-12)
-
新增 组件示例地址
-
新增 组件示例地址
## 0.0.11(2021-05-07)
## 0.0.11(2021-05-07)
-
修复 input-border 属性不生效的问题
-
修复 input-border 属性不生效的问题
## 0.0.10(2021-04-30)
## 0.0.10(2021-04-30)
-
修复 ios 遮挡文字、显示一半的问题
-
修复 ios 遮挡文字、显示一半的问题
## 0.0.9(2021-02-05)
## 0.0.9(2021-02-05)
-
调整为uni_modules目录规范
-
调整为 uni_modules 目录规范
-
优化 兼容 nvue 页面
-
优化 兼容 nvue 页面
uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue
浏览文件 @
721bf925
此差异已折叠。
点击以展开。
uni_modules/uni-easyinput/package.json
浏览文件 @
721bf925
{
{
"id"
:
"uni-easyinput"
,
"id"
:
"uni-easyinput"
,
"displayName"
:
"uni-easyinput 增强输入框"
,
"displayName"
:
"uni-easyinput 增强输入框"
,
"version"
:
"1.1.
3
"
,
"version"
:
"1.1.
4
"
,
"description"
:
"Easyinput 组件是对原生input组件的增强"
,
"description"
:
"Easyinput 组件是对原生input组件的增强"
,
"keywords"
:
[
"keywords"
:
[
"uni-ui"
,
"uni-ui"
,
...
...
uni_modules/uni-id-pages/changelog.md
浏览文件 @
721bf925
## 1.0.26(2022-10-18)
## 1.0.30(2022-11-11)
-
修复 uni-id-pages 导入时异常的Bug
-
uni-id-co 修复 用户只有openid时绑定微信/QQ报错
## 1.0.29(2022-11-10)
-
uni-id-co 支持URL化方式请求
[
详情
](
https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#adapter-http
)
## 1.0.28(2022-11-09)
-
uni-id-co 升级密码加密算法,支持hmac-sha256加密
[
详情
](
https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#password-safe
)
-
uni-id-co 新增 开发者可以自定义密码加密规则
[
详情
](
https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#custom-password-encrypt
)
-
uni-id-co 新增 支持将其他系统用户迁移至uni-id
[
详情
](
https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#move-users-to-uni-id
)
## 1.0.27(2022-10-26)
-
uni-id-co 新增 secureNetworkHandshakeByWeixin 接口,用于建立和微信小程序的安全网络连接
## 1.0.26(2022-10-18)
-
修复 uni-id-pages 导入时异常的Bug
## 1.0.25(2022-10-14)
## 1.0.25(2022-10-14)
-
uni-id-co 增加 微信授权手机号登录方式
[
文档
](
https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#login-by-weixin-mobile
)
-
uni-id-co 增加 微信授权手机号登录方式
[
文档
](
https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#login-by-weixin-mobile
)
-
uni-id-co 增加 解绑第三方平台账号
[
文档
](
https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-third-account
)
-
uni-id-co 增加 解绑第三方平台账号
[
文档
](
https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-third-account
)
...
...
uni_modules/uni-id-pages/init.js
浏览文件 @
721bf925
...
@@ -34,7 +34,7 @@ export default async function() {
...
@@ -34,7 +34,7 @@ export default async function() {
google
:
'
google
'
,
google
:
'
google
'
,
alipay
:
'
alipay
'
,
alipay
:
'
alipay
'
,
apple
:
"
apple
"
apple
:
"
apple
"
}
}
//遍历客户端配置的登录方式,与服务端比对。并在错误时抛出错误提示
//遍历客户端配置的登录方式,与服务端比对。并在错误时抛出错误提示
let
list
=
loginTypes
.
filter
(
type
=>
!
supportedLoginType
.
includes
(
data
[
type
]))
let
list
=
loginTypes
.
filter
(
type
=>
!
supportedLoginType
.
includes
(
data
[
type
]))
if
(
list
.
length
)
{
if
(
list
.
length
)
{
...
@@ -55,8 +55,7 @@ export default async function() {
...
@@ -55,8 +55,7 @@ export default async function() {
})
})
}
}
// #endif
// #endif
/* 注释此代码块原因:与uni-starter中的appinit逻辑一致
//3. 绑定clientDB错误事件
//3. 绑定clientDB错误事件
// clientDB对象
// clientDB对象
const
db
=
uniCloud
.
database
()
const
db
=
uniCloud
.
database
()
...
@@ -73,9 +72,9 @@ export default async function() {
...
@@ -73,9 +72,9 @@ export default async function() {
}
}
// 解绑clientDB错误事件
// 解绑clientDB错误事件
//db.off('error', onDBError)
//db.off('error', onDBError)
*/
//4. 同步客户端push_clientid至uni-id-device表
//4. 同步客户端push_clientid至device表
if
(
uniCloud
.
onRefreshToken
)
{
if
(
uniCloud
.
onRefreshToken
)
{
uniCloud
.
onRefreshToken
(()
=>
{
uniCloud
.
onRefreshToken
(()
=>
{
console
.
log
(
'
onRefreshToken
'
);
console
.
log
(
'
onRefreshToken
'
);
...
@@ -91,10 +90,10 @@ export default async function() {
...
@@ -91,10 +90,10 @@ export default async function() {
console
.
log
(
'
getPushClientId
'
,
res
);
console
.
log
(
'
getPushClientId
'
,
res
);
},
},
fail
(
e
)
{
fail
(
e
)
{
console
.
error
(
e
,
'
更多详情:https://uniapp.dcloud.net.cn/uniCloud/uni-starter.html#%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9
'
)
console
.
log
(
e
)
}
}
})
})
}
}
})
})
}
}
}
}
uni_modules/uni-id-pages/package.json
浏览文件 @
721bf925
{
{
"id"
:
"uni-id-pages"
,
"id"
:
"uni-id-pages"
,
"displayName"
:
"uni-id-pages"
,
"displayName"
:
"uni-id-pages"
,
"version"
:
"1.0.
26
"
,
"version"
:
"1.0.
30
"
,
"description"
:
"云端一体简单、统一、可扩展的用户中心页面模版"
,
"description"
:
"云端一体简单、统一、可扩展的用户中心页面模版"
,
"keywords"
:
[
"keywords"
:
[
"用户管理"
,
"用户管理"
,
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/constants.js
浏览文件 @
721bf925
...
@@ -6,6 +6,8 @@ const verifyCollectionName = 'opendb-verify-codes'
...
@@ -6,6 +6,8 @@ const verifyCollectionName = 'opendb-verify-codes'
const
verifyCollection
=
db
.
collection
(
verifyCollectionName
)
const
verifyCollection
=
db
.
collection
(
verifyCollectionName
)
const
deviceCollectionName
=
'
uni-id-device
'
const
deviceCollectionName
=
'
uni-id-device
'
const
deviceCollection
=
db
.
collection
(
deviceCollectionName
)
const
deviceCollection
=
db
.
collection
(
deviceCollectionName
)
const
openDataCollectionName
=
'
opendb-open-data
'
const
openDataCollection
=
db
.
collection
(
openDataCollectionName
)
const
USER_IDENTIFIER
=
{
const
USER_IDENTIFIER
=
{
username
:
'
username
'
,
username
:
'
username
'
,
...
@@ -78,6 +80,7 @@ module.exports = {
...
@@ -78,6 +80,7 @@ module.exports = {
userCollection
,
userCollection
,
verifyCollection
,
verifyCollection
,
deviceCollection
,
deviceCollection
,
openDataCollection
,
USER_IDENTIFIER
,
USER_IDENTIFIER
,
USER_STATUS
,
USER_STATUS
,
CAPTCHA_SCENE
,
CAPTCHA_SCENE
,
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js
浏览文件 @
721bf925
...
@@ -35,7 +35,8 @@ const ERROR = {
...
@@ -35,7 +35,8 @@ const ERROR = {
UNBIND_NOT_SUPPORTED
:
'
uni-id-unbind-not-supported
'
,
UNBIND_NOT_SUPPORTED
:
'
uni-id-unbind-not-supported
'
,
UNBIND_UNIQUE_LOGIN
:
'
uni-id-unbind-unique-login
'
,
UNBIND_UNIQUE_LOGIN
:
'
uni-id-unbind-unique-login
'
,
UNBIND_PASSWORD_NOT_EXISTS
:
'
uni-id-unbind-password-not-exists
'
,
UNBIND_PASSWORD_NOT_EXISTS
:
'
uni-id-unbind-password-not-exists
'
,
UNBIND_MOBILE_NOT_EXISTS
:
'
uni-id-unbind-mobile-not-exists
'
UNBIND_MOBILE_NOT_EXISTS
:
'
uni-id-unbind-mobile-not-exists
'
,
UNSUPPORTED_REQUEST
:
'
uni-id-unsupported-request
'
}
}
function
isUniIdError
(
errCode
)
{
function
isUniIdError
(
errCode
)
{
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/universal.js
0 → 100644
浏览文件 @
721bf925
const
{
ERROR
}
=
require
(
'
./error
'
)
function
getHttpClientInfo
()
{
const
requestId
=
this
.
getUniCloudRequestId
()
const
{
clientIP
,
userAgent
,
source
,
secretType
=
'
none
'
}
=
this
.
getClientInfo
()
const
{
clientInfo
=
{}
}
=
JSON
.
parse
(
this
.
getHttpInfo
().
body
)
return
{
...
clientInfo
,
clientIP
,
userAgent
,
source
,
secretType
,
requestId
}
}
function
getHttpUniIdToken
()
{
const
{
uniIdToken
=
''
}
=
JSON
.
parse
(
this
.
getHttpInfo
().
body
)
return
uniIdToken
}
function
verifyHttpMethod
()
{
const
{
headers
,
httpMethod
}
=
this
.
getHttpInfo
()
if
(
!
/^application
\/
json/
.
test
(
headers
[
'
content-type
'
])
||
httpMethod
.
toUpperCase
()
!==
'
POST
'
)
{
throw
{
errCode
:
ERROR
.
UNSUPPORTED_REQUEST
,
errMsg
:
'
unsupported request
'
}
}
}
function
universal
()
{
if
(
this
.
getClientInfo
().
source
===
'
http
'
)
{
verifyHttpMethod
.
call
(
this
)
this
.
getParams
()[
0
]
=
JSON
.
parse
(
this
.
getHttpInfo
().
body
).
params
this
.
getUniversalClientInfo
=
getHttpClientInfo
.
bind
(
this
)
this
.
getUniversalUniIdToken
=
getHttpUniIdToken
.
bind
(
this
)
}
else
{
this
.
getUniversalClientInfo
=
this
.
getClientInfo
this
.
getUniversalUniIdToken
=
this
.
getUniIdToken
}
}
module
.
exports
=
universal
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js
浏览文件 @
721bf925
...
@@ -12,6 +12,7 @@ const {
...
@@ -12,6 +12,7 @@ const {
isUniIdError
isUniIdError
}
=
require
(
'
./common/error
'
)
}
=
require
(
'
./common/error
'
)
const
middleware
=
require
(
'
./middleware/index
'
)
const
middleware
=
require
(
'
./middleware/index
'
)
const
universal
=
require
(
'
./common/universal
'
)
const
{
const
{
registerAdmin
,
registerAdmin
,
...
@@ -63,7 +64,8 @@ const {
...
@@ -63,7 +64,8 @@ const {
}
=
require
(
'
./module/verify/index
'
)
}
=
require
(
'
./module/verify/index
'
)
const
{
const
{
refreshToken
,
refreshToken
,
setPushCid
setPushCid
,
secureNetworkHandshakeByWeixin
}
=
require
(
'
./module/utils/index
'
)
}
=
require
(
'
./module/utils/index
'
)
const
{
const
{
getInvitedUser
,
getInvitedUser
,
...
@@ -80,7 +82,10 @@ const {
...
@@ -80,7 +82,10 @@ const {
module
.
exports
=
{
module
.
exports
=
{
async
_before
()
{
async
_before
()
{
const
clientInfo
=
this
.
getClientInfo
()
// 支持 callFunction 与 URL化
universal
.
call
(
this
)
const
clientInfo
=
this
.
getUniversalClientInfo
()
/**
/**
* 检查clientInfo,无appId和uniPlatform时本云对象无法正常运行
* 检查clientInfo,无appId和uniPlatform时本云对象无法正常运行
* 此外需要保证用到的clientInfo字段均经过类型检查
* 此外需要保证用到的clientInfo字段均经过类型检查
...
@@ -576,5 +581,9 @@ module.exports = {
...
@@ -576,5 +581,9 @@ module.exports = {
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-apple
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-apple
* @returns
* @returns
*/
*/
unbindApple
unbindApple
,
/**
* 安全网络握手,目前仅处理微信小程序安全网络握手
*/
secureNetworkHandshakeByWeixin
}
}
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js
浏览文件 @
721bf925
...
@@ -40,7 +40,8 @@ const sentence = {
...
@@ -40,7 +40,8 @@ const sentence = {
'
uni-id-unbind-failed
'
:
'
Please bind first and then unbind
'
,
'
uni-id-unbind-failed
'
:
'
Please bind first and then unbind
'
,
'
uni-id-unbind-not-supported
'
:
'
Unbinding is not supported
'
,
'
uni-id-unbind-not-supported
'
:
'
Unbinding is not supported
'
,
'
uni-id-unbind-mobile-not-exists
'
:
'
This is the only way to login at the moment, please bind your phone number and then try to unbind
'
,
'
uni-id-unbind-mobile-not-exists
'
:
'
This is the only way to login at the moment, please bind your phone number and then try to unbind
'
,
'
uni-id-unbind-password-not-exists
'
:
'
Please set a password first
'
'
uni-id-unbind-password-not-exists
'
:
'
Please set a password first
'
,
'
uni-id-unsupported-request
'
:
'
Unsupported request
'
}
}
module
.
exports
=
{
module
.
exports
=
{
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js
浏览文件 @
721bf925
...
@@ -40,7 +40,8 @@ const sentence = {
...
@@ -40,7 +40,8 @@ const sentence = {
'
uni-id-unbind-failed
'
:
'
请先绑定后再解绑
'
,
'
uni-id-unbind-failed
'
:
'
请先绑定后再解绑
'
,
'
uni-id-unbind-not-supported
'
:
'
不支持解绑
'
,
'
uni-id-unbind-not-supported
'
:
'
不支持解绑
'
,
'
uni-id-unbind-mobile-not-exists
'
:
'
这是当前唯一登录方式,请绑定手机号后再尝试解绑
'
,
'
uni-id-unbind-mobile-not-exists
'
:
'
这是当前唯一登录方式,请绑定手机号后再尝试解绑
'
,
'
uni-id-unbind-password-not-exists
'
:
'
请先设置密码在尝试解绑
'
'
uni-id-unbind-password-not-exists
'
:
'
请先设置密码在尝试解绑
'
,
'
uni-id-unsupported-request
'
:
'
不支持的请求方式
'
}
}
module
.
exports
=
{
module
.
exports
=
{
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/captcha.js
浏览文件 @
721bf925
...
@@ -39,7 +39,7 @@ async function getNeedCaptcha ({
...
@@ -39,7 +39,7 @@ async function getNeedCaptcha ({
const
{
const
{
data
:
recentRecord
data
:
recentRecord
}
=
await
uniIdLogCollection
.
where
({
}
=
await
uniIdLogCollection
.
where
({
ip
:
this
.
getClientInfo
().
clientIP
,
ip
:
this
.
get
Universal
ClientInfo
().
clientIP
,
...
userIdentifier
,
...
userIdentifier
,
type
,
type
,
create_date
:
dbCmd
.
gt
(
now
-
limitDuration
)
create_date
:
dbCmd
.
gt
(
now
-
limitDuration
)
...
@@ -61,7 +61,7 @@ async function verifyCaptcha (params = {}) {
...
@@ -61,7 +61,7 @@ async function verifyCaptcha (params = {}) {
}
}
}
}
const
payload
=
await
this
.
uniCaptcha
.
verify
({
const
payload
=
await
this
.
uniCaptcha
.
verify
({
deviceId
:
this
.
getClientInfo
().
deviceId
,
deviceId
:
this
.
get
Universal
ClientInfo
().
deviceId
,
captcha
,
captcha
,
scene
scene
})
})
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/login.js
浏览文件 @
721bf925
...
@@ -17,7 +17,7 @@ async function realPreLogin (params = {}) {
...
@@ -17,7 +17,7 @@ async function realPreLogin (params = {}) {
const
{
const
{
user
user
}
=
params
}
=
params
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
userMatched
=
await
findUser
({
const
userMatched
=
await
findUser
({
userQuery
:
user
,
userQuery
:
user
,
authorizedApp
:
appId
authorizedApp
:
appId
...
@@ -66,7 +66,7 @@ async function preLoginWithPassword (params = {}) {
...
@@ -66,7 +66,7 @@ async function preLoginWithPassword (params = {}) {
}
=
this
.
config
}
=
this
.
config
const
{
const
{
clientIP
clientIP
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
// 根据ip地址,密码错误次数过多,锁定登录
// 根据ip地址,密码错误次数过多,锁定登录
let
loginIPLimit
=
userRecord
.
login_ip_limit
||
[]
let
loginIPLimit
=
userRecord
.
login_ip_limit
||
[]
// 清理无用记录
// 清理无用记录
...
@@ -78,6 +78,8 @@ async function preLoginWithPassword (params = {}) {
...
@@ -78,6 +78,8 @@ async function preLoginWithPassword (params = {}) {
}
}
}
}
const
passwordUtils
=
new
PasswordUtils
({
const
passwordUtils
=
new
PasswordUtils
({
userRecord
,
clientInfo
:
this
.
getUniversalClientInfo
(),
passwordSecret
:
this
.
config
.
passwordSecret
passwordSecret
:
this
.
config
.
passwordSecret
})
})
...
@@ -85,9 +87,7 @@ async function preLoginWithPassword (params = {}) {
...
@@ -85,9 +87,7 @@ async function preLoginWithPassword (params = {}) {
success
:
checkPasswordSuccess
,
success
:
checkPasswordSuccess
,
refreshPasswordInfo
refreshPasswordInfo
}
=
passwordUtils
.
checkUserPassword
({
}
=
passwordUtils
.
checkUserPassword
({
password
,
password
passwordHash
:
userRecord
.
password
,
passwordSecretVersion
:
userRecord
.
password_secret_version
})
})
if
(
!
checkPasswordSuccess
)
{
if
(
!
checkPasswordSuccess
)
{
// 更新用户ip对应的密码错误记录
// 更新用户ip对应的密码错误记录
...
@@ -179,7 +179,7 @@ async function postLogin (params = {}) {
...
@@ -179,7 +179,7 @@ async function postLogin (params = {}) {
const
{
const
{
clientIP
,
clientIP
,
uniIdToken
uniIdToken
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
const
uid
=
user
.
_id
const
uid
=
user
.
_id
const
updateData
=
{
const
updateData
=
{
last_login_date
:
Date
.
now
(),
last_login_date
:
Date
.
now
(),
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/logout.js
浏览文件 @
721bf925
...
@@ -5,11 +5,11 @@ const {
...
@@ -5,11 +5,11 @@ const {
userCollection
userCollection
}
=
require
(
'
../../common/constants
'
)
}
=
require
(
'
../../common/constants
'
)
async
function
logout
()
{
async
function
logout
()
{
const
{
const
{
uniIdToken
,
uniIdToken
,
deviceId
deviceId
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
const
{
const
{
uid
uid
}
=
await
this
.
uniIdCommon
.
checkToken
(
}
=
await
this
.
uniIdCommon
.
checkToken
(
...
@@ -44,4 +44,4 @@ async function logout() {
...
@@ -44,4 +44,4 @@ async function logout() {
module
.
exports
=
{
module
.
exports
=
{
logout
logout
}
}
\ No newline at end of file
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/password.js
浏览文件 @
721bf925
...
@@ -2,37 +2,160 @@ const {
...
@@ -2,37 +2,160 @@ const {
getType
getType
}
=
require
(
'
../../common/utils
'
)
}
=
require
(
'
../../common/utils
'
)
const
crypto
=
require
(
'
crypto
'
)
const
crypto
=
require
(
'
crypto
'
)
const
createConfig
=
require
(
'
uni-config-center
'
)
const
shareConfig
=
createConfig
({
pluginId
:
'
uni-id
'
})
let
customPassword
=
{}
if
(
shareConfig
.
hasFile
(
'
custom-password.js
'
))
{
customPassword
=
shareConfig
.
requireFile
(
'
custom-password.js
'
)
||
{}
}
const
passwordAlgorithmMap
=
{
UNI_ID_HMAC_SHA1
:
'
hmac-sha1
'
,
UNI_ID_HMAC_SHA256
:
'
hmac-sha256
'
,
UNI_ID_CUSTOM
:
'
custom
'
}
const
passwordAlgorithmKeyMap
=
Object
.
keys
(
passwordAlgorithmMap
).
reduce
((
res
,
item
)
=>
{
res
[
passwordAlgorithmMap
[
item
]]
=
item
return
res
},
{})
const
passwordExtMethod
=
{
[
passwordAlgorithmMap
.
UNI_ID_HMAC_SHA1
]:
{
verify
({
password
})
{
const
{
password_secret_version
:
passwordSecretVersion
}
=
this
.
userRecord
const
passwordSecret
=
this
.
_getSecretByVersion
({
version
:
passwordSecretVersion
})
const
{
passwordHash
}
=
this
.
encrypt
({
password
,
passwordSecret
})
return
passwordHash
===
this
.
userRecord
.
password
},
encrypt
({
password
,
passwordSecret
})
{
const
{
value
:
secret
,
version
}
=
passwordSecret
const
hmac
=
crypto
.
createHmac
(
'
sha1
'
,
secret
.
toString
(
'
ascii
'
))
hmac
.
update
(
password
)
return
{
passwordHash
:
hmac
.
digest
(
'
hex
'
),
version
}
}
},
[
passwordAlgorithmMap
.
UNI_ID_HMAC_SHA256
]:
{
verify
({
password
})
{
const
parse
=
this
.
_parsePassword
()
const
passwordHash
=
crypto
.
createHmac
(
parse
.
algorithm
,
parse
.
salt
).
update
(
password
).
digest
(
'
hex
'
)
return
passwordHash
===
parse
.
hash
},
encrypt
({
password
,
passwordSecret
})
{
const
{
version
}
=
passwordSecret
// 默认使用 sha256 加密算法
const
salt
=
crypto
.
randomBytes
(
10
).
toString
(
'
hex
'
)
const
sha256Hash
=
crypto
.
createHmac
(
passwordAlgorithmMap
.
UNI_ID_HMAC_SHA256
.
substring
(
5
),
salt
).
update
(
password
).
digest
(
'
hex
'
)
const
algorithm
=
passwordAlgorithmKeyMap
[
passwordAlgorithmMap
.
UNI_ID_HMAC_SHA256
]
// B 为固定值,对应 PasswordMethodMaps 中的 sha256算法
// hash 格式 $[PasswordMethodFlagMapsKey]$[salt size]$[salt][Hash]
const
passwordHash
=
`$
${
algorithm
}
$
${
salt
.
length
}
$
${
salt
}${
sha256Hash
}
`
return
{
passwordHash
,
version
}
}
},
[
passwordAlgorithmMap
.
UNI_ID_CUSTOM
]:
{
verify
({
password
,
passwordSecret
})
{
if
(
!
customPassword
.
verifyPassword
)
throw
new
Error
(
'
verifyPassword method not found in custom password file
'
)
// return true or false
return
customPassword
.
verifyPassword
({
password
,
passwordSecret
,
userRecord
:
this
.
userRecord
,
clientInfo
:
this
.
clientInfo
})
},
encrypt
({
password
,
passwordSecret
})
{
if
(
!
customPassword
.
encryptPassword
)
throw
new
Error
(
'
encryptPassword method not found in custom password file
'
)
const
PasswordHashMethod
=
{
// return object<{passwordHash: string, version: number}>
'
hmac-sha1
'
:
function
(
content
,
secret
)
{
return
customPassword
.
encryptPassword
({
const
hmac
=
crypto
.
createHmac
(
'
sha1
'
,
secret
.
toString
(
'
ascii
'
))
password
,
hmac
.
update
(
content
)
passwordSecret
,
return
hmac
.
digest
(
'
hex
'
)
clientInfo
:
this
.
clientInfo
})
}
}
}
}
}
class
PasswordUtils
{
class
PasswordUtils
{
constructor
({
constructor
({
userRecord
=
{},
clientInfo
,
passwordSecret
passwordSecret
}
=
{})
{
}
=
{})
{
const
passwordSecretType
=
getType
(
passwordSecret
)
if
(
!
clientInfo
)
throw
new
Error
(
'
Invalid clientInfo
'
)
if
(
passwordSecretType
===
'
array
'
)
{
if
(
!
passwordSecret
)
throw
new
Error
(
'
Invalid password secret
'
)
this
.
passwordSecret
=
passwordSecret
.
sort
((
a
,
b
)
=>
{
return
a
.
version
-
b
.
version
this
.
clientInfo
=
clientInfo
this
.
userRecord
=
userRecord
this
.
passwordSecret
=
this
.
prePasswordSecret
(
passwordSecret
)
}
/**
* passwordSecret 预处理
* @param passwordSecret
* @return {*[]}
*/
prePasswordSecret
(
passwordSecret
)
{
const
newPasswordSecret
=
[]
if
(
getType
(
passwordSecret
)
===
'
string
'
)
{
newPasswordSecret
.
push
({
value
:
passwordSecret
,
type
:
passwordAlgorithmMap
.
UNI_ID_HMAC_SHA1
})
})
}
else
if
(
passwordSecretType
===
'
string
'
)
{
}
else
if
(
getType
(
passwordSecret
)
===
'
array
'
)
{
this
.
passwordSecret
=
[{
value
:
passwordSecret
}]
for
(
const
secret
of
passwordSecret
.
sort
((
a
,
b
)
=>
a
.
version
-
b
.
version
))
{
newPasswordSecret
.
push
({
...
secret
,
// 没有 type 设置默认 type hmac-sha1
type
:
secret
.
type
||
passwordAlgorithmMap
.
UNI_ID_HMAC_SHA1
})
}
}
else
{
}
else
{
throw
new
Error
(
'
Invalid password secret
'
)
throw
new
Error
(
'
Invalid password secret
'
)
}
}
return
newPasswordSecret
}
}
getSecretByVersion
(
params
=
{})
{
/**
const
{
* 获取最新加密密钥
version
* @return {*}
}
=
params
* @private
*/
_getLastestSecret
()
{
return
this
.
passwordSecret
[
this
.
passwordSecret
.
length
-
1
]
}
_getOldestSecret
()
{
return
this
.
passwordSecret
[
0
]
}
_getSecretByVersion
({
version
}
=
{})
{
if
(
!
version
&&
version
!==
0
)
{
if
(
!
version
&&
version
!==
0
)
{
return
this
.
getOldestSecret
()
return
this
.
_
getOldestSecret
()
}
}
if
(
this
.
passwordSecret
.
length
===
1
)
{
if
(
this
.
passwordSecret
.
length
===
1
)
{
return
this
.
passwordSecret
[
0
]
return
this
.
passwordSecret
[
0
]
...
@@ -40,77 +163,99 @@ class PasswordUtils {
...
@@ -40,77 +163,99 @@ class PasswordUtils {
return
this
.
passwordSecret
.
find
(
item
=>
item
.
version
===
version
)
return
this
.
passwordSecret
.
find
(
item
=>
item
.
version
===
version
)
}
}
getLastestSecret
()
{
/**
return
this
.
passwordSecret
[
this
.
passwordSecret
.
length
-
1
]
* 获取密码的验证/加密方法
* @param passwordSecret
* @return {*[]}
* @private
*/
_getPasswordExt
(
passwordSecret
)
{
const
ext
=
passwordExtMethod
[
passwordSecret
.
type
]
if
(
!
ext
)
{
throw
new
Error
(
`暂不支持
${
passwordSecret
.
type
}
类型的加密算法`
)
}
const
passwordExt
=
Object
.
create
(
null
)
for
(
const
key
in
ext
)
{
passwordExt
[
key
]
=
ext
[
key
].
bind
(
Object
.
assign
(
this
,
Object
.
keys
(
ext
).
reduce
((
res
,
item
)
=>
{
if
(
item
!==
key
)
{
res
[
item
]
=
ext
[
item
].
bind
(
this
)
}
return
res
},
{})))
}
return
passwordExt
}
}
getOldestSecret
()
{
_parsePassword
()
{
return
this
.
passwordSecret
[
0
]
const
[
algorithmKey
=
''
,
cost
=
0
,
hashStr
=
''
]
=
this
.
userRecord
.
password
.
split
(
'
$
'
).
filter
(
key
=>
key
)
const
algorithm
=
passwordAlgorithmMap
[
algorithmKey
]
?
passwordAlgorithmMap
[
algorithmKey
].
substring
(
5
)
:
null
const
salt
=
hashStr
.
substring
(
0
,
Number
(
cost
))
const
hash
=
hashStr
.
substring
(
Number
(
cost
))
return
{
algorithm
,
salt
,
hash
}
}
}
checkUserPassword
(
params
=
{})
{
/**
const
{
* 生成加密后的密码
* @param {String} password 密码
*/
generatePasswordHash
({
password
})
{
if
(
!
password
)
throw
new
Error
(
'
Invalid password
'
)
const
passwordSecret
=
this
.
_getLastestSecret
()
const
ext
=
this
.
_getPasswordExt
(
passwordSecret
)
const
{
passwordHash
,
version
}
=
ext
.
encrypt
({
password
,
password
,
passwordHash
:
passwordHashToCheck
,
passwordSecret
passwordSecretVersion
,
autoRefresh
=
true
}
=
params
const
currentPasswordSecret
=
this
.
getSecretByVersion
({
version
:
passwordSecretVersion
})
})
if
(
!
currentPasswordSecret
)
{
throw
new
Error
(
'
Invalid password version
'
)
return
{
passwordHash
,
version
}
}
const
{
}
value
:
passwordSecret
}
=
currentPasswordSecret
/**
const
{
* 密码校验
passwordHash
* @param {String} password
}
=
this
.
generatePasswordHash
({
* @param {Boolean} autoRefresh
password
,
* @return {{refreshPasswordInfo: {version: *, passwordHash: *}, success: boolean}|{success: boolean}}
passwordSecret
,
*/
passwordSecretVersion
checkUserPassword
({
password
,
autoRefresh
=
true
})
{
if
(
!
password
)
throw
new
Error
(
'
Invalid password
'
)
const
{
password_secret_version
:
passwordSecretVersion
}
=
this
.
userRecord
const
passwordSecret
=
this
.
_getSecretByVersion
({
version
:
passwordSecretVersion
})
})
if
(
passwordHashToCheck
!==
passwordHash
)
{
const
ext
=
this
.
_getPasswordExt
(
passwordSecret
)
const
success
=
ext
.
verify
({
password
,
passwordSecret
})
if
(
!
success
)
{
return
{
return
{
success
:
false
success
:
false
}
}
}
}
let
refreshPasswordInfo
let
refreshPasswordInfo
if
(
autoRefresh
&&
passwordSecretVersion
!==
this
.
getLastestSecret
().
version
)
{
if
(
autoRefresh
&&
passwordSecretVersion
!==
this
.
_getLastestSecret
().
version
)
{
refreshPasswordInfo
=
this
.
generatePasswordHash
({
refreshPasswordInfo
=
this
.
generatePasswordHash
({
password
})
password
})
}
}
return
{
return
{
success
:
true
,
success
:
true
,
refreshPasswordInfo
refreshPasswordInfo
}
}
}
}
generatePasswordHash
(
params
=
{})
{
let
{
password
,
passwordSecret
,
passwordSecretVersion
}
=
params
if
(
getType
(
password
)
!==
'
string
'
)
{
throw
new
Error
(
'
Invalid password
'
)
}
password
=
password
&&
password
.
trim
()
if
(
!
password
)
{
throw
new
Error
(
'
Invalid password
'
)
}
if
(
!
passwordSecret
)
{
const
lastestSecret
=
this
.
getLastestSecret
()
passwordSecret
=
lastestSecret
.
value
passwordSecretVersion
=
lastestSecret
.
version
}
return
{
passwordHash
:
PasswordHashMethod
[
'
hmac-sha1
'
](
password
,
passwordSecret
),
version
:
passwordSecretVersion
}
}
}
}
module
.
exports
=
PasswordUtils
module
.
exports
=
PasswordUtils
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/qq.js
浏览文件 @
721bf925
...
@@ -5,7 +5,7 @@ const {
...
@@ -5,7 +5,7 @@ const {
ERROR
ERROR
}
=
require
(
'
../../common/error
'
)
}
=
require
(
'
../../common/error
'
)
function
getQQPlatform
()
{
function
getQQPlatform
()
{
const
platform
=
this
.
clientPlatform
const
platform
=
this
.
clientPlatform
switch
(
platform
)
{
switch
(
platform
)
{
case
'
app
'
:
case
'
app
'
:
...
@@ -18,7 +18,7 @@ function getQQPlatform() {
...
@@ -18,7 +18,7 @@ function getQQPlatform() {
}
}
}
}
async
function
saveQQUserKey
({
async
function
saveQQUserKey
({
openid
,
openid
,
sessionKey
,
// QQ小程序用户sessionKey
sessionKey
,
// QQ小程序用户sessionKey
accessToken
,
// App端QQ用户accessToken
accessToken
,
// App端QQ用户accessToken
...
@@ -26,7 +26,7 @@ async function saveQQUserKey({
...
@@ -26,7 +26,7 @@ async function saveQQUserKey({
}
=
{})
{
}
=
{})
{
// 微信公众平台、开放平台refreshToken有效期均为30天(微信没有在网络请求里面返回30天这个值,务必注意未来可能出现调整,需及时更新此处逻辑)。
// 微信公众平台、开放平台refreshToken有效期均为30天(微信没有在网络请求里面返回30天这个值,务必注意未来可能出现调整,需及时更新此处逻辑)。
// 此前QQ开放平台有调整过accessToken的过期时间:[access_token有效期由90天缩短至30天](https://wiki.connect.qq.com/%E3%80%90qq%E4%BA%92%E8%81%94%E3%80%91access_token%E6%9C%89%E6%95%88%E6%9C%9F%E8%B0%83%E6%95%B4)
// 此前QQ开放平台有调整过accessToken的过期时间:[access_token有效期由90天缩短至30天](https://wiki.connect.qq.com/%E3%80%90qq%E4%BA%92%E8%81%94%E3%80%91access_token%E6%9C%89%E6%95%88%E6%9C%9F%E8%B0%83%E6%95%B4)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
const
keyObj
=
{
const
keyObj
=
{
dcloudAppid
:
appId
,
dcloudAppid
:
appId
,
...
@@ -45,9 +45,9 @@ async function saveQQUserKey({
...
@@ -45,9 +45,9 @@ async function saveQQUserKey({
await
this
.
uniOpenBridge
.
setUserAccessToken
(
keyObj
,
{
await
this
.
uniOpenBridge
.
setUserAccessToken
(
keyObj
,
{
access_token
:
accessToken
,
access_token
:
accessToken
,
access_token_expired
:
accessTokenExpired
access_token_expired
:
accessTokenExpired
},
accessTokenExpired
?
},
accessTokenExpired
Math
.
floor
((
accessTokenExpired
-
Date
.
now
())
/
1000
)
:
?
Math
.
floor
((
accessTokenExpired
-
Date
.
now
())
/
1000
)
30
*
24
*
60
*
60
:
30
*
24
*
60
*
60
)
)
break
break
default
:
default
:
...
@@ -55,7 +55,7 @@ async function saveQQUserKey({
...
@@ -55,7 +55,7 @@ async function saveQQUserKey({
}
}
}
}
function
generateQQCache
({
function
generateQQCache
({
sessionKey
,
// QQ小程序用户sessionKey
sessionKey
,
// QQ小程序用户sessionKey
accessToken
,
// App端QQ用户accessToken
accessToken
,
// App端QQ用户accessToken
accessTokenExpired
// App端QQ用户accessToken过期时间
accessTokenExpired
// App端QQ用户accessToken过期时间
...
@@ -84,11 +84,11 @@ function generateQQCache({
...
@@ -84,11 +84,11 @@ function generateQQCache({
}
}
}
}
function
getQQOpenid
({
function
getQQOpenid
({
userRecord
userRecord
}
=
{})
{
}
=
{})
{
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
qqOpenidObj
=
userRecord
.
qq_openid
const
qqOpenidObj
=
userRecord
.
qq_openid
if
(
!
qqOpenidObj
)
{
if
(
!
qqOpenidObj
)
{
return
return
...
@@ -96,7 +96,7 @@ function getQQOpenid({
...
@@ -96,7 +96,7 @@ function getQQOpenid({
return
qqOpenidObj
[
`
${
qqPlatform
}
_
${
appId
}
`
]
||
qqOpenidObj
[
qqPlatform
]
return
qqOpenidObj
[
`
${
qqPlatform
}
_
${
appId
}
`
]
||
qqOpenidObj
[
qqPlatform
]
}
}
async
function
getQQCacheFallback
({
async
function
getQQCacheFallback
({
userRecord
,
userRecord
,
key
key
}
=
{})
{
}
=
{})
{
...
@@ -109,13 +109,13 @@ async function getQQCacheFallback({
...
@@ -109,13 +109,13 @@ async function getQQCacheFallback({
return
qqCache
&&
qqCache
[
key
]
return
qqCache
&&
qqCache
[
key
]
}
}
async
function
getQQCache
({
async
function
getQQCache
({
uid
,
uid
,
userRecord
,
userRecord
,
key
key
}
=
{})
{
}
=
{})
{
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
if
(
!
userRecord
)
{
if
(
!
userRecord
)
{
const
getUserRes
=
await
userCollection
.
doc
(
uid
).
get
()
const
getUserRes
=
await
userCollection
.
doc
(
uid
).
get
()
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js
浏览文件 @
721bf925
...
@@ -18,13 +18,13 @@ const {
...
@@ -18,13 +18,13 @@ const {
const
PasswordUtils
=
require
(
'
./password
'
)
const
PasswordUtils
=
require
(
'
./password
'
)
const
merge
=
require
(
'
lodash.merge
'
)
const
merge
=
require
(
'
lodash.merge
'
)
async
function
realPreRegister
(
params
=
{})
{
async
function
realPreRegister
(
params
=
{})
{
const
{
const
{
user
user
}
=
params
}
=
params
const
userMatched
=
await
findUser
({
const
userMatched
=
await
findUser
({
userQuery
:
user
,
userQuery
:
user
,
authorizedApp
:
this
.
getClientInfo
().
appId
authorizedApp
:
this
.
get
Universal
ClientInfo
().
appId
})
})
if
(
userMatched
.
length
>
0
)
{
if
(
userMatched
.
length
>
0
)
{
throw
{
throw
{
...
@@ -33,7 +33,7 @@ async function realPreRegister(params = {}) {
...
@@ -33,7 +33,7 @@ async function realPreRegister(params = {}) {
}
}
}
}
async
function
preRegister
(
params
=
{})
{
async
function
preRegister
(
params
=
{})
{
try
{
try
{
await
realPreRegister
.
call
(
this
,
params
)
await
realPreRegister
.
call
(
this
,
params
)
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -45,7 +45,7 @@ async function preRegister(params = {}) {
...
@@ -45,7 +45,7 @@ async function preRegister(params = {}) {
}
}
}
}
async
function
preRegisterWithPassword
(
params
=
{})
{
async
function
preRegisterWithPassword
(
params
=
{})
{
const
{
const
{
user
,
user
,
password
password
...
@@ -54,6 +54,7 @@ async function preRegisterWithPassword(params = {}) {
...
@@ -54,6 +54,7 @@ async function preRegisterWithPassword(params = {}) {
user
user
})
})
const
passwordUtils
=
new
PasswordUtils
({
const
passwordUtils
=
new
PasswordUtils
({
clientInfo
:
this
.
getUniversalClientInfo
(),
passwordSecret
:
this
.
config
.
passwordSecret
passwordSecret
:
this
.
config
.
passwordSecret
})
})
const
{
const
{
...
@@ -72,7 +73,7 @@ async function preRegisterWithPassword(params = {}) {
...
@@ -72,7 +73,7 @@ async function preRegisterWithPassword(params = {}) {
}
}
}
}
async
function
thirdPartyRegister
({
async
function
thirdPartyRegister
({
user
=
{}
user
=
{}
}
=
{})
{
}
=
{})
{
return
{
return
{
...
@@ -81,7 +82,7 @@ async function thirdPartyRegister({
...
@@ -81,7 +82,7 @@ async function thirdPartyRegister({
}
}
}
}
async
function
postRegister
(
params
=
{})
{
async
function
postRegister
(
params
=
{})
{
const
{
const
{
user
,
user
,
extraData
=
{},
extraData
=
{},
...
@@ -98,7 +99,7 @@ async function postRegister(params = {}) {
...
@@ -98,7 +99,7 @@ async function postRegister(params = {}) {
clientIP
,
clientIP
,
osName
,
osName
,
uniIdToken
uniIdToken
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
merge
(
user
,
extraData
)
merge
(
user
,
extraData
)
...
@@ -162,7 +163,7 @@ async function postRegister(params = {}) {
...
@@ -162,7 +163,7 @@ async function postRegister(params = {}) {
if
(
beforeRegister
)
{
if
(
beforeRegister
)
{
userRecord
=
await
beforeRegister
({
userRecord
=
await
beforeRegister
({
userRecord
,
userRecord
,
clientInfo
:
this
.
getClientInfo
()
clientInfo
:
this
.
get
Universal
ClientInfo
()
})
})
}
}
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js
浏览文件 @
721bf925
...
@@ -29,7 +29,7 @@ async function preBind ({
...
@@ -29,7 +29,7 @@ async function preBind ({
}
=
{})
{
}
=
{})
{
const
userMatched
=
await
findUser
({
const
userMatched
=
await
findUser
({
userQuery
:
bindAccount
,
userQuery
:
bindAccount
,
authorizedApp
:
this
.
getClientInfo
().
appId
authorizedApp
:
this
.
get
Universal
ClientInfo
().
appId
})
})
if
(
userMatched
.
length
>
0
)
{
if
(
userMatched
.
length
>
0
)
{
await
this
.
middleware
.
uniIdLog
({
await
this
.
middleware
.
uniIdLog
({
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/unified-login.js
浏览文件 @
721bf925
...
@@ -17,7 +17,7 @@ async function realPreUnifiedLogin (params = {}) {
...
@@ -17,7 +17,7 @@ async function realPreUnifiedLogin (params = {}) {
user
,
user
,
type
type
}
=
params
}
=
params
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
userMatched
=
await
findUser
({
const
userMatched
=
await
findUser
({
userQuery
:
user
,
userQuery
:
user
,
authorizedApp
:
appId
authorizedApp
:
appId
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/univerify.js
浏览文件 @
721bf925
...
@@ -13,7 +13,7 @@ async function getPhoneNumber ({
...
@@ -13,7 +13,7 @@ async function getPhoneNumber ({
}
}
return
uniCloud
.
getPhoneNumber
({
return
uniCloud
.
getPhoneNumber
({
provider
:
'
univerify
'
,
provider
:
'
univerify
'
,
appid
:
this
.
getClientInfo
().
appId
,
appid
:
this
.
get
Universal
ClientInfo
().
appId
,
apiKey
:
univerifyConfig
.
apiKey
,
apiKey
:
univerifyConfig
.
apiKey
,
apiSecret
:
univerifyConfig
.
apiSecret
,
apiSecret
:
univerifyConfig
.
apiSecret
,
// eslint-disable-next-line camelcase
// eslint-disable-next-line camelcase
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/utils.js
0 → 100644
浏览文件 @
721bf925
let
redisEnable
=
null
function
getRedisEnable
()
{
// 未用到的时候不调用redis接口,节省一些连接数
if
(
redisEnable
!==
null
)
{
return
redisEnable
}
try
{
uniCloud
.
redis
()
redisEnable
=
true
}
catch
(
error
)
{
redisEnable
=
false
}
return
redisEnable
}
module
.
exports
=
{
getRedisEnable
}
\ No newline at end of file
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/verify-code.js
浏览文件 @
721bf925
...
@@ -23,7 +23,7 @@ async function setVerifyCode ({
...
@@ -23,7 +23,7 @@ async function setVerifyCode ({
scene
,
scene
,
code
:
code
||
getVerifyCode
(),
code
:
code
||
getVerifyCode
(),
state
:
0
,
state
:
0
,
ip
:
this
.
getClientInfo
().
clientIP
,
ip
:
this
.
get
Universal
ClientInfo
().
clientIP
,
created_date
:
now
,
created_date
:
now
,
expired_date
:
now
+
expiresIn
*
1000
expired_date
:
now
+
expiresIn
*
1000
}
}
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/weixin.js
浏览文件 @
721bf925
...
@@ -5,6 +5,12 @@ const {
...
@@ -5,6 +5,12 @@ const {
const
{
const
{
ERROR
ERROR
}
=
require
(
'
../../common/error
'
)
}
=
require
(
'
../../common/error
'
)
const
{
getRedisEnable
}
=
require
(
'
./utils
'
)
const
{
openDataCollection
}
=
require
(
'
../../common/constants
'
)
function
decryptWeixinData
({
function
decryptWeixinData
({
encryptedData
,
encryptedData
,
...
@@ -33,7 +39,7 @@ function decryptWeixinData ({
...
@@ -33,7 +39,7 @@ function decryptWeixinData ({
function
getWeixinPlatform
()
{
function
getWeixinPlatform
()
{
const
platform
=
this
.
clientPlatform
const
platform
=
this
.
clientPlatform
const
userAgent
=
this
.
getClientInfo
().
userAgent
const
userAgent
=
this
.
get
Universal
ClientInfo
().
userAgent
switch
(
platform
)
{
switch
(
platform
)
{
case
'
app
'
:
case
'
app
'
:
case
'
app-plus
'
:
case
'
app-plus
'
:
...
@@ -58,7 +64,7 @@ async function saveWeixinUserKey ({
...
@@ -58,7 +64,7 @@ async function saveWeixinUserKey ({
// 微信公众平台、开放平台refreshToken有效期均为30天(微信没有在网络请求里面返回30天这个值,务必注意未来可能出现调整,需及时更新此处逻辑)。
// 微信公众平台、开放平台refreshToken有效期均为30天(微信没有在网络请求里面返回30天这个值,务必注意未来可能出现调整,需及时更新此处逻辑)。
// 此前QQ开放平台有调整过accessToken的过期时间:[access_token有效期由90天缩短至30天](https://wiki.connect.qq.com/%E3%80%90qq%E4%BA%92%E8%81%94%E3%80%91access_token%E6%9C%89%E6%95%88%E6%9C%9F%E8%B0%83%E6%95%B4)
// 此前QQ开放平台有调整过accessToken的过期时间:[access_token有效期由90天缩短至30天](https://wiki.connect.qq.com/%E3%80%90qq%E4%BA%92%E8%81%94%E3%80%91access_token%E6%9C%89%E6%95%88%E6%9C%9F%E8%B0%83%E6%95%B4)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
keyObj
=
{
const
keyObj
=
{
dcloudAppid
:
appId
,
dcloudAppid
:
appId
,
...
@@ -85,6 +91,35 @@ async function saveWeixinUserKey ({
...
@@ -85,6 +91,35 @@ async function saveWeixinUserKey ({
}
}
}
}
async
function
saveSecureNetworkCache
({
code
,
openid
,
unionid
,
sessionKey
})
{
const
{
appId
}
=
this
.
getUniversalClientInfo
()
const
key
=
`uni-id:
${
appId
}
:weixin-mp:code:
${
code
}
:secure-network-cache`
const
value
=
JSON
.
stringify
({
openid
,
unionid
,
session_key
:
sessionKey
})
// 此处存储的是code的缓存,有效期两天即可
const
expiredSeconds
=
2
*
24
*
60
*
60
await
openDataCollection
.
doc
(
key
).
set
({
value
,
expired
:
Date
.
now
()
+
expiredSeconds
*
1000
})
const
isRedisEnable
=
getRedisEnable
()
if
(
isRedisEnable
)
{
const
redis
=
uniCloud
.
redis
()
await
redis
.
set
(
key
,
value
,
'
EX
'
,
expiredSeconds
)
}
}
function
generateWeixinCache
({
function
generateWeixinCache
({
sessionKey
,
// 微信小程序用户sessionKey
sessionKey
,
// 微信小程序用户sessionKey
accessToken
,
// App端微信用户accessToken
accessToken
,
// App端微信用户accessToken
...
@@ -122,7 +157,7 @@ function getWeixinOpenid ({
...
@@ -122,7 +157,7 @@ function getWeixinOpenid ({
userRecord
userRecord
}
=
{})
{
}
=
{})
{
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
wxOpenidObj
=
userRecord
.
wx_openid
const
wxOpenidObj
=
userRecord
.
wx_openid
if
(
!
wxOpenidObj
)
{
if
(
!
wxOpenidObj
)
{
return
return
...
@@ -149,7 +184,7 @@ async function getWeixinCache ({
...
@@ -149,7 +184,7 @@ async function getWeixinCache ({
key
key
}
=
{})
{
}
=
{})
{
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
if
(
!
userRecord
)
{
if
(
!
userRecord
)
{
const
getUserRes
=
await
userCollection
.
doc
(
uid
).
get
()
const
getUserRes
=
await
userCollection
.
doc
(
uid
).
get
()
userRecord
=
getUserRes
.
data
[
0
]
userRecord
=
getUserRes
.
data
[
0
]
...
@@ -179,7 +214,7 @@ async function getWeixinCache ({
...
@@ -179,7 +214,7 @@ async function getWeixinCache ({
async
function
getWeixinAccessToken
()
{
async
function
getWeixinAccessToken
()
{
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
cache
=
await
this
.
uniOpenBridge
.
getAccessToken
({
const
cache
=
await
this
.
uniOpenBridge
.
getAccessToken
({
dcloudAppid
:
appId
,
dcloudAppid
:
appId
,
...
@@ -194,5 +229,6 @@ module.exports = {
...
@@ -194,5 +229,6 @@ module.exports = {
generateWeixinCache
,
generateWeixinCache
,
getWeixinCache
,
getWeixinCache
,
saveWeixinUserKey
,
saveWeixinUserKey
,
getWeixinAccessToken
getWeixinAccessToken
,
saveSecureNetworkCache
}
}
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/auth.js
浏览文件 @
721bf925
...
@@ -2,7 +2,7 @@ module.exports = async function () {
...
@@ -2,7 +2,7 @@ module.exports = async function () {
if
(
this
.
authInfo
)
{
// 多次执行auth时如果第一次成功后续不再执行
if
(
this
.
authInfo
)
{
// 多次执行auth时如果第一次成功后续不再执行
return
return
}
}
const
token
=
this
.
getUniIdToken
()
const
token
=
this
.
getUni
versalUni
IdToken
()
const
payload
=
await
this
.
uniIdCommon
.
checkToken
(
token
)
const
payload
=
await
this
.
uniIdCommon
.
checkToken
(
token
)
if
(
payload
.
errCode
)
{
if
(
payload
.
errCode
)
{
throw
payload
throw
payload
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/uni-id-log.js
浏览文件 @
721bf925
...
@@ -19,7 +19,7 @@ module.exports = async function ({
...
@@ -19,7 +19,7 @@ module.exports = async function ({
clientIP
,
clientIP
,
deviceId
,
deviceId
,
userAgent
userAgent
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
const
logData
=
{
const
logData
=
{
appid
:
appId
,
appid
:
appId
,
device_id
:
deviceId
,
device_id
:
deviceId
,
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js
浏览文件 @
721bf925
...
@@ -79,7 +79,7 @@ module.exports = async function (params = {}) {
...
@@ -79,7 +79,7 @@ module.exports = async function (params = {}) {
userQuery
:
{
userQuery
:
{
email
email
},
},
authorizedApp
:
[
this
.
getClientInfo
().
appId
]
authorizedApp
:
[
this
.
get
Universal
ClientInfo
().
appId
]
})
})
if
(
userMatched
.
length
===
0
)
{
if
(
userMatched
.
length
===
0
)
{
throw
{
throw
{
...
@@ -95,6 +95,7 @@ module.exports = async function (params = {}) {
...
@@ -95,6 +95,7 @@ module.exports = async function (params = {}) {
passwordHash
,
passwordHash
,
version
version
}
=
new
PasswordUtils
({
}
=
new
PasswordUtils
({
clientInfo
:
this
.
getUniversalClientInfo
(),
passwordSecret
:
this
.
config
.
passwordSecret
passwordSecret
:
this
.
config
.
passwordSecret
}).
generatePasswordHash
({
}).
generatePasswordHash
({
password
password
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js
浏览文件 @
721bf925
...
@@ -79,7 +79,7 @@ module.exports = async function (params = {}) {
...
@@ -79,7 +79,7 @@ module.exports = async function (params = {}) {
userQuery
:
{
userQuery
:
{
mobile
mobile
},
},
authorizedApp
:
[
this
.
getClientInfo
().
appId
]
authorizedApp
:
[
this
.
get
Universal
ClientInfo
().
appId
]
})
})
if
(
userMatched
.
length
===
0
)
{
if
(
userMatched
.
length
===
0
)
{
throw
{
throw
{
...
@@ -95,6 +95,7 @@ module.exports = async function (params = {}) {
...
@@ -95,6 +95,7 @@ module.exports = async function (params = {}) {
passwordHash
,
passwordHash
,
version
version
}
=
new
PasswordUtils
({
}
=
new
PasswordUtils
({
clientInfo
:
this
.
getUniversalClientInfo
(),
passwordSecret
:
this
.
config
.
passwordSecret
passwordSecret
:
this
.
config
.
passwordSecret
}).
generatePasswordHash
({
}).
generatePasswordHash
({
password
password
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/update-pwd.js
浏览文件 @
721bf925
...
@@ -32,16 +32,18 @@ module.exports = async function (params = {}) {
...
@@ -32,16 +32,18 @@ module.exports = async function (params = {}) {
newPassword
newPassword
}
=
params
}
=
params
const
passwordUtils
=
new
PasswordUtils
({
const
passwordUtils
=
new
PasswordUtils
({
userRecord
,
clientInfo
:
this
.
getUniversalClientInfo
(),
passwordSecret
:
this
.
config
.
passwordSecret
passwordSecret
:
this
.
config
.
passwordSecret
})
})
const
{
const
{
success
:
checkPasswordSuccess
success
:
checkPasswordSuccess
}
=
passwordUtils
.
checkUserPassword
({
}
=
passwordUtils
.
checkUserPassword
({
password
:
oldPassword
,
password
:
oldPassword
,
passwordHash
:
userRecord
.
password
,
passwordSecretVersion
:
userRecord
.
password_secret_version
,
autoRefresh
:
false
autoRefresh
:
false
})
})
if
(
!
checkPasswordSuccess
)
{
if
(
!
checkPasswordSuccess
)
{
throw
{
throw
{
errCode
:
ERROR
.
PASSWORD_ERROR
errCode
:
ERROR
.
PASSWORD_ERROR
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/add-user.js
浏览文件 @
721bf925
...
@@ -83,6 +83,7 @@ module.exports = async function (params = {}) {
...
@@ -83,6 +83,7 @@ module.exports = async function (params = {}) {
}
}
}
}
const
passwordUtils
=
new
PasswordUtils
({
const
passwordUtils
=
new
PasswordUtils
({
clientInfo
:
this
.
getUniversalClientInfo
(),
passwordSecret
:
this
.
config
.
passwordSecret
passwordSecret
:
this
.
config
.
passwordSecret
})
})
const
{
const
{
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/update-user.js
浏览文件 @
721bf925
...
@@ -107,6 +107,7 @@ module.exports = async function (params = {}) {
...
@@ -107,6 +107,7 @@ module.exports = async function (params = {}) {
if
(
password
)
{
if
(
password
)
{
const
passwordUtils
=
new
PasswordUtils
({
const
passwordUtils
=
new
PasswordUtils
({
clientInfo
:
this
.
getUniversalClientInfo
(),
passwordSecret
:
this
.
config
.
passwordSecret
passwordSecret
:
this
.
config
.
passwordSecret
})
})
const
{
const
{
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-qq.js
浏览文件 @
721bf925
...
@@ -56,7 +56,7 @@ module.exports = async function (params = {}) {
...
@@ -56,7 +56,7 @@ module.exports = async function (params = {}) {
}
=
params
}
=
params
const
{
const
{
appId
appId
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
const
qqApi
=
initQQ
.
call
(
this
)
const
qqApi
=
initQQ
.
call
(
this
)
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
let
apiName
let
apiName
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin-mobile.js
浏览文件 @
721bf925
...
@@ -2,10 +2,7 @@ const {
...
@@ -2,10 +2,7 @@ const {
initWeixin
initWeixin
}
=
require
(
'
../../lib/third-party/index
'
)
}
=
require
(
'
../../lib/third-party/index
'
)
const
{
const
{
getWeixinPlatform
,
getWeixinAccessToken
getWeixinAccessToken
,
generateWeixinCache
,
saveWeixinUserKey
}
=
require
(
'
../../lib/utils/weixin
'
)
}
=
require
(
'
../../lib/utils/weixin
'
)
const
{
const
{
ERROR
ERROR
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin.js
浏览文件 @
721bf925
...
@@ -11,7 +11,8 @@ const {
...
@@ -11,7 +11,8 @@ const {
const
{
const
{
generateWeixinCache
,
generateWeixinCache
,
getWeixinPlatform
,
getWeixinPlatform
,
saveWeixinUserKey
saveWeixinUserKey
,
saveSecureNetworkCache
}
=
require
(
'
../../lib/utils/weixin
'
)
}
=
require
(
'
../../lib/utils/weixin
'
)
const
{
const
{
LOG_TYPE
LOG_TYPE
...
@@ -37,11 +38,13 @@ module.exports = async function (params = {}) {
...
@@ -37,11 +38,13 @@ module.exports = async function (params = {}) {
this
.
middleware
.
validate
(
params
,
schema
)
this
.
middleware
.
validate
(
params
,
schema
)
const
{
const
{
code
,
code
,
inviteCode
inviteCode
,
// 内部参数,暂不暴露
secureNetworkCache
=
false
}
=
params
}
=
params
const
{
const
{
appId
appId
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
const
weixinApi
=
initWeixin
.
call
(
this
)
const
weixinApi
=
initWeixin
.
call
(
this
)
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
let
apiName
let
apiName
...
@@ -81,6 +84,18 @@ module.exports = async function (params = {}) {
...
@@ -81,6 +84,18 @@ module.exports = async function (params = {}) {
expired
:
accessTokenExpired
// App端微信用户accessToken过期时间
expired
:
accessTokenExpired
// App端微信用户accessToken过期时间
}
=
getWeixinAccountResult
}
=
getWeixinAccountResult
if
(
secureNetworkCache
)
{
if
(
weixinPlatform
!==
'
mp
'
)
{
throw
new
Error
(
'
Unsupported weixin platform, expect mp-weixin
'
)
}
await
saveSecureNetworkCache
({
code
,
openid
,
unionid
,
sessionKey
})
}
const
{
const
{
type
,
type
,
user
user
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/register/register-admin.js
浏览文件 @
721bf925
...
@@ -38,7 +38,7 @@ module.exports = async function (params = {}) {
...
@@ -38,7 +38,7 @@ module.exports = async function (params = {}) {
}).
limit
(
1
).
get
()
}).
limit
(
1
).
get
()
if
(
getAdminRes
.
data
.
length
>
0
)
{
if
(
getAdminRes
.
data
.
length
>
0
)
{
const
[
admin
]
=
getAdminRes
.
data
const
[
admin
]
=
getAdminRes
.
data
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
if
(
!
admin
.
dcloud_appid
||
(
admin
.
dcloud_appid
&&
admin
.
dcloud_appid
.
includes
(
appId
)))
{
if
(
!
admin
.
dcloud_appid
||
(
admin
.
dcloud_appid
&&
admin
.
dcloud_appid
.
includes
(
appId
)))
{
return
{
return
{
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-qq.js
浏览文件 @
721bf925
...
@@ -49,7 +49,7 @@ module.exports = async function (params = {}) {
...
@@ -49,7 +49,7 @@ module.exports = async function (params = {}) {
accessTokenExpired
accessTokenExpired
}
=
params
}
=
params
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
qqApi
=
initQQ
.
call
(
this
)
const
qqApi
=
initQQ
.
call
(
this
)
const
clientPlatform
=
this
.
clientPlatform
const
clientPlatform
=
this
.
clientPlatform
const
apiName
=
clientPlatform
===
'
mp-qq
'
?
'
code2Session
'
:
'
getOpenidByToken
'
const
apiName
=
clientPlatform
===
'
mp-qq
'
?
'
code2Session
'
:
'
getOpenidByToken
'
...
@@ -78,7 +78,7 @@ module.exports = async function (params = {}) {
...
@@ -78,7 +78,7 @@ module.exports = async function (params = {}) {
const
bindAccount
=
{
const
bindAccount
=
{
qq_openid
:
{
qq_openid
:
{
[
client
Platform
]:
openid
[
qq
Platform
]:
openid
},
},
qq_unionid
:
unionid
qq_unionid
:
unionid
}
}
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-weixin.js
浏览文件 @
721bf925
...
@@ -34,7 +34,7 @@ module.exports = async function (params = {}) {
...
@@ -34,7 +34,7 @@ module.exports = async function (params = {}) {
code
code
}
=
params
}
=
params
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
weixinApi
=
initWeixin
.
call
(
this
)
const
weixinApi
=
initWeixin
.
call
(
this
)
const
clientPlatform
=
this
.
clientPlatform
const
clientPlatform
=
this
.
clientPlatform
...
@@ -64,7 +64,7 @@ module.exports = async function (params = {}) {
...
@@ -64,7 +64,7 @@ module.exports = async function (params = {}) {
const
bindAccount
=
{
const
bindAccount
=
{
wx_openid
:
{
wx_openid
:
{
[
client
Platform
]:
openid
[
weixin
Platform
]:
openid
},
},
wx_unionid
:
unionid
wx_unionid
:
unionid
}
}
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/unbind-qq.js
浏览文件 @
721bf925
...
@@ -16,7 +16,7 @@ const {
...
@@ -16,7 +16,7 @@ const {
*/
*/
module
.
exports
=
async
function
()
{
module
.
exports
=
async
function
()
{
const
{
uid
}
=
this
.
authInfo
const
{
uid
}
=
this
.
authInfo
const
{
appId
}
=
this
.
getClientInfo
()
const
{
appId
}
=
this
.
get
Universal
ClientInfo
()
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
await
preUnBind
.
call
(
this
,
{
await
preUnBind
.
call
(
this
,
{
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/index.js
浏览文件 @
721bf925
module
.
exports
=
{
module
.
exports
=
{
refreshToken
:
require
(
'
./refresh-token
'
),
refreshToken
:
require
(
'
./refresh-token
'
),
setPushCid
:
require
(
'
./set-push-cid
'
)
setPushCid
:
require
(
'
./set-push-cid
'
),
secureNetworkHandshakeByWeixin
:
require
(
'
./secure-network-handshake-by-weixin
'
)
}
}
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/refresh-token.js
浏览文件 @
721bf925
...
@@ -7,7 +7,7 @@ module.exports = async function () {
...
@@ -7,7 +7,7 @@ module.exports = async function () {
token
,
token
,
tokenExpired
tokenExpired
}
=
await
this
.
uniIdCommon
.
refreshToken
({
}
=
await
this
.
uniIdCommon
.
refreshToken
({
token
:
this
.
getUniIdToken
()
token
:
this
.
getUni
versalUni
IdToken
()
})
})
return
{
return
{
errCode
:
0
,
errCode
:
0
,
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/secure-network-handshake-by-weixin.js
0 → 100644
浏览文件 @
721bf925
const
{
ERROR
}
=
require
(
'
../../common/error
'
)
const
{
initWeixin
}
=
require
(
'
../../lib/third-party/index
'
)
const
{
saveWeixinUserKey
,
saveSecureNetworkCache
}
=
require
(
'
../../lib/utils/weixin
'
)
const
loginByWeixin
=
require
(
'
../login/login-by-weixin
'
)
/**
* 微信安全网络握手
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#set-push-cid
* @param {object} params
* @param {string} params.code 微信登录返回的code
* @param {boolean} params.callLoginByWeixin 是否同时调用一次微信登录
* @returns
*/
module
.
exports
=
async
function
(
params
=
{})
{
const
schema
=
{
code
:
'
string
'
,
callLoginByWeixin
:
{
type
:
'
boolean
'
,
required
:
false
}
}
this
.
middleware
.
validate
(
params
,
schema
)
let
platform
=
this
.
clientPlatform
if
(
platform
!==
'
mp-weixin
'
)
{
throw
new
Error
(
`[secureNetworkHandshake] platform
${
platform
}
is not supported`
)
}
const
{
code
,
callLoginByWeixin
=
false
}
=
params
if
(
callLoginByWeixin
)
{
return
loginByWeixin
.
call
(
this
,
{
code
,
secureNetworkCache
:
true
})
}
const
weixinApi
=
initWeixin
.
call
(
this
)
let
getWeixinAccountResult
try
{
getWeixinAccountResult
=
await
weixinApi
.
code2Session
(
code
)
}
catch
(
error
)
{
console
.
error
(
error
)
throw
{
errCode
:
ERROR
.
GET_THIRD_PARTY_ACCOUNT_FAILED
}
}
const
{
openid
,
unionid
,
sessionKey
// 微信小程序用户sessionKey
}
=
getWeixinAccountResult
await
saveSecureNetworkCache
.
call
(
this
,
{
code
,
openid
,
unionid
,
sessionKey
})
await
saveWeixinUserKey
.
call
(
this
,
{
openid
,
sessionKey
})
return
{
errCode
:
0
}
}
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/set-push-cid.js
浏览文件 @
721bf925
...
@@ -25,7 +25,7 @@ async function setOpendbDevice ({
...
@@ -25,7 +25,7 @@ async function setOpendbDevice ({
screenHeight
,
screenHeight
,
romName
,
romName
,
romVersion
romVersion
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
const
platform
=
this
.
clientPlatform
const
platform
=
this
.
clientPlatform
const
now
=
Date
.
now
()
const
now
=
Date
.
now
()
...
@@ -80,7 +80,7 @@ module.exports = async function (params = {}) {
...
@@ -80,7 +80,7 @@ module.exports = async function (params = {}) {
deviceId
,
deviceId
,
appId
,
appId
,
osName
osName
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
let
platform
=
this
.
clientPlatform
let
platform
=
this
.
clientPlatform
if
(
platform
===
'
app
'
)
{
if
(
platform
===
'
app
'
)
{
platform
+=
osName
platform
+=
osName
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/create-captcha.js
浏览文件 @
721bf925
...
@@ -18,7 +18,7 @@ module.exports = async function (params = {}) {
...
@@ -18,7 +18,7 @@ module.exports = async function (params = {}) {
}
}
this
.
middleware
.
validate
(
params
,
schema
)
this
.
middleware
.
validate
(
params
,
schema
)
const
deviceId
=
this
.
getClientInfo
().
deviceId
const
deviceId
=
this
.
get
Universal
ClientInfo
().
deviceId
const
{
const
{
scene
scene
}
=
params
}
=
params
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/refresh-captcha.js
浏览文件 @
721bf925
...
@@ -18,7 +18,7 @@ module.exports = async function (params = {}) {
...
@@ -18,7 +18,7 @@ module.exports = async function (params = {}) {
}
}
this
.
middleware
.
validate
(
params
,
schema
)
this
.
middleware
.
validate
(
params
,
schema
)
const
deviceId
=
this
.
getClientInfo
().
deviceId
const
deviceId
=
this
.
get
Universal
ClientInfo
().
deviceId
const
{
const
{
scene
scene
}
=
params
}
=
params
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json
浏览文件 @
721bf925
{
{
"name"
:
"uni-id-co"
,
"name"
:
"uni-id-co"
,
"version"
:
"1.0.
26
"
,
"version"
:
"1.0.
30
"
,
"description"
:
""
,
"description"
:
""
,
"main"
:
"index.js"
,
"main"
:
"index.js"
,
"keywords"
:
[],
"keywords"
:
[],
...
@@ -14,6 +14,10 @@
...
@@ -14,6 +14,10 @@
"uni-open-bridge-common"
:
"file:../../../../uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common"
"uni-open-bridge-common"
:
"file:../../../../uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common"
},
},
"extensions"
:
{
"extensions"
:
{
"uni-cloud-sms"
:
{}
"uni-cloud-sms"
:
{},
"uni-cloud-redis"
:
{}
},
"cloudfunction-config"
:
{
"keepRunningAfterReturn"
:
false
}
}
}
}
uni_modules/uni-list/changelog.md
浏览文件 @
721bf925
## 1.2.2(2022-11-11)
-
uni-list 新增属性 render-reverse 详情参考:
[
https://uniapp.dcloud.net.cn/component/list.html
](
https://uniapp.dcloud.net.cn/component/list.html
)
-
uni-list-chat note属性 支持:“草稿”字样 加红显示 详情参考uni-im:
[
https://ext.dcloud.net.cn/plugin?name=uni-im
](
https://ext.dcloud.net.cn/plugin?name=uni-im
)
-
uni-list-item 新增属性 customStyle 支持设置padding、backgroundColor
## 1.2.1(2022-03-30)
## 1.2.1(2022-03-30)
-
删除无用文件
-
删除无用文件
## 1.2.0(2021-11-23)
## 1.2.0(2021-11-23)
...
...
uni_modules/uni-list/components/uni-list-chat/uni-list-chat.vue
浏览文件 @
721bf925
...
@@ -23,8 +23,11 @@
...
@@ -23,8 +23,11 @@
</view>
</view>
<view
class=
"uni-list-chat__content"
>
<view
class=
"uni-list-chat__content"
>
<view
class=
"uni-list-chat__content-main"
>
<view
class=
"uni-list-chat__content-main"
>
<text
class=
"uni-list-chat__content-title uni-ellipsis"
>
{{
title
}}
</text>
<text
class=
"uni-list-chat__content-title uni-ellipsis"
>
{{
title
}}
</text>
<text
class=
"uni-list-chat__content-note uni-ellipsis"
>
{{
note
}}
</text>
<view
style=
"flex-direction: row;"
>
<text
class=
"draft"
v-if=
"isDraft"
>
[草稿]
</text>
<text
class=
"uni-list-chat__content-note uni-ellipsis"
>
{{
isDraft
?
note
.
slice
(
14
,
-
1
):
note
}}
</text>
</view>
</view>
</view>
<view
class=
"uni-list-chat__content-extra"
>
<view
class=
"uni-list-chat__content-extra"
>
<slot>
<slot>
...
@@ -120,7 +123,10 @@
...
@@ -120,7 +123,10 @@
}
}
},
},
// inject: ['list'],
// inject: ['list'],
computed
:
{
computed
:
{
isDraft
(){
return
this
.
note
.
slice
(
0
,
14
)
==
'
[uni-im-draft]
'
},
isSingle
()
{
isSingle
()
{
if
(
this
.
badgeText
===
'
dot
'
)
{
if
(
this
.
badgeText
===
'
dot
'
)
{
return
'
uni-badge--dot
'
;
return
'
uni-badge--dot
'
;
...
@@ -445,12 +451,19 @@
...
@@ -445,12 +451,19 @@
overflow
:
hidden
;
overflow
:
hidden
;
}
}
.uni-list-chat__content-note
{
.
draft
,
.
uni-list-chat__content-note
{
margin-top
:
3px
;
margin-top
:
3px
;
color
:
$note-color
;
color
:
$note-color
;
font-size
:
$note-size
;
font-size
:
$note-size
;
font-weight
:
$title-weight
;
font-weight
:
$title-weight
;
overflow
:
hidden
;
overflow
:
hidden
;
}
.draft
{
color
:
#eb3a41
;
/* #ifndef APP-NVUE */
flex-shrink
:
0
;
/* #endif */
padding-right
:
3px
;
}
}
.uni-list-chat__content-extra
{
.uni-list-chat__content-extra
{
...
...
uni_modules/uni-list/components/uni-list-item/uni-list-item.vue
浏览文件 @
721bf925
<
template
>
<
template
>
<!-- #ifdef APP-NVUE -->
<!-- #ifdef APP-NVUE -->
<cell>
<cell
keep-scroll-position
>
<!-- #endif -->
<!-- #endif -->
<view
:class=
"
{ 'uni-list-item--disabled': disabled }" :style="{'background-color':customStyle.backgroundColor}"
<view
:class=
"
{ 'uni-list-item--disabled': disabled }"
:hover-class="(!clickable
&&
!link) || disabled || showSwitch ? '' : 'uni-list-item--hover'"
:hover-class="(!clickable
&&
!link) || disabled || showSwitch ? '' : 'uni-list-item--hover'"
class="uni-list-item" @click="onClick">
class="uni-list-item" @click="onClick">
<view
v-if=
"!isFirstChild"
class=
"border--left"
:class=
"
{ 'uni-list--border': border }">
</view>
<view
v-if=
"!isFirstChild"
class=
"border--left"
:class=
"
{ 'uni-list--border': border }">
</view>
<view
class=
"uni-list-item__container"
<view
class=
"uni-list-item__container"
:class=
"
{ 'container--right': showArrow || link, 'flex--direction': direction === 'column' }">
:class=
"
{ 'container--right': showArrow || link, 'flex--direction': direction === 'column'}"
:style="{padding:customStyle.padding}">
<slot
name=
"header"
>
<slot
name=
"header"
>
<view
class=
"uni-list-item__header"
>
<view
class=
"uni-list-item__header"
>
<view
v-if=
"thumb"
class=
"uni-list-item__icon"
>
<view
v-if=
"thumb"
class=
"uni-list-item__icon"
>
...
@@ -96,7 +96,7 @@
...
@@ -96,7 +96,7 @@
default
:
''
default
:
''
},
},
ellipsis
:
{
ellipsis
:
{
type
:
[
Number
,
String
],
type
:
[
Number
,
String
],
default
:
0
default
:
0
},
},
disabled
:
{
disabled
:
{
...
@@ -139,7 +139,7 @@
...
@@ -139,7 +139,7 @@
type
:
String
,
type
:
String
,
default
:
'
success
'
default
:
'
success
'
},
},
badgeStyle
:{
badgeStyle
:
{
type
:
Object
,
type
:
Object
,
default
()
{
default
()
{
return
{}
return
{}
...
@@ -174,6 +174,15 @@
...
@@ -174,6 +174,15 @@
border
:
{
border
:
{
type
:
Boolean
,
type
:
Boolean
,
default
:
true
default
:
true
},
customStyle
:
{
type
:
Object
,
default
()
{
return
{
padding
:
''
,
backgroundColor
:
'
#FFFFFF
'
}
}
}
}
},
},
// inject: ['list'],
// inject: ['list'],
...
@@ -255,7 +264,7 @@
...
@@ -255,7 +264,7 @@
uni
.
switchTab
(
callback
)
uni
.
switchTab
(
callback
)
break
break
default
:
default
:
uni
.
navigateTo
(
callback
)
uni
.
navigateTo
(
callback
)
}
}
}
}
}
}
...
@@ -275,6 +284,7 @@
...
@@ -275,6 +284,7 @@
$uni-bg-color-hover
:
#f1f1f1
;
$uni-bg-color-hover
:
#f1f1f1
;
$uni-text-color-grey
:
#999
;
$uni-text-color-grey
:
#999
;
$list-item-pd
:
$uni-spacing-col-lg
$uni-spacing-row-lg
;
$list-item-pd
:
$uni-spacing-col-lg
$uni-spacing-row-lg
;
.uni-list-item
{
.uni-list-item
{
/* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */
display
:
flex
;
display
:
flex
;
...
@@ -289,12 +299,15 @@
...
@@ -289,12 +299,15 @@
cursor
:
pointer
;
cursor
:
pointer
;
/* #endif */
/* #endif */
}
}
.uni-list-item--disabled
{
.uni-list-item--disabled
{
opacity
:
0
.3
;
opacity
:
0
.3
;
}
}
.uni-list-item--hover
{
.uni-list-item--hover
{
background-color
:
$uni-bg-color-hover
;
background-color
:
$uni-bg-color-hover
;
}
}
.uni-list-item__container
{
.uni-list-item__container
{
position
:
relative
;
position
:
relative
;
/* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */
...
@@ -307,9 +320,11 @@
...
@@ -307,9 +320,11 @@
overflow
:
hidden
;
overflow
:
hidden
;
// align-items: center;
// align-items: center;
}
}
.container--right
{
.container--right
{
padding-right
:
0
;
padding-right
:
0
;
}
}
// .border--left {
// .border--left {
// margin-left: $uni-spacing-row-lg;
// margin-left: $uni-spacing-row-lg;
// }
// }
...
@@ -324,6 +339,7 @@
...
@@ -324,6 +339,7 @@
border-top-width
:
0
.5px
;
border-top-width
:
0
.5px
;
/* #endif */
/* #endif */
}
}
/* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */
.uni-list--border
:after
{
.uni-list--border
:after
{
position
:
absolute
;
position
:
absolute
;
...
@@ -336,6 +352,7 @@
...
@@ -336,6 +352,7 @@
transform
:
scaleY
(
0
.5
);
transform
:
scaleY
(
0
.5
);
background-color
:
$uni-border-color
;
background-color
:
$uni-border-color
;
}
}
/* #endif */
/* #endif */
.uni-list-item__content
{
.uni-list-item__content
{
/* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */
...
@@ -349,20 +366,24 @@
...
@@ -349,20 +366,24 @@
justify-content
:
space-between
;
justify-content
:
space-between
;
overflow
:
hidden
;
overflow
:
hidden
;
}
}
.uni-list-item__content--center
{
.uni-list-item__content--center
{
justify-content
:
center
;
justify-content
:
center
;
}
}
.uni-list-item__content-title
{
.uni-list-item__content-title
{
font-size
:
$uni-font-size-base
;
font-size
:
$uni-font-size-base
;
color
:
#3b4144
;
color
:
#3b4144
;
overflow
:
hidden
;
overflow
:
hidden
;
}
}
.uni-list-item__content-note
{
.uni-list-item__content-note
{
margin-top
:
6rpx
;
margin-top
:
6rpx
;
color
:
$uni-text-color-grey
;
color
:
$uni-text-color-grey
;
font-size
:
$uni-font-size-sm
;
font-size
:
$uni-font-size-sm
;
overflow
:
hidden
;
overflow
:
hidden
;
}
}
.uni-list-item__extra
{
.uni-list-item__extra
{
// width: 25%;
// width: 25%;
/* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */
...
@@ -372,6 +393,7 @@
...
@@ -372,6 +393,7 @@
justify-content
:
flex-end
;
justify-content
:
flex-end
;
align-items
:
center
;
align-items
:
center
;
}
}
.uni-list-item__header
{
.uni-list-item__header
{
/* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */
display
:
flex
;
display
:
flex
;
...
@@ -379,12 +401,14 @@
...
@@ -379,12 +401,14 @@
flex-direction
:
row
;
flex-direction
:
row
;
align-items
:
center
;
align-items
:
center
;
}
}
.uni-list-item__icon
{
.uni-list-item__icon
{
margin-right
:
18rpx
;
margin-right
:
18rpx
;
flex-direction
:
row
;
flex-direction
:
row
;
justify-content
:
center
;
justify-content
:
center
;
align-items
:
center
;
align-items
:
center
;
}
}
.uni-list-item__icon-img
{
.uni-list-item__icon-img
{
/* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */
display
:
block
;
display
:
block
;
...
@@ -393,6 +417,7 @@
...
@@ -393,6 +417,7 @@
width
:
$uni-img-size-base
;
width
:
$uni-img-size-base
;
margin-right
:
10px
;
margin-right
:
10px
;
}
}
.uni-icon-wrapper
{
.uni-icon-wrapper
{
/* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */
display
:
flex
;
display
:
flex
;
...
@@ -400,33 +425,40 @@
...
@@ -400,33 +425,40 @@
align-items
:
center
;
align-items
:
center
;
padding
:
0
10px
;
padding
:
0
10px
;
}
}
.flex--direction
{
.flex--direction
{
flex-direction
:
column
;
flex-direction
:
column
;
/* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */
align-items
:
initial
;
align-items
:
initial
;
/* #endif */
/* #endif */
}
}
.flex--justify
{
.flex--justify
{
/* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */
justify-content
:
initial
;
justify-content
:
initial
;
/* #endif */
/* #endif */
}
}
.uni-list--lg
{
.uni-list--lg
{
height
:
$uni-img-size-lg
;
height
:
$uni-img-size-lg
;
width
:
$uni-img-size-lg
;
width
:
$uni-img-size-lg
;
}
}
.uni-list--base
{
.uni-list--base
{
height
:
$uni-img-size-base
;
height
:
$uni-img-size-base
;
width
:
$uni-img-size-base
;
width
:
$uni-img-size-base
;
}
}
.uni-list--sm
{
.uni-list--sm
{
height
:
$uni-img-size-sm
;
height
:
$uni-img-size-sm
;
width
:
$uni-img-size-sm
;
width
:
$uni-img-size-sm
;
}
}
.uni-list-item__extra-text
{
.uni-list-item__extra-text
{
color
:
$uni-text-color-grey
;
color
:
$uni-text-color-grey
;
font-size
:
$uni-font-size-sm
;
font-size
:
$uni-font-size-sm
;
}
}
.uni-ellipsis-1
{
.uni-ellipsis-1
{
/* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */
overflow
:
hidden
;
overflow
:
hidden
;
...
@@ -435,9 +467,10 @@
...
@@ -435,9 +467,10 @@
/* #endif */
/* #endif */
/* #ifdef APP-NVUE */
/* #ifdef APP-NVUE */
lines
:
1
;
lines
:
1
;
text-overflow
:ellipsis
;
text-overflow
:
ellipsis
;
/* #endif */
/* #endif */
}
}
.uni-ellipsis-2
{
.uni-ellipsis-2
{
/* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */
overflow
:
hidden
;
overflow
:
hidden
;
...
@@ -448,7 +481,7 @@
...
@@ -448,7 +481,7 @@
/* #endif */
/* #endif */
/* #ifdef APP-NVUE */
/* #ifdef APP-NVUE */
lines
:
2
;
lines
:
2
;
text-overflow
:ellipsis
;
text-overflow
:
ellipsis
;
/* #endif */
/* #endif */
}
}
</
style
>
</
style
>
uni_modules/uni-list/components/uni-list/uni-list.vue
浏览文件 @
721bf925
...
@@ -5,104 +5,119 @@
...
@@ -5,104 +5,119 @@
<slot
/>
<slot
/>
<view
v-if=
"border"
class=
"uni-list--border-bottom"
></view>
<view
v-if=
"border"
class=
"uni-list--border-bottom"
></view>
</view>
</view>
<!-- #endif -->
<!-- #endif -->
<!-- #ifdef APP-NVUE -->
<!-- #ifdef APP-NVUE -->
<list
class=
"uni-list"
:class=
"
{ 'uni-list--border': border }" :enableBackToTop="enableBackToTop" loadmoreoffset="15">
<slot
/></list>
<list
:bounce=
"false"
:scrollable=
"true"
show-scrollbar
:render-reverse=
"renderReverse"
@
scroll=
"scroll"
class=
"uni-list"
:class=
"
{ 'uni-list--border': border }" :enableBackToTop="enableBackToTop"
loadmoreoffset="15">
<slot
/>
</list>
<!-- #endif -->
<!-- #endif -->
</
template
>
</
template
>
<
script
>
<
script
>
/**
/**
* List 列表
* List 列表
* @description 列表组件
* @description 列表组件
* @tutorial https://ext.dcloud.net.cn/plugin?id=24
* @tutorial https://ext.dcloud.net.cn/plugin?id=24
* @property {String} border = [true|false] 标题
* @property {String} border = [true|false] 标题
*/
*/
export
default
{
export
default
{
name
:
'
uniList
'
,
name
:
'
uniList
'
,
'
mp-weixin
'
:
{
'
mp-weixin
'
:
{
options
:
{
options
:
{
multipleSlots
:
false
multipleSlots
:
false
}
}
},
props
:
{
enableBackToTop
:
{
type
:
[
Boolean
,
String
],
default
:
false
},
},
scrollY
:
{
props
:
{
type
:
[
Boolean
,
String
],
stackFromEnd
:{
default
:
false
type
:
Boolean
,
default
:
false
},
enableBackToTop
:
{
type
:
[
Boolean
,
String
],
default
:
false
},
scrollY
:
{
type
:
[
Boolean
,
String
],
default
:
false
},
border
:
{
type
:
Boolean
,
default
:
true
},
renderReverse
:{
type
:
Boolean
,
default
:
false
}
},
},
border
:
{
// provide() {
type
:
Boolean
,
// return {
default
:
true
// list: this
}
// };
},
// },
// provide() {
created
()
{
// return {
this
.
firstChildAppend
=
false
;
// list: this
},
// };
methods
:
{
// },
loadMore
(
e
)
{
created
()
{
this
.
$emit
(
'
scrolltolower
'
);
this
.
firstChildAppend
=
false
;
},
},
scroll
(
e
)
{
methods
:
{
this
.
$emit
(
'
scroll
'
,
e
);
loadMore
(
e
)
{
}
this
.
$emit
(
'
scrolltolower
'
);
}
}
}
};
};
</
script
>
</
script
>
<
style
lang=
"scss"
>
<
style
lang=
"scss"
>
$uni-bg-color
:
#ffffff
;
$uni-bg-color
:
#ffffff
;
$uni-border-color
:
#e5e5e5
;
$uni-border-color
:
#e5e5e5
;
.uni-list
{
/* #ifndef APP-NVUE */
display
:
flex
;
/* #endif */
background-color
:
$uni-bg-color
;
position
:
relative
;
flex-direction
:
column
;
}
.uni-list--border
{
.uni-list
{
position
:
relative
;
/* #ifndef APP-NVUE */
/* #ifdef APP-NVUE */
display
:
flex
;
border-top-color
:
$uni-border-color
;
/* #endif */
border-top-style
:
solid
;
background-color
:
$uni-bg-color
;
border-top-width
:
0
.5px
;
position
:
relative
;
border-bottom-color
:
$uni-border-color
;
flex-direction
:
column
;
border-bottom-style
:
solid
;
}
border-bottom-width
:
0
.5px
;
/* #endif */
z-index
:
-1
;
}
/* #ifndef APP-NVUE */
.uni-list--border
{
position
:
relative
;
/* #ifdef APP-NVUE */
border-top-color
:
$uni-border-color
;
border-top-style
:
solid
;
border-top-width
:
0
.5px
;
border-bottom-color
:
$uni-border-color
;
border-bottom-style
:
solid
;
border-bottom-width
:
0
.5px
;
/* #endif */
z-index
:
-1
;
}
.uni-list--border-top
{
/* #ifndef APP-NVUE */
position
:
absolute
;
top
:
0
;
right
:
0
;
left
:
0
;
height
:
1px
;
-webkit-transform
:
scaleY
(
0
.5
);
transform
:
scaleY
(
0
.5
);
background-color
:
$uni-border-color
;
z-index
:
1
;
}
.uni-list--border-bottom
{
.uni-list--border-top
{
position
:
absolute
;
position
:
absolute
;
bottom
:
0
;
top
:
0
;
right
:
0
;
right
:
0
;
left
:
0
;
left
:
0
;
height
:
1px
;
height
:
1px
;
-webkit-transform
:
scaleY
(
0
.5
);
-webkit-transform
:
scaleY
(
0
.5
);
transform
:
scaleY
(
0
.5
);
transform
:
scaleY
(
0
.5
);
background-color
:
$uni-border-color
;
background-color
:
$uni-border-color
;
}
z-index
:
1
;
}
/* #endif */
.uni-list--border-bottom
{
</
style
>
position
:
absolute
;
bottom
:
0
;
right
:
0
;
left
:
0
;
height
:
1px
;
-webkit-transform
:
scaleY
(
0
.5
);
transform
:
scaleY
(
0
.5
);
background-color
:
$uni-border-color
;
}
/* #endif */
</
style
>
uni_modules/uni-list/package.json
浏览文件 @
721bf925
{
{
"id"
:
"uni-list"
,
"id"
:
"uni-list"
,
"displayName"
:
"uni-list 列表"
,
"displayName"
:
"uni-list 列表"
,
"version"
:
"1.2.
1
"
,
"version"
:
"1.2.
2
"
,
"description"
:
"List 组件 ,帮助使用者快速构建列表。"
,
"description"
:
"List 组件 ,帮助使用者快速构建列表。"
,
"keywords"
:
[
"keywords"
:
[
""
,
""
,
...
@@ -18,11 +18,7 @@
...
@@ -18,11 +18,7 @@
"directories"
:
{
"directories"
:
{
"example"
:
"../../temps/example_temps"
"example"
:
"../../temps/example_temps"
},
},
"dcloudext"
:
{
"dcloudext"
:
{
"category"
:
[
"前端组件"
,
"通用组件"
],
"sale"
:
{
"sale"
:
{
"regular"
:
{
"regular"
:
{
"price"
:
"0.00"
"price"
:
"0.00"
...
@@ -39,7 +35,8 @@
...
@@ -39,7 +35,8 @@
"data"
:
"无"
,
"data"
:
"无"
,
"permissions"
:
"无"
"permissions"
:
"无"
},
},
"npmurl"
:
"https://www.npmjs.com/package/@dcloudio/uni-ui"
"npmurl"
:
"https://www.npmjs.com/package/@dcloudio/uni-ui"
,
"type"
:
"component-vue"
},
},
"uni_modules"
:
{
"uni_modules"
:
{
"dependencies"
:
[
"dependencies"
:
[
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录