diff --git a/pages/im/components/conversation/messageCell.vue b/pages/im/components/conversation/messageCell.vue
index 25b78a5..7041980 100644
--- a/pages/im/components/conversation/messageCell.vue
+++ b/pages/im/components/conversation/messageCell.vue
@@ -8,7 +8,7 @@
diff --git a/pages/im/group/chat.vue b/pages/im/group/chat.vue
index 9f1a5c1..62c8741 100644
--- a/pages/im/group/chat.vue
+++ b/pages/im/group/chat.vue
@@ -1,6 +1,6 @@
-
+
@@ -11,7 +11,8 @@
-
+
+
@@ -51,7 +52,9 @@
messages: [],
groupInfo: {
name: ''
- }
+ },
+ placeHeight: uni.getSystemInfoSync().windowHeight,
+ bottomHeihgt: 56
}
},
computed: {
@@ -68,7 +71,21 @@
onShow() {
this.initGroupInfo()
},
- onLoad(e) {
+ onLoad(e) {
+ const query = uni.createSelectorQuery().in(this);
+ this.$nextTick(function() {
+ query.select('#msgbar').boundingClientRect(bottom => {
+ this.bottomHeihgt = bottom.height
+ }).exec();
+ })
+ // 监听键盘高度变化
+ uni.onKeyboardHeightChange(keyboard => {
+ query.select('#scroll').boundingClientRect(scroll => {
+ const placeHeight = this.windowHeight - scroll.height - keyboard.height - this
+ .bottomHeihgt
+ this.placeHeight = placeHeight > 0 ? placeHeight : 0
+ }).exec();
+ })
this.targetId = e.targetId
// 获取历史消息列表
this.getMessageList()
diff --git a/pages/im/mixins/imBase.js b/pages/im/mixins/imBase.js
index faaf422..fb37af2 100644
--- a/pages/im/mixins/imBase.js
+++ b/pages/im/mixins/imBase.js
@@ -12,6 +12,9 @@ export default {
},
sender() {
return this.$store.getters.sender
+ },
+ windowHeight() {
+ return uni.getSystemInfoSync().windowHeight
}
},
methods: {
diff --git a/pages/im/private/chat.vue b/pages/im/private/chat.vue
index 24f48ce..ec87b2d 100644
--- a/pages/im/private/chat.vue
+++ b/pages/im/private/chat.vue
@@ -1,6 +1,7 @@
-
+
@@ -10,7 +11,8 @@
-
+
+
@@ -26,11 +28,11 @@
import showMessageCell from '../components/showMessageCell'
import utils from '@/utils/index.js'
import imBase from '../mixins/imBase.js'
- import messageActions from '../mixins/messageActions.js'
-
+ import messageActions from '../mixins/messageActions.js'
+
export default {
mixins: [
- imBase,
+ imBase,
messageActions
],
components: {
@@ -46,7 +48,9 @@
name: '',
userId: '',
portraitUrl: ''
- }
+ },
+ placeHeight: uni.getSystemInfoSync().windowHeight,
+ bottomHeihgt: 56
}
},
computed: {
@@ -59,13 +63,27 @@
}
}
}
- },
- onShow() {
- uni.setNavigationBarTitle({
- title: this.contact(this.targetId).name
- })
},
- onLoad(e) {
+ onShow() {
+ uni.setNavigationBarTitle({
+ title: this.contact(this.targetId).name
+ })
+ },
+ onLoad(e) {
+ const query = uni.createSelectorQuery().in(this);
+ this.$nextTick(function() {
+ query.select('#msgbar').boundingClientRect(bottom => {
+ this.bottomHeihgt = bottom.height
+ }).exec();
+ })
+ // 监听键盘高度变化
+ uni.onKeyboardHeightChange(keyboard => {
+ query.select('#scroll').boundingClientRect(scroll => {
+ const placeHeight = this.windowHeight - scroll.height - keyboard.height - this
+ .bottomHeihgt
+ this.placeHeight = placeHeight > 0 ? placeHeight : 0
+ }).exec();
+ })
this.targetId = e.targetId
this.userInfo = this.$store.getters.contactInfo(this.targetId)
// 获取消息列表
@@ -106,16 +124,19 @@
})
},
onUnload() {
+ uni.offKeyboardHeightChange(res => {
+ console.log('卸载监听键盘高度变化', res);
+ })
uni.$off('onUserDelete_' + this.targetId)
uni.$off('onReceiveMessage_' + this.targetId)
uni.$off('onRecallMessage_' + this.targetId)
uni.$off('onRecallMessage')
uni.$off('onReadReceiptReceived')
- },
- onNavigationBarButtonTap() {
- uni.navigateTo({
- url:'/pages/im/friends/info?targetId='+this.targetId
- })
+ },
+ onNavigationBarButtonTap() {
+ uni.navigateTo({
+ url: '/pages/im/friends/info?targetId=' + this.targetId
+ })
},
methods: {
getNewMessage() {
@@ -160,6 +181,8 @@