Explorar el Código

fix: Yl_ListBox 滚动区域修复 — 高度绑定、goTop、全局适配

- scroll-view 绑定 style='height: {{height}}px' 实现独立滚动区
- 新增 goTop() 方法,6 个页面 getList(init=true) 时回到顶部
- 修复 Yl_Head setTimeout 丢失 this 上下文
- workOrder/index 页面禁止 body 滚动避免双滚动

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
xiaohaizhao hace 1 semana
padre
commit
5e0be85f43

+ 1 - 0
bgj/handling/assignAgent/assign.js

@@ -23,6 +23,7 @@ Page({
   },
 
   getList(init = false) {
+    if (init) this.selectComponent('#ListBox').goTop();
     _Http.init(this.data.content, init).then(content => {
       _Http.basic({
         id: this.data.id,

+ 1 - 0
bgj/handling/index.js

@@ -41,6 +41,7 @@ Page({
   },
 
   getList(init = false) {
+    if (init) this.selectComponent('#ListBox').goTop();
     _Http.init(this.data.content, init).then(content => {
       _Http.basic({
         id: this.data.id,

+ 1 - 6
bgj/workOrder/index.js

@@ -23,12 +23,6 @@ Page({
     isback: false,
   },
 
-  onShow() {
-    if (this.data.isback) {
-      this.getList(true);
-    }
-  },
-
   onSearch({
     detail
   }) {
@@ -46,6 +40,7 @@ Page({
   },
 
   getList(init = false) {
+    if (init) this.selectComponent('#ListBox').goTop();
     _Http.init(this.data.content, init).then(content => {
       _Http.basic({
         id: this.data.id,

+ 5 - 0
bgj/workOrder/index.scss

@@ -1,3 +1,8 @@
+page {
+  height: 100vh;
+  overflow: hidden;
+}
+
 .item {
   width: 690rpx;
   background: #ffffff;

+ 1 - 0
bgj/workOrder/materialAdd/material.js

@@ -20,6 +20,7 @@ Page({
   },
 
   getList(init = false) {
+    if (init) this.selectComponent('#ListBox').goTop();
     _Http.init(this.data.content, init).then(content => {
       _Http.basic({
         id: this.data.id,

+ 1 - 0
bgj/workOrder/nodes/selectProduct/index.js

@@ -82,6 +82,7 @@ Page({
     getList(init = false) {
         //init 用于初始化分页
         if (init.detail != undefined) init = init.detail;
+        if (init) this.selectComponent('#ListBox').goTop();
         let params = this.data.params;
         if (init) params.content.pageNumber = 1
         if (params.content.pageNumber > params.content.pageTotal) return;

+ 3 - 3
components/Yl_Head/index.js

@@ -46,7 +46,7 @@ Component({
       this.setData({
         startUsing: !this.data.startUsing
       });
-      setTimeout(this.setListHeight, 400)
+      setTimeout(() => this.setListHeight(), 400)
     },
     /* 搜索 */
     confirmSearch(e) {
@@ -135,14 +135,14 @@ Component({
       this.setData({
         showHistory: true
       });
-      setTimeout(this.setListHeight, 50);
+      setTimeout(() => this.setListHeight(), 50);
     },
     /* 搜索框失焦 */
     onBlur() {
       this.setData({
         showHistory: false
       })
-      setTimeout(this.setListHeight, 50);
+      setTimeout(() => this.setListHeight(), 50);
     },
     clickFiltration() {
       let page = getCurrentPages()[getCurrentPages().length - 1];

+ 10 - 0
components/Yl_ListBox/index.js

@@ -76,6 +76,16 @@ Component({
     },
 
     methods: {
+        /* 回到顶部 */
+        goTop() {
+            const ts = Date.now();
+            this.setData({ _innerScrollTop: ts }, () => {
+                if (!this._detached) {
+                    this.setData({ _innerScrollTop: 0 });
+                }
+            });
+        },
+
         /* 下拉刷新 */
         pullToRefresh() {
             if (this.data.inRefresh) return;

+ 1 - 0
components/Yl_ListBox/index.wxml

@@ -1,6 +1,7 @@
 <view id="mylisttop" />
 <scroll-view
   class="scroll-view"
+  style="height: {{height}}px"
   scroll-y
   enhanced="{{true}}"
   show-scrollbar="{{showScrollbar}}"

+ 7 - 4
pages/teams/index.js

@@ -38,10 +38,13 @@ Page({
     /* 获取列表 */
     getList(init = false) {
         if (init.detail != undefined) init = init.detail;
-        if (init) this.setData({
-            ['content.pageNumber']: 1,
-            finished: false
-        })
+        if (init) {
+            this.selectComponent('#ListBox').goTop();
+            this.setData({
+                ['content.pageNumber']: 1,
+                finished: false
+            })
+        }
         if (this.data.content.pageNumber > this.data.content.pageTotal) {
             this.selectComponent('#ListBox').completeLoad();
             return;