Commit 66d1fc77 authored by 王's avatar

表情读出

parent 6fc8d04c
......@@ -13,7 +13,10 @@
<el-form label-position="top" class="demo-table-expand">
<el-form-item label="回复内容">
<div v-for="(item, index) in JSON.parse(props.row.desc)">
<span v-if="item.content && item.type==='text'">回复{{index+1}}{{ item.content }}</span>
<span v-if="item.content && item.type==='text'">
回复{{index+1}}
<span v-html="item.content.replace(/\#[\u4E00-\u9FA5]{1,3}\;/gi, emotion)"></span>
</span>
<span v-if="item.content && item.type==='image'">回复{{index+1}}<img class="img" :src="item.content"/></span>
<span v-if="item.variable">回复{{index+1}}:老师二维码</span>
</div>
......@@ -80,6 +83,13 @@
this.getList()
},
methods: {
// 将匹配结果替换表情图片
emotion (res) {
let word = res.replace(/\#|\;/gi,'')
const list = ['微笑', '撇嘴', '色', '发呆', '得意', '流泪', '害羞', '闭嘴', '睡', '大哭', '尴尬', '发怒', '调皮', '呲牙', '惊讶', '难过', '酷', '冷汗', '抓狂', '吐', '偷笑', '可爱', '白眼', '傲慢', '饥饿', '困', '惊恐', '流汗', '憨笑', '大兵', '奋斗', '咒骂', '疑问', '嘘', '晕', '折磨', '衰', '骷髅', '敲打', '再见', '擦汗', '抠鼻', '鼓掌', '糗大了', '坏笑', '左哼哼', '右哼哼', '哈欠', '鄙视', '委屈', '快哭了', '阴险', '亲亲', '吓', '可怜', '菜刀', '西瓜', '啤酒', '篮球', '乒乓', '咖啡', '饭', '猪头', '玫瑰', '凋谢', '示爱', '爱心', '心碎', '蛋糕', '闪电', '炸弹', '刀', '足球', '瓢虫', '便便', '月亮', '太阳', '礼物', '拥抱', '强', '弱', '握手', '胜利', '抱拳', '勾引', '拳头', '差劲', '爱你', 'NO', 'OK', '爱情', '飞吻', '跳跳', '发抖', '怄火', '转圈', '磕头', '回头', '跳绳', '挥手', '激动', '街舞', '献吻', '左太极', '右太极']
let index = list.indexOf(word)
return `<img src="https://res.wx.qq.com/mpres/htmledition/images/icon/emotion/${index}.gif" align="middle">`
},
changeShow(data){
this.dialogObj.show=data
},
......
......@@ -24,9 +24,10 @@
<el-table-column
label="内容">
<template slot-scope="scope">
<div v-if="scope.row.type === 'text'">
{{scope.row.content}}
</div>
<!--<div v-if="scope.row.type === 'text'">-->
<!--{{scope.row.content}}-->
<!--</div>-->
<div v-if="scope.row.type === 'text'" v-html="scope.row.content.replace(/\#[\u4E00-\u9FA5]{1,3}\;/gi, emotion)"></div>
<a v-else-if="scope.row.type === 'image' && scope.row.content" :href="scope.row.content" target="_blank">
<img class="shotcut" :src="scope.row.content">
</a>
......@@ -160,6 +161,13 @@
}
},
methods:{
emotion (res) {
console.log('emotion', res)
let word = res.replace(/\#|\;/gi,'')
const list = ['微笑', '撇嘴', '色', '发呆', '得意', '流泪', '害羞', '闭嘴', '睡', '大哭', '尴尬', '发怒', '调皮', '呲牙', '惊讶', '难过', '酷', '冷汗', '抓狂', '吐', '偷笑', '可爱', '白眼', '傲慢', '饥饿', '困', '惊恐', '流汗', '憨笑', '大兵', '奋斗', '咒骂', '疑问', '嘘', '晕', '折磨', '衰', '骷髅', '敲打', '再见', '擦汗', '抠鼻', '鼓掌', '糗大了', '坏笑', '左哼哼', '右哼哼', '哈欠', '鄙视', '委屈', '快哭了', '阴险', '亲亲', '吓', '可怜', '菜刀', '西瓜', '啤酒', '篮球', '乒乓', '咖啡', '饭', '猪头', '玫瑰', '凋谢', '示爱', '爱心', '心碎', '蛋糕', '闪电', '炸弹', '刀', '足球', '瓢虫', '便便', '月亮', '太阳', '礼物', '拥抱', '强', '弱', '握手', '胜利', '抱拳', '勾引', '拳头', '差劲', '爱你', 'NO', 'OK', '爱情', '飞吻', '跳跳', '发抖', '怄火', '转圈', '磕头', '回头', '跳绳', '挥手', '激动', '街舞', '献吻', '左太极', '右太极']
let index = list.indexOf(word)
return `<img src="https://res.wx.qq.com/mpres/htmledition/images/icon/emotion/${index}.gif" align="middle">`
},
handleClick(tab) {
console.log(tab.name);
this.form = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment