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();
  if (message.ext && !message.isHistory) {
    let ext = JSONBigString.parse(message.ext);
    if (ext && ext.ai && ext.ai.stream && !ext.ai.finish) {
      this.calculateScroll(message);
    } else {
      this.scroll();
    }
  } else {
    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;
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;
      });
    });
}
//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 app_id = this.$store.state.im.userManage.getAppid();
const info = this.getCallInviteInfo;
if (info) {
  this.caller = false;
  this.refreshUserInfo(info.initiator);
} else {
  this.caller = true;
  this.refreshUserInfo(this.getSid);
  this.startPhoneRing();
}
document.getElementById('roster_remote_only_audio').muted = false;
this.$store.getters.im.rtcManage.initRTCEngine({
  server: this.$store.state.im.sysManage.getServers(app_id).rtc,
  id: this.$store.state.im.userManage.getUid(),
  caller: this.caller,
  receiver: this.caller ? this.getSid : info.initiator,
  roomId: this.caller ? 0 : info.roomId,
  secret: this.caller ? this.randomString(8) : '',
  callId: this.caller ? this.getCallId : '',
  pin: this.caller ? this.randomString(8) : info.pin,
  hasVideo: false,
  hasAudio: true,
  getThrough: this.getThrough,
  hangupCall: this.hangupCall,
  getHangUpStatus: this.getHang...
const url = d + '&access-token=' + this.im.userManage.getToken() + '&app_id=' + this.im.userManage.getAppid();
window.open(url);
const app_id = this.$store.state.im.userManage.getAppid();
const info = this.getCallInviteInfo;
if (info) {
  this.caller = false;
  this.refreshUserInfo(info.initiator);
} else {
  this.caller = true;
  this.refreshUserInfo(this.getSid);
  this.startPhoneRing();
}
document.getElementById('roster_remote_audio').muted = false;
this.$store.getters.im.rtcManage.initRTCEngine({
  server: this.$store.state.im.sysManage.getServers(app_id).rtc,
  id: this.$store.state.im.userManage.getUid(),
  caller: this.caller,
  receiver: this.caller ? this.getSid : info.initiator,
  roomId: this.caller ? 0 : info.roomId,
  secret: this.caller ? this.randomString(8) : '',
  callId: this.caller ? this.getCallId : '',
  pin: this.caller ? this.randomString(8) : info.pin,
  hasVideo: true,
  hasAudio: true,
  width: 360,
  height: 640,
  getThrough: this.getThrough,
  hangupCall: this.hangupCall,
...
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;
return this.$store.state.im.userManage.getAppid();

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 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;
  totalUnreadCount += unread;
  if (item.type === 'roster') {
    //roster
    const sroster = allRosterMap[id] || {};
   ...

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

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

© 2019-2023 美信拓扑 | 官网 该文件修订时间: 2024-03-14 15:59:02

results matching ""

    No results matching ""