|
| 1 | +<a name="module_miot/Account"></a> |
| 2 | + |
| 3 | +## miot/Account |
| 4 | +用于获取当前用户信息,通过Service.account获取当前用户对象实例。 |
| 5 | +其中Service.account.ID可直接使用,其余属性需要使用Service.account.load().then()来进行获取,可参考下方Example。 |
| 6 | +具体的可用属性与方法请参考Interface -> IAccount类API说明。 |
| 7 | +IAccount不支持直接创建使用,如需使用请调用: |
| 8 | +Service.account.load().then((info)=>{info 中各个字段才有值}})) |
| 9 | + |
| 10 | +**Export**: public |
| 11 | +**Doc_name**: 账户模块 |
| 12 | +**Doc_index**: 4 |
| 13 | +**Example** |
| 14 | +```js |
| 15 | +import {Service} from 'miot' |
| 16 | +console.log(Service.account.ID) |
| 17 | +Service.account.load().then(account=>{ |
| 18 | + console.log(Service.account.nickName) |
| 19 | +}) |
| 20 | +``` |
| 21 | + |
| 22 | +* [miot/Account](#module_miot/Account) |
| 23 | + * [~IAccount](#module_miot/Account..IAccount) |
| 24 | + * [.isLoaded](#module_miot/Account..IAccount+isLoaded) : <code>boolean</code> |
| 25 | + * [.ID](#module_miot/Account..IAccount+ID) : <code>string</code> |
| 26 | + * [.nickName](#module_miot/Account..IAccount+nickName) : <code>string</code> |
| 27 | + * [.avatarURL](#module_miot/Account..IAccount+avatarURL) : <code>string</code> |
| 28 | + * [.birth](#module_miot/Account..IAccount+birth) : <code>string</code> |
| 29 | + * [.email](#module_miot/Account..IAccount+email) : <code>string</code> |
| 30 | + * [.phone](#module_miot/Account..IAccount+phone) : <code>string</code> |
| 31 | + * [.sex](#module_miot/Account..IAccount+sex) : <code>string</code> |
| 32 | + * [.shareTime](#module_miot/Account..IAccount+shareTime) : <code>string</code> |
| 33 | + * [.load(force)](#module_miot/Account..IAccount+load) ⇒ <code>Promise.<IAccount></code> |
| 34 | + |
| 35 | +<a name="module_miot/Account..IAccount"></a> |
| 36 | + |
| 37 | +### miot/Account~IAccount |
| 38 | +用户信息属性与方法说明 |
| 39 | + |
| 40 | +**Kind**: inner interface of [<code>miot/Account</code>](#module_miot/Account) |
| 41 | +**Example** |
| 42 | +```js |
| 43 | +import {Service} from 'miot' |
| 44 | +... |
| 45 | +console.log(Service.account.ID) |
| 46 | +if (Service.account.isLoaded) { |
| 47 | + console.log(Service.account.nickName) |
| 48 | +}else { |
| 49 | + Service.account.load().then(account=>{ |
| 50 | + console.log(Service.account.nickName) |
| 51 | + ... |
| 52 | + }) |
| 53 | +} |
| 54 | +... |
| 55 | +``` |
| 56 | + |
| 57 | +* [~IAccount](#module_miot/Account..IAccount) |
| 58 | + * [.isLoaded](#module_miot/Account..IAccount+isLoaded) : <code>boolean</code> |
| 59 | + * [.ID](#module_miot/Account..IAccount+ID) : <code>string</code> |
| 60 | + * [.nickName](#module_miot/Account..IAccount+nickName) : <code>string</code> |
| 61 | + * [.avatarURL](#module_miot/Account..IAccount+avatarURL) : <code>string</code> |
| 62 | + * [.birth](#module_miot/Account..IAccount+birth) : <code>string</code> |
| 63 | + * [.email](#module_miot/Account..IAccount+email) : <code>string</code> |
| 64 | + * [.phone](#module_miot/Account..IAccount+phone) : <code>string</code> |
| 65 | + * [.sex](#module_miot/Account..IAccount+sex) : <code>string</code> |
| 66 | + * [.shareTime](#module_miot/Account..IAccount+shareTime) : <code>string</code> |
| 67 | + * [.load(force)](#module_miot/Account..IAccount+load) ⇒ <code>Promise.<IAccount></code> |
| 68 | + |
| 69 | +<a name="module_miot/Account..IAccount+isLoaded"></a> |
| 70 | + |
| 71 | +#### iAccount.isLoaded : <code>boolean</code> |
| 72 | +用户详情是否已经加载,不依赖于load方法。 |
| 73 | +如果已加载则所有属性可直接使用。 |
| 74 | + |
| 75 | +**Kind**: instance property of [<code>IAccount</code>](#module_miot/Account..IAccount) |
| 76 | +**Read only**: true |
| 77 | +<a name="module_miot/Account..IAccount+ID"></a> |
| 78 | + |
| 79 | +#### iAccount.ID : <code>string</code> |
| 80 | +当前登录账户userid,不依赖于load方法 |
| 81 | + |
| 82 | +**Kind**: instance property of [<code>IAccount</code>](#module_miot/Account..IAccount) |
| 83 | +**Read only**: true |
| 84 | +<a name="module_miot/Account..IAccount+nickName"></a> |
| 85 | + |
| 86 | +#### iAccount.nickName : <code>string</code> |
| 87 | +用户昵称,依赖于load方法 |
| 88 | + |
| 89 | +**Kind**: instance property of [<code>IAccount</code>](#module_miot/Account..IAccount) |
| 90 | +**Read only**: true |
| 91 | +<a name="module_miot/Account..IAccount+avatarURL"></a> |
| 92 | + |
| 93 | +#### iAccount.avatarURL : <code>string</code> |
| 94 | +用户头像的下载地址,依赖于load方法 |
| 95 | + |
| 96 | +**Kind**: instance property of [<code>IAccount</code>](#module_miot/Account..IAccount) |
| 97 | +**Read only**: true |
| 98 | +<a name="module_miot/Account..IAccount+birth"></a> |
| 99 | + |
| 100 | +#### iAccount.birth : <code>string</code> |
| 101 | +用户生日,依赖于load方法 |
| 102 | + |
| 103 | +**Kind**: instance property of [<code>IAccount</code>](#module_miot/Account..IAccount) |
| 104 | +**Read only**: true |
| 105 | +<a name="module_miot/Account..IAccount+email"></a> |
| 106 | + |
| 107 | +#### iAccount.email : <code>string</code> |
| 108 | +用户邮箱,依赖于load方法 |
| 109 | + |
| 110 | +**Kind**: instance property of [<code>IAccount</code>](#module_miot/Account..IAccount) |
| 111 | +**Read only**: true |
| 112 | +<a name="module_miot/Account..IAccount+phone"></a> |
| 113 | + |
| 114 | +#### iAccount.phone : <code>string</code> |
| 115 | +用户电话,依赖于load方法 |
| 116 | + |
| 117 | +**Kind**: instance property of [<code>IAccount</code>](#module_miot/Account..IAccount) |
| 118 | +**Read only**: true |
| 119 | +<a name="module_miot/Account..IAccount+sex"></a> |
| 120 | + |
| 121 | +#### iAccount.sex : <code>string</code> |
| 122 | +用户性别,依赖于load方法 |
| 123 | + |
| 124 | +**Kind**: instance property of [<code>IAccount</code>](#module_miot/Account..IAccount) |
| 125 | +**Read only**: true |
| 126 | +<a name="module_miot/Account..IAccount+shareTime"></a> |
| 127 | + |
| 128 | +#### iAccount.shareTime : <code>string</code> |
| 129 | +用户分享时间,依赖于load方法 |
| 130 | + |
| 131 | +**Kind**: instance property of [<code>IAccount</code>](#module_miot/Account..IAccount) |
| 132 | +**Read only**: true |
| 133 | +<a name="module_miot/Account..IAccount+load"></a> |
| 134 | + |
| 135 | +#### iAccount.load(force) ⇒ <code>Promise.<IAccount></code> |
| 136 | +加载用户信息,所有依赖于load的用户信息需要在回调方法中会返回时才有值 |
| 137 | + |
| 138 | +**Kind**: instance method of [<code>IAccount</code>](#module_miot/Account..IAccount) |
| 139 | + |
| 140 | +| Param | Type | Default | Description | |
| 141 | +| --- | --- | --- | --- | |
| 142 | +| force | <code>boolean</code> | <code>false</code> | 强制刷新缓存,加载米家服务器的用户信息 | |
| 143 | + |
0 commit comments