|
(五)环信 easeChat模块demo发送表情
[复制链接]
本帖最后由 Mr.ZhouHeng 于 2019-9-3 15:27 编辑
环信 easeChat模块demo发送表情
- <div class="center-body ellipsis-1" v-html="fnType(lists.latestMessage.body.type,index)"></div>
- <!-- 表情转换js -->
- <script type="text/javascript" src="../script/emotion.js"></script>
- fnType: function(types, index) {
- //text:文本类型
- //image:图片类型
- //video:视频类型
- //location:位置类型
- //voice:语音类型
- //file:文件类型
- if (types == "text") {
复制代码
- <!-- 文本消息 -->
- <div class="chat-content" v-if="chats.body.type=='text'">
- <div class="chat-arrow"></div>
- <div class="body picbody" v-html="translateText(chats.body.text)"></div>
- </div>
- <!-- 表情转换js -->
- <script type="text/javascript" src="../../script/emotion.js"></script>
- //文本表情转化
- translateText: function(text) {
- if (text == '' || text == undefined) {
- return;
- }
- msg = text;
- var emotionObj = emotion;
- var regx = /\[(.*?)\]/gm;
- var translateMSg = text.replace(regx, function(math) {
- var imgSrc = emotionObj[math];
- if (!imgSrc) {
- return math;
- }
- var img = '<img src="../../res/img/emotion/' + imgSrc + '.png" class="emotion">'
- return img;
- })
- console.log(translateMSg)
- return translateMSg;
- }
复制代码
|
本帖子中包含更多资源,您需要 登录 才可以下载或查看,没有帐号?立即注册
X
|