From befd1f21839939b54254bd316bbd158b136fcd15 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 12 十一月 2024 16:54:25 +0800
Subject: [PATCH] 简化主页

---
 miniprogram_npm/tdesign-miniprogram/pull-down-refresh/pull-down-refresh.js |   67 +++++++++++++++++++++------------
 1 files changed, 43 insertions(+), 24 deletions(-)

diff --git a/miniprogram_npm/tdesign-miniprogram/pull-down-refresh/pull-down-refresh.js b/miniprogram_npm/tdesign-miniprogram/pull-down-refresh/pull-down-refresh.js
index 7ed6e8d..d0aeb8e 100644
--- a/miniprogram_npm/tdesign-miniprogram/pull-down-refresh/pull-down-refresh.js
+++ b/miniprogram_npm/tdesign-miniprogram/pull-down-refresh/pull-down-refresh.js
@@ -16,12 +16,12 @@
         this.pixelRatio = 1;
         this.startPoint = null;
         this.isPulling = false;
-        this.loadingBarHeight = 100;
         this.maxRefreshAnimateTimeFlag = 0;
         this.closingAnimateTimeFlag = 0;
         this.externalClasses = [`${prefix}-class`, `${prefix}-class-loading`, `${prefix}-class-text`, `${prefix}-class-indicator`];
         this.options = {
             multipleSlots: true,
+            pureDataPattern: /^_/,
         };
         this.relations = {
             '../back-top/back-top': {
@@ -33,36 +33,26 @@
             prefix,
             classPrefix: name,
             barHeight: 0,
+            tipsHeight: 0,
             refreshStatus: -1,
             loosing: false,
             enableToRefresh: true,
             scrollTop: 0,
+            _maxBarHeight: 0,
+            _loadingBarHeight: 0,
         };
         this.lifetimes = {
             attached() {
                 const { screenWidth } = wx.getSystemInfoSync();
-                const { loadingBarHeight, loadingTexts } = this.properties;
+                const { loadingTexts, maxBarHeight, loadingBarHeight } = this.properties;
                 this.setData({
+                    _maxBarHeight: unitConvert(maxBarHeight),
+                    _loadingBarHeight: unitConvert(loadingBarHeight),
                     loadingTexts: Array.isArray(loadingTexts) && loadingTexts.length >= 4
                         ? loadingTexts
                         : ['涓嬫媺鍒锋柊', '鏉炬墜鍒锋柊', '姝e湪鍒锋柊', '鍒锋柊瀹屾垚'],
                 });
                 this.pixelRatio = 750 / screenWidth;
-                Object.defineProperty(this, 'maxBarHeight', {
-                    get() {
-                        return unitConvert(this.data.maxBarHeight);
-                    },
-                });
-                Object.defineProperty(this, 'loadingBarHeight', {
-                    get() {
-                        return unitConvert(this.data.loadingBarHeight);
-                    },
-                });
-                if (loadingBarHeight) {
-                    this.setData({
-                        computedLoadingBarHeight: unitConvert(loadingBarHeight),
-                    });
-                }
             },
             detached() {
                 clearTimeout(this.maxRefreshAnimateTimeFlag);
@@ -84,6 +74,15 @@
                     this.doRefresh();
                 }
             },
+            barHeight(val) {
+                this.setData({ tipsHeight: Math.min(val, this.data._loadingBarHeight) });
+            },
+            maxBarHeight(v) {
+                this.setData({ _maxBarHeight: unitConvert(v) });
+            },
+            loadingBarHeight(v) {
+                this.setData({ _loadingBarHeight: unitConvert(v) });
+            },
         };
         this.methods = {
             onScrollToBottom() {
@@ -102,7 +101,7 @@
                 this.triggerEvent('scroll', { scrollTop });
             },
             onTouchStart(e) {
-                if (this.isPulling || !this.data.enableToRefresh)
+                if (this.isPulling || !this.data.enableToRefresh || this.properties.disabled)
                     return;
                 const { touches } = e;
                 if (touches.length !== 1)
@@ -113,7 +112,7 @@
                 this.isPulling = true;
             },
             onTouchMove(e) {
-                if (!this.startPoint)
+                if (!this.startPoint || this.properties.disabled)
                     return;
                 const { touches } = e;
                 if (touches.length !== 1)
@@ -125,7 +124,7 @@
                 }
             },
             onTouchEnd(e) {
-                if (!this.startPoint)
+                if (!this.startPoint || this.properties.disabled)
                     return;
                 const { changedTouches } = e;
                 if (changedTouches.length !== 1)
@@ -135,7 +134,7 @@
                 this.startPoint = null;
                 this.isPulling = false;
                 this.setData({ loosing: true });
-                if (barHeight > this.loadingBarHeight) {
+                if (barHeight > this.data._loadingBarHeight) {
                     this._trigger('change', { value: true });
                     this.triggerEvent('refresh');
                 }
@@ -143,9 +142,29 @@
                     this.setData({ barHeight: 0 });
                 }
             },
+            onDragStart(e) {
+                if (this.properties.disabled)
+                    return;
+                const { scrollTop, scrollLeft } = e.detail;
+                this.triggerEvent('dragstart', { scrollTop, scrollLeft });
+            },
+            onDragging(e) {
+                if (this.properties.disabled)
+                    return;
+                const { scrollTop, scrollLeft } = e.detail;
+                this.triggerEvent('dragging', { scrollTop, scrollLeft });
+            },
+            onDragEnd(e) {
+                if (this.properties.disabled)
+                    return;
+                const { scrollTop, scrollLeft } = e.detail;
+                this.triggerEvent('dragend', { scrollTop, scrollLeft });
+            },
             doRefresh() {
+                if (this.properties.disabled)
+                    return;
                 this.setData({
-                    barHeight: this.loadingBarHeight,
+                    barHeight: this.data._loadingBarHeight,
                     refreshStatus: 2,
                     loosing: true,
                 });
@@ -158,9 +177,9 @@
                 }, this.properties.refreshTimeout);
             },
             setRefreshBarHeight(value) {
-                const barHeight = Math.min(value, this.maxBarHeight);
+                const barHeight = Math.min(value, this.data._maxBarHeight);
                 const data = { barHeight };
-                if (barHeight >= this.loadingBarHeight) {
+                if (barHeight >= this.data._loadingBarHeight) {
                     data.refreshStatus = 1;
                 }
                 else {

--
Gitblit v1.9.3