From c98acc813b9172b18768f6f063bd6dc5d45553cf Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Mon, 10 Mar 2025 10:43:21 +0800
Subject: [PATCH] 输入框,修复小程序中光标位置总是跳到首位的问题

---
 plugins/infiniteScroll/CInfiniteScroll.vue |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/plugins/infiniteScroll/CInfiniteScroll.vue b/plugins/infiniteScroll/CInfiniteScroll.vue
index 2b8e9b4..72bb052 100644
--- a/plugins/infiniteScroll/CInfiniteScroll.vue
+++ b/plugins/infiniteScroll/CInfiniteScroll.vue
@@ -141,6 +141,7 @@
                             // 没有数据
                             if (!options.pageTotal || options.pageTotal <= 0) {
                                 this.ending = true;
+                                this.pageTotal = 0;
                             }
                             // 有数据
                             else {
@@ -163,6 +164,8 @@
                     // 加载失败
                     fail: () => {
                         this.loading = false;
+                        this.ending = true;
+                        this.pageTotal = 0;
                         // 如果下拉刷新,还原下拉
                         if (this.touch.dargState === 2) {
                             this.touch.driftTop = 0;
@@ -299,17 +302,17 @@
             this.hanldeLoadMore();
         },
         // 刷新加载
-        $refresh(autoStart = 'on') {
+        $refresh(autoStart) {
             Taro.pageScrollTo({
                 selector: '#' + this.elmId,
                 scrollTop: 0,
             });
             this.ending = false;
             this.current = 0;
-            if (autoStart === 'on') {
-                this.hanldeLoadMore();
-            } else {
+            if (autoStart === 'off') {
                 this.inital = false;
+            } else {
+                this.hanldeLoadMore();
             }
         },
     },

--
Gitblit v1.9.1