Browse Source

修复小程序表情不显示的bug

master
xsx 1 year ago
parent
commit
0da45debf2
  1. 13
      im-uniapp/common/emotion.js
  2. 6
      im-uniapp/manifest.json
  3. 7
      im-uniapp/pages/chat/chat-box.vue
  4. BIN
      im-uniapp/static/logo/logo.png

13
im-uniapp/common/emotion.js

@ -20,16 +20,23 @@ let transform = (content, extClass) => {
if (idx == -1) {
return emoText;
}
let path = textToPath(emoText);
let path = textToPath(emoText, true);
let img = `<img src="${path}" class="${extClass}"/>`;
return img;
});
}
let textToPath = (emoText) => {
let textToPath = (emoText, isRichText) => {
let word = emoText.replace(/\#|\;/gi, '');
let idx = emoTextList.indexOf(word);
return `/static/emoji/${idx}.gif`;
let path = `/static/emoji/${idx}.gif`;
// #ifdef MP-WEIXIN
// 小程序的表情要去掉最前面"/"(但有的时候又不能去掉,十分奇怪)
if (isRichText) {
path = path.slice(1);
}
// #endif
return path;
}
export default {

6
im-uniapp/manifest.json

@ -106,9 +106,11 @@
"appid" : "wxda94f40bfad0262c",
"libVersion" : "latest",
"setting" : {
"urlCheck" : false
"urlCheck" : false,
"minified" : true
},
"usingComponents" : true
"usingComponents" : true,
"lazyCodeLoading" : "requiredComponents"
},
"mp-alipay" : {
"usingComponents" : true

7
im-uniapp/pages/chat/chat-box.vue

@ -32,7 +32,8 @@
<chat-record v-if="showRecord" class="chat-record" @send="onSendRecord"></chat-record>
<view v-else class="send-text">
<editor id="editor" class="send-text-area" :placeholder="isReceipt ? '[回执消息]' : ''"
:read-only="isReadOnly" @focus="onEditorFocus" @blur="onEditorBlur" @ready="onEditorReady" @input="onTextInput">
:read-only="isReadOnly" @focus="onEditorFocus" @blur="onEditorBlur" @ready="onEditorReady"
@input="onTextInput">
</editor>
</view>
<view v-if="chat && chat.type == 'GROUP'" class="iconfont icon-at" @click="openAtBox()"></view>
@ -93,7 +94,7 @@
<scroll-view v-if="chatTabBox === 'emo'" class="chat-emotion" scroll-y="true"
:style="{height: keyboardHeight+'px'}">
<view class="emotion-item-list">
<image class="emotion-item emoji-large" :title="emoText" :src="$emo.textToPath(emoText)"
<image class="emotion-item emoji-large" :title="emoText" :src="$emo.textToPath(emoText,false)"
v-for="(emoText, i) in $emo.emoTextList" :key="i" @click="selectEmoji(emoText)" mode="aspectFit"
lazy-load="true"></image>
</view>
@ -369,7 +370,7 @@ export default {
}
},
selectEmoji(emoText) {
let path = this.$emo.textToPath(emoText)
let path = this.$emo.textToPath(emoText, true)
//
this.isReadOnly = true;
this.isEmpty = false;

BIN
im-uniapp/static/logo/logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 KiB

Loading…
Cancel
Save