userManage
userManage
- userManage
- .getToken() ⇒
string - .getUid() ⇒
number - .getAppid() ⇒
string - .getConversationList() ⇒
Array.<ConversationItem> - .getDeviceSN() ⇒
number - .asyncBindDeviceToken(param) ⇒
Promise.<boolean> - .asyncUnbindDeviceToken(param) ⇒
Promise.<boolean> - .asyncRegister(opt) ⇒
Promise.<UserSettings> - .asyncUpdateAvatar(params) ⇒
Promise.<boolean> - .asyncUpdateNickName(params) ⇒
Promise.<boolean> - .asyncUserChangePassword(params) ⇒
Promise.<boolean> - .asyncGetProfile() ⇒
Promise.<UserProfile> - .asyncUpdateProfile(params) ⇒
Promise.<boolean> - .asyncGetSettings() ⇒
Promise.<UserSettings> - .asyncUpdateSettings(settings) ⇒
Promise.<boolean>
- .getToken() ⇒
userManage.getToken() ⇒ string
获取登录用户的token
Kind: static method of userManage
Returns: string - 用户的token
Example
return this.$store.getters.im.userManage.getToken();return this.$store.getters.im.userManage.getToken();return this.$store.getters.im.userManage.getToken();token: this.$store.state.im.userManage.getToken()return this.$store.getters.im.userManage.getToken();return this.$store.getters.im.userManage.getToken();return this.$store.getters.im.userManage.getToken();return this.$store.getters.im.userManage.getToken();
userManage.getUid() ⇒ number
获取登录用户的uid
Kind: static method of userManage
Returns: number - 用户ID
Example
const uid = this.$store.getters.im.userManage.getUid();
if (uid + '' === message.uid + '') {
this.requireMessage();
}const toUid = toNumber(message.to);
const pid = this.getSid;
const uid = this.$store.getters.im.userManage.getUid();
return toUid === pid;const toUid = toNumber(message.to);
const pid = this.getSid;
const uid = this.$store.getters.im.userManage.getUid();
if (toUid === pid) {
if (uid + '' !== message.from + '' && !this.getAutoReadSuppressed) {
this.$store.getters.im.groupManage.readGroupMessage(this.getSid);
}
const ext = this.parseMessageExt(message);
if (ext && ext.ai && ext.ai.stream) {
this.$store.dispatch('content/actionAppendMessage', {
messages: [message]
});
if (!ext.ai.finish) {
this.calculateScroll(message);
} else {
this.scroll();
}
} else {
this.requireMessage();
this.scroll();
}
}const uid = this.$store.getters.im.userManage.getUid();
return this.getAdminList.filter((x) => x.user_id === uid).length > 0 || this.getGroupInfo.member_modify;const uid = this.$store.getters.im.userManage.getUid();
return this.getGroupInfo.owner_id === uid;res.avatar = this.$store.getters.im.sysManage.getImage({
avatar: res.avatar,
type: 'group'
});
this.groupInfo = res;
const uid = this.$store.getters.im.userManage.getUid();
const user = this.getMemberList.find((x) => x.user_id === uid);
this.cardName = (user && (user.display_name || user.name)) || '';
if (!this.cardName) {
this.$store.getters.im.groupManage
.asyncGetMemberDisplayName({
group_id: newSid,
user_list: [uid]
})
.then((res) => {
if (!res || !res.length) {
return;
}
res.forEach((item) => {
this.cardName = item.display_name;
});
});
}const uid = this.$store.getters.im.userManage.getUid();
return this.getAdminList.filter((x) => x.user_id === uid).length > 0;return x.user_id != this.im.userManage.getUid();
userManage.getAppid() ⇒ string
获取appid
Kind: static method of userManage
Returns: string - APP ID
Example
let hide = true;
let hide_member_info = this.getGroupInfo.hide_member_info;
let app_hide_member_info = false;
const uid = this.im.userManage.getUid();
let appConfig = this.im.sysManage.getAppConfig(this.im.userManage.getAppid());
if (appConfig) {
app_hide_member_info = appConfig.hide_member_info;
}
if (app_hide_member_info) {
if (!hide_member_info) {
hide = false;
}
} else {
hide = false;
}
return hide;let hide = true;
let hide_member_info = this.getGroupInfo.hide_member_info;
let app_hide_member_info = false;
const uid = this.im.userManage.getUid();
let appConfig = this.im.sysManage.getAppConfig(this.im.userManage.getAppid());
if (appConfig) {
app_hide_member_info = appConfig.hide_member_info;
}
if (app_hide_member_info) {
if (!hide_member_info) {
hide = false;
}
} else {
hide = false;
}
return hide;const im = this.$store.getters.im;
if (!im) return this.$t('认证信息');
const appid = im.userManage.getAppid();
const accountVerification = im.sysManage.getAccountVerification(appid);
if (!accountVerification) return this.$t('认证信息');
let prefix = '';
if (!accountVerification.type || accountVerification.type !== 'enterprise') {
prefix = `${this.$translateText('个人开发者:').replace(/:$/, '')} `;
} else if (accountVerification.status === 'unverified' && !accountVerification.name) {
prefix = `${this.$translateText('公司')} `;
}
const statusPrefixMap = {
verified: this.$t('已认证:'),
expired: this.$t('认证失败:'),
unverified: this.$t('未认证开发者:')
};
return prefix + (statusPrefixMap[accountVerification.status] || '') + (accountVerification.name || this.$t('认证信息'));const image_id = this.user_verification_model.image_captcha_id;
if (!image_id) return '';
const app_id = this.$store.state.im.userManage.getAppid();
const url = this.$store.state.im.sysManage.getServers(app_id).ratel + '/app/captcha/image';
return url + '?image_id=' + image_id + '&app_id=' + app_id;const image_id = this.user_bind_mobile_model.image_captcha_id;
if (!image_id) return '';
const app_id = this.$store.state.im.userManage.getAppid();
const url = this.$store.state.im.sysManage.getServers(app_id).ratel + '/app/captcha/image';
return url + '?image_id=' + image_id + '&app_id=' + app_id;const image_id = this.change_bind_mobile_model.image_captcha_id;
if (!image_id) return '';
const app_id = this.$store.state.im.userManage.getAppid();
const url = this.$store.state.im.sysManage.getServers(app_id).ratel + '/app/captcha/image';
return url + '?image_id=' + image_id + '&app_id=' + app_id;
userManage.getConversationList() ⇒ Array.<ConversationItem>
获取最近会话列表
Kind: static method of userManage
Example
const { rootState } = context;
const convlist = rootState.im.userManage.getConversationList();
const allGroupMap = rootState.im.groupManage.getAllGroupDetail();
const allRosterMap = rootState.im.rosterManage.getAllRosterDetail() || {};
let totalUnreadCount = 0;
const convData = convlist.map((item, index) => {
let name;
const id = item.id;
const draft = typeof item.draft === 'string' ? item.draft : '';
const hasDraft = !!draft.trim();
const needsFallbackContent = !hasDraft && !item.content;
const needsFallbackTimestamp = (!hasDraft && !item.timestamp) || (hasDraft && !item.draftTimestamp && !item.timestamp);
let fallbackPreview = {
content: '',
timestamp: ''
};
if (needsFallbackContent || needsFallbackTimestamp) {
const fallbackMessages = item.type === 'roster' ? rootState.im.rosterManage.getRosterMessageByRid(id) : rootState.im.groupManage.getGruopMessage(id);
fallbackPrev...const { rootState } = context;
const sid = x.sid;
const type = x.type;
if (typeof sid === 'undefined' || sid === null || sid < 0 || !type) {
return Promise.resolve();
}
const existing = (rootState.im.userManage.getConversationList() || []).find((item) => `${item.id}` === `${sid}` && item.type === type);
if (existing) {
return Promise.resolve(existing);
}
if (type === 'group') {
return rootState.im.groupManage
.asyncGetGroupInfo(sid, true)
.catch(() => null)
.then((groupInfo) => {
rootState.im.sysManage.touchConversation(sid, 'group');
return groupInfo;
});
}
return rootState.im.rosterManage
.asyncGetRosterInfo(sid, true)
.catch(() => null)
.then((rosterInfo) => {
rootState.im.sysManage.touchConversation(sid, 'roster');
return rosterInfo;
});
userManage.getDeviceSN() ⇒ number
获取设备序号
Kind: static method of userManage
Returns: number - 设备序号
Example
userManage.asyncBindDeviceToken(param) ⇒ Promise.<boolean>
绑定推送设备
Kind: static method of userManage
Returns: Promise.<boolean> - 是否成功
| Param | Type | Description |
|---|---|---|
| param | object |
绑定请求 |
| param.device_sn | number |
设备序号 |
| param.notifier_name | string |
证书名称,即在蓝莺IM控制台内上传证书时候设置的名称。 |
| param.device_token | string |
推送设备Token |
Example
userManage.asyncUnbindDeviceToken(param) ⇒ Promise.<boolean>
解绑推送设备
Kind: static method of userManage
Returns: Promise.<boolean> - 是否成功
| Param | Type | Description |
|---|---|---|
| param | object |
解绑请求 |
| param.deviceSn | number |
设备序号 |
Example
userManage.asyncRegister(opt) ⇒ Promise.<UserSettings>
用户注册
Kind: static method of userManage
Returns: Promise.<UserSettings> - 用户设置
| Param | Type | Description |
|---|---|---|
| opt | object |
用户信息 |
| opt.username | string |
用户名 |
| opt.password | string |
密码 |
Example
userManage.asyncUpdateAvatar(params) ⇒ Promise.<boolean>
更新头像
Kind: static method of userManage
Returns: Promise.<boolean> - 是否成功
| Param | Type | Description |
|---|---|---|
| params | object |
参数 |
| params.avatar | string |
头像 url |
Example
userManage.asyncUpdateNickName(params) ⇒ Promise.<boolean>
更新昵称
Kind: static method of userManage
Returns: Promise.<boolean> - 是否成功
| Param | Type | Description |
|---|---|---|
| params | object |
参数 |
| params.nick_name | string |
昵称 |
Example
if (!value) return;
im.userManage.asyncUpdateNickName({ nick_name: value }).then(() => {
this.nick_name = value;
this.$store.dispatch('header/actionGetHeaderProfile');
alert(this.$t('修改成功'));
});
userManage.asyncUserChangePassword(params) ⇒ Promise.<boolean>
更新用户密码
Kind: static method of userManage
Returns: Promise.<boolean> - 是否成功
| Param | Type | Description |
|---|---|---|
| params | object |
参数 |
| params.old_password | string |
旧密码 |
| params.new_password | string |
新密码 |
Example
userManage.asyncGetProfile() ⇒ Promise.<UserProfile>
获取用户profile
Kind: static method of userManage
Returns: Promise.<UserProfile> - 用户信息
Example
const { rootState } = context;
rootState.im.userManage.asyncGetProfile(true).then((profile) => {
context.commit('changeHeaderUserProfile', profile);
});headerRequestFlag.profile = true;
rootState.im.userManage.asyncGetProfile().then((profile) => {
context.commit('changeHeaderUserProfile', profile);
headerRequestFlag.profile = false;
});const { rootState } = context;
rootState.im.userManage.asyncGetProfile(true).then((res) => {
context.commit('setProfileInfo', res);
});
userManage.asyncUpdateProfile(params) ⇒ Promise.<boolean>
更新用户profile
Kind: static method of userManage
Returns: Promise.<boolean> - 是否成功
| Param | Type | Description |
|---|---|---|
| params | object |
|
| params.description | string |
描述信息 |
| params.nick_name | string |
昵称 |
| params.private_info | string |
私有信息,仅自己可见 |
| params.public_info | string |
公开信息,好友和陌生人可见 |
Example
userManage.asyncGetSettings() ⇒ Promise.<UserSettings>
获取用户设置信息
Kind: static method of userManage
Returns: Promise.<UserSettings> - 用户信息
Example
const { rootState } = context;
rootState.im.userManage.asyncGetSettings().then((res) => {
context.commit('setSettingInfo', res);
});
userManage.asyncUpdateSettings(settings) ⇒ Promise.<boolean>
修改用户设置
Kind: static method of userManage
Returns: Promise.<boolean> - 是否成功
| Param | Type | Description |
|---|---|---|
| settings | UserSettings |
更新的设置 |
Example
const auth_mode = this.auth_mode === 1 ? 0 : 1;
const user_id = this.$store.state.im.userManage.getUid();
this.$store.state.im.userManage.asyncUpdateSettings({ auth_mode, user_id }).then(() => {
this.auth_mode = auth_mode;
});const group_confirm = !this.group_confirm;
const user_id = this.$store.state.im.userManage.getUid();
this.$store.state.im.userManage.asyncUpdateSettings({ group_confirm, user_id }).then(() => {
this.group_confirm = group_confirm;
});
