1.图形界面展示如下
2.scroll-view详解
<!-- 消息滚动区域 开始 -->
<scroll-view bindrefresherrefresh="freshPages" refresher-triggered="{{triggered}}" refresher-enabled="{{true}}" class="scroll-wrapper" style="height:{{scrollHeight}}" scroll-into-view="{{scrollTo}}" scroll-y="true" scroll-with-animation="{{true}}">
<!-- <view class="record-wrapper"> -->
<chat-items
ref="chatItem"
id="item{{index}}"
message="{{item.message}}"
>
</chat-items>
</scroll-view>
<!-- 消息滚动区域 结束 -->
this.setData({
scrollTo:`item${this.data.messageList.length - 1}`
})
this.setData({
scrollHeight:this.data.inputShow ? '76%' : '90%'
})
3.下拉刷新
freshPages(){
if(this.data.lastPage){
this.setData({
triggered:false
})
wx.showToast({
title:'没有更多了~',
icon:'none',
duration:3000
})
}else{
this.setData({
pageNum:this.data.pageNum + 1
})
this.getMoreMsg()
}
},
4.键盘弹起不遮挡对话文字
<!-- 底部输入框 开始 -->
<view class="msg-bottom" style="bottom:{{bottom}}px" wx:if="{{inputShow}}">
<!-- 症状列表功能 开始-->
<!-- <view class="question-examples" wx:if="{{serviceBaseUrl == 3}}">
<view bind:tap="handleUploadImg">
<image src="{{symptomUrl}}">
</image>
<text>上传图片</text>
</view>
</view> -->
<!-- 症状列表功能 结束-->
<view class="msg-bottom-content">
<!-- <image src="{{yyUrl}}" bindtap="switchVoice" wx:if="{{isVoice}}" mode="widthFix"></image>
<image src="{{wzUrl}}" wx:if="{{!isVoice}}" bindtap="switchKeyboard" mode="widthFix"></image>
<view class="sound-recording" bindtouchstart="handleTouchStart" bindtouchmove="handleTouchMove" bindtouchend="handleTouchEnd" bindtouchcancel="handleTouchCancel" wx:if="{{!isVoice}}">
{{isRecording ? '松开 结束' : '按住 说话'}}
</view> -->
<textarea class="intelligent_textarea" maxlength="-1" auto-height bindblur="textareaBlur" confirm-type="send" bindinput="textareaInput" bindconfirm="handleSend" bindfocus="textareaFocus" bindkeyboardheightchange="getKeyboardHeight" adjust-position="{{false}}" type="text" wx:if="{{isVoice}}" placeholder-style="background:#f2f7ff" show-confirm-bar="{{false}}" value="{{textVal}}"></textarea>
<!-- <view class="send-btn" bindtap="handleSend">发送</view> -->
<image src="{{addImgUrl}}" wx:if="{{serviceBaseUrl == 3}}" class="addImage" bind:tap="handleUploadImg" mode="widthFix"></image>
<image src="{{sendImg}}" class="sendBtn" bind:tap="handleSend" mode="widthFix"></image>
</view>
<view class="{{blankStatus ? 'msg-bottom-blank' : 'msg-bottom-none'}}" >
</view>
</view>
<!-- 底部输入框 结束 -->
textareaFocus(e) {
let keyHeight = e.detail.height
let windowHeight = wx.getSystemInfoSync().windowHeight
let safeHeight = wx.getSystemInfoSync().screenHeight - wx.getSystemInfoSync().safeArea.bottom
let safeView = this.data.blankStatus ? 32 : 0
this.setData({
scrollHeight:(windowHeight - keyHeight - safeHeight - safeView) + 'px'
})
this.setData({
scrollTo:`item${this.data.messageList.length - 1}`,
})
},
getKeyboardHeight(e){
let keyHeight = e.detail.height || 0
this.setData({
bottom:keyHeight
})
},
textareaBlur(e) {
this.setData({
bottom: 0,
scrollHeight:this.data.inputShow ? '76%' : '90%'
})
},
isIPhoneX(){
let screenHeight = wx.getSystemInfoSync().screenHeight
let bottom = wx.getSystemInfoSync().safeArea.bottom
console.log(screenHeight,bottom);
this.setData({
blankStatus:screenHeight !== bottom
})
},