2019-11-25更新

npm install --save easemob-websdk
请直接使用官方安装方式即可。
import WebIM from 'easemob-websdk'

以下是最开始版本 环信不适配所写

配置文件可用下面的

使用时请仔细检查域名与host 是否是HTTP/HHTPS协议

// Step1、安装 easemob-websdk

// npm install --save easemob-websdk

// Step2、安装 strophe.js    underscore    crypto-js

// npm install --save strophe.js underscore crypto-js

Update 2019-6-19  更新  使用 hx-websdk

npm install --save hx-websdk

Step3、使用 新建一个webim.js

import store from '@/store'
// window.Strophe = require('strophe.js').Strophe // 务必在前面引入
// let WebIM = require('easemob-websdk')
let WebIM = require('hx-websdk') // 使用hx-websdk集成 直接使用 WebIM.config = {
/*
* XMPP server
*/
xmppURL: 'im-api.easemob.com',
/*
* Backend REST API URL
*/
apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//a1.easemob.com',
/*
* Application AppKey
*/
appkey: '你公司的环信AppKey', /*
* Whether to use wss
* @parameter {Boolean} true or false
*/
https: false,
/*
* isMultiLoginSessions
* true: A visitor can sign in to multiple webpages and receive messages at all the webpages.
* false: A visitor can sign in to only one webpage and receive messages at the webpage.
*/
isMultiLoginSessions: false,
/*
* set presence after login
*/
isAutoLogin: true,
/**
* Whether to use window.doQuery()
* @parameter {Boolean} true or false
*/
isWindowSDK: false,
/**
* isSandBox=true: xmppURL: 'im-api-sandbox.easemob.com', apiURL: '//a1-sdb.easemob.com',
* isSandBox=false: xmppURL: 'im-api.easemob.com', apiURL: '//a1.easemob.com',
* @parameter {Boolean} true or false
*/
isSandBox: false,
/**
* Whether to console.log in strophe.log()
* @parameter {Boolean} true or false
*/
isDebug: true,
/**
* will auto connect the xmpp server autoReconnectNumMax times in background when client is offline.
* won't auto connect if autoReconnectNumMax=0.
*/
autoReconnectNumMax: 2,
/**
* the interval seconds between each auto reconnectting.
* works only if autoReconnectMaxNum >= 2.
*/
autoReconnectInterval: 2,
/**
* webrtc supports WebKit and https only
*/
isWebRTC: (/Firefox/.test(navigator.userAgent) || /WebKit/.test(navigator.userAgent)) && /^https:$/.test(window.location.protocol),
/**
* after login, send empty message to xmpp server like heartBeat every 45s, to keep the ws connection alive.
*/
heartBeatWait: 4500,
/**
* while http access,use ip directly,instead of ServerName,avoiding DNS problem.
*/
isHttpDNS: false, /**
* Will show the status of messages in single chat
* msgStatus: true show
* msgStatus: true hide
*/
msgStatus: true, /**
* When a message arrived, the receiver send an ack message to the
* sender, in order to tell the sender the message has delivered.
* See call back function onReceivedMessage
*/
delivery: true, /**
* When a message read, the receiver send an ack message to the
* sender, in order to tell the sender the message has been read.
* See call back function onReadMessage
*/
read: false, /**
* Will encrypt text message and emoji message
* {type:'none'} no encrypt
* {type:'base64'} encrypt with base64
* {type:'aes',mode: 'ebc',key: '123456789easemob',iv: '0000000000000000'} encrypt with aes(ebc)
* {type:'aes',mode: 'cbc',key: '123456789easemob',iv: '0000000000000000'} encrypt with aes(cbc)
*/
encrypt: {
type: 'none'
}
}
WebIM.Emoji = {
path: 'images/faces/',
map: {
'[):]': 'ee_1.png',
'[:D]': 'ee_2.png',
'[;)]': 'ee_3.png',
'[:-o]': 'ee_4.png',
'[:p]': 'ee_5.png',
'[(H)]': 'ee_6.png',
'[:@]': 'ee_7.png',
'[:s]': 'ee_8.png',
'[:$]': 'ee_9.png',
'[:(]': 'ee_10.png',
'[:\'(]': 'ee_11.png',
'[:|]': 'ee_12.png',
'[(a)]': 'ee_13.png',
'[8o|]': 'ee_14.png',
'[|]': 'ee_15.png',
'[+o(]': 'ee_16.png',
'[<o)]': 'ee_17.png',
'[|-)]': 'ee_18.png',
'[*-)]': 'ee_19.png',
'[:-#]': 'ee_20.png',
'[:-*]': 'ee_21.png',
'[^o)]': 'ee_22.png',
'[8-)]': 'ee_23.png',
'[(|)]': 'ee_24.png',
'[(u)]': 'ee_25.png',
'[(S)]': 'ee_26.png',
'[(*)]': 'ee_27.png',
'[(#)]': 'ee_28.png',
'[(R)]': 'ee_29.png',
'[({)]': 'ee_30.png',
'[(})]': 'ee_31.png',
'[(k)]': 'ee_32.png',
'[(F)]': 'ee_33.png',
'[(W)]': 'ee_34.png',
'[(D)]': 'ee_35.png'
}
}
WebIM.NewEmoji = {
map: ['

Vue 集成环信 全局封装环信WebSDK 可直接使用的更多相关文章

  1. vue集成环信IM

    vue 集成环信im 简单demo 环信AppKey:1106190415055331#test 测试账号: test1  123456  test2  123456  test3  123456 默 ...

  2. 李洪强iOS开发之-环信02.2_环信官网下载环信 SDK

    李洪强iOS开发之-环信02.2_环信官网下载环信 SDK 移动客服即时通讯云 iOS SDK 当前版本:V3.1.4 2016-07-08 [ 版本历史 ] | 开发指南 | 知识库 | Demo源 ...

  3. 李洪强iOS开发之-环信02.1_环信 SDK 2.x到3.0升级文档

    李洪强iOS开发之-环信02.1_环信 SDK 2.x到3.0升级文档 SDK 2.x 至 3.0 升级指南 环信 SDK 3.0 升级文档 3.0 中的核心类为 EMClient 类,通过 EMCl ...

  4. Android 环信(Android)设置头像和昵称的方法

    最近,经常有朋友问到,如何集成环信头像,怎么才能快速显示头像,因时间紧急,很多朋友都没有时间慢慢的研究代码,这里大家稍微花10分钟看一下文章,看完后再花5分钟改一下代码,即可达到你们所要的效果. 当然 ...

  5. 环信集成 2---基于环信Demo3.0,实现单聊功能

    这几天在做环信,所以把环信相关的东西拿过来,做个系统点的东西 注意: 这里Demo集成的是带有实时语音功能的(libEaseMobClientSDK.a). 环信库是直接拖拽EaseMobSDK文件夹 ...

  6. 李洪强iOS开发本人集成环信的经验总结_01环信SDK的导入

    李洪强iOS开发本人集成环信的经验总结_01环信SDK的导入 01 - 直接在项目中导入SDK和一些静态库 这个时候,没有错误的编译没有错误的话,就说明SDK已经配置成功 还有一种方法是用cocoap ...

  7. Apple Watch 集成环信SDK

    本文简单的讲述下怎样用Apple Watch Kit集成环信SDK. 升级xcode到version 6.2,和 IOS SDK8.2 下载环信SDK从官网 打开XCode->new proje ...

  8. iOS:集成环信EaseMobSDK单聊功能

    当然在集成环信之前需要一些准备操作: 1.首先注册环信开发者账号,直接进入环信官网注册即可:http://www.easemob.com 2.按照文档一步一步将需要的文件全部拖入工程中:http:// ...

  9. 李洪强iOS开发本人集成环信的经验总结_03_注册

    李洪强iOS开发本人集成环信的经验总结_03_注册 环信一共提供了三种注册的方法:  01 同步注册:  02 异步注册:  03 - 使用代理回调进行注册,但是3.0没有了,3.0之前有  调用注册 ...

随机推荐

  1. c++链表演示

    #include<iostream> #include<string.h> #include<conio.h> using namespace std; #defi ...

  2. 官网英文版学习——RabbitMQ学习笔记(六)Routing

    有选择的接收消息. 上一节我们使用的是fanout exchange来实现消息的发布/订阅模式,这并没有给我们带来多大的灵活性——它只能够让人盲目地进行广播.而本节我们采用direct类型的交换器来实 ...

  3. Jinja2语法小记

    jinja2模板语法小记 Jinja2模板中文文档 三种常见界定符 表达式 {{ ... }} 用于装载字符串.变量.函数调用等 语句 {% ... %} 用于装载控制语句,比如if判断.for循环等 ...

  4. 七十一、SAP中内表的修改,改一行数据,或一行的某个字段

    一.SAP中内表的修改,只能通过工作区来修改,代码如下 二.效果如下

  5. POJ 1770 树形DP

    咋一看确实想到的是树形DP,但是我一开始也马上想到环的情况,这样应该是不可以进行树形DP的,然后我自以为是地想用有向图代替无向图,而且总是从能量高的指向能量低的,这样自以为消除了环,但是其实是不对滴, ...

  6. bmp

    function GetNumberBuffer(cZi: string; cwidth, cheight: Integer; FontName: string; bold, italic: Bool ...

  7. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 字体图标(Glyphicons):glyphicon glyphicon-facetime-video

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...

  8. NumPy 矩阵库函数

    章节 Numpy 介绍 Numpy 安装 NumPy ndarray NumPy 数据类型 NumPy 数组创建 NumPy 基于已有数据创建数组 NumPy 基于数值区间创建数组 NumPy 数组切 ...

  9. json字符串格式化显示

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. tensorflow--建立一个简单的小网络

    In [19]:           import tensorflow as tf import numpy as np # #简单的数据形网络 # #定义输入参数 # X=tf.constant( ...