作者 xuqiang

提交

<template>
<view>
<view v-if="showRoom">
<view class="content" @touchstart="hideDrawer">
<scroll-view class="msg-list" scroll-y="true" :scroll-with-animation="scrollAnimation" :scroll-top="scrollTop"
:scroll-into-view="scrollToView" @scrolltoupper="loadHistory" upper-threshold="50">
... ... @@ -56,6 +56,9 @@
</view>
</scroll-view>
</view>
<navigator class="giftWrap" hover-class="none" :url="'/pages/index/landHome?id='+toUserInfo.id" :style="{bottom: keyboardHeight + 150 +'rpx'}">
<image src="../../static/image/roomGiftIcon.png" mode=""></image>
</navigator>
<!-- 抽屉栏 -->
<view class="popup-layer" :class="popupLayerClass" @touchmove.stop.prevent="discard">
<!-- 表情 -->
... ... @@ -152,6 +155,7 @@
export default {
data() {
return {
showRoom:false,
keyboardHeight:-2,
//TIM变量
conversationActive:null,
... ... @@ -223,11 +227,13 @@
},
watch:{
currentMessageList(newVal,oldVal){
console.log('222222222222222222222222',newVal)
this.msgList = newVal
this.screenMsg(newVal,oldVal)
},
},
onLoad(option) {
this.showRoom = false
//监听键盘高度变化
uni.onKeyboardHeightChange(res => {
console.log('键盘高度变化了',res.height)
... ... @@ -238,7 +244,6 @@
}
})
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
console.log('this.userInfo11111111111111111111',this.userInfo)
this.toUserId = this.$store.state.toUserId
this.conversationActive = this.$store.state.conversationActive
this.TIM = this.$TIM
... ... @@ -250,8 +255,9 @@
uni.setNavigationBarTitle({
title:this.toUserInfo.nickname
})
this.getMsgList();
})
this.getMsgList();
},
onShow(){
this.scrollTop = 9999999;
... ... @@ -281,6 +287,7 @@
},
// 接受消息(定位消息)
screenMsg(newVal,oldVal){
console.log('screenMsg===================',newVal,oldVal)
if(newVal.length > 0 && oldVal.length > 0){
if(newVal[0].ID != oldVal[0].ID && newVal.length>=this.count ){
this.$nextTick(()=> {this.scrollToView =oldVal[0].ID});
... ... @@ -316,6 +323,9 @@
},
// 加载初始页面消息
getMsgList(){
uni.showLoading({
title:'加载中...'
})
// 历史消息列表
let conversationID = this.conversationActive.conversationID
... ... @@ -325,7 +335,9 @@
this.nextReqMessageID = res.data.nextReqMessageID // 用于续拉,分页续拉时需传入该字段。
this.isCompleted = res.data.isCompleted
this.scrollToView = res.data.messageList[res.data.messageList.length-1].ID
console.log(this.nextReqMessageID)
console.log(this.nextReqMessageID)
uni.hideLoading()
this.showRoom = true
});
// 滚动到底部
this.$nextTick(function() {
... ... @@ -470,6 +482,7 @@
text: content.text
}
});
console.log('00000000000000000',message)
this.$store.commit('pushCurrentMessageList', message)
let pomise = this.tim.sendMessage(message)
pomise.then(res=>{
... ...
... ... @@ -56,6 +56,13 @@ page{
.hidden{
display: none !important;
}
.giftWrap{
position: fixed;
right: 30rpx;
width: 64rpx;
height: 58rpx;
image{width: 64rpx;height: 58rpx;}
}
.popup-layer{
&.showLayer{transform: translate3d(0,-42vw,0);}
transition: all .15s linear;
... ...