rong_cloud_h5_ui

功能描述

1、该模块具有发送语音,发送表情,发送图片等功能的 融云聊天UI 2、该模块需要集成 rongCloudIM 模块 和 UIChatBox模块 + imageBrowser模块,支持语音+图片+表情文字的聊天窗口,使用时注意添加以上模块

依赖的模块

  1. vue.js,rongCloudIM模块,UIChatBox模块,imageBrowser模块

快速使用

  1. section class="aui-chat" id="chat_message_body" style="margin-top:50px;">
  2. <div class="aui-chat-header"><a id="user_msg_time">暂无消息</a></div>
  3. <div class="app-chat-data-list" id="chat_message_html">
  4. <div v-cloak v-for="(vo,index) in list">
  5. <div v-if="user_id != vo.user_id">
  6. <div class="app-chat-data-list-left-msg">
  7. <div class="app-chat-data-list-left-msg-l"><img :src="vo.head_portrait"></div>
  8. <div class="app-chat-data-list-left-msg-r">
  9. <div v-if="vo.msg_type == 'RC:TxtMsg'">
  10. <i style="top:25px;"><img src="./image/msg_l.png"></i>
  11. <p v-html="vo.user_msg"></p>
  12. </div>
  13. <div v-else-if="vo.msg_type == 'RC:VcMsg'">
  14. <i style="top:25px;"><img src="./image/msg_l.png"></i>
  15. <p class="yuyin yuyin_left" @click="video_click" v-duration="vo.duration" :video_src="vo.user_video" :message_id="vo.message_id" video_type="left">
  16. <img src="./image/yuyin_left.png">
  17. <a v-if="vo.read_state!='1'"></a>
  18. <b style="text-align: left;">{{vo.duration}}"</b>
  19. </p>
  20. </div>
  21. <div v-else-if="vo.msg_type == 'RC:ImgMsg'">
  22. <p class="image"><img @click="image_click" :image_src="vo.image_url" :src="vo.user_image"></p>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. <div v-else>
  28. <div class="app-chat-data-list-right-msg">
  29. <div class="app-chat-data-list-right-msg-l"><img :src="vo.head_portrait"></div>
  30. <div class="app-chat-data-list-right-msg-r">
  31. <div v-if="vo.msg_type == 'RC:TxtMsg'">
  32. <i style="top:25px;"><img src="./image/msg_r.png"></i>
  33. <p v-html="vo.user_msg"></p>
  34. </div>
  35. <div v-else-if="vo.msg_type == 'RC:VcMsg'">
  36. <i style="top:25px;"><img src="./image/msg_r.png"></i>
  37. <p class="yuyin yuyin_right" @click="video_click" v-duration="vo.duration" :video_src="vo.user_video" :message_id="vo.message_id" video_type="right">
  38. <img src="./image/yuyin_right.png">
  39. <a v-if="vo.read_state!='1'"></a>
  40. <b style="text-align: right; right:0px;left:-24px;">{{vo.duration}}"</b>
  41. </p>
  42. </div>
  43. <div v-else-if="vo.msg_type == 'RC:ImgMsg'">
  44. <p class="image"><img @click="image_click" :image_src="vo.image_url" :src="vo.user_image"></p>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </section>
  52. <div class="app-chat-open-mai-box" id="start_del_mai">
  53. <div class="app-chat-open-mai-data">
  54. <div class="app-chat-open-mai">
  55. <h2><img style="width:58px;height:58px; margin-left:26px;" src="./image/chat_mai.png"><img id="chat_yin" style="width:40px;height:40px; margin-top:18px;" src="./image/chat_yin.png"></h2>
  56. <p>手指上滑,取消发送</p>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="app-chat-open-mai-box" id="end_del_mai">
  61. <div class="app-chat-open-mai-data">
  62. <div class="app-chat-open-mai">
  63. <h2><img style="width:58px;height:58px; margin-left:46px;" src="./image/del_mai.png"></h2>
  64. <p><a style="background:#863935; height:20px; line-height:20px; border-radius:4px; color:#fff; padding:0px 6px;">松开手指,取消发送</a></p>
  65. </div>
  66. </div>
  67. </div>
  68. <script type="text/javascript">
  69. apiready = function(){
  70. // 注意, 用户id 和 token 仅供演示,实际项目需要使用者跟进实情配置真实的参数
  71. // 当前用户id
  72. var get_user_id = '47';
  73. var get_user_head_portrait = './image/user_1.png';
  74. // 目标用户id
  75. var target_user_id = '1';
  76. var target_user_head_portrait = './image/user_2.png';
  77. var user_token = 'plNA3XDOITrSRvZP24L5AWRmf7MNMXtPsXk+1SycgW4E+nRgH0bCuw9Dw8WjkkiYgYb+EtD8QOWRQ1191DdP+Hx6BIY37Lbt';
  78. var chat_message_html = new Vue({
  79. el: '#chat_message_html',
  80. data: {
  81. user_id:get_user_id,
  82. list: [{
  83. message_id:1,
  84. user_id:target_user_id,
  85. user_name:'',
  86. head_portrait:'./image/user_2.png',
  87. user_msg:'你好,此模块有哪些功能!',
  88. user_image:'',
  89. image_url:'',
  90. user_video:'',
  91. duration:'',
  92. msg_type:'RC:TxtMsg',
  93. read_state:1,
  94. },{
  95. message_id:1,
  96. user_id:get_user_id,
  97. user_name:'',
  98. head_portrait:'./image/user_1.png',
  99. user_msg:'你好,该模块需要集成 rongCloudIM 模块 和 UIChatBox模块 + imageBrowser模块,支持语音+图片+表情文字的聊天窗口',
  100. user_image:'',
  101. image_url:'',
  102. user_video:'',
  103. duration:'',
  104. msg_type:'RC:TxtMsg',
  105. read_state:1,
  106. }]
  107. },
  108. methods:{
  109. video_click:function(event){
  110. var message_id = $api.attr(event.target,'message_id');
  111. var video_src = $api.attr(event.target,'video_src');
  112. var video_type = $api.attr(event.target,'video_type');
  113. $api.attr($api.dom('.yuyin_left img'),'src','./image/yuyin_left.png');
  114. $api.attr($api.dom('.yuyin_right img'),'src','./image/yuyin_right.png');
  115. api.stopPlay();
  116. if(video_src){
  117. $api.attr($api.first(event.target,'img'),'src','./image/yuyin_'+video_type+'_gif.gif');
  118. api.startPlay({
  119. path:video_src
  120. }, function(ret, err) {
  121. $api.attr($api.first(event.target,'img'),'src','./image/yuyin_'+video_type+'.png');
  122. });
  123. }else{
  124. $api.attr(event.target,'src','./image/icon/yuyin_'+$api.attr($api.closest(event.target, 'p'),'video_type')+'_gif.gif');
  125. api.startPlay({
  126. path:$api.attr($api.closest(event.target, 'p'),'video_src')
  127. }, function(ret, err) {
  128. $api.attr(event.target,'src','./image/yuyin_'+$api.attr($api.closest(event.target, 'p'),'video_type')+'.png');
  129. });
  130. }
  131. var rong = api.require('rongCloudIM');
  132. rong.setMessageReceivedStatus({
  133. messageId: message_id,
  134. receivedStatus: 'LISTENED'
  135. }, function(ret, err) {
  136. });
  137. $api.css($api.dom(event.target,'a'),'display:none');
  138. },
  139. image_click:function(event){
  140. var image_src = $api.attr(event.target,'image_src');
  141. if(image_src){
  142. var imageBrowser = api.require('imageBrowser');
  143. imageBrowser.openImages({
  144. imageUrls: [image_src],
  145. showList:false,
  146. activeIndex:0
  147. });
  148. }
  149. }
  150. }
  151. });
  152. // 初始化聊天室
  153. var rong = api.require('rongCloudIM');
  154. rong.init(function(ret, err) {
  155. });
  156. rong.configurationParameter({
  157. showNickname:true
  158. });
  159. rong.setConnectionStatusListener(function(ret, err) {
  160. });
  161. rong.connect({
  162. token: user_token
  163. },function(ret, err) {
  164. if (ret.status == 'success'){
  165. }
  166. });
  167. // 已读消息
  168. rong.clearMessagesUnreadStatus({
  169. conversationType: 'PRIVATE',
  170. targetId:get_user_id
  171. }, function(ret, err) {
  172. });
  173. var UIChatBox = api.require('UIChatBox');
  174. UIChatBox.open({
  175. placeholder: '',
  176. maxRows: 4,
  177. emotionPath: 'widget://libs/img/emotion',
  178. texts: {
  179. recordBtn: {
  180. normalTitle: '按住说话',
  181. activeTitle: '松开结束'
  182. },
  183. sendBtn: {
  184. title: '发送'
  185. }
  186. },
  187. styles: {
  188. topDivider:{
  189. width:0,
  190. color:'#E6E6E6'
  191. },
  192. inputBar: {
  193. borderColor: '#A5ABAF',
  194. bgColor: '#FFFFFF'
  195. },
  196. inputBox: {
  197. borderColor: '#A5ABAF',
  198. bgColor: '#FFFFFF'
  199. },
  200. emotionBtn: {
  201. normalImg: 'widget://libs/img/emotion/chat01.png'
  202. },
  203. extrasBtn: {
  204. normalImg: 'widget://libs/img/emotion/chat02.png'
  205. },
  206. keyboardBtn: {
  207. normalImg: 'widget://libs/img/emotion/chat03.png'
  208. },
  209. speechBtn: {
  210. normalImg: 'widget://libs/img/emotion/mai.png'
  211. },
  212. recordBtn: {
  213. normalBg: 'widget://image/icon/mai_bj.png',
  214. activeBg: 'widget://image/icon/mai_bj_ok.png',
  215. color: '#000',
  216. size: 14
  217. },
  218. indicator: {
  219. target: 'both',
  220. color: '#c4c4c4',
  221. activeColor: '#9e9e9e'
  222. },
  223. sendBtn: {
  224. titleColor: '#ffffff',
  225. bg: '#DD4338',
  226. activeBg: '#DD4338',
  227. titleSize: 14
  228. }
  229. },
  230. extras: {
  231. titleSize: 10,
  232. titleColor: '#a3a3a3',
  233. btns: [{
  234. title: '图片',
  235. normalImg: 'widget://libs/img/emotion/image_a.png',
  236. activeImg: 'widget://libs/img/emotion/image_b.png'
  237. }, {
  238. title: '拍照',
  239. normalImg: 'widget://libs/img/emotion/shooting_a.png',
  240. activeImg: 'widget://libs/img/emotion/shooting_b.png'
  241. }]
  242. }
  243. }, function(ret, err) {
  244. if (ret) {
  245. if(ret.eventType=='send'){
  246. if(ret.msg){
  247. send_rong('text',target_user_id,ret.msg,0);
  248. }
  249. UIChatBox.closeKeyboard();
  250. UIChatBox.closeBoard();
  251. }else if(ret.click==true){
  252. if(ret.index==0 && ret.eventType=='clickExtras'){
  253. api.getPicture({
  254. sourceType: 'album',
  255. encodingType: 'jpg',
  256. mediaValue: 'pic',
  257. destinationType: 'url',
  258. allowEdit: false,
  259. quality: 90,
  260. saveToPhotoAlbum: false
  261. }, function(ret, err) {
  262. if (ret) {
  263. if(ret.data){
  264. send_rong('image',target_user_id,ret.data,0);
  265. UIChatBox.closeBoard();
  266. }
  267. }
  268. });
  269. }else if(ret.index==1 && ret.eventType=='clickExtras'){
  270. api.getPicture({
  271. sourceType: 'camera',
  272. encodingType: 'jpg',
  273. mediaValue: 'pic',
  274. destinationType: 'url',
  275. allowEdit: false,
  276. quality: 90,
  277. saveToPhotoAlbum: false
  278. }, function(ret, err) {
  279. if (ret) {
  280. if(ret.data){
  281. send_rong('image',target_user_id,ret.data,0);
  282. UIChatBox.closeBoard();
  283. }
  284. }
  285. });
  286. }
  287. }else if(ret.eventType=='show'){
  288. $api.css($api.dom('#chat_message_body'),'height:'+(api.frameHeight - ret.inputBarHeight - 55)+'px;overflow-x:hidden;overflow-y:auto;-webkit-overflow-scrolling: touch;');
  289. }
  290. }
  291. });
  292. UIChatBox.addEventListener({
  293. target: 'recordBtn',
  294. name: 'press'
  295. }, function(ret, err) {
  296. if (ret) {
  297. $api.css($api.dom('#start_del_mai'),'display:block');
  298. // 开始录音
  299. $api.attr($api.dom('#chat_yin'),'src','./image/chat_yin.gif');
  300. var time = new Date().getTime();
  301. api.startRecord({
  302. path: 'fs://lemon/chat/chat_record_'+time+'.amr'
  303. });
  304. }
  305. });
  306. UIChatBox.addEventListener({
  307. target: 'recordBtn',
  308. name: 'move_out'
  309. }, function(ret, err) {
  310. if (ret) {
  311. $api.css($api.dom('#start_del_mai'),'display:none');
  312. $api.css($api.dom('#end_del_mai'),'display:block');
  313. api.stopRecord(function(ret, err) {});
  314. $api.attr($api.dom('#chat_yin'),'src','./image/chat_yin.png');
  315. }
  316. });
  317. UIChatBox.addEventListener({
  318. target: 'recordBtn',
  319. name: 'move_out_cancel'
  320. }, function(ret, err) {
  321. if (ret) {
  322. $api.css($api.dom('#start_del_mai'),'display:none');
  323. $api.css($api.dom('#end_del_mai'),'display:none');
  324. api.stopRecord(function(ret, err) {});
  325. $api.attr($api.dom('#chat_yin'),'src','./image/chat_yin.png');
  326. }
  327. });
  328. UIChatBox.addEventListener({
  329. target: 'recordBtn',
  330. name: 'press_cancel'
  331. }, function(ret, err) {
  332. if (ret) {
  333. $api.css($api.dom('#start_del_mai'),'display:none');
  334. $api.css($api.dom('#end_del_mai'),'display:none');
  335. // 发送语音
  336. api.stopRecord(function(ret, err) {
  337. if (ret) {
  338. var path = ret.path;
  339. var duration = ret.duration;
  340. send_rong('video',target_user_id,path,duration);
  341. $api.attr($api.dom('#chat_yin'),'src','./image/chat_yin.png');
  342. }
  343. });
  344. }
  345. });
  346. // 统一接收融云会话加
  347. api.addEventListener({
  348. name: 'get_rong_message_data'
  349. }, function(rrr, eee) {
  350. var ret = rrr.value;
  351. if(ret.result.message.conversationType=='PRIVATE' && ret.result.message.senderUserId==target_user_id){
  352. $lemon.css('#user_msg_time','display:none');
  353. // 接受消息
  354. var rong = api.require('rongCloudIM');
  355. rong.clearMessagesUnreadStatus({
  356. conversationType: 'PRIVATE',
  357. targetId:target_user_id
  358. }, function(ret, err) {
  359. });
  360. if(api.systemType=='ios'){
  361. if(ret.result.message.receivedStatus=='LISTENED'){
  362. var read_state = 1;
  363. }else{
  364. var read_state = 0;
  365. }
  366. }else{
  367. if(ret.result.message.isListened==true){
  368. var read_state = 1;
  369. }else{
  370. var read_state = 0;
  371. }
  372. }
  373. if(ret.result.message.objectName=='RC:TxtMsg'){
  374. chat_message_html.list.push({
  375. message_id:ret.result.message.messageId,
  376. user_id:target_user_id,
  377. user_name:'',
  378. head_portrait:$lemon.db_select_user(target_user_id,'user_img'),
  379. user_msg:emotion_replace(ret.result.message.content.text),
  380. user_image:'',
  381. image_url:'',
  382. user_video:'',
  383. duration:'',
  384. msg_type:'RC:TxtMsg',
  385. read_state:ret.result.message.receivedStatus,
  386. });
  387. }else if(ret.result.message.objectName=='RC:VcMsg'){
  388. chat_message_html.list.push({
  389. message_id:ret.result.message.messageId,
  390. user_id:target_user_id,
  391. user_name:'',
  392. head_portrait:$lemon.db_select_user(target_user_id,'user_img'),
  393. user_msg:'',
  394. user_image:'',
  395. image_url:'',
  396. user_video:ret.result.message.content.voicePath,
  397. duration:ret.result.message.content.duration,
  398. msg_type:'RC:VcMsg',
  399. read_state:ret.result.message.receivedStatus,
  400. });
  401. }else if(ret.result.message.objectName=='RC:ImgMsg'){
  402. chat_message_html.list.push({
  403. message_id:ret.result.message.messageId,
  404. user_id:target_user_id,
  405. user_name:'',
  406. head_portrait:$lemon.db_select_user(target_user_id,'user_img'),
  407. user_msg:'',
  408. user_image:ret.result.message.content.thumbPath,
  409. image_url:ret.result.message.content.imageUrl,
  410. user_video:'',
  411. duration:'',
  412. msg_type:'RC:ImgMsg',
  413. read_state:ret.result.message.receivedStatus,
  414. });
  415. }
  416. setTimeout(function(){
  417. $api.css($api.dom('#chat_message_body'),'display:block');
  418. var div = document.getElementById('chat_message_body');
  419. div.scrollTop = div.scrollHeight;
  420. },300);
  421. }
  422. });
  423. // 监听键盘
  424. $api.setStorage('s_frameHeight',api.frameHeight);
  425. UIChatBox.addEventListener({
  426. target: 'inputBar',
  427. name: 'move'
  428. }, function(ret, err) {
  429. if (ret) {
  430. var win_height = ret.panelHeight;
  431. $api.css($api.dom('#chat_message_body'),'height:'+(api.frameHeight - ret.inputBarHeight - 55)+'px;overflow-x:hidden;overflow-y:auto;-webkit-overflow-scrolling: touch;');
  432. setTimeout(function(){
  433. var div = document.getElementById('chat_message_body');
  434. div.scrollTop = div.scrollHeight;
  435. },100);
  436. }
  437. });
  438. function send_rong(type,target_id,target_msg,duration){
  439. var rong = api.require('rongCloudIM');
  440. if(type=='text'){
  441. rong.sendTextMessage({
  442. conversationType: 'PRIVATE',
  443. targetId: target_user_id,
  444. text: target_msg,
  445. extra:'{userInfo:{nickName:"自定义用户名称"}}'
  446. }, function(ret, err) {
  447. if(ret.status=='success'){
  448. var data = ret.result.message;
  449. if(data){
  450. chat_message_html.list.push({
  451. message_id:data.messageId,
  452. user_id:get_user_id,
  453. user_name:'',
  454. head_portrait:get_user_head_portrait,
  455. user_msg:emotion_replace(target_msg),
  456. user_image:'',
  457. image_url:'',
  458. user_video:'',
  459. duration:'',
  460. msg_type:'RC:TxtMsg',
  461. read_state:'READ',
  462. });
  463. setTimeout(function(){
  464. var div = document.getElementById('chat_message_body');
  465. div.scrollTop = div.scrollHeight;
  466. },300);
  467. }
  468. }
  469. });
  470. }else if(type=='video'){
  471. rong.sendVoiceMessage({
  472. conversationType: 'PRIVATE',
  473. targetId: target_user_id,
  474. voicePath: target_msg,
  475. duration: duration,
  476. extra:'{userInfo:{nickName:"自定义用户名称"}}'
  477. }, function(ret, err) {
  478. if(ret.status=='success'){
  479. rong.setMessageReceivedStatus({
  480. messageId:ret.result.message.messageId,
  481. receivedStatus: 'LISTENED'
  482. }, function(ret, err) {
  483. });
  484. var data = ret.result.message;
  485. chat_message_html.list.push({
  486. message_id:data.messageId,
  487. user_id:get_user_id,
  488. user_name:'',
  489. head_portrait:get_user_head_portrait,
  490. user_msg:'',
  491. user_image:'',
  492. image_url:'',
  493. user_video:target_msg,
  494. duration:duration,
  495. msg_type:'RC:VcMsg',
  496. read_state:'READ',
  497. });
  498. setTimeout(function(){
  499. var div = document.getElementById('chat_message_body');
  500. div.scrollTop = div.scrollHeight;
  501. },300);
  502. }
  503. });
  504. }else if(type=='image'){
  505. rong.sendImageMessage({
  506. conversationType: 'PRIVATE',
  507. targetId: target_user_id,
  508. imagePath:target_msg,
  509. extra:'{userInfo:{nickName:"自定义用户名称"}}'
  510. }, function(ret, err) {
  511. if(ret.status=='success'){
  512. var data = ret.result.message;
  513. chat_message_html.list.push({
  514. message_id:data.messageId,
  515. user_id:get_user_id,
  516. user_name:'',
  517. head_portrait:get_user_head_portrait,
  518. user_msg:'',
  519. user_image:target_msg,
  520. image_url:target_msg,
  521. user_video:'',
  522. duration:'',
  523. msg_type:'RC:ImgMsg',
  524. read_state:'READ',
  525. });
  526. setTimeout(function(){
  527. var div = document.getElementById('chat_message_body');
  528. div.scrollTop = div.scrollHeight;
  529. },300);
  530. }
  531. });
  532. }
  533. }
  534. // 表情字典替换
  535. function emotion_replace(str){
  536. var face = {
  537. "[微笑]":"./libs/img/emotion/Expression_1.png",
  538. "[撇嘴]":"./libs/img/emotion/Expression_2.png",
  539. "[色]":"./libs/img/emotion/Expression_3.png",
  540. "[发呆]":"./libs/img/emotion/Expression_4.png",
  541. "[得意]":"./libs/img/emotion/Expression_5.png",
  542. "[流泪]":"./libs/img/emotion/Expression_6.png",
  543. "[害羞]":"./libs/img/emotion/Expression_7.png",
  544. "[闭嘴]":"./libs/img/emotion/Expression_8.png",
  545. "[睡]":"./libs/img/emotion/Expression_9.png",
  546. "[大哭]":"./libs/img/emotion/Expression_10.png",
  547. "[尴尬]":"./libs/img/emotion/Expression_11.png",
  548. "[发怒]":"./libs/img/emotion/Expression_12.png",
  549. "[调皮]":"./libs/img/emotion/Expression_13.png",
  550. "[呲牙]":"./libs/img/emotion/Expression_14.png",
  551. "[惊讶]":"./libs/img/emotion/Expression_15.png",
  552. "[难过]":"./libs/img/emotion/Expression_16.png",
  553. "[酷]":"./libs/img/emotion/Expression_17.png",
  554. "[冷汗]":"./libs/img/emotion/Expression_18.png",
  555. "[抓狂]":"./libs/img/emotion/Expression_19.png",
  556. "[吐]":"./libs/img/emotion/Expression_20.png",
  557. "[偷笑]":"./libs/img/emotion/Expression_21.png",
  558. "[愉快]":"./libs/img/emotion/Expression_22.png",
  559. "[白眼]":"./libs/img/emotion/Expression_23.png",
  560. "[傲慢]":"./libs/img/emotion/Expression_24.png",
  561. "[饥饿]":"./libs/img/emotion/Expression_25.png",
  562. "[困]":"./libs/img/emotion/Expression_26.png",
  563. "[恐惧]":"./libs/img/emotion/Expression_27.png",
  564. "[流汗]":"./libs/img/emotion/Expression_28.png",
  565. "[憨笑]":"./libs/img/emotion/Expression_29.png",
  566. "[悠闲]":"./libs/img/emotion/Expression_30.png",
  567. "[奋斗]":"./libs/img/emotion/Expression_31.png",
  568. "[咒骂]":"./libs/img/emotion/Expression_32.png",
  569. "[疑问]":"./libs/img/emotion/Expression_33.png",
  570. "[嘘]":"./libs/img/emotion/Expression_34.png",
  571. "[晕]":"./libs/img/emotion/Expression_35.png",
  572. "[疯了]":"./libs/img/emotion/Expression_36.png",
  573. "[衰]":"./libs/img/emotion/Expression_37.png",
  574. "[骷髅]":"./libs/img/emotion/Expression_38.png",
  575. "[敲打]":"./libs/img/emotion/Expression_39.png",
  576. "[再见]":"./libs/img/emotion/Expression_40.png",
  577. "[擦汗]":"./libs/img/emotion/Expression_41.png",
  578. "[抠鼻]":"./libs/img/emotion/Expression_42.png",
  579. "[鼓掌]":"./libs/img/emotion/Expression_43.png",
  580. "[糗大了]":"./libs/img/emotion/Expression_44.png",
  581. "[坏笑]":"./libs/img/emotion/Expression_45.png",
  582. "[左哼哼]":"./libs/img/emotion/Expression_46.png",
  583. "[右哼哼]":"./libs/img/emotion/Expression_47.png",
  584. "[哈欠]":"./libs/img/emotion/Expression_48.png",
  585. "[鄙视]":"./libs/img/emotion/Expression_49.png",
  586. "[委屈]":"./libs/img/emotion/Expression_50.png",
  587. "[快哭了]":"./libs/img/emotion/Expression_51.png",
  588. "[阴险]":"./libs/img/emotion/Expression_52.png",
  589. "[亲亲]":"./libs/img/emotion/Expression_53.png",
  590. "[吓]":"./libs/img/emotion/Expression_54.png",
  591. "[可怜]":"./libs/img/emotion/Expression_55.png",
  592. "[菜刀]":"./libs/img/emotion/Expression_56.png",
  593. "[西瓜]":"./libs/img/emotion/Expression_57.png",
  594. "[啤酒]":"./libs/img/emotion/Expression_58.png",
  595. "[篮球]":"./libs/img/emotion/Expression_59.png",
  596. "[乒乓]":"./libs/img/emotion/Expression_60.png",
  597. "[咖啡]":"./libs/img/emotion/Expression_61.png",
  598. "[饭]":"./libs/img/emotion/Expression_62.png",
  599. "[猪头]":"./libs/img/emotion/Expression_63.png",
  600. "[玫瑰]":"./libs/img/emotion/Expression_64.png",
  601. "[凋谢]":"./libs/img/emotion/Expression_65.png",
  602. "[嘴唇]":"./libs/img/emotion/Expression_66.png",
  603. "[爱心]":"./libs/img/emotion/Expression_67.png",
  604. "[心碎]":"./libs/img/emotion/Expression_68.png",
  605. "[蛋糕]":"./libs/img/emotion/Expression_69.png",
  606. "[闪电]":"./libs/img/emotion/Expression_70.png",
  607. "[炸弹]":"./libs/img/emotion/Expression_71.png",
  608. "[刀]":"./libs/img/emotion/Expression_72.png",
  609. "[足球]":"./libs/img/emotion/Expression_73.png",
  610. "[瓢虫]":"./libs/img/emotion/Expression_74.png",
  611. "[便便]":"./libs/img/emotion/Expression_75.png",
  612. "[月亮]":"./libs/img/emotion/Expression_76.png",
  613. "[太阳]":"./libs/img/emotion/Expression_77.png",
  614. "[礼物]":"./libs/img/emotion/Expression_78.png",
  615. "[拥抱]":"./libs/img/emotion/Expression_79.png",
  616. "[强]":"./libs/img/emotion/Expression_80.png",
  617. "[弱]":"./libs/img/emotion/Expression_81.png",
  618. "[握手]":"./libs/img/emotion/Expression_82.png",
  619. "[胜利]":"./libs/img/emotion/Expression_83.png",
  620. "[抱拳]":"./libs/img/emotion/Expression_84.png",
  621. "[勾引]":"./libs/img/emotion/Expression_85.png",
  622. "[拳头]":"./libs/img/emotion/Expression_86.png",
  623. "[差劲]":"./libs/img/emotion/Expression_87.png",
  624. "[爱你]":"./libs/img/emotion/Expression_88.png",
  625. "[NO]":"./libs/img/emotion/Expression_89.png",
  626. "[OK]":"./libs/img/emotion/Expression_90.png",
  627. "[爱情]":"./libs/img/emotion/Expression_91.png",
  628. "[飞吻]":"./libs/img/emotion/Expression_92.png",
  629. "[跳跳]":"./libs/img/emotion/Expression_93.png",
  630. "[发抖]":"./libs/img/emotion/Expression_94.png",
  631. "[怄火]":"./libs/img/emotion/Expression_95.png",
  632. "[转圈]":"./libs/img/emotion/Expression_96.png",
  633. "[磕头]":"./libs/img/emotion/Expression_97.png",
  634. "[回头]":"./libs/img/emotion/Expression_98.png",
  635. "[跳绳]":"./libs/img/emotion/Expression_99.png",
  636. "[投降]":"./libs/img/emotion/Expression_100.png",
  637. "[激动]":"./libs/img/emotion/Expression_101.png",
  638. "[街舞]":"./libs/img/emotion/Expression_102.png",
  639. "[献吻]":"./libs/img/emotion/Expression_103.png",
  640. "[左太极]":"./libs/img/emotion/Expression_104.png",
  641. "[右太极]":"./libs/img/emotion/Expression_105.png",
  642. "[gif动画]":"./libs/img/emotion/Expression_106.png",
  643. };
  644. var reg = /\[.+?\]/g;
  645. if(str){
  646. str = str.replace(reg,function(a,b){
  647. if(face[a]){
  648. return '<img style="width:18px; height:18px;vertical-align:text-bottom" src="'+face[a]+'">';
  649. }else{
  650. return str;
  651. }
  652. });
  653. return str;
  654. }else{
  655. return str;
  656. }
  657. }
  658. };
  659. </script>

特别说明

  1. 注意,该模块必须使用融云配置好相关参数
  2. 该模块需要集成 rongCloudIM 模块 UIChatBox模块 + imageBrowser模块,支持语音+图片+表情文字的聊天窗口,使用时注意添加以上模块