Browse Source

聊天键盘保持

master
xie.bx 3 years ago
parent
commit
9443b1e80e
  1. 24
      im-uniapp/pages/chat/chat-box.vue

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

@ -4,7 +4,7 @@
<text class="title">{{title}}</text> <text class="title">{{title}}</text>
<uni-icons class="btn-side" type="more-filled" size="30"></uni-icons> <uni-icons class="btn-side" type="more-filled" size="30"></uni-icons>
</view> </view>
<view class="chat-msg" @click="switchChatTabBox('none')"> <view class="chat-msg" @click="switchChatTabBox('none',false)">
<scroll-view class="scroll-box" scroll-y="true" :scroll-into-view="'chat-item-'+scrollMsgIdx"> <scroll-view class="scroll-box" scroll-y="true" :scroll-into-view="'chat-item-'+scrollMsgIdx">
<view v-for="(msgInfo,idx) in chat.messages" :key="idx"> <view v-for="(msgInfo,idx) in chat.messages" :key="idx">
<chat-message-item :headImage="headImage(msgInfo)" :showName="showName(msgInfo)" <chat-message-item :headImage="headImage(msgInfo)" :showName="showName(msgInfo)"
@ -16,12 +16,12 @@
<view class="send-bar"> <view class="send-bar">
<view class="iconfont icon-voice-circle"></view> <view class="iconfont icon-voice-circle"></view>
<view class="send-text"> <view class="send-text">
<textarea class="send-text-area" v-model="sendText" auto-height :show-confirm-bar="false" :focus="sendTextFocus" @blur="onSendTextBlur()" <textarea class="send-text-area" v-model="sendText" auto-height :show-confirm-bar="false" :focus="sendTextFocus"
@focus="onSendTextFoucs()" cursor-spacing="20" @keydown.enter="sendTextMessage()" @click="switchChatTabBox('none')"></textarea> @focus="onSendTextFoucs()" cursor-spacing="20" @keydown.enter="sendTextMessage()" @click="switchChatTabBox('none',true)" :hold-keyboard="sendTextFocus"></textarea>
</view> </view>
<view class="iconfont icon-icon_emoji" @click="switchChatTabBox('emo')"></view> <view class="iconfont icon-icon_emoji" @click="switchChatTabBox('emo',false)"></view>
<view v-show="sendText==''" class="iconfont icon-add-circle" @click="switchChatTabBox('tools')"></view> <view v-show="sendText==''" class="iconfont icon-add-circle" @click="switchChatTabBox('tools',false)"></view>
<button v-show="sendText!=''" class="btn-send" type="primary" @click="sendTextMessage()" <button v-show="sendText!=''" class="btn-send" type="primary" @touchend.prevent="sendTextMessage()"
size="mini">发送</button> size="mini">发送</button>
</view> </view>
@ -130,7 +130,7 @@
// //
this.scrollToBottom(); this.scrollToBottom();
// //
this.sendTextFocus = true; //this.sendTextFocus = true;
}); });
}, },
fillTargetId(msgInfo, targetId) { fillTargetId(msgInfo, targetId) {
@ -162,16 +162,16 @@
}); });
}, },
switchChatTabBox(v) { switchChatTabBox(chatTabBox,sendTextFocus) {
this.chatTabBox = v; console.log("switchChatTabBox")
this.chatTabBox = chatTabBox;
this.sendTextFocus = sendTextFocus
this.scrollToBottom(); this.scrollToBottom();
console.log(this.sendTextFocus)
}, },
selectEmoji(emoText) { selectEmoji(emoText) {
this.sendText += `#${emoText};`; this.sendText += `#${emoText};`;
}, },
onSendTextBlur(){
this.sendTextFocus=false;
},
onSendTextFoucs(){ onSendTextFoucs(){
console.log("onSendTextFoucs") console.log("onSendTextFoucs")
this.scrollToBottom(); this.scrollToBottom();

Loading…
Cancel
Save