Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
6ad9f816
U
uni-app
项目概览
DCloud
/
uni-app
2 个月 前同步成功
通知
717
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6ad9f816
编写于
6月 22, 2020
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs: uni-id
上级
f1aaa94e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
337 addition
and
740 deletion
+337
-740
docs/uniCloud/_sidebar.md
docs/uniCloud/_sidebar.md
+1
-0
docs/uniCloud/uni-account.md
docs/uniCloud/uni-account.md
+2
-0
docs/uniCloud/uni-id-copy
docs/uniCloud/uni-id-copy
+0
-449
docs/uniCloud/uni-id.md
docs/uniCloud/uni-id.md
+334
-291
未找到文件。
docs/uniCloud/_sidebar.md
浏览文件 @
6ad9f816
...
...
@@ -15,6 +15,7 @@
*
[
云存储
](
uniCloud/storage.md
)
*
扩展能力
*
[
uni-account
](
uniCloud/uni-account.md
)
*
[
uni-id
](
uniCloud/uni-id.md
)
*
[
unipay
](
uniCloud/unipay.md
)
*
[
前端网页托管
](
uniCloud/hosting.md
)
*
[
腾讯云自定义登录
](
uniCloud/authentication.md
)
...
...
docs/uniCloud/uni-account.md
浏览文件 @
6ad9f816
...
...
@@ -2,6 +2,8 @@
`uni-account`
是一个适用于微信小程序和支付宝小程序的平台账户登录的云函数模板。
`uni-account`
内部对不同平台的 api 进行了拉齐,有助于开发者更方便的调用相关功能。
**后续uni-account会整合到uni-id内**
## 引入 uni-account
开发者可以自行选择是从插件市场导入还是从 npm 安装,引入方式略有不同,请看下面示例
...
...
docs/uniCloud/uni-id-copy
已删除
100644 → 0
浏览文件 @
f1aaa94e
## 简介
`uni-id`是`uniCloud`提供的一套标准化的用户中心,我们的目标是使用`uni-id`可以轻松的对接各种各样的系统。
## 用户注册 @register
用法`uniID.register(Object user)`
**user参数说明**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| username | String| 是 |用户名,唯一 |
| password | String| 是 |密码 |
**响应参数**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| code | Number| 是 |错误码,0表示成功 |
| msg | String| 是 |详细信息 |
| token | String| - |注册完成自动登录之后返回的token信息|
**示例代码**
```js
// 云函数代码
const uniID = require('uni-id')
exports.main = async function(event,context) {
const {
username,
password
} = event
// username、password验证是否合法的逻辑
const res = await uniID.register({
username,
password
})
return res
}
// 客户端代码
uniCloud.callFunction({
name: 'register',
data: {
username: 'username',
password: 'user password'
},
success(res){
if(res.result.code === 0) {
uni.setStorageSync('uniIdToken',res.result.token)
// 其他业务代码,如跳转到首页等
uni.showToast({
title: '注册成功',
icon: 'none'
})
} else {
uni.showModal({
content: res.result.msg,
showCancel: false
})
}
},
fail(){
uni.showModal({
content: '注册失败,请稍后再试',
showCancel: false
})
}
})
```
## 用户登录 @login
用法:`uniID.login(Object user)`
**user参数说明**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| username | String| 是 |用户名 |
| password | String| 是 |密码 |
**响应参数**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| code | Number| 是 |错误码,0表示成功 |
| msg | String| 是 |详细信息 |
| token | String| - |登录成功之后返回的token信息|
**示例代码**
```js
// 云函数代码
const uniID = require('uni-id')
exports.main = async function(event,context) {
const {
username,
password
} = event
// username、password验证是否合法的逻辑
const res = await uniID.login({
username,
password
})
return res
}
// 客户端代码
uniCloud.callFunction({
name: 'login',
data: {
username: 'username',
password: 'user password'
},
success(res){
if(res.result.code === 0) {
uni.setStorageSync('uniIdToken',res.result.token)
// 其他业务代码,如跳转到首页等
uni.showToast('注册成功')
} else {
uni.showModal({
content: res.result.msg,
showCancel: false
})
}
},
fail(){
uni.showModal({
content: '登录失败,请稍后再试',
showCancel: false
})
}
})
```
## 修改密码 @update-password
用法:`uniID.updatePwd(Object passwordInfo)`
**passwordInfo参数说明**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| oldPassword | String| 是 |旧密码 |
| newPassword | String| 是 |新密码 |
| passwordConfirmation | String| 是 |确认新密码 |
**响应参数**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| code | Number| 是 |错误码,0表示成功 |
| msg | String| 是 |详细信息 |
**示例代码**
```js
// 云函数update-pwd代码
const uniID = require('uni-id')
exports.main = async function(event,context) {
const {
oldPassword,
newPassword,
passwordConfirmation
} = event
// 校验新密码与确认新密码是否一致
const res = await uniID.updatePwd({
oldPassword,
newPassword,
passwordConfirmation
})
return res
}
// 客户端代码
uniCloud.callFunction({
name: 'update-pwd',
data: {
oldPassword: 'oldPassword',
newPassword: 'newPassword',
passwordConfirmation: 'confirmed new password'
},
success(res){
if(res.result.code === 0) {
// 修改成功跳转到登录页面
} else {
uni.showModal({
content: res.result.msg,
showCancel: false
})
}
},
fail(){
uni.showModal({
content: '修改失败,请稍后再试',
showCancel: false
})
}
})
```
## 设置头像
用法:`uniID.setAvatar(Object avatarInfo)`
**avatarInfo**参数说明
| 字段 | 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| avatar| String| 是 |用户头像URL|
**响应参数**
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| code| Number| 是 |错误码,0表示成功|
| msg | String| 是 |详细信息 |
**示例代码**
```js
// 云函数set-avatar代码
const uniID = require('uni-id')
exports.main = async function(event,context) {
const {
avatar
} = event
// 校验avatar链接合法性
const res = await uniID.setAvatar({
avatar
})
return res
}
// 客户端代码
uniCloud.callFunction({
name: 'set-avatar',
data: {
avatar: 'avatar url'
},
success(res){
if(res.result.code === 0) {
// 修改成功
uni.showToast({
title: '头像修改成功',
icon: 'none'
})
} else {
uni.showModal({
content: res.result.msg,
showCancel: false
})
}
},
fail(){
uni.showModal({
content: '修改失败,请稍后再试',
showCancel: false
})
}
})
```
## 绑定手机号
用法:`uniID.bindMobile(Object mobileInfo)`
**mobileInfo**参数说明
| 字段 | 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| mobile| String| 是 |用户手机号|
**响应参数**
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| code| Number| 是 |错误码,0表示成功|
| msg | String| 是 |详细信息 |
**示例代码**
```js
// 云函数bind-mobile代码
const uniID = require('uni-id')
exports.main = async function(event,context) {
const {
mobile
} = event
// 校验手机号合法性
const res = await uniID.bindMobile({
mobile
})
return res
}
// 客户端代码
uniCloud.callFunction({
name: 'bind-mobile',
data: {
mobile: 'mobile phone number'
},
success(res){
if(res.result.code === 0) {
// 绑定成功
uni.showToast({
title: '手机号绑定成功',
icon: 'none'
})
} else {
uni.showModal({
content: res.result.msg,
showCancel: false
})
}
},
fail(){
uni.showModal({
content: '绑定失败,请稍后再试',
showCancel: false
})
}
})
```
## 绑定邮箱
用法:`uniID.bindEmail(Object emailInfo)`
**emailInfo**参数说明
| 字段 | 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| email | String| 是 |用户邮箱 |
**响应参数**
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| code| Number| 是 |错误码,0表示成功|
| msg | String| 是 |详细信息 |
**示例代码**
```js
// 云函数bind-email代码
const uniID = require('uni-id')
exports.main = async function(event,context) {
const {
email
} = event
// 校验手机号合法性
const res = await uniID.bindEmail({
email
})
return res
}
// 客户端代码
uniCloud.callFunction({
name: 'bind-email',
data: {
email: 'user email'
},
success(res){
if(res.result.code === 0) {
// 绑定成功
uni.showToast({
title: '邮箱绑定成功',
icon: 'none'
})
} else {
uni.showModal({
content: res.result.msg,
showCancel: false
})
}
},
fail(){
uni.showModal({
content: '绑定失败,请稍后再试',
showCancel: false
})
}
})
```
## 登出
用法:`uniID.logout(String uid);`
参数说明
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| uid | String| 是 |用户uid|
**响应参数**
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| code| Number| 是 |错误码,0表示成功|
| msg | String| 是 |详细信息 |
**示例代码**
```js
// 云函数logout代码
const uniID = require('uni-id')
exports.main = async function(event,context) {
const {
uniIdToken
} = event
payload = await uniID.checkToken(uniIdToken)
if (payload.code && payload.code > 0) {
return payload
}
const res = await uniID.logout(payload.uid)
return res
}
// 客户端代码
uniCloud.callFunction({
name: 'logout',
success(e) {
if(res.result.code === 0) {
uni.showToast({
title: '登出成功',
icon: 'none'
})
uni.removeStorageSync('uniIdToken')
} else {
uni.showModal({
content: res.result.msg,
showCancel: false
})
}
},
fail(e) {
uni.showModal({
content: '登出失败,请稍后再试',
showCancel: false
})
}
})
```
docs/uniCloud/uni-id.md
浏览文件 @
6ad9f816
...
...
@@ -11,295 +11,337 @@
对于
`uni-id`
还未封装的能力,欢迎大家在开源项目上提交 pr,共同完善这个开源项目,
[
uni-id git仓库
](
https://gitee.com/dcloud/uni-id.git
)
。
# API列表
## 用户注册 @register
用法
`uniID.register(Object user)`
**user参数说明**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| username | String| 是 |用户名,唯一 |
| password | String| 是 |密码 |
**响应参数**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| code | Number| 是 |错误码,0表示成功 |
| msg | String| 是 |详细信息 |
| token | String| - |注册完成自动登录之后返回的token信息|
**示例代码**
```
js
// 云函数代码
const
uniID
=
require
(
'
uni-id
'
)
exports
.
main
=
async
function
(
event
,
context
)
{
const
{
username
,
password
}
=
event
// username、password验证是否合法的逻辑
const
res
=
await
uniID
.
register
({
username
,
password
})
return
res
}
// 客户端代码
uniCloud
.
callFunction
({
name
:
'
register
'
,
data
:
{
username
:
'
username
'
,
password
:
'
user password
'
},
success
(
res
){
if
(
res
.
result
.
code
===
0
)
{
uni
.
setStorageSync
(
'
uniIdToken
'
,
res
.
result
.
token
)
// 其他业务代码,如跳转到首页等
uni
.
showToast
({
title
:
'
注册成功
'
,
icon
:
'
none
'
})
}
else
{
uni
.
showModal
({
content
:
res
.
result
.
msg
,
showCancel
:
false
})
}
},
fail
(){
uni
.
showModal
({
content
:
'
注册失败,请稍后再试
'
,
showCancel
:
false
})
}
})
```
## 用户登录 @login
用法:
`uniID.login(Object user)`
**user参数说明**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| username | String| 是 |用户名 |
| password | String| 是 |密码 |
**响应参数**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| code | Number| 是 |错误码,0表示成功 |
| msg | String| 是 |详细信息 |
| token | String| - |登录成功之后返回的token信息|
**示例代码**
```
js
// 云函数代码
const
uniID
=
require
(
'
uni-id
'
)
exports
.
main
=
async
function
(
event
,
context
)
{
const
{
username
,
password
}
=
event
// username、password验证是否合法的逻辑
const
res
=
await
uniID
.
login
({
username
,
password
})
return
res
}
```
## 修改密码 @update-password
用法:
`uniID.updatePwd(Object passwordInfo)`
**passwordInfo参数说明**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| oldPassword | String| 是 |旧密码 |
| newPassword | String| 是 |新密码 |
| passwordConfirmation | String| 是 |确认新密码 |
**响应参数**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| code | Number| 是 |错误码,0表示成功 |
| msg | String| 是 |详细信息 |
**示例代码**
```
js
// 云函数update-pwd代码
const
uniID
=
require
(
'
uni-id
'
)
exports
.
main
=
async
function
(
event
,
context
)
{
const
{
oldPassword
,
newPassword
,
passwordConfirmation
}
=
event
// 校验新密码与确认新密码是否一致
const
res
=
await
uniID
.
updatePwd
({
oldPassword
,
newPassword
,
passwordConfirmation
})
return
res
}
```
## 设置头像
用法:
`uniID.setAvatar(Object avatarInfo)`
**avatarInfo**
参数说明
| 字段 | 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| avatar| String| 是 |用户头像URL|
**响应参数**
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| code| Number| 是 |错误码,0表示成功|
| msg | String| 是 |详细信息 |
**示例代码**
```
js
// 云函数set-avatar代码
const
uniID
=
require
(
'
uni-id
'
)
exports
.
main
=
async
function
(
event
,
context
)
{
const
{
avatar
}
=
event
// 校验avatar链接合法性
const
res
=
await
uniID
.
setAvatar
({
avatar
})
return
res
}
```
## 绑定手机号
用法:
`uniID.bindMobile(Object mobileInfo)`
**mobileInfo**
参数说明
| 字段 | 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| mobile| String| 是 |用户手机号|
**响应参数**
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| code| Number| 是 |错误码,0表示成功|
| msg | String| 是 |详细信息 |
**示例代码**
```
js
// 云函数bind-mobile代码
const
uniID
=
require
(
'
uni-id
'
)
exports
.
main
=
async
function
(
event
,
context
)
{
const
{
mobile
}
=
event
// 校验手机号合法性
const
res
=
await
uniID
.
bindMobile
({
mobile
})
return
res
}
```
## 绑定邮箱
用法:
`uniID.bindEmail(Object emailInfo)`
**emailInfo**
参数说明
| 字段 | 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| email | String| 是 |用户邮箱 |
**响应参数**
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| code| Number| 是 |错误码,0表示成功|
| msg | String| 是 |详细信息 |
**示例代码**
```
js
// 云函数bind-email代码
const
uniID
=
require
(
'
uni-id
'
)
exports
.
main
=
async
function
(
event
,
context
)
{
const
{
email
}
=
event
// 校验手机号合法性
const
res
=
await
uniID
.
bindEmail
({
email
})
return
res
}
```
## 登出
用法:
`uniID.logout(String uid);`
参数说明
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| uid | String| 是 |用户uid|
**响应参数**
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| code| Number| 是 |错误码,0表示成功|
| msg | String| 是 |详细信息 |
**示例代码**
```
js
// 云函数logout代码
const
uniID
=
require
(
'
uni-id
'
)
exports
.
main
=
async
function
(
event
,
context
)
{
const
{
uniIdToken
}
=
event
payload
=
await
uniID
.
checkToken
(
uniIdToken
)
if
(
payload
.
code
&&
payload
.
code
>
0
)
{
return
payload
}
const
res
=
await
uniID
.
logout
(
payload
.
uid
)
return
res
}
```
## 用户注册 @register
用法
`uniID.register(Object user)`
**user参数说明**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| username | String| 是 |用户名,唯一 |
| password | String| 是 |密码 |
username可以是字符串、可以是email、可以是手机号,本插件不约束,开发者可以自己定。
比如要求username为手机号,则自行在前端界面上做好提示,在后台对格式进行校验。
password入库时会自动转为md5,不明文存储密码。
**响应参数**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| code | Number| 是 |错误码,0表示成功 |
| msg | String| 是 |详细信息 |
| token | String| - |注册完成自动登录之后返回的token信息|
**示例代码**
```
js
// 云函数代码
const
uniID
=
require
(
'
uni-id
'
)
exports
.
main
=
async
function
(
event
,
context
)
{
const
{
username
,
password
}
=
event
// username、password验证是否合法的逻辑
const
res
=
await
uniID
.
register
({
username
,
password
})
return
res
}
```
```
js
// 客户端代码
uniCloud
.
callFunction
({
name
:
'
register
'
,
data
:
{
username
:
'
username
'
,
password
:
'
user password
'
},
success
(
res
){
if
(
res
.
result
.
code
===
0
)
{
// 目前版本是驼峰形式uniIdToken,后面会调整为蛇形uni_id_token(调整后会在一段时间内兼容驼峰)
uni
.
setStorageSync
(
'
uniIdToken
'
,
res
.
result
.
token
)
// 其他业务代码,如跳转到首页等
uni
.
showToast
({
title
:
'
注册成功
'
,
icon
:
'
none
'
})
}
else
{
uni
.
showModal
({
content
:
res
.
result
.
msg
,
showCancel
:
false
})
}
},
fail
(){
uni
.
showModal
({
content
:
'
注册失败,请稍后再试
'
,
showCancel
:
false
})
}
})
```
## 用户登录 @login
用法:
`uniID.login(Object user)`
**user参数说明**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| username | String| 是 |用户名 |
| password | String| 是 |密码 |
**响应参数**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| code | Number| 是 |错误码,0表示成功 |
| msg | String| 是 |详细信息 |
| token | String| - |登录成功之后返回的token信息|
**示例代码**
```
js
// 云函数代码
const
uniID
=
require
(
'
uni-id
'
)
exports
.
main
=
async
function
(
event
,
context
)
{
const
{
username
,
password
}
=
event
// username、password验证是否合法的逻辑
const
res
=
await
uniID
.
login
({
username
,
password
})
return
res
}
```
## token校验
用法:
`uniID.checkToken(String token)`
**参数说明**
| 字段 | 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| token | String| 是 |客户端callFunction带上的token|
**响应参数**
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| code| Number| 是 |错误码,0表示成功 |
| msg | String| 是 |详细信息 |
|uid | String|否 |用户Id,校验成功之后会返回 |
**注意:**
-
2.7.14+ 客户端会自动查找storage内的token在callFunction时插入
-
2.7.14 版本token存储在storage内使用的是驼峰形式的键值
`uniIdToken`
,下版会调整为蛇形
`uni_id_token`
,调整后会在一段时间内兼容驼峰形式
**示例代码**
```
js
const
uniID
=
require
(
'
uni-id
'
)
exports
.
main
=
async
function
(
event
,
context
)
{
const
payload
=
await
uniID
.
updatePwd
(
event
.
uniIdToken
)
return
payload
}
```
## 修改密码 @update-password
用法:
`uniID.updatePwd(Object passwordInfo)`
**passwordInfo参数说明**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| oldPassword | String| 是 |旧密码 |
| newPassword | String| 是 |新密码 |
| passwordConfirmation | String| 是 |确认新密码 |
**响应参数**
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| code | Number| 是 |错误码,0表示成功 |
| msg | String| 是 |详细信息 |
**示例代码**
```
js
// 云函数update-pwd代码
const
uniID
=
require
(
'
uni-id
'
)
exports
.
main
=
async
function
(
event
,
context
)
{
const
{
oldPassword
,
newPassword
,
passwordConfirmation
}
=
event
// 校验新密码与确认新密码是否一致
const
res
=
await
uniID
.
updatePwd
({
oldPassword
,
newPassword
,
passwordConfirmation
})
return
res
}
```
## 设置头像
用法:
`uniID.setAvatar(Object avatarInfo)`
**avatarInfo**
参数说明
| 字段 | 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| avatar| String| 是 |用户头像URL|
**响应参数**
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| code| Number| 是 |错误码,0表示成功|
| msg | String| 是 |详细信息 |
**示例代码**
```
js
// 云函数set-avatar代码
const
uniID
=
require
(
'
uni-id
'
)
exports
.
main
=
async
function
(
event
,
context
)
{
const
{
avatar
}
=
event
// 校验avatar链接合法性
const
res
=
await
uniID
.
setAvatar
({
avatar
})
return
res
}
```
## 绑定手机号
用法:
`uniID.bindMobile(Object mobileInfo)`
**mobileInfo**
参数说明
| 字段 | 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| mobile| String| 是 |用户手机号|
**响应参数**
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| code| Number| 是 |错误码,0表示成功|
| msg | String| 是 |详细信息 |
**示例代码**
```
js
// 云函数bind-mobile代码
const
uniID
=
require
(
'
uni-id
'
)
exports
.
main
=
async
function
(
event
,
context
)
{
const
{
mobile
}
=
event
// 校验手机号合法性
const
res
=
await
uniID
.
bindMobile
({
mobile
})
return
res
}
```
## 绑定邮箱
用法:
`uniID.bindEmail(Object emailInfo)`
**emailInfo**
参数说明
| 字段 | 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| email | String| 是 |用户邮箱 |
**响应参数**
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| code| Number| 是 |错误码,0表示成功|
| msg | String| 是 |详细信息 |
**示例代码**
```
js
// 云函数bind-email代码
const
uniID
=
require
(
'
uni-id
'
)
exports
.
main
=
async
function
(
event
,
context
)
{
const
{
email
}
=
event
// 校验手机号合法性
const
res
=
await
uniID
.
bindEmail
({
email
})
return
res
}
```
## 登出
用法:
`uniID.logout(String uid);`
参数说明
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| uid | String| 是 |用户uid|
**响应参数**
| 字段| 类型 | 必填| 说明 |
| --- | --- | --- | --- |
| code| Number| 是 |错误码,0表示成功|
| msg | String| 是 |详细信息 |
**示例代码**
```
js
// 云函数logout代码
const
uniID
=
require
(
'
uni-id
'
)
exports
.
main
=
async
function
(
event
,
context
)
{
const
{
uniIdToken
}
=
event
payload
=
await
uniID
.
checkToken
(
uniIdToken
)
if
(
payload
.
code
&&
payload
.
code
>
0
)
{
return
payload
}
const
res
=
await
uniID
.
logout
(
payload
.
uid
)
return
res
}
```
# 数据库结构
...
...
@@ -327,7 +369,8 @@ exports.main = async function(event,context) {
| last_login_date | Timestamp | 否 | 最后登录时间 |
| last_login_ip | String | 否 | 最后登录时 IP 地址 |
**realNameAuth 字段定义**
**realNameAuth 扩展字段定义**
该字段存储实名认证信息。
| 字段 | 类型 | 必填 | 描述 |
| --------------- | --------- | ---- | --------------------------------------------------- |
...
...
@@ -344,7 +387,7 @@ exports.main = async function(event,context) {
| contact_mobile | String | 否 | 联系人手机号码 |
| contact_email | String | 否 | 联系人邮箱 |
**job 字段定义**
**job
扩展
字段定义**
| 字段 | 类型 | 必填 | 描述 |
| ------- | ------ | ---- | -------- |
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录