09 账户模块 - MiEcosystem/miot-plugin-sdk GitHub Wiki

miot/service/Account

用于获取当前用户信息,通过Service.account获取当前用户对象实例。 其中Service.account.ID可直接使用,其余属性需要使用Service.account.load().then()来进行获取,可参考下方Example。 具体的可用属性与方法请参考Interface -> IAccount类API说明。 IAccount不支持直接创建使用,如需使用请调用: Service.account.load().then((info)=>{info 中各个字段才有值}}))

Export: public
Doc_name: 账户模块
Doc_index: 9
Doc_directory: service
Example

import {Service} from 'miot'
console.log(Service.account.ID)
Service.account.load().then(account=>{
 console.log(Service.account.nickName)
})

miot/service/Account~IAccount

用户信息属性与方法说明

Kind: inner interface of miot/service/Account
Example

import {Service} from 'miot'
...
console.log(Service.account.ID)
if (Service.account.isLoaded) {
 console.log(Service.account.nickName)
}else {
 Service.account.load().then(account=>{
     console.log(Service.account.nickName)
     ...
 })
}
...

iAccount.isLoaded : boolean

用户详情是否已经加载,不依赖于load方法。 如果已加载则所有属性可直接使用。

Kind: instance property of IAccount
Read only: true


iAccount.ID : string

当前登录账户userid,不依赖于load方法

Kind: instance property of IAccount
Read only: true


iAccount.nickName : string

用户昵称,依赖于load方法

Kind: instance property of IAccount
Read only: true


iAccount.avatarURL : string

用户头像的下载地址,依赖于load方法

Kind: instance property of IAccount
Read only: true


iAccount.birth : string

用户生日,依赖于load方法

Kind: instance property of IAccount
Read only: true


iAccount.email : string

用户邮箱,依赖于load方法

Kind: instance property of IAccount
Read only: true


iAccount.phone : string

用户电话,依赖于load方法

Kind: instance property of IAccount
Read only: true


iAccount.sex : string

用户性别,依赖于load方法

Kind: instance property of IAccount
Read only: true


iAccount.shareTime : string

用户分享时间,依赖于load方法

Kind: instance property of IAccount
Read only: true


iAccount.load(force) ⇒ [ 'Promise' ].<IAccount>

加载用户信息,所有依赖于load的用户信息需要在回调方法中会返回时才有值

Kind: instance method of IAccount
Returns: [ 'Promise' ].<IAccount> - 成功时:{IAccount} 可以查看 IAccount 类(位于Account.js中)具体信息 失败时:{"code":xxx, "message":"xxx" }

Param Type Default Description
force boolean false 是否从网络获取信息, true:表示从网络进行获取数据 false:表示从缓存获取数据; 默认为false

iAccount.getAccountInfoById(accountId) ⇒ [ 'Promise' ].<unknown>

获取指定某一账号id的信息

Kind: instance method of IAccount
Returns: [ 'Promise' ].<unknown> - 成功时:{IAccount} 可以查看 IAccount 类(位于Account.js中)具体信息 失败时:{"code":xxx, "message":"xxx" }
Since: 10032

Param Description
accountId 账号id 或 手机号

iAccount.getAccountInfoList(ids) ⇒ [ 'Promise' ].<Array.<object>>

批量获取账号信息

Kind: instance method of IAccount
Returns: [ 'Promise' ].<Array.<object>> - 账号信息列表(数组结构) 成功时:[{ID:xxx, avatarURL: {size_75:xxx,size_90:xxx,...}, icon:xxx, nickName:xxx, userName:xxx}, ...] 失败时:{"code":xxx, "message":"xxx" }
Since: 10032

Param Type Description
ids [ 'Array' ].<string> 数组,仅支持账号id,不支持手机号查询

⚠️ **GitHub.com Fallback** ⚠️