From 9d5789148e866f95f86d975011a9ef39d534c807 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期三, 17 七月 2024 17:37:19 +0800
Subject: [PATCH] 拼树结构优化

---
 pages/home/home.js |   49 +++++++++++++++++++++++++++++++++++++------------
 1 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/pages/home/home.js b/pages/home/home.js
index 1522c7c..7df68cf 100644
--- a/pages/home/home.js
+++ b/pages/home/home.js
@@ -11,6 +11,7 @@
     barHeight: '',
     navBarHeight: '',
     searchVal: '',
+    scoll: false,
     isWhite: false,
     userInfo: {},
     tabList: [], //鐩綍
@@ -40,12 +41,15 @@
     loading: true
   },
   onShow() {
+    this.setData({
+      searchVal: "",
+    });
+    console.log(this.data.searchVal)
     this.loadHomePage();
-    this.getBannerList()
-
   },
 
   onLoad() {
+    this.getBannerList()
     const systInfo = wx.getSystemInfoSync();
     const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅
     const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴�
@@ -146,6 +150,7 @@
   //鐐瑰嚮鐩綍
   toPages(item) {
     let info = item.target.dataset.info
+    console.log(info);
     if (info.url) {
       if (info.text == "鍥句功鏈嶅姟") {
         wx.switchTab({
@@ -586,20 +591,40 @@
 
   },
 
-
-  // 鐩戝惉婊氬姩鏉�
-  onScroll(e) {
-    this.setData({
-      isWhite: true
-    })
-    this.setData({
-      isWhite: e.detail.scrollTop > 20 ? true : false
+  // 鎵竴鎵�
+  onIconScanTap() {
+    wx.scanCode({
+      success(res) {
+        console.log(res);
+        if (res.errMsg == "scanCode:ok" && res.path || res.result) {
+          let path = res.path || res.result
+          wx.redirectTo({
+            url: '/' + path,
+          })
+        }
+      }
     })
   },
 
-  onScrollToTop(e) {
+
+
+  // 鐩戝惉婊氬姩鏉�
+  onScroll(e) {
+    if (this.data.scoll) {
+      if (e.detail.scrollTop < 20) {
+        this.data.scoll = false
+        this.isChange(false);
+      }
+    } else {
+      if (e.detail.scrollTop > 20) {
+        this.data.scoll = true
+        this.isChange(true);
+      }
+    }
+  },
+  isChange(data) {
     this.setData({
-      isWhite: e.detail.scrollTop > 50 ? true : false
+      isWhite: data
     })
   },
 

--
Gitblit v1.9.1