messageitem.vue 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405
  1. <template>
  2. <block v-if="isshow">
  3. <!-- {{}} -->
  4. <view v-if="m.type=='tips' || m.message.type=='tips'" class="chat-tips">
  5. <view v-if="m.message.content.type=='time' && m.message.content.text!=''" class="chat-tips-time">
  6. {{m.message.content.text}}
  7. </view>
  8. <view v-else class="chat-tips-time">{{m.message.content}}</view>
  9. <view v-if="m.message.content.type=='redpack_tip'" class="chat-tips-time">
  10. <text class="redpack-icon"></text>
  11. {{m.message.content.text}}
  12. </view>
  13. </view>
  14. <!-- 消息类型 开始 -->
  15. <view v-else :class="{'chat-item':true,'chat-item-reverse': m.sender.id==userid}" :id="m._mid">
  16. <!-- 头像 -->
  17. <view class="avatar" @tap="clickAvatar(m)" @longtap="atusuer(m)">
  18. <image :src="image_cache(m.sender.avatar)"></image>
  19. </view>
  20. <view class="content" :id="'msg_'+m.msg_id">
  21. <!-- 用户昵称 -->
  22. <view class="nickname" v-if="m.sender.id!=userid && m.group_id>0 || m.id==0">
  23. {{m.sender.nickname}}
  24. </view>
  25. <view class="item">
  26. <view v-if="m.message.type=='text'" class="text" @longtap="msgAction($event,m)">
  27. <block v-if="m.message.content.type=='remind' || m.message.content.type=='emotion'">
  28. <view v-if="m.message.content.remind.id==userid" style="color: #FF0000;">
  29. <block v-if="isindexhtml(m.message.content.content)">
  30. <rich-text :nodes="m.message.content.content"></rich-text>
  31. </block>
  32. <block v-else> {{m.message.content.content}}</block>
  33. </view>
  34. <block v-else>
  35. <block v-if="isindexhtml(m.message.content.content)">
  36. <rich-text :nodes="m.message.content.content"></rich-text>
  37. </block>
  38. <block v-else> {{m.message.content.content}}</block>
  39. </block>
  40. </block>
  41. <block v-else>
  42. <block v-if="isindexhtml(m.message.content)">
  43. <rich-text :nodes="m.message.content"></rich-text>
  44. </block>
  45. <block v-else> {{m.message.content}}</block>
  46. </block>
  47. </view>
  48. <!-- 表情 -->
  49. <view v-if="m.message.type=='emotion' " class="text" @longtap="msgAction($event,m)">
  50. <block v-for="(m1,index1) in faces" :key="index1">
  51. <block v-if="m1.type=='img'">
  52. <image :src="m1.content" class="emotion"></image>
  53. </block>
  54. <block v-else>{{m1.content}}</block>
  55. </block>
  56. </view>
  57. <!-- 超链接 -->
  58. <view v-if="m.message.type=='url'" class="text" @longtap="msgAction($event,m)">
  59. <url :content="m.message.content" :self="m.self" @clickurl="clickurl" />
  60. </view>
  61. <!-- 加群申请 -->
  62. <view v-if="m.message.type=='apply'" class="text" style="font-size: 14px;"
  63. @longtap="msgAction($event,m)">
  64. <view class="showname">{{m.message.content.other.nickname}}</view>
  65. 申请加入<view class="showname">{{m.message.content.other.groupname}}</view>
  66. <view v-if="m.message.content.other.content">
  67. <span style="color: #666;">附言:</span>
  68. {{m.message.content.other.content}}
  69. </view>
  70. </view>
  71. <!-- 视频 -->
  72. <view v-if="m.message.type=='vedio'" class="vedio" @tap="play_vedio(m)"
  73. @longtap="msgAction($event,m)">
  74. <block v-if="m.isloading==1">
  75. </block>
  76. <block v-else>
  77. <image :src="poster_show(m)" class="vedio_src" mode="widthFix"></image>
  78. <image src="/static/img/play.png" class="play_btn"></image>
  79. <view class="timeshow" v-if="m.message.content.time>0">{{showtime(m.message.content.time)}}
  80. </view>
  81. </block>
  82. </view>
  83. <!-- 图片 -->
  84. <view v-if="m.message.type=='image'" class="image" @longtap="msgAction($event,m)">
  85. <image @click="onPreview(m.message.content,m.message.type!='face')" :src="image_show(m)"
  86. :data-src="image_show(m)" mode="aspectFit" @load="onSetImageSize($event,m.message.content)"
  87. class='chatimg'
  88. :style="{width: (isizes[m.message.content] && isizes[m.message.content].width || 0) + 'px', 'height': (isizes[m.message.content] && isizes[m.message.content].height || 200) + 'px'}">
  89. </image>
  90. </view>
  91. <!-- 语音 -->
  92. <view v-if="m.message.type=='voice'" :class="{'voice': true,'voice-play': playVoiceId == m._mid}"
  93. @tap="playVoice(m)" @longtap="msgAction($event,m)">
  94. <view class="box">
  95. <view class="wifi-symbol">
  96. <view class="wifi-circle first"></view>
  97. <view class="wifi-circle second"></view>
  98. <view class="wifi-circle third"></view>
  99. </view>
  100. </view>
  101. <view :class="{'voice-text': true,'voice-text-right': m.self}">
  102. {{m.message.content.time}}''
  103. </view>
  104. </view>
  105. <!-- 红包 -->
  106. <view v-if="m.message.type=='redpacket' " @tap='redpack_open(m)'
  107. :class="{'redpack':true,'redpack-open':m.message.content.isopen==1}"
  108. @longtap="msgAction($event,m)">
  109. <view class="info">
  110. <block v-if="m.sender.id==userid">
  111. <view class="showtext">{{m.message.content.title}}</view>
  112. <view class="icon">
  113. <image
  114. :src="m.message.content.isopen==1?'/static/img/redpackopen-icon.png':'/static/img/redpack-icon.png'">
  115. </image>
  116. </view>
  117. </block>
  118. <block v-else>
  119. <view class="icon">
  120. <image
  121. :src="m.message.content.isopen==1?'/static/img/redpackopen-icon.png':'/static/img/redpack-icon.png'">
  122. </image>
  123. </view>
  124. <view class="showtext">{{m.message.content.title}}</view>
  125. </block>
  126. </view>
  127. <view class="title">红包</view>
  128. </view>
  129. </view>
  130. <!-- 引用 -->
  131. <view class="qute" v-if="m.message.qute" :class="{'qute-reverse': m.sender.id==userid}">
  132. <!-- 文本引用其他 -->
  133. <template v-if="m.message.type == 'text'">
  134. <view class="msg">
  135. {{m.message.qute.nickname}}:
  136. <block v-if="m.message.qute.ttype == 'emotion'"
  137. v-for="(m2,index2) in getFace(m.message.qute.content)" :key="index2">
  138. <block v-if="m2.type=='img'">
  139. <image :src="m2.content" class="emotion1"></image>
  140. </block>
  141. <block v-else>{{m2.content}}</block>
  142. </block>
  143. <block v-else-if="m.message.qute.ttype == 'image'">
  144. <image :src="m.message.qute.content" mode="" style="width: 60rpx;height: 60rpx;"
  145. @click.stop="showImage(m.message.qute.content)"></image>
  146. </block>
  147. <block v-else>
  148. {{m.message.qute.content}}
  149. </block>
  150. </view>
  151. </template>
  152. <!-- 表情引用其他 -->
  153. <template v-if="m.message.type == 'emotion'">
  154. <view class="msg">
  155. {{m.message.qute.nickname}}:
  156. <template v-if="m.message.qute.ttype == 'text' || m.message.qute.ttype == 'remind' ">
  157. {{m.message.qute.content}}
  158. </template>
  159. <block v-if="m.message.qute.ttype=='emotion'"
  160. v-for="(m2,index2) in getFace(m.message.qute.content)" :key="index2">
  161. <block v-if="m2.type=='img'">
  162. <image :src="m2.content" class="emotion1"></image>
  163. </block>
  164. <block v-else>{{m2.content}}</block>
  165. </block>
  166. <template v-if="m.message.qute.ttype=='image'">
  167. <image :src="m.message.qute.content" mode="" style="width: 60rpx;height: 60rpx;"
  168. @click.stop="showImage(m.message.qute.content)"></image>
  169. </template>
  170. </view>
  171. </template>
  172. <!-- <view class="">
  173. {{m.message.qute.content}}
  174. </view> -->
  175. </view>
  176. <!-- 加载中 -->
  177. <view class="loadingbox" v-if="m._mid==loading_id || m.isloading==1 || m.isloading==2">
  178. <image src="/static/loading.gif" v-if="m._mid==loading_id || m.isloading==1"></image>
  179. <image src="/static/fail.png" v-if="m.isloading==2"></image>
  180. </view>
  181. </view>
  182. </view>
  183. </block>
  184. </template>
  185. <script>
  186. import url from './url.vue'
  187. export default {
  188. components: {
  189. url
  190. },
  191. props: {
  192. item: {
  193. required: true
  194. },
  195. loading_id: {
  196. default: 0
  197. },
  198. playVoiceId: {
  199. default: 0
  200. },
  201. userid: {
  202. default: 0
  203. },
  204. unreadid: {
  205. default: 0
  206. },
  207. },
  208. data() {
  209. return {
  210. isizes: {},
  211. faces: [],
  212. m: [],
  213. isshow: false,
  214. }
  215. },
  216. computed: {
  217. },
  218. methods: {
  219. getFace(item) {
  220. var content = item.replace(/\[\S{1,3}\]/gi, this.emotion);
  221. content = content.split('^');
  222. var imgs = [];
  223. for (var i = 0; i < content.length; i++) {
  224. if (content[i] >= 100 && content[i] <= 222) {
  225. imgs.push({
  226. 'type': 'img',
  227. 'content': "/static/emoji/" + content[i] + '.gif'
  228. })
  229. } else {
  230. imgs.push({
  231. 'type': 'text',
  232. 'content': content[i]
  233. })
  234. }
  235. }
  236. return imgs
  237. },
  238. touchend() {
  239. return false;
  240. },
  241. clickAvatar(m) {
  242. this.$emit('clickAvatar', m)
  243. },
  244. msgAction(e, m) {
  245. this.$emit('msgAction', e, m)
  246. },
  247. play_vedio(m) {
  248. this.$emit('play_vedio', m)
  249. },
  250. playVoice(m) {
  251. this.$emit('playVoice', m)
  252. },
  253. atusuer(m) {
  254. this.$emit('atusuer', m)
  255. },
  256. redpack_open(m) {
  257. if (m.message.content.isgroup != 1 && (m.message.content.money > 0 || m.sender.id == this.userid)) {
  258. uni.navigateTo({
  259. url: '../friend/redpacket_detail?msg_id=' + m.msg_id + '&storekey=' + m.cache_key
  260. })
  261. } else
  262. this.$emit('redpack_open', m)
  263. },
  264. updatedata(m) {
  265. console.log(m);
  266. },
  267. toText(str) {
  268. str = str.replace(/&nbsp;/g, " ");
  269. str = str.replace(/<br>/g, " \n");
  270. return str;
  271. },
  272. toHtml(str) {
  273. var text = msg.replace(/<\/?[^>]*>/g, '');
  274. text = text.replace(/\n/g, '<br>');
  275. text = text.replace(/ /g, '&nbsp;');
  276. return text;
  277. },
  278. isindexhtml(str) {
  279. var arr = ['<br', '&nbsp;', "<div", "<span"];
  280. str = str.toString();
  281. for (var i = 0; i < arr.length; i++) {
  282. if (str.indexOf(arr[i]) > -1) return true;
  283. }
  284. return false;
  285. },
  286. poster_show(m) {
  287. if (m.isloading == 1) {
  288. return false;
  289. } else {
  290. // try{
  291. // var src=m.message.content.src;
  292. // var arr=src.split('/');
  293. // var filename=arr[arr.length-1];
  294. // var arr1=filename.split('.');
  295. // var newname=arr1[0]+"_video.jpg";
  296. // var poster= src.replace(filename,newname);
  297. // return poster;
  298. // }catch(e){
  299. // //TODO handle the exception
  300. // return "/static/img/vediobanner.jpg";
  301. // }
  302. if (m.message.content && m.message.content.src) {
  303. var src = m.message.content.src;
  304. var arr = src.split('/');
  305. var filename = arr[arr.length - 1];
  306. var arr1 = filename.split('.');
  307. var newname = arr1[0] + "_video.jpg";
  308. var poster = src.replace(filename, newname);
  309. return poster;
  310. } else {
  311. return "/static/img/vediobanner.jpg";
  312. }
  313. }
  314. },
  315. clickurl(url) {
  316. if (url.indexOf('http') <= -1) url = 'http://' + url;
  317. let params = {
  318. url: url
  319. };
  320. return this.$jump('web.index', params)
  321. },
  322. httpString(str) {
  323. if (str.toString().indexOf('http') <= -1) {
  324. // str='https://'+str;
  325. // str=str.toString()
  326. }
  327. // var reg = /(?=^.{3,255}$)(http(s)?:\/\/)?(www\.)?[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  328. var reg =
  329. /(?=^.{3,255}$)(http(s)?:\/\/)?(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9\/][-a-zA-Z0-9\/]{0,62})+(:\d+)*(\/\w+\.\w+)*$/g
  330. try {
  331. var s = str.match(reg);
  332. if (s != null) {
  333. return s;
  334. } else {
  335. return false;
  336. }
  337. } catch (e) {
  338. return false;
  339. }
  340. },
  341. showtime(time) {
  342. var lost_s = parseInt(time);
  343. if (lost_s >= 0) {
  344. var l_s = Math.floor(lost_s % 60);
  345. var next_s = Math.floor(lost_s / 60);
  346. var l_m = Math.floor(next_s % 60);
  347. var next_m = Math.floor(next_s / 60);
  348. var l_h = Math.floor(next_m % 60);
  349. if (l_h - 10 < 0) {
  350. var n_h = "0" + (l_h);
  351. } else {
  352. var n_h = (l_h);
  353. }
  354. if (l_m - 10 < 0) {
  355. var n_m = "0" + (l_m);
  356. } else {
  357. var n_m = (l_m);
  358. }
  359. if (l_s - 10 < 0) {
  360. var n_s = "0" + (l_s);
  361. } else {
  362. var n_s = (l_s);
  363. }
  364. if (n_h != '00') var hh = n_h + ":";
  365. else var hh = '';
  366. var str = hh + n_m + ':' + n_s + '';
  367. return str;
  368. } else {
  369. return "00:00";
  370. }
  371. },
  372. image_show(m) {
  373. var src = m.message.content;
  374. if (src.indexOf('"') > -1) src = src.replace(/"/g, '');
  375. if (m.isloading == 1) {
  376. return src;
  377. } else
  378. return this.image_cache(src)
  379. },
  380. onSetImageSize(e, index) {
  381. let {
  382. width,
  383. height
  384. } = e.detail;
  385. let size = 150;
  386. if (height > size) {
  387. let p = size / height;
  388. height = size;
  389. width = width * p;
  390. }
  391. this.$set(this.isizes, index, {
  392. width,
  393. height
  394. });
  395. },
  396. onPreview(url, show) {
  397. if (show) {
  398. uni.previewImage({
  399. current: this.image_cache(url),
  400. urls: [this.image_cache(url)]
  401. });
  402. }
  403. },
  404. showImage(url) {
  405. console.log('img');
  406. uni.previewImage({
  407. current: url,
  408. urls: [url]
  409. });
  410. },
  411. emotion(res) {
  412. let word = res.replace(/\[|\]/gi, '')
  413. const list = ['微笑', '撇嘴', '色', '发呆', '得意', '流泪', '害羞', '闭嘴', '睡', '大哭', '尴尬', '发怒', '调皮', '呲牙', '惊讶',
  414. '难过', '酷', '冷汗', '抓狂', '吐', '偷笑', '可爱', '白眼', '傲慢', '饥饿', '困', '惊恐', '流汗', '憨笑', '大兵', '奋斗',
  415. '咒骂', '疑问', '嘘', '晕', '折磨', '衰', '骷髅', '敲打', '再见', '擦汗', '抠鼻', '鼓掌', '糗大了', '坏笑', '左哼哼', '右哼哼',
  416. '哈欠', '鄙视', '委屈', '快哭了', '阴险', '亲亲', '吓', '可怜', '菜刀', '西瓜', '啤酒', '篮球', '乒乓', '咖啡', '饭', '猪头',
  417. '玫瑰', '凋谢', '示爱', '爱心', '心碎', '蛋糕', '闪电', '炸弹', '刀', '足球', '瓢虫', '便便', '月亮', '太阳', '礼物', '拥抱',
  418. '强', '弱', '握手', '胜利', '抱拳', '勾引', '拳头', '差劲', '爱你', 'NO', 'OK', '爱情', '飞吻', '跳跳', '发抖', '怄火',
  419. '转圈', '磕头', '回头', '跳绳', '挥手', '激动',
  420. '闭嘴', '笑哭', '吐舌', '耶', '跳舞', '恐惧', '失望', '脸红', '无语', '奸笑', '嘿哈', '鬼混', '福', '合十', '强壮', '红包',
  421. '发财', '庆祝', '礼物'
  422. ]
  423. let index = list.indexOf(word);
  424. var index1 = index + 100;
  425. return '^' + index1 + '^';
  426. },
  427. getGroupmemebrs(group_id, userid) {
  428. var members = uni.getStorageSync(group_id + '_group_members');
  429. if (!members) members = [];
  430. let result = [];
  431. members.forEach(item => {
  432. if (item.id == userid) result = item;
  433. })
  434. return result;
  435. },
  436. message_format(v) {
  437. // console.log(v,'内容')
  438. if (v.message.type == 'text' && v.message.content.type != 'emotion') {
  439. try {
  440. v.message.content = JSON.parse(v.message.content);
  441. } catch (e) {
  442. try{
  443. var content;
  444. let strarr = v.message.content.split(';;')
  445. if(!strarr[1]) {
  446. }else {
  447. let starr = strarr[1].split('"')
  448. console.log(starr,'starr')
  449. v.message.content = '<span style="color:#2319dc;">' + starr[starr.length -2].replace(/^>/,'')
  450. }
  451. content = v.message.content;
  452. }catch (e) {
  453. var content = v.message.content;
  454. }
  455. }
  456. var type = v.message.content.type;
  457. if (type == 'remind') {
  458. // console.log('remind',v)
  459. console.log(v.message.content.content,'remind-msg')
  460. // console.log('');
  461. if (v.message.content.remind.id == uni.getStorageSync('access_token')) {
  462. // 区分
  463. let arr = v.message.content.content.split('-qute-')
  464. v.message.content.content = arr[0]
  465. v.message.content.qute = ''
  466. if (arr[1]) {
  467. v.message.qute = this.parseQuery(arr[1])
  468. }
  469. v.message.content.content = v.message.content.content.replace('@{' + v.message.content
  470. .remind.id + '}', '<span style="color:#ff0000;">有人@我</span>');
  471. } else {
  472. var str = v.message.content.content;
  473. // var reg =/@{(.*)}/g;
  474. // var tt=reg.exec(str);
  475. // console.log('其他人');
  476. var mem = this.getGroupmemebrs(v.group_id, v.message.content.remind.id);
  477. if (mem.id == v.message.content.remind.id) {
  478. var atname = mem.nickname;
  479. } else
  480. var atname = v.message.content.remind.nickname;
  481. if (v.self == 1) var color = "#ff0000"
  482. else var color = "#2319dc";
  483. let arr = v.message.content.content.split('-qute-')
  484. // console.log(arr,'arr')
  485. v.message.content.content = arr[0]
  486. // console.log(arr[1],'arr[1]');
  487. v.message.qute = arr[1] ? this.parseQuery(arr[1]) : ''
  488. // console.log('call他人的qute',v.message.qute);
  489. v.message.content.content = v.message.content.content.replace('@{' + v.message.content
  490. .remind.id + '}', '<span style="color:' + color + ';">@' + atname + "</span>");
  491. // console.log(atname,v.message)
  492. if (color == '#ff0000') {
  493. // console.log(v.message.content.content,'v.message.content.content',v)
  494. }
  495. }
  496. var content = v.message.content.content;
  497. } else {
  498. // 文本
  499. // console.log('处理文本');
  500. try {
  501. let arr = v.message.content.split('-qute-')
  502. v.message.content = arr[0]
  503. var content = v.message.content;
  504. console.log('正确',v)
  505. v.message.qute = ''
  506. if (arr[1]) {
  507. v.message.qute = this.parseQuery(arr[1])
  508. }
  509. } catch (e) {
  510. //TODO handle the exception
  511. console.log('错误', e);
  512. // v.message.content = v.message.content
  513. var content = v.message.content;
  514. console.log(content,'content',v)
  515. }
  516. // console.log(v.message.);
  517. // try{
  518. // v.message.content.qute = arr[1] ? this.parseQuery(arr[1]) : ''
  519. // }catch(e){
  520. // var content = v.message.content;
  521. // //TODO handle the exception
  522. // console.log('完成处理',e);
  523. // }
  524. }
  525. if (this.isindexhtml(content)) {
  526. var content1 = this.toText(content);
  527. } else {
  528. var content1 = content;
  529. // console.log('content2:',content)
  530. }
  531. var res = this.httpString(content);
  532. if (res != false) {
  533. v.message.type = 'url';
  534. v.message.content = {};
  535. v.message.content.content = content;
  536. v.message.content.urls = res;
  537. }
  538. }
  539. if (v.message.type == 'redpacket') {
  540. try {
  541. v.message.content = JSON.parse(v.message.content)
  542. } catch (e) {
  543. //TODO handle the exception
  544. }
  545. }
  546. this.isshow = true;
  547. return v;
  548. },
  549. parseQuery(query) {
  550. let baseArr = query.split('q&q')
  551. let result = {}
  552. baseArr.forEach(item => {
  553. let arr = item.split('=')
  554. let key = arr[0]
  555. let val = arr[1]
  556. result[key] = val
  557. })
  558. return result
  559. },
  560. init() {
  561. try {
  562. // 处理表情
  563. if (this.item.message.type == 'emotion') {
  564. try {
  565. this.item.message.content = JSON.parse(this.item.message.content);
  566. } catch (e) {
  567. //TODO handle the exception
  568. }
  569. let arr = this.item.message.content.content.split('-qute-')
  570. this.item.message.content.content = arr[0]
  571. this.item.message.qute = arr[1] ? this.parseQuery(arr[1]) : ''
  572. var content = this.item.message.content.content.replace(/\[\S{1,3}\]/gi, this.emotion);
  573. content = content.split('^');
  574. var imgs = [];
  575. for (var i = 0; i < content.length; i++) {
  576. if (content[i] >= 100 && content[i] <= 222) {
  577. imgs.push({
  578. 'type': 'img',
  579. 'content': "/static/emoji/" + content[i] + '.gif'
  580. })
  581. } else {
  582. imgs.push({
  583. 'type': 'text',
  584. 'content': content[i]
  585. })
  586. }
  587. }
  588. this.faces = imgs;
  589. // if(this.item.message.content.content.indexOf('[')>-1) console.log(imgs)
  590. }
  591. } catch (e) {
  592. //TODO handle the exception
  593. console.log(e,'错误')
  594. }
  595. try {
  596. // 处理文本
  597. this.m = this.message_format(this.item);
  598. } catch (e) {
  599. //TODO handle the exception
  600. this.m = this.item;
  601. }
  602. }
  603. },
  604. watch: {
  605. item(val) {
  606. // console.log('消息改变详情',val)
  607. this.init();
  608. }
  609. },
  610. mounted() {
  611. this.init();
  612. ///
  613. }
  614. }
  615. </script>
  616. <style lang="scss" scoped>
  617. $redpackBgColor: #fa9e3b;
  618. $reverseTextBgColor: #3388ff;
  619. $voiceBgColor: #fafafa;
  620. $voiceColor: #000;
  621. $reverseVoiceBgColor: #3388ff;
  622. $reverseVoiceColor: #fff;
  623. .emotion {
  624. height: 30px;
  625. width: 30px;
  626. ;
  627. vertical-align: middle;
  628. }
  629. .chatimg {
  630. max-width: 70vw;
  631. vertical-align: top;
  632. border-radius: 5px;
  633. }
  634. .chatimg img {
  635. vertical-align: top;
  636. }
  637. .showname {
  638. display: inline-block;
  639. color: #2319DC;
  640. }
  641. .chat-tips {
  642. text-align: center;
  643. &-time {
  644. display: inline-block;
  645. padding: 0upx 20upx;
  646. font-size: 24upx;
  647. line-height: 40upx;
  648. color: #bbb;
  649. border-radius: 30upx;
  650. }
  651. }
  652. .chat-panel {
  653. width: 96%;
  654. padding: 0 2%;
  655. position: absolute;
  656. top: 0;
  657. left: 0;
  658. }
  659. .vedio {
  660. display: inline-block;
  661. float: left;
  662. width: calc(100% - 200upx);
  663. border-radius: 10upx;
  664. padding-top: 0upx;
  665. padding-bottom: 0upx;
  666. overflow: hidden;
  667. position: relative;
  668. z-index: 0;
  669. }
  670. .vedio .timeshow {
  671. position: absolute;
  672. right: 12upx;
  673. bottom: 16upx;
  674. font-size: 24upx;
  675. color: #FFFFFF;
  676. z-index: 999999999;
  677. }
  678. .vedio .play_btn {
  679. position: absolute;
  680. height: 80upx;
  681. width: 80upx;
  682. left: calc(50% - 40upx);
  683. top: calc(50% - 40upx);
  684. z-index: 999999999;
  685. }
  686. .vedio_src {
  687. max-width: 100%;
  688. border-radius: 10upx;
  689. max-height: 70vw;
  690. z-index: 0 !important;
  691. }
  692. .chat-item .item {
  693. display: inline;
  694. }
  695. .touch_menu {
  696. position: fixed;
  697. z-index: 9999;
  698. background-color: rgba(0, 0, 0, 0.8);
  699. border: 1px #000 solid;
  700. border-radius: 10px;
  701. padding: 0px 10px;
  702. line-height: 30px;
  703. max-width: 100%;
  704. font-size: 14px;
  705. min-height: 40px;
  706. }
  707. .chat-item {
  708. display: flex;
  709. font-size: 32upx;
  710. padding-bottom: 20upx;
  711. padding: 10upx 12upx;
  712. position: relative;
  713. /*反向*/
  714. &-reverse {
  715. flex-direction: row-reverse;
  716. .loadingbox,
  717. .vedio {
  718. float: right;
  719. }
  720. .content {
  721. display: flex;
  722. flex-direction: column;
  723. }
  724. .text,
  725. .redpack,
  726. .voice,
  727. .image {
  728. float: right;
  729. &:before {
  730. opacity: 0;
  731. }
  732. &:after {
  733. display: block;
  734. content: "";
  735. position: absolute;
  736. right: -12upx;
  737. top: 22upx;
  738. width: 0;
  739. height: 0;
  740. border-style: solid;
  741. border-width: 12upx 0upx 12upx 12upx;
  742. }
  743. }
  744. .image:after {
  745. opacity: 0
  746. }
  747. .text {
  748. color: #fff !important;
  749. background-color: $reverseTextBgColor !important;
  750. &:after {
  751. border-color: transparent transparent transparent $reverseTextBgColor;
  752. }
  753. }
  754. .redpack {
  755. text-align: right !important;
  756. &:after {
  757. border-color: transparent transparent transparent $redpackBgColor;
  758. }
  759. &-open {
  760. &:after {
  761. border-color: transparent transparent transparent #FDE1C3;
  762. }
  763. }
  764. }
  765. .voice {
  766. background-color: $reverseVoiceBgColor !important;
  767. color: $reverseVoiceColor !important;
  768. &:after {
  769. border-color: transparent transparent transparent $reverseVoiceBgColor;
  770. }
  771. .box {
  772. transform: rotate(180deg) translate(15px, 50%);
  773. transform-origin: center;
  774. right: 0;
  775. .first {
  776. background: $reverseVoiceColor;
  777. }
  778. .wifi-circle {
  779. border-color: $reverseVoiceColor;
  780. }
  781. }
  782. }
  783. .voice:hover,
  784. .text:hover {
  785. background-color: #2319DC !important;
  786. &:after {
  787. border-color: transparent transparent transparent #2319DC !important;
  788. }
  789. }
  790. }
  791. .avatar {
  792. width: 90upx;
  793. height: 90upx;
  794. border-radius: 12upx;
  795. background: rgba(0, 0, 0, 0.05);
  796. overflow: hidden;
  797. image {
  798. width: 90upx;
  799. height: 90upx;
  800. }
  801. }
  802. .content {
  803. margin: 0 20upx;
  804. width: 70%;
  805. position: relative;
  806. .nickname {
  807. max-width: 100%;
  808. height: 24upx;
  809. padding-bottom: 10upx;
  810. font-size: 24upx;
  811. line-height: 24upx;
  812. color: #222;
  813. text-align: left;
  814. }
  815. }
  816. .text,
  817. .redpack,
  818. .voice,
  819. .image {
  820. display: inline-block;
  821. width: auto;
  822. border-radius: 12upx;
  823. max-width: 100%;
  824. position: relative;
  825. &:before {
  826. display: block;
  827. content: "";
  828. position: absolute;
  829. left: -12upx;
  830. top: 26upx;
  831. width: 0;
  832. height: 0;
  833. border-style: solid;
  834. border-width: 12upx 12upx 12upx 0;
  835. }
  836. }
  837. .redpack {
  838. width: 200px;
  839. height: 86px;
  840. text-align: left;
  841. padding: 0px 10px;
  842. }
  843. .redpack image {
  844. height: 40px;
  845. width: 30px;
  846. }
  847. .redpack .info {
  848. display: table;
  849. table-layout: fixed;
  850. width: 100%;
  851. height: 60px;
  852. line-height: 60px;
  853. }
  854. .redpack .info view {
  855. display: table-cell;
  856. vertical-align: middle;
  857. padding: 0px 0px;
  858. margin: 0px 0px;
  859. }
  860. .redpack .info view.icon {
  861. width: 55px;
  862. text-align: center;
  863. }
  864. .redpack .info view.showtext {
  865. color: #fff;
  866. font-size: 16px;
  867. ;
  868. overflow: hidden;
  869. text-overflow: ellipsis;
  870. white-space: nowrap;
  871. }
  872. .redpack .info view.icon image {
  873. vertical-align: middle;
  874. }
  875. .redpack .title {
  876. height: 25px;
  877. line-height: 25px;
  878. color: #eee;
  879. font-size: 12px;
  880. border-top: #fdac53 solid 1px;
  881. }
  882. .redpack.redpack-open .title {
  883. color: #fef5ec;
  884. border-top: #ffe6ca solid 1px;
  885. }
  886. .image:before {
  887. opacity: 0
  888. }
  889. .text {
  890. line-height: 50upx;
  891. padding: 12upx 20upx;
  892. background: #e5e5e5;
  893. color: #000;
  894. word-break: break-all;
  895. &:before {
  896. border-color: transparent #e5e5e5 transparent transparent;
  897. }
  898. }
  899. .text:hover,
  900. .voice:hover {
  901. background-color: #bbb;
  902. &:after {
  903. border-color: transparent #bbb transparent transparent;
  904. }
  905. }
  906. .redpack {
  907. background: $redpackBgColor;
  908. color: #fff;
  909. &:before {
  910. border-color: transparent $redpackBgColor transparent transparent;
  911. }
  912. &-open {
  913. background: #fce1c3;
  914. .redpack-body-image {
  915. background: #FB998A;
  916. }
  917. .redpack-body-image::before {
  918. background: #FFF3E7;
  919. top: -110upx;
  920. }
  921. &:before {
  922. border-color: transparent #FDE1C3 transparent transparent;
  923. }
  924. }
  925. &-body {
  926. padding: 20upx;
  927. display: flex;
  928. align-items: center;
  929. &-image {
  930. background: #CD3D35;
  931. width: 70upx;
  932. height: 90upx;
  933. overflow: hidden;
  934. position: relative;
  935. border-radius: 6upx;
  936. &:before {
  937. content: "";
  938. display: block;
  939. width: 140upx;
  940. height: 140upx;
  941. border-radius: 50%;
  942. position: absolute;
  943. top: -90upx;
  944. left: 50%;
  945. transform: translateX(-50%);
  946. background: #FA5151;
  947. }
  948. &:after {
  949. position: relative;
  950. display: block;
  951. content: '¥';
  952. width: 28upx;
  953. height: 28upx;
  954. background-color: #f2d252;
  955. color: #E08B34;
  956. border-radius: 28upx;
  957. line-height: 32upx;
  958. font-size: 24upx;
  959. transform: scale(.8);
  960. margin: 36upx auto;
  961. text-align: center;
  962. }
  963. }
  964. &-content {
  965. padding-left: 20upx;
  966. }
  967. }
  968. &-footer {
  969. font-size: 24upx;
  970. padding: 10upx 20upx;
  971. background: #fff;
  972. color: #999;
  973. border-bottom-left-radius: 12upx;
  974. border-bottom-right-radius: 12upx;
  975. }
  976. }
  977. .voice {
  978. display: inline-block;
  979. width: auto;
  980. position: relative;
  981. background: $voiceBgColor;
  982. color: $voiceColor;
  983. &:before {
  984. border-color: transparent $voiceBgColor transparent transparent;
  985. }
  986. &-text {
  987. margin-left: 60upx;
  988. line-height: 90upx;
  989. margin-right: 60upx;
  990. }
  991. &-text-right {
  992. text-align: right;
  993. }
  994. &-play {
  995. .second {
  996. animation: fadeInOut 1s infinite 0.2s;
  997. }
  998. .third {
  999. animation: fadeInOut 1s infinite 0.4s;
  1000. }
  1001. }
  1002. .first {
  1003. background: $voiceColor;
  1004. }
  1005. .wifi-circle {
  1006. border-color: $voiceColor;
  1007. }
  1008. }
  1009. }
  1010. /*语音*/
  1011. .box {
  1012. position: absolute;
  1013. top: 50%;
  1014. transform: translate(30upx, -50%);
  1015. }
  1016. .wifi-symbol {
  1017. width: 25px;
  1018. height: 25px;
  1019. // box-sizing: border-box;
  1020. position: relative;
  1021. overflow: hidden;
  1022. transform: rotate(135deg);
  1023. }
  1024. .wifi-circle {
  1025. border: 2px solid #fff;
  1026. border-radius: 50%;
  1027. position: absolute;
  1028. }
  1029. .first {
  1030. width: 2px;
  1031. height: 2px;
  1032. background: #fff;
  1033. top: 22px;
  1034. left: 22px;
  1035. }
  1036. .second {
  1037. width: 12px;
  1038. height: 12px;
  1039. top: 17px;
  1040. left: 17px;
  1041. }
  1042. .third {
  1043. width: 20px;
  1044. height: 20px;
  1045. top: 12px;
  1046. left: 12px;
  1047. }
  1048. @keyframes fadeInOut {
  1049. 0% {
  1050. opacity: 0;
  1051. }
  1052. 100% {
  1053. opacity: 1;
  1054. }
  1055. }
  1056. /**/
  1057. .loading {
  1058. //loading动画
  1059. display: flex;
  1060. justify-content: center;
  1061. @keyframes stretchdelay {
  1062. 0%,
  1063. 40%,
  1064. 100% {
  1065. transform: scaleY(0.6);
  1066. }
  1067. 20% {
  1068. transform: scaleY(1.0);
  1069. }
  1070. }
  1071. .spinner {
  1072. margin: 20upx 0;
  1073. width: 60upx;
  1074. height: 25px;
  1075. display: flex;
  1076. align-items: center;
  1077. justify-content: space-between;
  1078. view {
  1079. background-color: #ff9800;
  1080. height: 25px;
  1081. width: 3px;
  1082. border-radius: 3px;
  1083. animation: stretchdelay 1.2s infinite ease-in-out;
  1084. }
  1085. .rect2 {
  1086. animation-delay: -1.1s;
  1087. }
  1088. .rect3 {
  1089. animation-delay: -1.0s;
  1090. }
  1091. .rect4 {
  1092. animation-delay: -0.9s;
  1093. }
  1094. .rect5 {
  1095. animation-delay: -0.8s;
  1096. }
  1097. }
  1098. }
  1099. image {
  1100. will-change: transform;
  1101. }
  1102. .cssload-container {
  1103. width: 100%;
  1104. height: 17px;
  1105. text-align: center;
  1106. }
  1107. .cssload-zenith {
  1108. width: 17px;
  1109. height: 17px;
  1110. margin: 0 auto;
  1111. border-radius: 50%;
  1112. border-top-color: transparent;
  1113. border-left-color: transparent;
  1114. border-right-color: transparent;
  1115. box-shadow: 1px 1px 0px rgb(255, 255, 255);
  1116. animation: cssload-spin 690ms infinite linear;
  1117. }
  1118. @keyframes cssload-spin {
  1119. 100% {
  1120. transform: rotate(360deg);
  1121. transform: rotate(360deg);
  1122. }
  1123. }
  1124. /*红包小图标*/
  1125. @font-face {
  1126. font-family: "redpackfont";
  1127. src: url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAMcAAsAAAAABugAAALQAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCCcAqBcIFeATYCJAMICwYABCAFhG0HMxsHBsgekiRQQKEUijquIAIkxMPT2v/OnZ1ns188qUZtAmSTkEikJCKpEeqHRDTvtP2zrv7NrtNrZEk0khlnKp3laf0BnYSTeFbdobqDbWl6PM0n7p3+3wAKZL7zLse1N03qAowDKdA9MIoSaIOE3jB2aQnpNIFiWjbDidbuYfCS+ZMCcdVslMGrEZBlNd0V2gMrM8Qd7rppT3oD3M6+H38UhhdIWhX4VaevtGhQ/z01yKrWmjXTCUF4nA3qOipsApk4P5g4yVWoDFcl4WYePKs8+J7aNIlJPFUv1L/OL+0Dk1BAJ2EkoipvApn+nAIub7oZVV8Fsvvcfx/XkiXV7fwRrfc9Xj8bhgx5N8NvRp3cG3I8vXz0pNfOhI4AevDkzAlJgnItv/NQCR5e3ncqPFHa93z9JEKTSLl0Wf+9d7H/8b9vP/xyu1l5D8uN++wTNuD/dvTrq4HRX5++i6PliVOv3/vVN+4mmI509oYOH87wpAxnjKF36eWbsXxfn8if3nCxfjnxz78PxF438/vx8d+vz3HqAZovldk1RXJ/Y/bnnX1z/tX/vSQ3gA//VuXM13zJsMwFulRwBlIpXNiWHbFvTNkSDmaSU1ypWFMUNIA9Iz5v1YzTOxO6xmnv6piqUOlaJDN9Ey21LbR17aPY0La+NopzFdkbWLcNEIbcRTLgLSpD3pKZ/gktE76jbShcUVyM4B1ry2FGTZzIgmhYWcFmlTloaBYoLx8kxgWbzOvijDlKuG4O44Lc/Ha6jTgIP2KOvmgsFIJiypkdt4LziM3GsJMzC1FFrkkIZ2VeHh26Uq7K7IAcxxEygdBgihWYmYpxoEl3AXU+P4gwWmAj4xMtbf5RBKczD44VyJW/gGxTOBa1fMolukVGhQSBwiiOscNagY2wBQkGcw4PsyBUQi7ThphTpTzUiS5V5F6vsotuDxS+NkVgd4UezfNzBNEFAA==') format('woff2');
  1128. }
  1129. .redpack-icon {
  1130. font-family: "redpackfont" !important;
  1131. }
  1132. .redpack-icon:before {
  1133. content: "\e626";
  1134. color: red;
  1135. display: inline-block;
  1136. transform: scale(1.5);
  1137. margin-right: 10upx;
  1138. }
  1139. .loadingbox {
  1140. height: 80upx;
  1141. width: 70upx;
  1142. justify-content: center;
  1143. line-height: 80upx;
  1144. display: inline-block;
  1145. text-align: center;
  1146. vertical-align: top;
  1147. }
  1148. .loadingbox image {
  1149. height: 36upx;
  1150. width: 36upx;
  1151. vertical-align: middle;
  1152. }
  1153. .qute {
  1154. // text-overflow:ellipsis;
  1155. // white-space:nowrap;
  1156. // overflow:hidden;
  1157. margin-top: 10rpx;
  1158. display: flex;
  1159. font-size: 22rpx;
  1160. &-reverse {
  1161. // flex-direction:;
  1162. justify-content: flex-end;
  1163. }
  1164. .msg {
  1165. padding: 5rpx;
  1166. display: inline-block;
  1167. border-radius: 5rpx;
  1168. background-color: #e0e0e0;
  1169. }
  1170. }
  1171. .emotion1 {
  1172. width: 32rpx;
  1173. height: 32rpx;
  1174. }
  1175. </style>