获取用户信息
同步接口支持版本:iOS >= 6.3.0
Android >= 6.3.0
参数名 | 类型 | 是否可选 | 默认值 | 含义 |
---|---|---|---|---|
options |
Object |
选项 | ||
options.query |
Object |
可选 | 接口调用参数 | |
options.success |
Function |
可选 | 调用成功的回调函数 | |
options.error |
Function |
可选 | 调用失败的回调函数 |
参数名 | 类型 | 是否一定返回 | 含义 |
---|---|---|---|
result |
Object |
响应对象 | |
result.code |
String |
错误码,成功为 QAP_SUCCESS ;失败为其他 |
|
result.msg |
String |
错误信息 | |
result.data.user_id |
String |
是 | 用户的数字id |
result.data.user_nick |
String |
是 | 用户用户名 |
result.data.sub_user_id |
String |
如果登录账号为子账号,返回子账号的数字id,否则为空 | |
result.data.sub_user_nick |
String |
如果登录账号为子账号,返回子账号的用户名,否则为空 | |
result.data.avatar |
String |
用户头像 |
// 异步调用 QN.user.getInfo() .then(result => { console.log(result); }, error => { console.log(error); }); // 同步调用 let result = QN.user.getInfoSync(); console.log(result);
获取用户头像图片
参数名 | 类型 | 是否可选 | 默认值 | 含义 |
---|---|---|---|---|
options |
Object String |
Object 时为调用选项,String 时为userId |
||
options.userId |
String |
userId 用户id |
||
options.width |
Number |
是 | 80 | 头像宽度,默认为80,最小为20,最大为800,必须是10的倍数,高度和宽度相等 |
注意:如果传入的宽度大于用户上传的原始头像的宽度,则实际能请求到的尺寸为原始头像的大小。
参数名 | 类型 | 是否一定返回 | 含义 |
---|---|---|---|
URL |
String |
用户头像地址 |
let avatarURL = QN.user.getAvatar('12345'); let avatarURL = QN.user.getAvatar({ userId: '12345', width: 40, // 获取40x40尺寸的头像 });