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>
- .asyncGetProfile() ⇒
Promise.<UserProfile>
- .asyncUpdateProfile(params) ⇒
Promise.<boolean>
- .asyncGetSettings() ⇒
Promise.<UserSettings>
- .asyncUpdateSettings(settings) ⇒
Promise.<boolean>
- .getToken() ⇒
userManage.getToken() ⇒ string
Get token of logged-in user
Kind: static method of userManage
Returns: string
- User's 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.im.userManage.getToken();
return this.$store.getters.im.userManage.getToken();
return this.im.userManage.getToken();
return this.$store.getters.im.userManage.getToken();
userManage.getUid() ⇒ number
Get uid of logged-in user
Kind: static method of userManage
Returns: number
- User 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();
if (toUid === pid) {
if (uid + '' !== message.from + '') {
this.$store.getters.im.groupManage.readGroupMessage(this.getSid);
}
this.requireMessage();
if (message.ext && !message.isHistory) {
let ext = {};
try {
ext = JSON.parse(message.ext);
} catch (ex) {
//
}
if (ext && ext.ai && ext.ai.stream && !ext.ai.finish) {
this.calculateScroll(message);
} else {
this.scroll();
}
} else {
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();
if (x.user_id != that.im.userManage.getUid()) {
return x.display_name.indexOf(str) >= 0;
}
userManage.getAppid() ⇒ string
Get 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;
let hide = true;
let hide_member_info = this.getGroupInfo.hide_member_info;
let app_hide_member_info = false;
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;
let appConfig = im.sysManage.getAppConfig(im.userManage.getAppid());
if (appConfig) {
if (appConfig.account_verification_type && appConfig.account_verification_type == 'enterprise') {
this.verification_description += appConfig.account_verification_name;
} else {
this.verification_description += '个人开发者:' + appConfig.account_verification_name;
}
if (appConfig.account_verification_status) {
switch (appConfig.account_verification_status) {
case 'unverified':
this.verification_status = '未认证';
this.verification_img = '/image/unverified.png';
break;
case 'verified':
this.verification_status = '已认证';
this.verification_img = '/image/verifyed.png';
break;
case 'expired':
this.verification_status = '认证失败';
this.verification_img = '/image/verify_failed.png';
break...
userManage.getConversationList() ⇒ Array.<ConversationItem>
Get list of recent conversations
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 content = item.content;
const timestamp = item.timestamp;
const hasAt = item.hasAt;
// const img = allRosterMap[id] && allRosterMap[id].avatar;
let avatar = ''; //(img && this.client.signatureUrl(img, { expires: 600, process: 'image/resize,w_50' })) || '/image/roster.png';
const unreadCount = item.type == 'roster' ? rootState.im.rosterManage.getUnreadCount(id) : rootState.im.groupManage.getUnreadCount(id);
const unread = unreadCount > 0 ? unreadCount : 0;
totalUnreadCount += unread;
if (item.type === 'roster') {
//roster
const sroster =...
userManage.getDeviceSN() ⇒ number
Get device serial number
Kind: static method of userManage
Returns: number
- Device serial number
Example
userManage.asyncBindDeviceToken(param) ⇒ Promise.<boolean>
Bind push device
Kind: static method of userManage
Returns: Promise.<boolean>
- Success or not
Param | Type | Description |
---|---|---|
param | object |
Bind request |
param.device_sn | number |
Device serial number |
param.notifier_name | string |
The certificate name, that is, the name set when uploading the certificate in the LanyingIM Console. |
param.device_token | string |
Push device token |
Example
userManage.asyncUnbindDeviceToken(param) ⇒ Promise.<boolean>
Unbind push device
Kind: static method of userManage
Returns: Promise.<boolean>
- Success or not
Param | Type | Description |
---|---|---|
param | object |
Unbind request |
param.deviceSn | number |
Device serial number |
Example
userManage.asyncRegister(opt) ⇒ Promise.<UserSettings>
User registeration
Kind: static method of userManage
Returns: Promise.<UserSettings>
- User settings
Param | Type | Description |
---|---|---|
opt | object |
User information |
opt.username | string |
Username |
opt.password | string |
Password |
Example
userManage.asyncUpdateAvatar(params) ⇒ Promise.<boolean>
Update avatar
Kind: static method of userManage
Returns: Promise.<boolean>
- Success or not
Param | Type | Description |
---|---|---|
params | object |
Parameter |
params.avatar | string |
Avatar url |
Example
userManage.asyncUpdateNickName(params) ⇒ Promise.<boolean>
Update nickname
Kind: static method of userManage
Returns: Promise.<boolean>
- Success or not
Param | Type | Description |
---|---|---|
params | object |
Parameter |
params.nick_name | string |
Nickname |
Example
if (!value) return;
im.userManage.asyncUpdateNickName({ nick_name: value }).then(() => {
this.nick_name = value;
this.$store.dispatch('header/actionGetHeaderProfile');
alert('修改成功');
});
userManage.asyncGetProfile() ⇒ Promise.<UserProfile>
Get user profile
Kind: static method of userManage
Returns: Promise.<UserProfile>
- User information
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>
Update user profile
Kind: static method of userManage
Returns: Promise.<boolean>
- Success or not
Param | Type | Description |
---|---|---|
params | object |
|
params.description | string |
Description |
params.nick_name | string |
Nickname |
params.private_info | string |
Private information, visible only to yourself |
params.public_info | string |
Public information, visible to both friends and strangers |
Example
userManage.asyncGetSettings() ⇒ Promise.<UserSettings>
Get user settings
Kind: static method of userManage
Returns: Promise.<UserSettings>
- User information
Example
const { rootState } = context;
rootState.im.userManage.asyncGetSettings().then((res) => {
context.commit('setSettingInfo', res);
});
userManage.asyncUpdateSettings(settings) ⇒ Promise.<boolean>
Modify user settings
Kind: static method of userManage
Returns: Promise.<boolean>
- Success or not
Param | Type | Description |
---|---|---|
settings | UserSettings |
Updated settings |
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;
});