userManage

userManage

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.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

获取登录用户的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();
if (toUid === pid) {
  if (uid + '' !== message.from + '') {
    this.$store.getters.im.groupManage.readGroupMessage(this.getSid);
  }
  this.requireMessage();
  this.scroll();
}
// 如果有mention的
const uid = this.$store.getters.im.userManage.getUid();
const hasIndex = config.mentionList.findIndex((x) => x + '' === uid + '');
if (hasIndex > -1) {
  const umaps = this.$store.getters.im.rosterManage.getAllRosterDetail();
  const str = umaps[from].username + ' 在群中提到了您!';
  this.mentionMessage = str;
}
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;
this.$store.getters.im.groupManage
  .asyncGetInfo({ group_id: newSid })
  .then((res) => {
    res.avatar = this.$store.getters.im.sysManage.getImage({
      avatar: res.avatar,
      type: 'group'
    });
    this.groupInfo = res;
  })
  .catch((ex) => {
    this.serr(ex);
  });

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)) || '';
//mention消息
/**
 static const std::string kMentionAll = “mentionAll”;              // bool
 static const std::string kMentionList = “mentionList”;            // vector<int64_t>
 static const std::string kMentionedMessage = “mentionedMessage”;  // string
 static const std::string kPushMessage = “pushMessage”;            // string
 static const std::string kSenderNickname = “senderNickname”;      // string
 */
const mentionAll = false;
const mentionList = this.mentionSelectedUids.map((x) => x - 0);
const mentionedMessage = '';
const pushMessage = '';
const uid = this.im.userManage.getUid();
const rInfo = this.im.rosterManage.getRosterInfo(uid);
const senderNickname = rInfo.username || rInfo.user_id + '';
this.im.sysManage.sendMentionMessage({
  gid: this.getSid,
  // txt: this.willsendMessage,
  txt: this.message,
  mentionAl...
const uid = this.$store.getters.im.userManage.getUid();
return this.getAdminList.filter((x) => x.user_id === uid).length > 0;

userManage.getAppid() ⇒ string

获取appid

Kind: static method of userManage
Returns: string - APP ID
Example

const url = d + '&access-token=' + this.im.userManage.getToken() + '&app_id=' + this.im.userManage.getAppid();
window.open(url);
const image_id = this.user['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['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() || {};
const convData = convlist.map((item, index) => {
  let name;
  const id = item.id;
  const content = item.content;
  const timestamp = item.timestamp;
  // 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;
  if (item.type === 'roster') {
    //roster
    const sroster = allRosterMap[id] || {};
    name = sroster.nick_name || sroster.username || id;
    ava...

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

if (!this.user.username || !this.user.password) {
  this.$message.error('请输入用户名或密码');
  return;
}
const im = this.$store.state.im;
im.userManage.asyncRegister(this.user).then(() => {
  this.$store.dispatch('login/actionSetLoginInfo', this.user);
  this.$store.dispatch('login/actionChangeAppStatus', 'bind');
});

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;
  alert('修改成功');
});

userManage.asyncGetProfile() ⇒ Promise.<UserProfile>

获取用户profile

Kind: static method of userManage
Returns: Promise.<UserProfile> - 用户信息
Example

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;
});

© 2019-2022 美信拓扑 | 官网 该文件修订时间: 2022-09-21 11:43:07

results matching ""

    No results matching ""