From 2206df0da6499846c78a358cf95ca33c218a5c5d Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期三, 14 九月 2022 08:43:37 +0800
Subject: [PATCH] 2022.9.13

---
 component/switchtab/switchtab.js |   42 ++++++++++++++++--------------------------
 1 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/component/switchtab/switchtab.js b/component/switchtab/switchtab.js
index 59d2ed3..48f52b6 100644
--- a/component/switchtab/switchtab.js
+++ b/component/switchtab/switchtab.js
@@ -12,9 +12,11 @@
       type: Array,
       value: []
     },
-    pageList: {
-      type: Array,
-      value: []
+    //閫氱煡缁勪欢鍒锋柊楂樺害
+    refresh: {
+      type: Boolean,
+      value: false,
+      observer: 'refreshHeight'
     },
   },
 
@@ -27,34 +29,24 @@
     // pageheight: '600px',
   },
 
-  observers: {
-    'pageList': function() {
-      this.tabsHeight('.page0');
-    }
-  },
-
   /**
    * 缁勪欢鐨勬柟娉曞垪琛�
    */
   methods: {
+    refreshHeight: function(e) {
+      // console.log(`refreshHeight: ${e}`);
+      if (e) {
+        setTimeout(() => {
+          const p = `.page${this.data.currentTab}`
+          this.tabsHeight(p);
+        }, 50);
+      }
+    },
     //璁$畻swiper楂樺害鏂规硶锛堝湪鍒囨崲鐨勬椂鍊欒皟鐢級
     tabsHeight(element) {
       let that = this;
       let query = this.createSelectorQuery(); //蹇呴』瑕佸厛鍒涘缓涓�涓煡璇�
       query.select(element).boundingClientRect(function (rect) {
-        // if (that.data.pageheight) {
-        //   let pageheight = that.data.pageheight.split('px')[0]
-        //   pageheight = parseInt(pageheight)
-        //   if (rect.height > pageheight) {
-        //     that.setData({
-        //       pageheight: rect.height + 'px'
-        //     });
-        //   }
-        // } else {
-        //   that.setData({
-        //     pageheight: rect.height + 'px'
-        //   });
-        // }
         that.setData({
           pageheight: rect.height + 'px'
         });
@@ -67,18 +59,16 @@
       } else {
         that.setData({
           currentTab: e.target.dataset.current,
-          navScrollLeft: e.target.dataset.current >= 3 ? ((e.target.dataset.current) * 60) : 0 //鍒ゆ柇褰撳墠閫変腑鐨勪釜鏁版槸鍚︽槸绗�5涓�
         })
-        // that.tabsHeight('.page' + e.target.dataset.current); //鏌ヨ鍝竴涓厓绱�
       }
     },
     bindChange: function (e) {
       var that = this;
       that.setData({
         currentTab: e.detail.current,
-        navScrollLeft: e.detail.current >= 3 ? ((e.detail.current) * 60) : 0 //鍒ゆ柇褰撳墠閫変腑鐨勪釜鏁版槸鍚︽槸绗�5涓�
       });
-      that.tabsHeight('.page' + e.detail.current); //鏌ヨ鍝竴涓厓绱�        
+      that.tabsHeight('.page' + e.detail.current); //鏌ヨ鍝竴涓厓绱�
+      this.triggerEvent('tabchange', this.data.currentTab)
     },
   }
 })
\ No newline at end of file

--
Gitblit v1.9.3