Browse Source

fix:h5键盘无法拉起的bug

master
xsx 1 year ago
parent
commit
4f951e0980
  1. 48
      im-uniapp/pages/chat/chat-box.vue

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

@ -104,7 +104,6 @@
lazy-load="true"></image> lazy-load="true"></image>
</view> </view>
</scroll-view> </scroll-view>
<view v-if="showKeyBoard"></view>
</view> </view>
<!-- @用户时选择成员 --> <!-- @用户时选择成员 -->
<chat-at-box ref="atBox" :ownerId="group.ownerId" :members="groupMembers" <chat-at-box ref="atBox" :ownerId="group.ownerId" :members="groupMembers"
@ -133,6 +132,7 @@ export default {
chatTabBox: 'none', chatTabBox: 'none',
showRecord: false, showRecord: false,
keyboardHeight: 300, keyboardHeight: 300,
chatMainHeight: 0, //
atUserIds: [], atUserIds: [],
needScrollToBottom: false, // needScrollToBottom: false, //
showMinIdx: 0, // showMinIdx showMinIdx: 0, // showMinIdx
@ -355,6 +355,7 @@ export default {
}, },
switchChatTabBox(chatTabBox) { switchChatTabBox(chatTabBox) {
this.chatTabBox = chatTabBox; this.chatTabBox = chatTabBox;
this.reCalChatMainHeight();
if (chatTabBox != 'tools' && this.$refs.fileUpload) { if (chatTabBox != 'tools' && this.$refs.fileUpload) {
this.$refs.fileUpload.hide() this.$refs.fileUpload.hide()
} }
@ -683,6 +684,7 @@ export default {
if (this.isShowKeyBoard) { if (this.isShowKeyBoard) {
this.keyboardHeight = keyboardHeight; this.keyboardHeight = keyboardHeight;
} }
this.reCalChatMainHeight();
}); });
// #endif // #endif
// #ifndef H5 // #ifndef H5
@ -691,9 +693,31 @@ export default {
if (this.isShowKeyBoard) { if (this.isShowKeyBoard) {
this.keyboardHeight = res.height; // this.keyboardHeight = res.height; //
} }
this.reCalChatMainHeight();
}); });
// #endif // #endif
}, },
reCalChatMainHeight() {
const sysInfo = uni.getSystemInfoSync();
let h = sysInfo.windowHeight;
//
h -= 50;
// #ifdef H5
// h5sysInfo.windowHeight
if (this.chatTabBox != 'none') {
h -= this.keyboardHeight;
}
// #endif
// #ifndef H5
//
h -= sysInfo.statusBarHeight;
if (this.isShowKeyBoard || this.chatTabBox != 'none') {
h -= this.keyboardHeight;
}
// #endif
console.log("h:", h)
this.chatMainHeight = h;
},
generateId() { generateId() {
// id // id
return String(new Date().getTime()) + String(Math.floor(Math.random() * 1000)); return String(new Date().getTime()) + String(Math.floor(Math.random() * 1000));
@ -745,26 +769,6 @@ export default {
} }
}) })
return atUsers; return atUsers;
},
chatMainHeight() {
const sysInfo = uni.getSystemInfoSync();
let h = sysInfo.windowHeight;
//
h -= 50;
// #ifdef H5
// h5sysInfo.windowHeight
if (this.chatTabBox != 'none') {
h -= this.keyboardHeight;
}
// #endif
// #ifndef H5
//
h -= sysInfo.statusBarHeight;
if (this.isShowKeyBoard || this.chatTabBox != 'none') {
h -= this.keyboardHeight;
}
// #endif
return h;
} }
}, },
watch: { watch: {
@ -810,6 +814,8 @@ export default {
this.isReceipt = false; this.isReceipt = false;
// //
this.listenKeyBoard(); this.listenKeyBoard();
//
this.$nextTick(()=>this.reCalChatMainHeight())
}, },
onShow() { onShow() {
if (this.needScrollToBottom) { if (this.needScrollToBottom) {

Loading…
Cancel
Save