@@ -43,42 +43,14 @@ Component({
4343 showFeatureList : showWebSearchSwitch ,
4444 } ) ;
4545 } ,
46- showTools : function ( isShow ) {
47- // console.log('showTools', isShow)
48- if ( isShow ) {
49- this . setData ( {
50- footerHeight : this . data . footerHeight + 80 ,
51- } ) ;
52- } else {
53- this . setData ( {
54- footerHeight : this . data . footerHeight - 80 ,
55- } ) ;
56- }
46+ showTools : function ( ) {
47+ wx . nextTick ( ( ) => this . calcScrollHeight ( ) )
5748 } ,
58- showFileList : function ( isShow ) {
59- console . log ( "showFileList" , isShow ) ;
60- if ( isShow ) {
61- this . setData ( {
62- footerHeight : this . data . footerHeight + 80 ,
63- } ) ;
64- } else {
65- this . setData ( {
66- footerHeight : this . data . footerHeight - 80 ,
67- } ) ;
68- }
49+ showFileList : function ( ) {
50+ wx . nextTick ( ( ) => this . calcScrollHeight ( ) )
6951 } ,
70- showFeatureList : function ( isShow ) {
71- console . log ( "showFeatureList" , isShow ) ;
72- if ( isShow ) {
73- this . setData ( {
74- footerHeight : this . data . footerHeight + 30 ,
75- } ) ;
76- } else {
77- const subHeight = this . data . footerHeight - 30 ;
78- this . setData ( {
79- footerHeight : subHeight >= 80 ? subHeight : 80 ,
80- } ) ;
81- }
52+ showFeatureList : function ( ) {
53+ wx . nextTick ( ( ) => this . calcScrollHeight ( ) )
8254 } ,
8355 } ,
8456
@@ -90,10 +62,8 @@ Component({
9062 inputValue : "" ,
9163 output : "" ,
9264 chatRecords : [ ] ,
93- scrollTop : 0 ,
9465 setPanelVisibility : false ,
9566 questions : [ ] ,
96- scrollTop : 0 ,
9767 scrollTop : 0 , // 文字撑起来后能滚动的最大高度
9868 viewTop : 0 , // 根据实际情况,可能用户手动滚动,需要记录当前滚动的位置
9969 scrollTo : "" , // 快速定位到指定元素,置底用
@@ -103,7 +73,6 @@ Component({
10373 showFileList : false , // 展示输入框顶部文件行
10474 showTopBar : false , // 展示顶部bar
10575 sendFileList : [ ] ,
106- footerHeight : 73 ,
10776 lastScrollTop : 0 ,
10877 showUploadFile : true ,
10978 showUploadImg : true ,
@@ -123,8 +92,8 @@ Component({
12392 feedbackRecordId : "" ,
12493 feedbackType : "" ,
12594 textareaHeight : 50 ,
126- curLineCount : 1 ,
12795 defaultErrorMsg : "网络繁忙,请稍后重试!" ,
96+ curScrollHeight : 0
12897 } ,
12998 attached : async function ( ) {
13099 const chatMode = this . data . chatMode ;
@@ -182,8 +151,30 @@ Component({
182151 this . setData ( {
183152 contentHeightInScrollViewTop : topHeight ,
184153 } ) ;
154+ this . calcScrollHeight ( )
185155 } ,
186156 methods : {
157+ calcScrollHeight : async function ( ) {
158+ // windowHeight - topHeight - footerHeight
159+ const topAndFooterHeight = await new Promise ( ( resolve ) => {
160+ const query = wx . createSelectorQuery ( ) . in ( this ) ;
161+ query
162+ . selectAll ( ".agent-ui >>> .navBar, .agent-ui >>> .footer" )
163+ . boundingClientRect ( ( rects ) => {
164+ let totalHeight = 0 ;
165+ rects . forEach ( ( rect ) => {
166+ totalHeight += rect . height ;
167+ } ) ;
168+ // console.log('top height', totalHeight);
169+ resolve ( totalHeight ) ;
170+ } )
171+ . exec ( ) ;
172+ } ) ;
173+ // console.log('this.data.windowInfo.windowHeight - topAndFooterHeight', this.data.windowInfo.windowHeight - topAndFooterHeight)
174+ this . setData ( {
175+ curScrollHeight : this . data . windowInfo . windowHeight - topAndFooterHeight
176+ } )
177+ } ,
187178 showErrorMsg : function ( e ) {
188179 const { content } = e . currentTarget . dataset ;
189180 console . log ( "content" , content ) ;
@@ -201,19 +192,10 @@ Component({
201192 . select ( ".foot_function" )
202193 . boundingClientRect ( function ( res ) {
203194 if ( res ) {
204- if ( res . height < self . data . textareaHeight ) {
205- self . setData ( {
206- footerHeight : self . data . footerHeight - ( self . data . textareaHeight - res . height ) ,
207- } ) ;
208- }
209- if ( res . height > self . data . textareaHeight ) {
210- self . setData ( {
211- footerHeight : self . data . footerHeight + ( res . height - self . data . textareaHeight ) ,
212- } ) ;
213- }
214195 self . setData ( {
215196 textareaHeight : res . height ,
216197 } ) ;
198+ self . calcScrollHeight ( )
217199 } else {
218200 console . log ( "未找到指定元素" ) ;
219201 }
@@ -333,12 +315,10 @@ Component({
333315 } ) ;
334316 } ,
335317 autoToBottom : function ( ) {
336- // console.log("autoToBottom");
337318 this . setData ( {
338319 manualScroll : false ,
339320 scrollTo : "scroll-bottom" ,
340321 } ) ;
341- // console.log('scrollTop', this.data.scrollTop);
342322 } ,
343323 bindInputFocus : function ( e ) {
344324 this . setData ( {
@@ -1019,8 +999,9 @@ Component({
1019999 }
10201000
10211001 // 只有当内容高度接近scroll 区域视口高度时才开始增加 scrollTop
1022- const clientHeight =
1023- this . data . windowInfo . windowHeight - this . data . footerHeight - ( this . data . chatMode === "bot" ? 40 : 0 ) ; // 视口高度
1002+ // const clientHeight =
1003+ // this.data.windowInfo.windowHeight - this.data.footerHeight - (this.data.chatMode === "bot" ? 40 : 0); // 视口高度
1004+ const clientHeight = this . data . curScrollHeight
10241005 const contentHeight =
10251006 ( await this . calculateContentHeight ( ) ) +
10261007 ( this . data . contentHeightInScrollViewTop || ( await this . calculateContentInTop ( ) ) ) ; // 内容总高度
0 commit comments