@@ -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
@@ -103,7 +75,6 @@ Component({
10375 showFileList : false , // 展示输入框顶部文件行
10476 showTopBar : false , // 展示顶部bar
10577 sendFileList : [ ] ,
106- footerHeight : 73 ,
10778 lastScrollTop : 0 ,
10879 showUploadFile : true ,
10980 showUploadImg : true ,
@@ -125,6 +96,7 @@ Component({
12596 textareaHeight : 50 ,
12697 curLineCount : 1 ,
12798 defaultErrorMsg : "网络繁忙,请稍后重试!" ,
99+ curScrollHeight : 0
128100 } ,
129101 attached : async function ( ) {
130102 const chatMode = this . data . chatMode ;
@@ -182,8 +154,30 @@ Component({
182154 this . setData ( {
183155 contentHeightInScrollViewTop : topHeight ,
184156 } ) ;
157+ this . calcScrollHeight ( )
185158 } ,
186159 methods : {
160+ calcScrollHeight : async function ( ) {
161+ // windowHeight - topHeight - footerHeight
162+ const topAndFooterHeight = await new Promise ( ( resolve ) => {
163+ const query = wx . createSelectorQuery ( ) . in ( this ) ;
164+ query
165+ . selectAll ( ".agent-ui >>> .navBar, .agent-ui >>> .footer" )
166+ . boundingClientRect ( ( rects ) => {
167+ let totalHeight = 0 ;
168+ rects . forEach ( ( rect ) => {
169+ totalHeight += rect . height ;
170+ } ) ;
171+ // console.log('top height', totalHeight);
172+ resolve ( totalHeight ) ;
173+ } )
174+ . exec ( ) ;
175+ } ) ;
176+ // console.log('this.data.windowInfo.windowHeight - topAndFooterHeight', this.data.windowInfo.windowHeight - topAndFooterHeight)
177+ this . setData ( {
178+ curScrollHeight : this . data . windowInfo . windowHeight - topAndFooterHeight
179+ } )
180+ } ,
187181 showErrorMsg : function ( e ) {
188182 const { content } = e . currentTarget . dataset ;
189183 console . log ( "content" , content ) ;
@@ -201,19 +195,10 @@ Component({
201195 . select ( ".foot_function" )
202196 . boundingClientRect ( function ( res ) {
203197 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- }
214198 self . setData ( {
215199 textareaHeight : res . height ,
216200 } ) ;
201+ self . calcScrollHeight ( )
217202 } else {
218203 console . log ( "未找到指定元素" ) ;
219204 }
@@ -333,12 +318,10 @@ Component({
333318 } ) ;
334319 } ,
335320 autoToBottom : function ( ) {
336- // console.log("autoToBottom");
337321 this . setData ( {
338322 manualScroll : false ,
339323 scrollTo : "scroll-bottom" ,
340324 } ) ;
341- // console.log('scrollTop', this.data.scrollTop);
342325 } ,
343326 bindInputFocus : function ( e ) {
344327 this . setData ( {
@@ -1019,8 +1002,9 @@ Component({
10191002 }
10201003
10211004 // 只有当内容高度接近scroll 区域视口高度时才开始增加 scrollTop
1022- const clientHeight =
1023- this . data . windowInfo . windowHeight - this . data . footerHeight - ( this . data . chatMode === "bot" ? 40 : 0 ) ; // 视口高度
1005+ // const clientHeight =
1006+ // this.data.windowInfo.windowHeight - this.data.footerHeight - (this.data.chatMode === "bot" ? 40 : 0); // 视口高度
1007+ const clientHeight = this . data . curScrollHeight
10241008 const contentHeight =
10251009 ( await this . calculateContentHeight ( ) ) +
10261010 ( this . data . contentHeightInScrollViewTop || ( await this . calculateContentInTop ( ) ) ) ; // 内容总高度
0 commit comments