From bd3a9d7086f5a428b385599ba2cb08299b22c0df Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 15 九月 2022 09:26:18 +0800
Subject: [PATCH] 2022.9.14

---
 component/switchtab/switchtab.js |   58 ++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 34 insertions(+), 24 deletions(-)

diff --git a/component/switchtab/switchtab.js b/component/switchtab/switchtab.js
index 59d2ed3..fb33732 100644
--- a/component/switchtab/switchtab.js
+++ b/component/switchtab/switchtab.js
@@ -8,13 +8,23 @@
    * 缁勪欢鐨勫睘鎬у垪琛�
    */
   properties: {
+    extClass: {
+      type: String,
+      value: ''
+    },
+    extClassOn: {
+      type: String,
+      value: ''
+    },
     tabList: {
       type: Array,
       value: []
     },
-    pageList: {
-      type: Array,
-      value: []
+    //閫氱煡缁勪欢鍒锋柊楂樺害
+    refresh: {
+      type: Boolean,
+      value: false,
+      observer: 'refreshHeight'
     },
   },
 
@@ -27,34 +37,36 @@
     // pageheight: '600px',
   },
 
-  observers: {
-    'pageList': function() {
-      this.tabsHeight('.page0');
-    }
+  pageLifetimes: {
+    // 缁勪欢鎵�鍦ㄩ〉闈㈢殑鐢熷懡鍛ㄦ湡鍑芥暟
+    show: function () {
+      // this.refreshHeight(true)
+
+    },
+    hide: function () { },
+    resize: function () {
+    },
   },
 
   /**
    * 缁勪欢鐨勬柟娉曞垪琛�
    */
   methods: {
+    refreshHeight: function(e) {
+      // console.log(`refreshHeight: ${e}`);
+      if (e) {
+        setTimeout(() => {
+          const p = `.page${this.data.currentTab}`
+          console.log(p);
+          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 +79,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