From dcfe83a022f2c4aa2a707baa6d5e98a67753bf76 Mon Sep 17 00:00:00 2001
From: zuoxiao <zuoxiao>
Date: 星期二, 18 三月 2025 16:11:12 +0800
Subject: [PATCH] 添加clientId字段到全局状态,优化请求参数处理,更新页面路由,调整取水口和灌溉相关界面,增强用户体验。

---
 pages/irrigation/irrigation.js               |   21 
 pages/groupDetail/groupDetail.js             |  168 ++
 pages/home/home.js                           | 1169 ++++++++++++++++++++----
 pages/login/login.js                         |  351 ++++++-
 images/irrigation.svg                        |    1 
 pages/createIrrigation/createIrrigation.wxml |    4 
 pages/createIrrigation/createIrrigation.wxss |   47 +
 app.json                                     |   10 
 app.js                                       |    1 
 utils/storage.js                             |   70 +
 api/request.js                               |   27 
 pages/irrigation/irrigation.wxml             |    4 
 pages/login/login.wxss                       |   21 
 pages/login/login.wxml                       |    2 
 pages/groupDetail/groupDetail.wxml           |   55 
 pages/groupDetail/groupDetail.wxss           |  199 ++-
 pages/irrigationDetail/irrigationDetail.js   |  308 ++++++
 pages/waterIntake/waterIntake.js             |    4 
 pages/home/home.wxml                         |    6 
 pages/irrigationDetail/irrigationDetail.json |    4 
 pages/irrigationDetail/irrigationDetail.wxss |  234 ++++
 pages/irrigationDetail/irrigationDetail.wxml |   74 +
 22 files changed, 2,370 insertions(+), 410 deletions(-)

diff --git a/api/request.js b/api/request.js
index 1f7bc0a..ab0c6e7 100644
--- a/api/request.js
+++ b/api/request.js
@@ -31,8 +31,16 @@
     form,
     isShowLoding,
     timeout,
-    header
+    header,
+    useParams
   } = _options
+
+  // 妫�鏌rl鏄惁涓簎ndefined
+  if (!url) {
+    console.error('璇锋眰URL涓嶈兘涓虹┖');
+    return Promise.reject(new Error('璇锋眰URL涓嶈兘涓虹┖'));
+  }
+
   const app = getApp()
   // 璁剧疆璇锋眰澶�
   if (form) {
@@ -58,7 +66,7 @@
   return new Promise((resolve, reject) => {
     // 鑾峰彇鏈�鏂扮殑 BASEURL
     let currentBaseUrl = app.globalData.baseUrl || config.BASEURL;
-    
+
     console.log("url:" + currentBaseUrl + url);
     if (isShowLoding) {
       wx.showLoading({
@@ -71,6 +79,12 @@
       myUrl = url;
     } else {
       myUrl = currentBaseUrl + url;
+    }
+    // 濡傛灉 useParams 涓� true锛屾嫾鎺ユ煡璇㈠弬鏁�
+    if (useParams && data) {
+      const queryString = objToQueryString(data); // 浣跨敤涓婇潰瀹氫箟鐨勫嚱鏁�
+      myUrl += `?${queryString}`; // 鎷兼帴鏌ヨ瀛楃涓�
+      data = {}; // 璇锋眰浣撴暟鎹涓虹┖
     }
     wx.request({
       url: myUrl,
@@ -116,7 +130,14 @@
     })
   })
 }
-
+function objToQueryString(obj) {
+  return Object.keys(obj)
+      .map(key => {
+          // 瀵归敭鍜屽�艰繘琛� URL 缂栫爜
+          return `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`;
+      })
+      .join('&'); // 灏嗘墍鏈夐敭鍊煎鐢� '&' 杩炴帴璧锋潵
+}
 // 灏佽toast鍑芥暟
 function showToast(title, icon = 'none', duration = 2500, mask = false) {
   wx.showToast({
diff --git a/app.js b/app.js
index ed3fbd2..ae3b8f1 100644
--- a/app.js
+++ b/app.js
@@ -23,6 +23,7 @@
     token:"",
     isLoggedIn:false,
     operator:"2025030416200600006",
+    clientId:"",
     AppID:"wxbc2b6a00dd904ead"
   }
 })
diff --git a/app.json b/app.json
index c133742..4d1ea1c 100644
--- a/app.json
+++ b/app.json
@@ -1,8 +1,6 @@
 {
   "pages": [
-    "pages/irrigation/irrigation",
-    "pages/createIrrigation/createIrrigation",
-    "pages/groupDetail/groupDetail",
+
     "pages/home/home",
     "pages/valveList/valveList",
     "pages/feedback/feedback",
@@ -17,7 +15,11 @@
     "pages/personCharge/personcharge",
     "pages/openCard/openCard",
     "pages/rechargeMoney/rechargMoney",
-    "pages/rechargeCard/rechargeCard"
+    "pages/rechargeCard/rechargeCard",
+    "pages/irrigation/irrigation",
+    "pages/createIrrigation/createIrrigation",
+    "pages/irrigationDetail/irrigationDetail",
+    "pages/groupDetail/groupDetail"
   ],
   "window": {
     "navigationBarTextStyle": "white",
diff --git a/images/irrigation.svg b/images/irrigation.svg
new file mode 100644
index 0000000..a5b16b6
--- /dev/null
+++ b/images/irrigation.svg
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><svg width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14 6.67578C8.02198 10.1339 4 16.5973 4 24.0001M14 6.67578V14.0001M14 6.67578H6.67564" stroke="#4090FF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M6.67564 34C10.1337 39.978 16.5972 44 24 44M6.67564 34H14M6.67564 34V41.3244" stroke="#4090FF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M34 41.3244C39.978 37.8663 44 31.4028 44 24M34 41.3244V34M34 41.3244H41.3244" stroke="#4090FF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M41.3242 14C37.8661 8.02199 31.4027 4 23.9999 4M41.3242 14H33.9999M41.3242 14V6.67564" stroke="#4090FF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></svg>
\ No newline at end of file
diff --git a/pages/createIrrigation/createIrrigation.wxml b/pages/createIrrigation/createIrrigation.wxml
index e1a77ca..5ba5323 100644
--- a/pages/createIrrigation/createIrrigation.wxml
+++ b/pages/createIrrigation/createIrrigation.wxml
@@ -34,8 +34,8 @@
           <!-- 杞亴缁勫垪琛� -->
           <view class="group-list {{item.expanded ? 'expanded' : ''}}">
             <block wx:for="{{item.groups}}" wx:for-item="group" wx:for-index="groupIndex" wx:key="id">
-              <view class="group-item {{group.selected ? 'selected' : ''}}">
-                <view class="group-info" bindtap="navigateToGroupDetail" data-project-index="{{index}}" data-group-index="{{groupIndex}}">
+              <view class="group-item {{group.selected ? 'selected' : ''}}" bindtap="navigateToGroupDetail" data-project-index="{{index}}" data-group-index="{{groupIndex}}">
+                <view class="group-info"  >
                   <view class="group-name">{{group.name}}</view>
                 </view>
                 <view class="group-duration">
diff --git a/pages/createIrrigation/createIrrigation.wxss b/pages/createIrrigation/createIrrigation.wxss
index 93c27a6..e91a1ec 100644
--- a/pages/createIrrigation/createIrrigation.wxss
+++ b/pages/createIrrigation/createIrrigation.wxss
@@ -162,6 +162,25 @@
   align-items: center;
   padding: 25rpx 30rpx;
   border-top: 1rpx solid #eee;
+  position: relative;
+  transition: all 0.3s ease;
+}
+
+.group-item::after {
+  content: '';
+  position: absolute;
+  right: 15rpx;
+  top: 50%;
+  transform: translateY(-50%);
+  width: 16rpx;
+  height: 16rpx;
+  border-top: 2rpx solid #999;
+  border-right: 2rpx solid #999;
+  transform: translateY(-50%) rotate(45deg);
+}
+
+.group-item:active {
+  background-color: #e6f7ff;
 }
 
 .group-item.selected {
@@ -172,16 +191,44 @@
   flex: 1;
   display: flex;
   align-items: center;
+  flex-wrap: wrap;
 }
 
 .group-name {
   font-size: 26rpx;
   color: #666;
+  position: relative;
+  padding-left: 10rpx;
+  background-color: rgba(24, 144, 255, 0.1);
+  padding: 4rpx 20rpx;
+  border-radius: 10rpx;
 }
+
+.group-hint {
+  font-size: 22rpx;
+  color: #1890FF;
+  margin-left: 10rpx;
+  background-color: rgba(24, 144, 255, 0.1);
+  padding: 4rpx 10rpx;
+  border-radius: 10rpx;
+}
+
+/* .group-name::before {
+  content: '';
+  position: absolute;
+  left: 0;
+  top: 50%;
+  transform: translateY(-50%);
+  width: 6rpx;
+  height: 6rpx;
+  background-color: #1890FF;
+  border-radius: 50%;
+} */
 
 .group-duration {
   display: flex;
   align-items: center;
+  margin-right: 20rpx; /* 涓哄彸渚х澶寸暀鍑虹┖闂� */
 }
 
 .duration-input {
diff --git a/pages/groupDetail/groupDetail.js b/pages/groupDetail/groupDetail.js
index ad8fb75..f663689 100644
--- a/pages/groupDetail/groupDetail.js
+++ b/pages/groupDetail/groupDetail.js
@@ -5,79 +5,179 @@
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
-    projectId: '',
     projectName: '',
-    groupId: '',
     groupName: '',
-    valveList: [
-      // 妯℃嫙鏁版嵁锛屽疄闄呭簲浠嶢PI鑾峰彇
-      { id: '1', name: '闃�鎺у櫒1', status: 'online', location: '浣嶇疆A' },
-      { id: '2', name: '闃�鎺у櫒2', status: 'offline', location: '浣嶇疆B' },
-      { id: '3', name: '闃�鎺у櫒3', status: 'online', location: '浣嶇疆C' },
-      { id: '4', name: '闃�鎺у櫒4', status: 'online', location: '浣嶇疆D' },
-      { id: '5', name: '闃�鎺у櫒5', status: 'offline', location: '浣嶇疆E' }
-    ],
-    loading: false
+    groupId: '',
+    waterOutletList: [],
+    refreshing: false,
+    isIrrigating: false // 鏄惁姝e湪鐏屾簤涓�
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad: function (options) {
+    console.log('鎺ユ敹鍒扮殑鍙傛暟:', options);
+    
     if (options) {
+      // 鐩存帴浣跨敤浼犻�掔殑isIrrigating鍙傛暟锛岃�屼笉鏄牴鎹畇tatus鍒ゆ柇
+      const isIrrigating = options.isIrrigating === 'true';
+      console.log('鐏屾簤鐘舵�佸垽鏂�:', options.status, '鏄惁姝e湪鐏屾簤:', isIrrigating);
+      
+      // 澶勭悊鎺ユ敹鍒扮殑鍙傛暟
       this.setData({
-        projectId: options.projectId || '',
         projectName: options.projectName || '',
+        groupName: options.groupName || '',
         groupId: options.groupId || '',
-        groupName: options.groupName || ''
+        isIrrigating: isIrrigating
       });
       
+      console.log('璁剧疆鍚庣殑鏁版嵁:', this.data);
+      
+      // 璁剧疆瀵艰埅鏍忔爣棰�
       wx.setNavigationBarTitle({
         title: this.data.groupName || '杞亴缁勮鎯�'
       });
       
-      // 鑾峰彇闃�鎺у櫒鍒楄〃
-      this.fetchValveList();
+      this.loadWaterOutletData();
     }
   },
 
   /**
-   * 鑾峰彇闃�鎺у櫒鍒楄〃
+   * 鍔犺浇鍙栨按鍙f暟鎹�
    */
-  fetchValveList: function () {
-    this.setData({ loading: true });
+  loadWaterOutletData: function() {
+    this.setData({
+      refreshing: true
+    });
     
-    // 杩欓噷搴旇鏄疄闄呯殑API璇锋眰
-    // 妯℃嫙API璇锋眰寤惰繜
+    console.log('鍔犺浇鍙栨按鍙f暟鎹紝鐏屾簤鐘舵��:', this.data.isIrrigating);
+    
+    // 妯℃嫙鏁版嵁
+    let mockData = {
+      waterOutlets: []
+    };
+    
+    // 鐢熸垚鍙栨按鍙f暟鎹紝鎵�鏈夊彇姘村彛閮芥湁鍛戒护鐘舵��
+    mockData.waterOutlets = [
+      {
+        id: 1,
+        name: '鍙栨按鍙� A-1',
+        status: 'online',
+        commandStatus: 'sent' // 鍛戒护宸蹭笅鍙�
+      },
+      {
+        id: 2,
+        name: '鍙栨按鍙� A-2',
+        status: 'online',
+        commandStatus: 'unsent' // 鍛戒护鏈笅鍙�
+      },
+      {
+        id: 3,
+        name: '鍙栨按鍙� A-3',
+        status: 'offline',
+        commandStatus: 'unsent' // 鍛戒护鏈笅鍙�
+      }
+    ];
+    
+    // 妯℃嫙缃戠粶璇锋眰寤惰繜
     setTimeout(() => {
-      this.setData({ loading: false });
-      // 瀹為檯鏁版嵁宸插湪data涓垵濮嬪寲锛岃繖閲屽彧鏄ā鎷熻姹傚畬鎴�
+      this.setData({
+        waterOutletList: mockData.waterOutlets,
+        refreshing: false
+      });
+      console.log('璁剧疆鍙栨按鍙f暟鎹畬鎴�:', this.data.waterOutletList);
     }, 1000);
     
-    // 瀹為檯API璇锋眰绀轰緥
+    // 瀹為檯椤圭洰涓簲璇ヤ娇鐢╳x.request鑾峰彇鏁版嵁
     // wx.request({
-    //   url: 'your-api-url',
-    //   data: {
-    //     projectId: this.data.projectId,
-    //     groupId: this.data.groupId
-    //   },
+    //   url: `https://your-api-url/groups/${this.data.groupId}/waterOutlets`,
+    //   method: 'GET',
     //   success: (res) => {
-    //     this.setData({
-    //       valveList: res.data,
-    //       loading: false
-    //     });
+    //     if (res.data && res.data.code === 0) {
+    //       this.setData({
+    //         waterOutletList: res.data.data.waterOutlets,
+    //         refreshing: false
+    //       });
+    //     } else {
+    //       wx.showToast({
+    //         title: '鑾峰彇鏁版嵁澶辫触',
+    //         icon: 'none'
+    //       });
+    //       this.setData({
+    //         refreshing: false
+    //       });
+    //     }
     //   },
     //   fail: () => {
-    //     this.setData({ loading: false });
     //     wx.showToast({
-    //       title: '鑾峰彇鏁版嵁澶辫触',
+    //       title: '缃戠粶閿欒',
     //       icon: 'none'
+    //     });
+    //     this.setData({
+    //       refreshing: false
     //     });
     //   }
     // });
   },
 
   /**
+   * 涓嬫媺鍒锋柊澶勭悊鍑芥暟
+   */
+  onRefresh: function() {
+    this.loadWaterOutletData();
+  },
+
+  /**
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
+   */
+  onPullDownRefresh: function () {
+    
+  },
+
+  /**
+   * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
+   */
+  onShareAppMessage: function () {
+
+  },
+
+  /**
    * 杩斿洖涓婁竴椤�
    */
   goBack: function () {
diff --git a/pages/groupDetail/groupDetail.wxml b/pages/groupDetail/groupDetail.wxml
index a024557..512385b 100644
--- a/pages/groupDetail/groupDetail.wxml
+++ b/pages/groupDetail/groupDetail.wxml
@@ -9,40 +9,49 @@
     </view>
   </view>
 
-  <!-- 闃�鎺у櫒鍒楄〃 -->
+  <!-- 鍙栨按鍙e垪琛� -->
   <view class="valve-list-container">
-    <view class="section-title">鍙栨按鍙i榾鎺у櫒鍒楄〃</view>
-    
-    <!-- 鍔犺浇涓� -->
+ 
+    <!-- 鍔犺浇涓�
     <view class="loading-container" wx:if="{{loading}}">
       <view class="loading-icon"></view>
       <view class="loading-text">鍔犺浇涓�...</view>
-    </view>
+    </view> -->
     
-    <!-- 闃�鎺у櫒鍒楄〃 -->
-    <view class="valve-list" wx:else>
-      <block wx:for="{{valveList}}" wx:key="id">
+    <!-- 鍙栨按鍙e垪琛� - 鍙笅鎷夊埛鏂扮殑scroll-view -->
+    <scroll-view 
+      class="valve-list" 
+      scroll-y="true"
+      refresher-enabled="{{true}}"
+      refresher-threshold="50"
+      refresher-default-style="black"
+      refresher-background="#f2f2f2"
+      refresher-triggered="{{refreshing}}"
+      bindrefresherrefresh="onRefresh"
+     >
+      <block wx:for="{{waterOutletList}}" wx:key="id">
         <view class="valve-item">
           <view class="valve-info">
-            <view class="valve-name">{{item.name}}</view>
-            <view class="valve-location">{{item.location}}</view>
+            <view class="valve-name">
+              <text>{{item.name}}</text>
+              <view class="valve-status-inline {{item.status === 'online' ? 'online' : 'offline'}}">
+                {{item.status === 'online' ? '鍦ㄧ嚎' : '绂荤嚎'}}
+              </view>
+            </view>
           </view>
-          <view class="valve-status {{item.status === 'online' ? 'online' : 'offline'}}">
-            {{item.status === 'online' ? '鍦ㄧ嚎' : '绂荤嚎'}}
+          <view class="command-status {{item.commandStatus}}">
+            {{item.commandStatus === 'sent' ? '鍛戒护宸蹭笅鍙�' : '鍛戒护鏈笅鍙�'}}
           </view>
         </view>
       </block>
-    </view>
-    
-    <!-- 绌虹姸鎬� -->
-    <view class="empty-state" wx:if="{{!loading && valveList.length === 0}}">
-      <image class="empty-icon" src="/images/empty.svg" mode="aspectFit"></image>
-      <view class="empty-text">鏆傛棤闃�鎺у櫒鏁版嵁</view>
-    </view>
+      
+      <!-- 绌虹姸鎬� -->
+      <view class="empty-state" wx:if="{{waterOutletList.length === 0}}">
+        <image class="empty-icon" src="/images/empty.svg" mode="aspectFit"></image>
+        <view class="empty-text">鏆傛棤鍙栨按鍙f暟鎹�</view>
+      </view>
+    </scroll-view>
   </view>
 
-  <!-- 搴曢儴鎸夐挳 -->
-  <view class="bottom-button">
-    <button class="back-button" hover-class="back-button-hover" bindtap="goBack">杩斿洖</button>
-  </view>
+
 </view> 
\ No newline at end of file
diff --git a/pages/groupDetail/groupDetail.wxss b/pages/groupDetail/groupDetail.wxss
index c27f91f..b614d46 100644
--- a/pages/groupDetail/groupDetail.wxss
+++ b/pages/groupDetail/groupDetail.wxss
@@ -1,15 +1,16 @@
 .group-detail-container {
   display: flex;
   flex-direction: column;
-  min-height: 100vh;
-  background-color: #f5f5f5;
+  height: 100vh;
+  background-color: #F5F5F5;
 }
 
 /* 椤甸潰鏍囬鏍峰紡 */
 .page-header {
-  background-color: #1890FF;
+  background-color: #FFFFFF;
   padding: 30rpx;
-  color: #fff;
+  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
+  margin-bottom: 20rpx;
 }
 
 .header-content {
@@ -23,43 +24,141 @@
 }
 
 .project-name {
-  font-size: 24rpx;
-  opacity: 0.8;
+  font-size: 28rpx;
+  color: #666666;
   margin-bottom: 10rpx;
 }
 
 .group-name {
-  font-size: 32rpx;
-  font-weight: 500;
+  font-size: 36rpx;
+  font-weight: bold;
+  color: #333333;
 }
 
-/* 闃�鎺у櫒鍒楄〃瀹瑰櫒 */
+/* 鍙栨按鍙e垪琛ㄥ鍣� */
 .valve-list-container {
   flex: 1;
-  padding: 30rpx;
+  padding: 0 30rpx;
+  overflow: hidden;
 }
 
-.section-title {
-  font-size: 28rpx;
-  color: #333;
-  font-weight: 500;
+/* 鍙栨按鍙e垪琛� */
+.valve-list {
+  height: 100%;
+}
+
+/* 鍙栨按鍙i」鐩� */
+.valve-item {
+  background-color: #FFFFFF;
+  border-radius: 12rpx;
+  padding: 30rpx;
   margin-bottom: 20rpx;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
+}
+
+.valve-info {
+  flex: 1;
+}
+
+.valve-name {
+  font-size: 32rpx;
+  font-weight: 500;
+  color: #333333;
+  display: flex;
+  align-items: center;
+  flex-wrap: wrap;
+}
+
+.valve-status-container {
+  display: flex;
+  flex-direction: column;
+  align-items: flex-end;
+}
+
+.valve-status {
+  padding: 8rpx 20rpx;
+  border-radius: 30rpx;
+  font-size: 24rpx;
+  font-weight: 500;
+  margin-bottom: 10rpx;
+}
+
+.valve-status.online {
+  background-color: rgba(82, 196, 26, 0.1);
+  color: #52C41A;
+}
+
+.valve-status.offline {
+  background-color: rgba(245, 34, 45, 0.1);
+  color: #F5222D;
+}
+
+/* 鍐呰仈鐘舵�佹牱寮� */
+.valve-status-inline {
+  font-size: 24rpx;
+  font-weight: 500;
+  padding: 4rpx 12rpx;
+  border-radius: 20rpx;
+  margin-left: 12rpx;
+  display: inline-flex;
+  align-items: center;
+  justify-content: center;
+  height: 32rpx;
+  line-height: 1;
+}
+
+.valve-status-inline.online {
+  background-color: rgba(82, 196, 26, 0.1);
+  color: #52C41A;
+}
+
+.valve-status-inline.offline {
+  background-color: rgba(245, 34, 45, 0.1);
+  color: #F5222D;
+}
+
+/* 鍛戒护鐘舵�佹牱寮� */
+.command-status {
+  padding: 8rpx 20rpx;
+  border-radius: 30rpx;
+  font-size: 24rpx;
+  font-weight: 500;
+  text-align: center;
+  min-width: 160rpx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  height: 40rpx;
+  line-height: 1;
+}
+
+.command-status.sent {
+  background-color: rgba(82, 196, 26, 0.1);
+  color: #52C41A;
+}
+
+.command-status.unsent {
+  background-color: rgba(250, 173, 20, 0.1);
+  color: #FAAD14;
 }
 
 /* 鍔犺浇涓牱寮� */
 .loading-container {
   display: flex;
   flex-direction: column;
-  align-items: center;
   justify-content: center;
-  padding: 60rpx 0;
+  align-items: center;
+  height: 300rpx;
 }
 
 .loading-icon {
-  width: 60rpx;
-  height: 60rpx;
-  border: 4rpx solid #f3f3f3;
-  border-top: 4rpx solid #1890FF;
+  width: 80rpx;
+  height: 80rpx;
+  border: 6rpx solid #f3f3f3;
+  border-top: 6rpx solid #3498db;
   border-radius: 50%;
   animation: spin 1s linear infinite;
   margin-bottom: 20rpx;
@@ -71,67 +170,17 @@
 }
 
 .loading-text {
-  font-size: 26rpx;
-  color: #999;
-}
-
-/* 闃�鎺у櫒鍒楄〃鏍峰紡 */
-.valve-list {
-  display: flex;
-  flex-direction: column;
-}
-
-.valve-item {
-  display: flex;
-  justify-content: space-between;
-  align-items: center;
-  padding: 30rpx;
-  background-color: #fff;
-  margin-bottom: 20rpx;
-  border-radius: 8rpx;
-  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
-}
-
-.valve-info {
-  display: flex;
-  flex-direction: column;
-}
-
-.valve-name {
   font-size: 28rpx;
-  color: #333;
-  margin-bottom: 10rpx;
-  font-weight: 500;
-}
-
-.valve-location {
-  font-size: 24rpx;
-  color: #999;
-}
-
-.valve-status {
-  padding: 8rpx 20rpx;
-  border-radius: 30rpx;
-  font-size: 24rpx;
-}
-
-.valve-status.online {
-  background-color: #e6f7ff;
-  color: #1890FF;
-}
-
-.valve-status.offline {
-  background-color: #fff1f0;
-  color: #f5222d;
+  color: #666666;
 }
 
 /* 绌虹姸鎬佹牱寮� */
 .empty-state {
   display: flex;
   flex-direction: column;
-  align-items: center;
   justify-content: center;
-  padding: 100rpx 0;
+  align-items: center;
+  height: 400rpx;
 }
 
 .empty-icon {
@@ -141,8 +190,8 @@
 }
 
 .empty-text {
-  font-size: 26rpx;
-  color: #999;
+  font-size: 28rpx;
+  color: #999999;
 }
 
 /* 搴曢儴鎸夐挳鏍峰紡 */
diff --git a/pages/home/home.js b/pages/home/home.js
index d38e37d..080656a 100644
--- a/pages/home/home.js
+++ b/pages/home/home.js
@@ -4,7 +4,9 @@
   get,
   post
 } = require('../../api/request.js');
-const { PROJECT_URLS } = require('../../api/config.js');
+const {
+  PROJECT_URLS
+} = require('../../api/config.js');
 Page({
 
   /**
@@ -17,7 +19,7 @@
     waterIntakeName: "",
     image: "/images/ic_head_bg.jpg",
     userPhone: "",
-    userName: "璇风櫥褰�",
+    userName: "璇风偣鍑荤櫥褰�",
     scrollViewHeight: 0,
     listData: [],
     isRefreshing: false,
@@ -32,13 +34,22 @@
     lastIntakeName: "",
     showProjectDialog: false,
     selectedProject: '',
-    avatarTapCount: 0
+    avatarTapCount: 0,
+    isFromLogin: false
   },
 
   openValve: function (e) {
-    wx.navigateTo({
-      url: '/pages/waterIntake/waterIntake',
-    })
+    const app = getApp();
+    if (app.globalData.isLoggedIn) {
+      wx.navigateTo({
+        url: '/pages/waterIntake/waterIntake',
+      })
+    } else {
+      wx.showToast({
+        title: '璇峰厛鐧诲綍',
+        icon: 'error'
+      })
+    }
   },
   calculateScrollViewHeight: function () {
     wx.createSelectorQuery().selectAll('.list-item').boundingClientRect((rects) => {
@@ -79,67 +90,171 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad(options) {
-    // 妫�鏌ユ槸鍚﹀凡閫夋嫨椤圭洰
-    const { PROJECT_URLS } = require('../../api/config.js');
-    
-    storage.getItem('selectedProject').then((project) => {
-      if (project) {
-        this.setData({
-          selectedProject: project
-        });
-        
-        // 纭繚鍏ㄥ眬鍙橀噺瀛樺湪
-        getApp().globalData = getApp().globalData || {};
-        // 璁剧疆 baseUrl
-        const baseUrl = PROJECT_URLS[project];
-        getApp().globalData.baseUrl = baseUrl;
-        getApp().globalData.selectedProject = project;
-        
-        // 鏍规嵁椤圭洰璁剧疆瀵瑰簲鐨則ag
-        if (project === 'JYG') {
-          getApp().globalData.tag = 'ym'; // 鍢夊唱鍏抽」鐩搴攖ag涓簓m
-        } else if (project === 'MQ') {
-          getApp().globalData.tag = 'mq'; // 姘戝嫟椤圭洰瀵瑰簲tag涓簃q
-        }
-        
-        console.log('鍔犺浇宸蹭繚瀛樼殑椤圭洰:', project, '鍩熷悕:', baseUrl, 'tag:', getApp().globalData.tag);
-        
-        // 妫�鏌ョ櫥褰曠姸鎬�
-        if (!getApp().globalData.isLoggedIn) {
-          this.checkLoginStatus();
-          return; // 濡傛灉鏈櫥褰曪紝绛夊緟璺宠浆鍒扮櫥褰曢〉闈�
-        }
-      } else {
-        // 棣栨杩涘叆锛屾樉绀洪」鐩�夋嫨寮圭獥
-        this.setData({
-          showProjectDialog: true
-        });
-        return; // 绛夊緟鐢ㄦ埛閫夋嫨椤圭洰
+    console.log('home椤甸潰onLoad寮�濮嬶紝鍙傛暟:', options);
+
+    // 妫�鏌ユ槸鍚︿粠鐧诲綍椤甸潰杩斿洖
+    let fromLogin = false;
+
+    // 妫�鏌RL鍙傛暟
+    if (options && options.fromLogin === 'true') {
+      console.log('妫�娴嬪埌URL鍙傛暟fromLogin=true');
+      fromLogin = true;
+    }
+
+    // 妫�鏌ユ槸鍚︽湁涓存椂鏍囪
+    try {
+      const tempFromLogin = wx.getStorageSync('_temp_from_login');
+      console.log('璇诲彇鍒扮殑涓存椂鏍囪鍊�:', tempFromLogin);
+
+      if (tempFromLogin === 'true') {
+        console.log('妫�娴嬪埌涓存椂fromLogin鏍囪');
+        fromLogin = true;
+
+        // 寤惰繜娓呴櫎涓存椂鏍囪锛岀‘淇濆叾浠栧湴鏂规湁瓒冲鏃堕棿璇诲彇
+        setTimeout(() => {
+          try {
+            wx.removeStorageSync('_temp_from_login');
+            console.log('鑷姩娓呴櫎涓存椂fromLogin鏍囪');
+          } catch (e) {
+            console.error('娓呴櫎涓存椂鏍囪澶辫触:', e);
+          }
+        }, 10000); // 寤堕暱鍒�10绉�
       }
-      
-      //鍒ゆ柇鏈湴鏄惁淇濆瓨sessionId
-      // 浣跨敤 wx.nextTick 绛夊緟椤甸潰娓叉煋瀹屾垚
-      wx.nextTick(() => {
-        this.calculateScrollViewHeight();
-      });
-      //褰撳紑闃�鎴愬姛鍚庤皟鐢ㄥ埛鏂�
-      console.log("onLoad锛�" + options.param);
-      if (options.param) {
-        wx.showToast({
-          title: '寮�闃�鎴愬姛',
-          icon: 'success',
-          duration: 3000
-        })
-        this.getOpenList();
-      }
-      this.initData();
-    }).catch(err => {
-      console.error('Failed to get selectedProject:', err);
-      // 鍑洪敊鏃朵篃鏄剧ず椤圭洰閫夋嫨寮圭獥
+    } catch (e) {
+      console.error('璇诲彇涓存椂鏍囪澶辫触:', e);
+    }
+
+    console.log('home椤甸潰鍔犺浇锛宖romLogin:', fromLogin, '鍙傛暟:', options);
+
+    // 璁剧疆fromLogin鏍囧織
+    if (fromLogin) {
+      console.log('璁剧疆isFromLogin=true');
       this.setData({
-        showProjectDialog: true
+        isFromLogin: true
       });
-    });
+    }
+
+    // 寤惰繜鎵ц鍓╀綑鐨勫垵濮嬪寲杩囩▼锛屼互纭繚涓存椂鏍囪鍜孶RL鍙傛暟鑳借姝g‘澶勭悊
+    setTimeout(() => {
+      this.initializePage(options, fromLogin);
+    }, 100);
+  },
+
+  // 鏂板鐨勫垵濮嬪寲椤甸潰杈呭姪鍑芥暟锛屽垎绂诲嚭onLoad涓殑閫昏緫浠ヤ究寤惰繜鎵ц
+  initializePage(options, fromLogin) {
+    // 妫�鏌ユ槸鍚﹀凡閫夋嫨椤圭洰
+    const {
+      PROJECT_URLS
+    } = require('../../api/config.js');
+
+    // 纭繚鍏ㄥ眬鍙橀噺瀛樺湪
+    getApp().globalData = getApp().globalData || {};
+
+    storage.getItemSafe('selectedProject')
+      .then((project) => {
+        if (project) {
+          this.setData({
+            selectedProject: project
+          });
+
+          // 璁剧疆 baseUrl
+          const baseUrl = PROJECT_URLS[project];
+          getApp().globalData.baseUrl = baseUrl;
+          getApp().globalData.selectedProject = project;
+
+          // 鏍规嵁椤圭洰璁剧疆瀵瑰簲鐨則ag
+          if (project === 'JYG') {
+            getApp().globalData.tag = 'ym'; // 鍢夊唱鍏抽」鐩搴攖ag涓簓m
+          } else if (project === 'MQ') {
+            getApp().globalData.tag = 'mq'; // 姘戝嫟椤圭洰瀵瑰簲tag涓簃q
+          }
+
+          console.log('鍔犺浇宸蹭繚瀛樼殑椤圭洰:', project, '鍩熷悕:', baseUrl, 'tag:', getApp().globalData.tag);
+
+          // 妫�鏌essionId鏄惁瀛樺湪
+          return storage.getItemSafe('sessionId');
+        } else {
+          // 棣栨杩涘叆锛屾樉绀洪」鐩�夋嫨寮圭獥
+          this.setData({
+            showProjectDialog: true
+          });
+          return Promise.reject({
+            type: 'project_not_selected',
+            message: '鏈�夋嫨椤圭洰'
+          }); // 缁堟鍚庣画澶勭悊
+        }
+      })
+      .then(sessionId => {
+        if (sessionId) {
+          // 濡傛灉sessionId瀛樺湪锛岃缃叏灞�鐧诲綍鐘舵��
+          getApp().globalData.sessionId = sessionId;
+          getApp().globalData.isLoggedIn = true;
+
+          // 灏濊瘯鑾峰彇clientId
+          return storage.getItemSafe('clientId');
+        } else {
+          return Promise.reject({
+            type: 'session_not_found',
+            message: '鏈壘鍒皊essionId'
+          });
+        }
+      })
+      .then(clientId => {
+        if (clientId) {
+          getApp().globalData.clientId = clientId;
+        }
+
+        // 缁х画鍒濆鍖栭〉闈�
+        this.continueInitPage(options);
+      })
+      .catch(err => {
+        // 灏嗛敊璇璞¤鑼冨寲
+        const error = typeof err === 'object' ? err : {
+          type: 'unknown',
+          message: String(err)
+        };
+        console.log('鑾峰彇瀛樺偍鏁版嵁涓柇:', error.message);
+
+        // 濡傛灉鏄粠鐧诲綍椤佃繑鍥炴垨宸茬櫥褰曪紝涓嶅啀璺宠浆
+        if (fromLogin || getApp().globalData.isLoggedIn) {
+          console.log('浠庣櫥褰曢〉杩斿洖鎴栧凡鐧诲綍锛岀户缁垵濮嬪寲椤甸潰');
+          this.continueInitPage(options);
+          return;
+        }
+
+        // 澶勭悊鏈�夋嫨椤圭洰鐨勬儏鍐�
+        if (error.type === 'project_not_selected') {
+          console.log('鏈�夋嫨椤圭洰锛屾樉绀洪」鐩�夋嫨寮圭獥');
+          this.setData({
+            showProjectDialog: true
+          });
+          return;
+        }
+
+        // 澶勭悊鏈壘鍒皊essionId鐨勬儏鍐�
+        if (error.type === 'session_not_found' && this.data.selectedProject) {
+          // 妫�鏌ユ槸鍚﹀凡浠庣櫥褰曢〉杩斿洖
+          const isReturning = this.getFromLogin();
+          console.log('鏈壘鍒皊essionId锛屾槸鍚︿粠鐧诲綍椤佃繑鍥�:', isReturning);
+
+          // 濡傛灉宸茬粡鏄粠鐧诲綍椤佃繑鍥炵殑锛屼笉瑕佸啀璺冲洖鍘�
+          if (isReturning) {
+            console.log('宸茬粡浠庣櫥褰曢〉杩斿洖锛屼笉鍐嶈烦杞洖鍘�');
+            this.continueInitPage(options);
+            return;
+          }
+
+          console.log('鏈壘鍒皊essionId锛岃烦杞埌鐧诲綍椤�');
+          wx.redirectTo({
+            url: `/pages/login/login?project=${this.data.selectedProject}`
+          });
+          return;
+        }
+
+        // 鍏朵粬鏈煡閿欒锛屽皾璇曠户缁垵濮嬪寲椤甸潰
+        console.warn('鏈煡閿欒锛屽皾璇曠户缁垵濮嬪寲椤甸潰:', error);
+        this.continueInitPage(options);
+      });
   },
 
   /**
@@ -153,21 +268,83 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
    */
   onShow() {
+    console.log('home椤甸潰onShow寮�濮�');
 
+    // 鑾峰彇褰撳墠椤甸潰鐨勫弬鏁�
+    const pages = getCurrentPages();
+    const currentPage = pages[pages.length - 1];
+
+    let fromLogin = false;
+
+    // 妫�鏌ユ槸鍚︽湁fromLogin鍙傛暟
+    if (currentPage && currentPage.options && currentPage.options.fromLogin === 'true') {
+      console.log('onShow: 妫�娴嬪埌fromLogin鍙傛暟锛岃缃甶sFromLogin鏍囪');
+      fromLogin = true;
+      this.setData({
+        isFromLogin: true
+      });
+    }
+
+    // 妫�鏌ユ槸鍚︽湁涓存椂鏍囪
+    try {
+      const tempFromLogin = wx.getStorageSync('_temp_from_login');
+      console.log('onShow: 璇诲彇鍒扮殑涓存椂鏍囪鍊�:', tempFromLogin);
+
+      if (tempFromLogin === 'true') {
+        console.log('onShow: 妫�娴嬪埌涓存椂fromLogin鏍囪');
+        fromLogin = true;
+        this.setData({
+          isFromLogin: true
+        });
+      }
+    } catch (e) {
+      console.error('onShow: 璇诲彇涓存椂鏍囪澶辫触:', e);
+    }
+
+    // 鍒濆鍖栧鐞�
+    if (fromLogin || this.data.isFromLogin) {
+      console.log('onShow: 浠庣櫥褰曢〉杩斿洖锛屼笉杩涜鐧诲綍妫�鏌�');
+    } else {
+      console.log('onShow: 姝e父鏄剧ず椤甸潰');
+      // 寤惰繜妫�鏌ョ櫥褰曠姸鎬侊紝纭繚鑳芥纭瘑鍒复鏃舵爣璁�
+      setTimeout(() => {
+        this.checkLoginStatusIfNeeded();
+      }, 300);
+    }
+  },
+
+  // 妫�鏌ョ櫥褰曠姸鎬侊紙浠呭湪闇�瑕佹椂锛�
+  checkLoginStatusIfNeeded() {
+    // 鍐嶆纭鏄惁浠庣櫥褰曢〉杩斿洖
+    if (this.getFromLogin()) {
+      console.log('妫�娴嬪埌浠庣櫥褰曢〉杩斿洖鐨勬爣璁帮紝涓嶈繘琛岀櫥褰曟鏌�');
+      return;
+    }
+
+    // 鍐嶆妫�鏌ュ叏灞�鐧诲綍鐘舵��
+    if (getApp().globalData.isLoggedIn) {
+      console.log('妫�娴嬪埌鍏ㄥ眬鐧诲綍鐘舵�侊紝涓嶈繘琛岀櫥褰曟鏌�');
+      return;
+    }
+
+    console.log('鎵ц鐧诲綍鐘舵�佹鏌�');
+    this.checkLoginStatus();
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
    */
   onHide() {
-
+    // 椤甸潰闅愯棌鏃惰�冭檻娓呯悊涓存椂鏍囪
+    this.cleanupTempMarkers();
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
    */
   onUnload() {
-
+    // 椤甸潰鍗歌浇鏃舵竻鐞嗕复鏃舵爣璁�
+    this.cleanupTempMarkers();
   },
 
   /**
@@ -222,6 +399,24 @@
       icon: 'none'
     })
   },
+  //瑙g粦鐢ㄦ埛
+  unbind() {
+    wx.showModal({
+      title: '瑙g粦纭',
+      content: '纭畾瑕佽В缁戝綋鍓嶈处鍙峰悧锛�',
+      success: (res) => {
+        if (res.confirm) {
+          this.unBindPost()
+        }
+      }
+    });
+  },
+  //杞亴
+  irrigation() {
+    wx.navigateTo({
+      url: '/pages/irrigation/irrigation',
+    })
+  },
   handleChange(e) {
     const item = e.currentTarget.dataset.item;
     console.log(item);
@@ -261,7 +456,7 @@
       rtuAddr: rtuAddr,
       vcNum: vcNum, //铏氭嫙鍗D
       orderNo: orderNo,
-      operator: app.globalData.operator //鎿嶄綔鍛�
+      operator: app.globalData.clientId //鎿嶄綔鍛�
     };
     console.log("postCloseValaue" + data);
     post({
@@ -298,29 +493,83 @@
    */
   getOpenList() {
     const app = getApp();
+
+    // 妫�鏌ユ槸鍚︿粠鐧诲綍椤佃繑鍥�
+    const fromLogin = this.getFromLogin();
+
+    // 妫�鏌lientId鏄惁瀛樺湪
+    if (!app.globalData.clientId) {
+      console.log('getOpenList: clientId涓嶅瓨鍦紝涓嶆墽琛孉PI璇锋眰');
+
+      // 濡傛灉鏄粠鐧诲綍椤佃繑鍥烇紝灏辨樉绀虹┖鍒楄〃鑰屼笉鏄敊璇彁绀�
+      this.setData({
+        listData: [],
+        isRefreshing: false,
+        isWXRefreshing: false
+      });
+
+      // 濡傛灉涓嶆槸浠庣櫥褰曢〉杩斿洖涓斾笉澶勪簬鍒锋柊鐘舵�侊紝鑰冭檻妫�鏌ョ櫥褰曠姸鎬�
+      if (!fromLogin && !this.data.isRefreshing && !this.data.isWXRefreshing) {
+        console.log('getOpenList: 闈炲埛鏂扮姸鎬佷笅妫�娴嬪埌鏃燾lientId锛屽皾璇曡嚜鍔ㄧ櫥褰�');
+        // 寤惰繜璋冪敤寰俊鐧诲綍锛屽皾璇曡嚜鍔ㄦ仮澶嶄細璇�
+        setTimeout(() => {
+          if (!getApp().globalData.clientId && !this.getFromLogin()) {
+            this.wxLogin();
+          }
+        }, 1000);
+      }
+      return;
+    }
+
+    console.log('getOpenList: 寮�濮嬭幏鍙栧垪琛ㄦ暟鎹�, clientId:', app.globalData.clientId);
+
     const params = {
       url: 'wx/valve/get',
       data: {
-        operator: app.globalData.operator
+        operator: app.globalData.clientId
       }
     };
+
     get(params).then(data => {
+      console.log('鑾峰彇鍒楄〃鏁版嵁鎴愬姛:', data);
       this.setData({
         listData: data.content,
         isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
         isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
-      })
+      });
+
+      // 鎴愬姛鑾峰彇鏁版嵁鍚庡埛鏂癠I楂樺害
+      setTimeout(() => {
+        this.calculateScrollViewHeight();
+      }, 200);
     }).catch(err => {
+      console.error('鑾峰彇鍒楄〃鏁版嵁澶辫触:', err);
       // 閿欒鍥炶皟
       this.setData({
         isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
         isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
-      })
-      wx.showToast({
-        title: err.msg,
-        icon: 'error',
-        duration: 3000
-      })
+      });
+
+      // 妫�鏌ラ敊璇被鍨�
+      if (err && err.code === '0003') {
+        console.log('浼氳瘽鏃犳晥鎴栬繃鏈燂紝浣嗕笉杩涜璺宠浆');
+
+        // 濡傛灉涓嶆槸浠庣櫥褰曢〉杩斿洖锛屾樉绀洪敊璇彁绀�
+        if (!fromLogin) {
+          wx.showToast({
+            title: '鐧诲綍宸茶繃鏈燂紝璇峰埛鏂伴噸璇�',
+            icon: 'none',
+            duration: 3000
+          });
+        }
+      } else {
+        // 涓�鑸敊璇紝鏄剧ず閿欒淇℃伅
+        wx.showToast({
+          title: err.msg || '鑾峰彇鍒楄〃鏁版嵁澶辫触',
+          icon: 'none',
+          duration: 3000
+        });
+      }
     });
   },
   /**
@@ -335,26 +584,65 @@
   },
   //鏍规嵁session鑾峰彇鍐滄埛淇℃伅
   getUserDataBySession() {
+    // 鍏堟鏌ユ槸鍚︿粠鐧诲綍椤佃繑鍥�
+    if (this.getFromLogin()) {
+      console.log('getUserDataBySession: 妫�娴嬪埌浠庣櫥褰曢〉杩斿洖鐨勬爣璁帮紝涓嶆墽琛孉PI璇锋眰');
+      return;
+    }
+
     const app = getApp();
+
+    // 妫�鏌ユ槸鍚︽湁sessionId
+    if (!app.globalData.sessionId) {
+      console.log('getUserDataBySession: sessionId涓嶅瓨鍦紝涓嶆墽琛孉PI璇锋眰');
+      return;
+    }
+
+    console.log('getUserDataBySession: 寮�濮嬭幏鍙栫敤鎴锋暟鎹�, sessionId:', app.globalData.sessionId);
+
     const params = {
       url: 'wx/client/simple_info',
       data: {
         sessionId: app.globalData.sessionId
       }
     };
+
     get(params).then(data => {
+      console.log('鑾峰彇鐢ㄦ埛鏁版嵁鎴愬姛:', data);
       this.setData({
         userName: data.content.clientName,
         userPhone: this.maskPhoneNumber(data.content.phone)
-      })
+      });
     }).catch(err => {
-      // 閿欒鍥炶皟
-      wx.showToast({
-        title: err.msg,
-        icon: 'error',
-        duration: 3000
-      })
-    })
+      console.error('鑾峰彇鐢ㄦ埛鏁版嵁澶辫触:', err);
+      // 閿欒鍥炶皟锛屼絾涓嶈繘琛岄〉闈㈣烦杞�
+
+      // 妫�鏌ラ敊璇被鍨�
+      if (err && err.code === '0003') {
+        console.log('浼氳瘽鏃犳晥鎴栬繃鏈燂紝浣嗕笉杩涜璺宠浆');
+        // 涓嶅啀鐩存帴璺宠浆鍒扮櫥褰曢〉
+
+        // 娓呴櫎浼氳瘽淇℃伅
+        app.globalData.sessionId = '';
+        app.globalData.isLoggedIn = false;
+
+        // 濡傛灉涓嶆槸浠庣櫥褰曢〉杩斿洖锛屾樉绀洪敊璇彁绀�
+        if (!this.getFromLogin()) {
+          wx.showToast({
+            title: '鐧诲綍宸茶繃鏈燂紝璇烽噸鏂扮櫥褰�',
+            icon: 'none',
+            duration: 3000
+          });
+        }
+      } else {
+        // 鍏朵粬閿欒锛屾樉绀洪敊璇俊鎭�
+        wx.showToast({
+          title: err.msg || '鑾峰彇鐢ㄦ埛淇℃伅澶辫触',
+          icon: 'none',
+          duration: 3000
+        });
+      }
+    });
   },
   maskPhoneNumber(phoneNumber) {
     if (phoneNumber.length !== 11) {
@@ -421,7 +709,7 @@
     const data = {
       intakeName: intakeName, //鍙栨按鍙D
       // vcId: vcId, //铏氭嫙鍗D
-      operator: app.globalData.operator, //鎿嶄綔鍛�
+      operator: app.globalData.clientId, //鎿嶄綔鍛�
       forceOpen: !!isforce // 浣跨敤閫昏緫闈炴搷浣滅 !! 鏉ョ‘淇� isForce 鏄竷灏斿��  
     };
     post({
@@ -468,32 +756,118 @@
   //杩涘叆鐣岄潰鑾峰彇鐣岄潰鏁版嵁
   initData() {
     const app = getApp();
-    console.log("tag>>>>:" +app.globalData.tag)
- 
-    if (storage.isHasKeySync("userData")) {
-      storage.getItem('userData').then((data) => {
-        let jsonObj = JSON.parse(data);
-        app.globalData.sessionId = jsonObj.sessionId;
-        app.globalData.tag = jsonObj.tag;
+    console.log("initData寮�濮嬶紝tag:", app.globalData.tag);
+
+    // 棣栧厛妫�鏌ユ槸鍚︿粠鐧诲綍椤佃繑鍥�
+    if (this.getFromLogin()) {
+      console.log('initData: 妫�娴嬪埌浠庣櫥褰曢〉杩斿洖鐨勬爣璁帮紝浠呰幏鍙栧熀鏈暟鎹�');
+
+      // 鍗充娇浠庣櫥褰曢〉杩斿洖锛屼篃灏濊瘯鑾峰彇寮�闃�鍒楄〃浠ユ樉绀哄熀鏈琔I
+      // 浣嗗厛妫�鏌ユ槸鍚︽湁瀹㈡埛绔疘D鍙敤
+      if (!app.globalData.clientId) {
+        console.log('initData: 浠庣櫥褰曢〉杩斿洖涓旀棤clientId锛屽皾璇曚粠瀛樺偍鎭㈠');
+        // 灏濊瘯浠庡瓨鍌ㄦ仮澶峜lientId
+        storage.getItemSafe('clientId')
+          .then(clientId => {
+            if (clientId) {
+              console.log('initData: 浠庡瓨鍌ㄦ仮澶峜lientId鎴愬姛:', clientId);
+              app.globalData.clientId = clientId;
+              this.getOpenList();
+            } else {
+              console.log('initData: 鏃犳硶鎭㈠clientId锛屾樉绀虹┖鍒楄〃');
+              this.setData({
+                listData: []
+              });
+            }
+          })
+          .catch(err => {
+            console.error('initData: 鎭㈠clientId澶辫触:', err);
+            this.setData({
+              listData: []
+            });
+          });
+      } else {
+        this.getOpenList();
+      }
+      return;
+    }
+
+    // 灏濊瘯鑾峰彇鐢ㄦ埛鏁版嵁鍜屽凡寮�闃�璁板綍
+    try {
+      // 浼樺厛妫�鏌ュ叏灞�鍙橀噺涓槸鍚︽湁sessionId
+      if (app.globalData.sessionId) {
+        console.log('initData: 浣跨敤鍏ㄥ眬sessionId鑾峰彇鏁版嵁');
         this.getUserDataBySession();
         this.getOpenList();
-        console.log("userData>>>>>>>" + data)
-      }).catch((err) => {
-        console.error('Failed to load parameter:', err);
-      });
-    } else {
-      this.getUserDataBySession();
-      this.getOpenList();
-      console.log('Failed to load parameter:false');
+        return;
+      }
+
+      // 妫�鏌ユ槸鍚︽湁瀛樺偍鐨剈serData
+      const hasUserData = storage.isHasKeySync("userData");
+      console.log('initData: 鏄惁瀛樺湪userData:', hasUserData);
+
+      if (hasUserData) {
+        storage.getItemSafe('userData')
+          .then((data) => {
+            console.log('initData: 鎴愬姛璇诲彇userData');
+            if (data) {
+              try {
+                let jsonObj = JSON.parse(data);
+                app.globalData.sessionId = jsonObj.sessionId;
+                app.globalData.tag = jsonObj.tag;
+                console.log("userData宸插姞杞�:", data);
+              } catch (e) {
+                console.error('userData瑙f瀽澶辫触:', e);
+              }
+            }
+            // 鏃犺濡備綍閮藉皾璇曡幏鍙栫敤鎴蜂俊鎭拰寮�闃�鍒楄〃
+            this.getUserDataBySession();
+            this.getOpenList();
+          })
+          .catch((err) => {
+            console.error('鍔犺浇userData澶辫触:', err);
+
+            // 鍐嶆妫�鏌ユ槸鍚︿粠鐧诲綍椤佃繑鍥�
+            if (this.getFromLogin()) {
+              console.log('initData:catch: 妫�娴嬪埌浠庣櫥褰曢〉杩斿洖鐨勬爣璁帮紝鍙幏鍙栧紑闃�鍒楄〃');
+              this.getOpenList();
+            } else {
+              this.getUserDataBySession();
+              this.getOpenList();
+            }
+          });
+      } else {
+        console.log('鏈壘鍒皍serData锛岀洿鎺ヨ幏鍙栨暟鎹�');
+
+        // 鍐嶆妫�鏌ユ槸鍚︿粠鐧诲綍椤佃繑鍥�
+        if (this.getFromLogin()) {
+          console.log('initData:else: 妫�娴嬪埌浠庣櫥褰曢〉杩斿洖鐨勬爣璁帮紝鍙幏鍙栧紑闃�鍒楄〃');
+          this.getOpenList();
+        } else {
+          this.getUserDataBySession();
+          this.getOpenList();
+        }
+      }
+    } catch (e) {
+      console.error('initData鎵ц鍑洪敊:', e);
+
+      // 鍐嶆妫�鏌ユ槸鍚︿粠鐧诲綍椤佃繑鍥�
+      if (this.getFromLogin()) {
+        console.log('initData:error: 妫�娴嬪埌浠庣櫥褰曢〉杩斿洖鐨勬爣璁帮紝鍙幏鍙栧紑闃�鍒楄〃');
+        this.getOpenList();
+      } else {
+        // 鍑洪敊鏃朵粛灏濊瘯鑾峰彇鏁版嵁
+        this.getUserDataBySession();
+        this.getOpenList();
+      }
     }
-  
   },
   // 澶勭悊澶村儚鐐瑰嚮
   handleAvatarTap() {
     this.setData({
       avatarTapCount: this.data.avatarTapCount + 1
     });
-    
+
     if (this.data.avatarTapCount >= 5) {
       this.setData({
         showProjectDialog: true,
@@ -508,7 +882,9 @@
     if (!e.detail.visible && !this.data.selectedProject) {
       return;
     }
-    this.setData({ showProjectDialog: e.detail.visible });
+    this.setData({
+      showProjectDialog: e.detail.visible
+    });
   },
 
   // 澶勭悊椤圭洰閫夋嫨鍙樺寲
@@ -528,164 +904,575 @@
       });
       return;
     }
-    const projectName = this.data.selectedProject === 'JYG' ? '鍢夊唱鍏抽」鐩�' : '姘戝嫟椤圭洰';
-    
+
+    // 鑾峰彇褰撳墠宸查�夐」鐩拰鏂伴�夋嫨鐨勯」鐩�
+    const currentProject = getApp().globalData.selectedProject;
+    const newProject = this.data.selectedProject;
+    const projectName = newProject === 'JYG' ? '鍢夊唱鍏抽」鐩�' : '姘戝嫟椤圭洰';
+
+    // 妫�鏌ユ槸鍚﹀垏鎹簡椤圭洰锛堝鏋滃綋鍓嶉」鐩笉鍚屼簬鏂伴�夋嫨鐨勯」鐩級
+    const isProjectChanged = currentProject && currentProject !== newProject;
+
+    // 濡傛灉鍒囨崲浜嗛」鐩紝鍏堟竻闄ょ櫥褰曠姸鎬�
+    if (isProjectChanged) {
+      console.log(`姝e湪浠庨」鐩� ${currentProject} 鍒囨崲鍒� ${newProject}锛屽皢娓呴櫎鐧诲綍鐘舵�乣);
+
+      // 娓呴櫎鍏ㄥ眬鐧诲綍鐘舵��
+      getApp().globalData.sessionId = '';
+      getApp().globalData.clientId = '';
+      getApp().globalData.isLoggedIn = false;
+      getApp().globalData.userInfo = null;
+
+      // 娓呴櫎瀛樺偍涓殑鐧诲綍鐘舵��
+      try {
+        wx.removeStorageSync('sessionId');
+        wx.removeStorageSync('clientId');
+        wx.removeStorageSync('userData');
+        wx.removeStorageSync('isLoggedIn');
+        console.log('宸叉竻闄ょ櫥褰曠浉鍏崇殑瀛樺偍鏁版嵁');
+      } catch (e) {
+        console.error('娓呴櫎瀛樺偍鏁版嵁澶辫触:', e);
+      }
+
+      // 閲嶇疆UI鏄剧ず鐘舵��
+      this.setData({
+        userName: "璇风櫥褰�",
+        userPhone: "",
+        listData: []
+      });
+    }
+
     // 淇濆瓨椤圭洰閫夋嫨鍒版湰鍦板瓨鍌�
-    storage.setItem('selectedProject', this.data.selectedProject).then(() => {
+    storage.setItem('selectedProject', newProject).then(() => {
       // 鏇存柊 BASEURL
-      const { PROJECT_URLS } = require('../../api/config.js');
-      const baseUrl = PROJECT_URLS[this.data.selectedProject];
-      
-      // 鐩存帴淇敼鍏ㄥ眬鍙橀噺
+      const {
+        PROJECT_URLS
+      } = require('../../api/config.js');
+      const baseUrl = PROJECT_URLS[newProject];
+
+      // 鏇存柊鍏ㄥ眬鍙橀噺
       getApp().globalData = getApp().globalData || {};
       getApp().globalData.baseUrl = baseUrl;
-      getApp().globalData.selectedProject = this.data.selectedProject;
-      
+      getApp().globalData.selectedProject = newProject;
+
       // 鏍规嵁椤圭洰璁剧疆瀵瑰簲鐨則ag
-      if (this.data.selectedProject === 'JYG') {
+      if (newProject === 'JYG') {
         getApp().globalData.tag = 'ym'; // 鍢夊唱鍏抽」鐩搴攖ag涓簓m
-      } else if (this.data.selectedProject === 'MQ') {
+      } else if (newProject === 'MQ') {
         getApp().globalData.tag = 'mq'; // 姘戝嫟椤圭洰瀵瑰簲tag涓簃q
       }
-      
+
       console.log('宸插垏鎹㈠埌椤圭洰:', projectName, '鍩熷悕:', baseUrl, 'tag:', getApp().globalData.tag);
-      
+
       this.setData({
         showProjectDialog: false
       });
 
+      // 鏄剧ず鍒囨崲鎴愬姛鎻愮ず
       wx.showToast({
-        title: `宸查�夋嫨${projectName}`,
+        title: isProjectChanged ? `宸插垏鎹㈣嚦${projectName}锛岃閲嶆柊鐧诲綍` : `宸查�夋嫨${projectName}`,
         icon: 'success',
         duration: 2000
       });
 
-      // 妫�鏌ョ櫥褰曠姸鎬�
-      // setTimeout(() => {
-      //   this.checkLoginStatus();
-      // }, 500);
+      // 濡傛灉鍒囨崲浜嗛」鐩紝寤惰繜璺宠浆鍒扮櫥褰曢〉闈�
+      if (isProjectChanged) {
+        setTimeout(() => {
+          console.log('椤圭洰宸插垏鎹紝姝e湪璺宠浆鍒扮櫥褰曢〉闈�');
+          wx.redirectTo({
+            url: `/pages/login/login?project=${newProject}`,
+            success: () => console.log('鎴愬姛璺宠浆鍒扮櫥褰曢〉'),
+            fail: (err) => console.error('璺宠浆鍒扮櫥褰曢〉澶辫触:', err)
+          });
+        }, 2000);
+      }
     }).catch(err => {
       console.error('淇濆瓨椤圭洰閫夋嫨澶辫触锛�', err);
       wx.showToast({
         title: '淇濆瓨澶辫触锛岃閲嶈瘯',
-        icon: 'success',
+        icon: 'none',
         duration: 2000
       });
     });
   },
-  
+
   // 妫�鏌ョ櫥褰曠姸鎬�
   checkLoginStatus() {
     const app = getApp();
-    
+
+    // 棣栧厛锛屽己鍒跺啀娆℃鏌ユ槸鍚︿粠鐧诲綍椤佃繑鍥�
+    try {
+      const tempFromLogin = wx.getStorageSync('_temp_from_login');
+      if (tempFromLogin === 'true') {
+        console.log('checkLoginStatus: 妫�娴嬪埌涓存椂瀛樺偍_temp_from_login=true锛屼笉鎵ц璺宠浆');
+        this.setData({
+          isFromLogin: true
+        });
+        return;
+      }
+    } catch (e) {
+      console.error('checkLoginStatus: 璇诲彇涓存椂鏍囪澶辫触:', e);
+    }
+
     // 妫�鏌ユ槸鍚﹀凡鐧诲綍
     if (app.globalData.isLoggedIn && app.globalData.sessionId) {
-      // 宸茬櫥褰曪紝閲嶆柊鍔犺浇椤甸潰
-      wx.reLaunch({
-        url: '/pages/home/home'
+      console.log('宸蹭粠鍏ㄥ眬鍙橀噺妫�娴嬪埌鐧诲綍鐘舵��');
+      return;
+    }
+
+    // 妫�鏌ユ湰椤甸潰鏄惁姝e湪澶勭悊杩斿洖閫昏緫
+    const fromLogin = this.getFromLogin();
+    if (fromLogin) {
+      console.log('浠庣櫥褰曢〉杩斿洖锛屼笉鍐嶉噸瀹氬悜');
+      return;
+    }
+
+    // 鑾峰彇褰撳墠椤甸潰璺敱鍜屽弬鏁�
+    const pages = getCurrentPages();
+    const currentPage = pages[pages.length - 1];
+    const currentRoute = currentPage ? currentPage.route : '';
+    const currentOptions = currentPage ? currentPage.options || {} : {};
+
+    console.log('褰撳墠椤甸潰璺敱:', currentRoute, '鍙傛暟:', currentOptions);
+
+    // 妫�鏌RL鍙傛暟涓槸鍚︽湁fromLogin
+    if (currentOptions.fromLogin === 'true') {
+      console.log('URL鍙傛暟涓娴嬪埌fromLogin=true锛屼笉鎵ц璺宠浆');
+      this.setData({
+        isFromLogin: true
       });
-    } else {
-      // 灏濊瘯浠庢湰鍦板瓨鍌ㄨ幏鍙栫敤鎴蜂俊鎭�
-      storage.getItem('userInfo').then(userInfoStr => {
-        if (userInfoStr) {
+      return;
+    }
+
+    // 濡傛灉褰撳墠宸插湪鐧诲綍椤碉紝涓嶅啀璺宠浆
+    if (currentRoute === 'pages/login/login') {
+      console.log('褰撳墠宸插湪鐧诲綍椤碉紝涓嶅啀璺宠浆');
+      return;
+    }
+
+    // Promise閾惧鐞嗗瓨鍌ㄦ鏌�
+    Promise.all([
+        storage.getItemSafe('sessionId'),
+        storage.getItemSafe('clientId'),
+        storage.getItemSafe('isLoggedIn')
+      ])
+      .then(([sessionId, clientId, isLoggedIn]) => {
+        // 鏈�鍚庝竴娆℃鏌ヤ复鏃舵爣璁�
+        try {
+          const tempFromLogin = wx.getStorageSync('_temp_from_login');
+          if (tempFromLogin === 'true') {
+            console.log('Promise鍐呴儴: 妫�娴嬪埌涓存椂瀛樺偍_temp_from_login=true锛屼笉鎵ц璺宠浆');
+            this.setData({
+              isFromLogin: true
+            });
+            return;
+          }
+        } catch (e) {}
+
+        if (sessionId) {
+          // 浠庡瓨鍌ㄤ腑鎭㈠鐧诲綍鐘舵��
+          app.globalData.sessionId = sessionId;
+          app.globalData.isLoggedIn = true;
+
+          if (clientId) {
+            app.globalData.clientId = clientId;
+          }
+
+          console.log('宸蹭粠瀛樺偍鎭㈠鐧诲綍鐘舵��');
+          // 宸茬櫥褰曪紝鍒锋柊椤甸潰
+          wx.reLaunch({
+            url: '/pages/home/home'
+          });
+        } else {
+          // 鏍囪褰撳墠椤甸潰姝e湪澶勭悊杩斿洖閫昏緫
+          this.setData({
+            isFromLogin: true
+          });
+
+          // 鏈櫥褰曪紝鍙兘闇�瑕佽烦杞埌鐧诲綍椤甸潰
+          console.log('鏈娴嬪埌鐧诲綍鐘舵�侊紝鍙兘闇�瑕佽烦杞埌鐧诲綍椤�');
+
+          // 鏈�鍚庡啀妫�鏌ヤ竴娆℃槸鍚﹀凡浠庣櫥褰曢〉杩斿洖
+          const finalCheck = this.getFromLogin();
+          if (finalCheck) {
+            console.log('鏈�缁堟鏌�: 宸蹭粠鐧诲綍椤佃繑鍥烇紝涓嶅啀璺宠浆');
+            return;
+          }
+
+          console.log('纭闇�瑕佽烦杞埌鐧诲綍椤�');
+
+          // 璺宠浆鍓嶅啀娆℃鏌ョ櫥褰曢〉闈复鏃舵爣璁�
           try {
-            const userInfo = JSON.parse(userInfoStr);
-            // 楠岃瘉鐢ㄦ埛淇℃伅鏄惁鏈夋晥
-            if (userInfo && userInfo.sessionId) {
-              // 鎭㈠鐧诲綍鐘舵��
-              app.globalData.sessionId = userInfo.sessionId;
-              app.globalData.token = userInfo.token;
-              app.globalData.userInfo = userInfo;
-              app.globalData.isLoggedIn = true;
-              
-              // 宸茬櫥褰曪紝閲嶆柊鍔犺浇椤甸潰
-              wx.reLaunch({
-                url: '/pages/home/home'
-              });
-              return;
-            }
-          } catch (e) {
-            console.error('瑙f瀽鐢ㄦ埛淇℃伅澶辫触:', e);
-          }
+            wx.setStorageSync('_attempted_login_redirect', 'true');
+          } catch (e) {}
+
+          wx.redirectTo({
+            url: `/pages/login/login?project=${this.data.selectedProject}`,
+            success: () => console.log('鎴愬姛璺宠浆鍒扮櫥褰曢〉'),
+            fail: (err) => console.error('璺宠浆鍒扮櫥褰曢〉澶辫触:', err)
+          });
         }
-        
-        // 鏈櫥褰曪紝璺宠浆鍒扮櫥褰曢〉闈�
-        wx.redirectTo({
-          url: `/pages/login/login?project=${this.data.selectedProject}`
+      })
+      .catch(err => {
+        console.error('妫�鏌ョ櫥褰曠姸鎬佹椂鍑洪敊:', err);
+
+        // 鏍囪褰撳墠椤甸潰姝e湪澶勭悊杩斿洖閫昏緫
+        this.setData({
+          isFromLogin: true
         });
-      }).catch(err => {
-        console.error('鑾峰彇鐢ㄦ埛淇℃伅澶辫触:', err);
-        // 鏈櫥褰曪紝璺宠浆鍒扮櫥褰曢〉闈�
+
+        // 鍐嶆妫�鏌ユ槸鍚﹀凡浠庣櫥褰曢〉杩斿洖
+        if (this.getFromLogin()) {
+          console.log('閿欒澶勭悊: 宸蹭粠鐧诲綍椤佃繑鍥烇紝涓嶅啀璺宠浆');
+          return;
+        }
+
+        // 鍑洪敊鏃朵篃璺宠浆鍒扮櫥褰曢〉
         wx.redirectTo({
-          url: `/pages/login/login?project=${this.data.selectedProject}`
+          url: `/pages/login/login?project=${this.data.selectedProject}`,
+          success: () => console.log('閿欒鍚庢垚鍔熻烦杞埌鐧诲綍椤�'),
+          fail: (err) => console.error('閿欒鍚庤烦杞埌鐧诲綍椤靛け璐�:', err)
         });
       });
+  },
+
+  // 杈呭姪鍑芥暟锛氭鏌ユ槸鍚︿粠鐧诲綍椤佃繑鍥�
+  getFromLogin() {
+    // 鍏堟鏌ュ叏灞�鍙橀噺锛堜綔涓哄鐢ㄦ柟妗堬級
+    if (getApp().globalData && getApp().globalData._tempFromLogin === true) {
+      console.log('getFromLogin: 妫�娴嬪埌鍏ㄥ眬鍙橀噺_tempFromLogin=true');
+      // 璁剧疆鏍囧織锛岀‘淇濅笅娆℃鏌ユ椂鑳借瘑鍒�
+      this.setData({
+        isFromLogin: true
+      });
+
+      // 娓呴櫎鍏ㄥ眬鏍囪锛岄槻姝㈤噸澶嶈瘑鍒�
+      setTimeout(() => {
+        getApp().globalData._tempFromLogin = false;
+        console.log('宸叉竻闄ゅ叏灞�鍙橀噺_tempFromLogin鏍囪');
+      }, 100);
+
+      return true;
+    }
+
+    // 妫�鏌ユ槸鍚︽湁璁剧疆fromLogin鏍囧織
+    if (this.data.isFromLogin) {
+      console.log('getFromLogin: 妫�娴嬪埌this.data.isFromLogin=true');
+      return true;
+    }
+
+    // 妫�鏌ュ綋鍓嶉〉闈㈢殑options
+    const pages = getCurrentPages();
+    const currentPage = pages[pages.length - 1];
+    if (currentPage && currentPage.options && currentPage.options.fromLogin === 'true') {
+      console.log('getFromLogin: 妫�娴嬪埌URL鍙傛暟fromLogin=true');
+      // 璁剧疆鏍囧織锛岀‘淇濅笅娆℃鏌ユ椂鑳借瘑鍒�
+      this.setData({
+        isFromLogin: true
+      });
+      return true;
+    }
+
+    // 妫�鏌ヤ复鏃舵爣璁�
+    try {
+      const tempFromLogin = wx.getStorageSync('_temp_from_login');
+      console.log('getFromLogin: 璇诲彇鍒扮殑涓存椂鏍囪鍊�:', tempFromLogin);
+
+      if (tempFromLogin === 'true') {
+        console.log('getFromLogin: 妫�娴嬪埌涓存椂瀛樺偍_temp_from_login=true');
+        // 璁剧疆鏍囧織锛岀‘淇濅笅娆℃鏌ユ椂鑳借瘑鍒�
+        this.setData({
+          isFromLogin: true
+        });
+        return true;
+      }
+    } catch (e) {
+      console.error('getFromLogin: 璇诲彇涓存椂鏍囪澶辫触:', e);
+    }
+
+    console.log('getFromLogin: 鏈娴嬪埌浠庣櫥褰曢〉杩斿洖鐨勬爣璁�');
+    return false;
+  },
+
+  // 缁х画鍒濆鍖栭〉闈�
+  continueInitPage(options) {
+    console.log('缁х画鍒濆鍖栭〉闈紝options:', options);
+
+    // 妫�鏌ユ槸鍚︿粠鐧诲綍椤佃繑鍥�
+    let fromLogin = false;
+
+    // 浠嶶RL鍙傛暟涓鏌�
+    if (options && options.fromLogin === 'true') {
+      console.log('continueInitPage: 浠嶶RL鍙傛暟妫�娴嬪埌fromLogin=true');
+      fromLogin = true;
+      this.setData({
+        isFromLogin: true
+      });
+    }
+
+    // 浠庝复鏃舵爣璁颁腑妫�鏌�
+    try {
+      const tempFromLogin = wx.getStorageSync('_temp_from_login');
+      if (tempFromLogin === 'true') {
+        console.log('continueInitPage: 妫�娴嬪埌涓存椂鏍囪_temp_from_login=true');
+        fromLogin = true;
+        this.setData({
+          isFromLogin: true
+        });
+      }
+    } catch (e) {
+      console.error('continueInitPage: 璇诲彇涓存椂鏍囪澶辫触:', e);
+    }
+
+    // 浠庨〉闈㈡暟鎹腑妫�鏌�
+    if (this.data.isFromLogin) {
+      console.log('continueInitPage: 浠庨〉闈㈡暟鎹腑妫�娴嬪埌isFromLogin=true');
+      fromLogin = true;
+    }
+
+    // 鍒ゆ柇鏈湴鏄惁淇濆瓨sessionId
+    // 浣跨敤 wx.nextTick 绛夊緟椤甸潰娓叉煋瀹屾垚
+    wx.nextTick(() => {
+      this.calculateScrollViewHeight();
+    });
+
+    // 褰撳紑闃�鎴愬姛鍚庤皟鐢ㄥ埛鏂�
+    if (options && options.param) {
+      console.log("寮�闃�鎴愬姛鍙傛暟:", options.param);
+      wx.showToast({
+        title: '寮�闃�鎴愬姛',
+        icon: 'success',
+        duration: 3000
+      });
+      this.getOpenList();
+    }
+
+    // 鍒濆鍖栨暟鎹�
+    this.initData();
+
+    // 濡傛灉涓嶆槸浠庣櫥褰曢〉杩斿洖锛屽垯璁剧疆寤惰繜妫�鏌ョ櫥褰曠姸鎬�
+    if (!fromLogin) {
+      console.log('涓嶆槸浠庣櫥褰曢〉杩斿洖锛屽欢杩熸鏌ョ櫥褰曠姸鎬�');
+      setTimeout(() => {
+        // 鍐嶆妫�鏌ユ槸鍚﹀凡浠庣櫥褰曢〉杩斿洖锛堝彲鑳藉湪鍒濆鍖栬繃绋嬩腑鐘舵�佸凡鍙橈級
+        if (this.getFromLogin()) {
+          console.log('寤惰繜妫�鏌ワ細妫�娴嬪埌浠庣櫥褰曢〉杩斿洖鐨勬爣璁帮紝涓嶅啀妫�鏌ョ櫥褰曠姸鎬�');
+          return;
+        }
+
+        // 浠呭湪鏈櫥褰曚笖涓嶆槸浠庣櫥褰曢〉杩斿洖鏃舵鏌ョ櫥褰曠姸鎬�
+        if (!getApp().globalData.isLoggedIn) {
+          console.log('寤惰繜妫�鏌ワ細鏈櫥褰曚笖涓嶆槸浠庣櫥褰曢〉杩斿洖锛屾墽琛岀櫥褰曠姸鎬佹鏌�');
+          this.checkLoginStatus();
+        }
+      }, 500);
+    } else {
+      console.log('浠庣櫥褰曢〉杩斿洖锛屼笉妫�鏌ョ櫥褰曠姸鎬�');
     }
   },
-  wxLogin(){
-    if(!getApp().globalData.isLoggedIn){
-      const that = this;
+
+  // 寰俊鐧诲綍
+  wxLogin() {
+    if (!getApp().globalData.isLoggedIn) {
+      wx.showLoading({
+        title: '姝e湪鐧诲綍璇风◢鍊�...',
+        mask: true
+      });
+
       wx.login({
-        success: function (res) {
+        success: (res) => {
           if (res.code) {
-            var code = res.code;
-            console.log(code);
             // 灏哻ode鍙戦�佸埌鏈嶅姟鍣ㄨ幏鍙杘penid
-            that.codeLogin(code);
+            post({
+              url: "wx/client/code_login",
+              data: {
+                code: res.code
+              }
+            }).then(response => {
+              wx.hideLoading();
+              if (response.code === "0001") {
+                if (response.content.client.clientId === "") {
+                  // 鏈粦瀹氳处鍙凤紝璺宠浆鍒扮櫥褰曢〉闈�
+                  wx.redirectTo({
+                    url: `/pages/login/login?project=${this.data.selectedProject}`
+                  });
+                } else {
+                  this.setData({
+                    userName: response.content.client.clientName,
+                    userPhone: response.content.client.userPhone
+                  })
+                  // 宸叉湁璐﹀彿锛屼繚瀛樻暟鎹苟鍒濆鍖�
+                  const sessionId = response.content.client.sessionId;
+                  const clientId = response.content.client.clientId;
+
+                  // 璁剧疆鍏ㄥ眬鍙橀噺
+                  getApp().globalData.sessionId = sessionId;
+                  getApp().globalData.clientId = clientId;
+                  getApp().globalData.isLoggedIn = true;
+
+                  // 璁剧疆姝g‘鐨勯」鐩畉ag
+                  const tag = this.data.selectedProject === 'JYG' ? 'ym' : 'mq';
+                  getApp().globalData.tag = tag;
+
+                  // 淇濆瓨鍒板瓨鍌�
+                  storage.setItem("sessionId", sessionId);
+                  storage.setItem("clientId", clientId);
+                  storage.setItem("isLoggedIn", "true");
+
+                  // 淇濆瓨userData淇℃伅锛屽寘鍚玸essionId鍜宼ag
+                  const userData = JSON.stringify({
+                    sessionId: sessionId,
+                    tag: tag,
+                    project: this.data.selectedProject,
+                    userName: response.content.client.clientName,
+                    userPhone: response.content.client.userPhone
+                  });
+                  storage.setItem("userData", userData)
+                    .then(() => {
+                      console.log('鐢ㄦ埛鏁版嵁淇濆瓨鎴愬姛锛屽寘鍚」鐩俊鎭�:', this.data.selectedProject, 'tag:', tag);
+                      this.initData();
+                    })
+                    .catch(err => {
+                      console.warn('淇濆瓨userData澶辫触锛屼絾缁х画鍒濆鍖�:', err);
+                      this.initData();
+                    });
+
+                }
+              } else {
+                wx.showToast({
+                  title: '鐧诲綍澶辫触',
+                  icon: 'error',
+                  duration: 2000
+                });
+                wx.redirectTo({
+                  url: `/pages/login/login?project=${this.data.selectedProject}`
+                });
+              }
+            }).catch(error => {
+              wx.hideLoading();
+              console.error('鐧诲綍璇锋眰澶辫触:', error);
+              wx.showToast({
+                title: '鐧诲綍澶辫触锛岃閲嶈瘯',
+                icon: 'none'
+              });
+              wx.redirectTo({
+                url: `/pages/login/login?project=${this.data.selectedProject}`
+              });
+            });
           } else {
+            wx.hideLoading();
             console.log('鐧诲綍澶辫触锛�' + res.errMsg);
-        
+            wx.showToast({
+              title: '寰俊鐧诲綍澶辫触',
+              icon: 'none'
+            });
           }
+        },
+        fail: (err) => {
+          wx.hideLoading();
+          console.error('寰俊鐧诲綍API璋冪敤澶辫触:', err);
+          wx.showToast({
+            title: '鐧诲綍澶辫触锛岃閲嶈瘯',
+            icon: 'none'
+          });
         }
       });
     }
   },
-  //寰俊code鐧诲綍
-  codeLogin(codeData) {
+
+  // 杈呭姪鍑芥暟锛氭竻鐞嗕复鏃舵爣璁�
+  cleanupTempMarkers() {
+    // 鍙湁鍦╥sFromLogin涓簍rue鏃舵墠杩涜娓呯悊
+    if (this.data.isFromLogin) {
+      console.log('娓呯悊涓存椂鏍囪');
+
+      // 娓呯悊瀛樺偍鏍囪
+      try {
+        wx.removeStorageSync('_temp_from_login');
+      } catch (e) {
+        console.error('娓呯悊瀛樺偍鏍囪澶辫触:', e);
+      }
+
+      // 娓呯悊鍏ㄥ眬鍙橀噺鏍囪
+      if (getApp().globalData) {
+        getApp().globalData._tempFromLogin = false;
+      }
+
+      // 閲嶈isFromLogin涓篺alse锛屼絾娣诲姞寤惰繜锛岄伩鍏嶅奖鍝嶅綋鍓嶉〉闈㈢殑杩斿洖閫昏緫
+      setTimeout(() => {
+        this.setData({
+          isFromLogin: false
+        });
+        console.log('閲嶇疆isFromLogin=false');
+      }, 5000);
+    }
+  }, //纭瑙g粦
+  unBindPost() {
+    this.setData({
+      showUnBind: false
+    })
     wx.showLoading({
-      title: '姝e湪鐧诲綍璇风◢鍊�...', // 鍔犺浇鎻愮ず鏂囧瓧
+      title: '姝e湪瑙g粦璇风◢鍊�...', // 鍔犺浇鎻愮ず鏂囧瓧
       mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false
     });
     const data = {
-      code: codeData, //涓存椂鐧诲綍鍑瘉
+      sessionId: getApp().globalData.sessionId //鍙栨按鍙D
     };
     post({
-      url: "wx/client/code_login",
+      url: 'wx/client/unbind',
       data: data,
+      useParams: true
     }).then(response => {
       // 澶勭悊鎴愬姛鍝嶅簲
       console.log('璇锋眰鎴愬姛:', response);
       // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
       wx.hideLoading();
-      if (response.code === "0001") {
-        //鍋囧涓虹┖鍒欒烦杞埌缁戝畾鐣岄潰
-        if (response.content.client.clientId === "") {
-          wx.navigateTo({
-            url: '/pages/login/login'
-          })
-        } else {
-          //缂撳瓨鍦ㄦ湰鍦�
+      const app = getApp();
+
+      // 娓呴櫎鍏ㄥ眬鐧诲綍鐘舵��
+      app.globalData.sessionId = '';
+      app.globalData.clientId = '';
+      app.globalData.isLoggedIn = false;
+      app.globalData.userInfo = null;
+
+      // 娓呴櫎瀛樺偍涓殑鐧诲綍鐘舵��
+      const storage = require('../../utils/storage.js');
+      storage.removeItem('sessionId')
+        .then(() => storage.removeItem('clientId'))
+        .then(() => storage.removeItem('userData'))
+        .then(() => storage.removeItem('isLoggedIn'))
+        .then(() => {
+          wx.showToast({
+            title: '瑙g粦鎴愬姛',
+            icon: 'success',
+            duration: 2000
+          });
+
+          // 閲嶇疆UI鏄剧ず鐘舵��
           this.setData({
-            isLogin: true
-          })
-          getApp().globalData.sessionId = response.content.client.sessionId
-          storage.setItem("sessionId", response.content.client.sessionId)
-          getApp().globalData.clientId = response.content.client.clientId
-          storage.setItem("clientId", response.content.client.clientId)
-          this.initData();
-        }
-      } else {
-        wx.showToast({
-          title: 'title',
-          icon: 'error',
-          duration: 2000
+            userName: "璇风偣鍑荤櫥褰�",
+            userPhone: "",
+            listData: []
+          });
         })
-      }
+        .catch(err => {
+          console.error('瑙g粦杩囩▼涓嚭閿�:', err);
+          wx.showToast({
+            title: '瑙g粦澶辫触锛岃閲嶈瘯',
+            icon: 'none',
+            duration: 2000
+          });
+        });
     }).catch(error => {
       // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
       wx.hideLoading();
       // 澶勭悊閿欒鍝嶅簲
       console.error('璇锋眰澶辫触:', error);
+      wx.showToast({
+        title: '瑙g粦澶辫触',
+        icon: 'error',
+        duration: 3000
+      })
     });
   },
 })
\ No newline at end of file
diff --git a/pages/home/home.wxml b/pages/home/home.wxml
index 923d87d..292b406 100644
--- a/pages/home/home.wxml
+++ b/pages/home/home.wxml
@@ -9,7 +9,7 @@
         <text class="head-bottom">{{userPhone}}</text>
       </view>
       <view class="head-button-wrapper">
-        <text class="unbind" bind:tap="feedBack">瑙g粦</text>
+        <text class="unbind" bind:tap="unbind">瑙g粦</text>
         <text class="head-bottom" bind:tap="feedBack">鑱旂郴瀹㈡湇</text>
       </view>
       <view class="scen-view" bind:tap="scenCode">
@@ -33,8 +33,8 @@
       <image src="/images/record.svg" />
       <text>寮�鍏抽榾璁板綍</text>
     </view>
-    <view class="center-view" bind:tap="feedBack">
-      <image src="/images/question.svg" />
+    <view class="center-view" bind:tap="irrigation">
+      <image src="/images/irrigation.svg" />
       <text>杞亴</text>
     </view>
   </view>
diff --git a/pages/irrigation/irrigation.js b/pages/irrigation/irrigation.js
index 6ff0e20..e906d7e 100644
--- a/pages/irrigation/irrigation.js
+++ b/pages/irrigation/irrigation.js
@@ -139,6 +139,19 @@
   },
 
   /**
+   * 鐐瑰嚮鍒楄〃椤�
+   */
+  onItemTap: function (e) {
+    const id = e.currentTarget.dataset.id;
+    const status = e.currentTarget.dataset.status;
+    
+    // 瀵艰埅鍒扮亴婧夎鎯呴〉闈紝骞朵紶閫掑弬鏁�
+    wx.navigateTo({
+      url: `/pages/irrigationDetail/irrigationDetail?id=${id}&fromList=true`
+    });
+  },
+
+  /**
    * 鐐瑰嚮鍙戝竷鎸夐挳
    */
   onPublish: function (e) {
@@ -214,6 +227,14 @@
   },
 
   /**
+   * 闃绘浜嬩欢鍐掓场
+   */
+  stopPropagation: function (e) {
+    // 闃绘浜嬩欢鍐掓场
+    return false;
+  },
+
+  /**
    * 寮�濮嬩笅鎷夊埛鏂�
    */
   startPullDownRefresh: function() {
diff --git a/pages/irrigation/irrigation.wxml b/pages/irrigation/irrigation.wxml
index 3b71e14..067fe45 100644
--- a/pages/irrigation/irrigation.wxml
+++ b/pages/irrigation/irrigation.wxml
@@ -19,7 +19,7 @@
     <view class="scroll-bg">
       <block wx:if="{{currentList.length > 0}}">
         <!-- 缁熶竴鏄剧ず鎵�鏈夊垪琛ㄩ」锛屼笉鍐嶆寜鐘舵�佸垎缁� -->
-        <view class="list-item" wx:for="{{currentList}}" wx:key="id">
+        <view class="list-item" wx:for="{{currentList}}" wx:key="id" bindtap="onItemTap" data-id="{{item.id}}" data-status="{{item.status}}">
           <view class="item-header">
             <view class="info-row title-row">
               <view class="info-label">缂栧彿锛�</view>
@@ -55,7 +55,7 @@
               </view>
             </block>
           </view>
-          <view class="item-actions">
+          <view class="item-actions" catchtap="stopPropagation">
             <!-- 鏍规嵁鐘舵�佹樉绀轰笉鍚岀殑鎸夐挳 -->
             <block wx:if="{{item.status === '鏈彂甯�'}}">
               <button class="action-button publish-button" hover-class="publish-button-hover" bindtap="onPublish" data-id="{{item.id}}">鍙戝竷</button>
diff --git a/pages/irrigationDetail/irrigationDetail.js b/pages/irrigationDetail/irrigationDetail.js
new file mode 100644
index 0000000..5b4907b
--- /dev/null
+++ b/pages/irrigationDetail/irrigationDetail.js
@@ -0,0 +1,308 @@
+Page({
+  /**
+   * 椤甸潰鐨勫垵濮嬫暟鎹�
+   */
+  data: {
+    planCode: '',
+    startTime: '',
+    projects: [],
+    isRefreshing: false, // 涓嬫媺鍒锋柊鐘舵��
+    planId: '' // 淇濆瓨璁″垝ID
+  },
+
+  /**
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
+   */
+  onLoad: function (options) {
+    if (options.id) {
+      this.setData({
+        planId: options.id
+      });
+      // 浠庡垪琛ㄩ〉闈㈣繘鍏ユ椂锛屾墍鏈夐」鐩粯璁ゆ敹璧�
+      const fromListPage = options.fromList === 'true';
+      this.loadIrrigationDetail(options.id, !fromListPage);
+    }
+  },
+
+  /**
+   * 鍔犺浇鐏屾簤璁″垝璇︽儏
+   * @param {string} id 鐏屾簤璁″垝ID
+   * @param {boolean} isFirstLoad 鏄惁棣栨鍔犺浇
+   */
+  loadIrrigationDetail: function (id, isFirstLoad = false) {
+    // 寮�濮嬪姞杞斤紝璁剧疆鍒锋柊鐘舵��
+    this.setData({
+      isRefreshing: true
+    });
+
+    // 淇濆瓨褰撳墠椤圭洰鐨勫睍寮�鐘舵��
+    const currentExpandStates = {};
+    if (!isFirstLoad && this.data.projects.length > 0) {
+      this.data.projects.forEach((project, index) => {
+        currentExpandStates[project.id] = project.expanded;
+      });
+    }
+
+    // 杩欓噷搴旇鏄粠API鑾峰彇鏁版嵁
+    // 浠ヤ笅鏄ā鎷熸暟鎹�
+    const mockData = {
+      planCode: 'IRG20240317001',
+      startTime: '2024-03-17 08:00',
+      projects: [
+        {
+          id: 1,
+          name: '椤圭洰A',
+          expanded: isFirstLoad ? true : false, // 浠呭湪闈炲垪琛ㄩ〉杩涘叆涓旈娆″姞杞芥椂灞曞紑绗竴涓」鐩�
+          groups: [
+            {
+              id: 1,
+              name: '杞亴缁凙-1',
+              status: 'irrigated', // 宸茬亴婧�
+              statusText: '宸茬亴婧�',
+              startTime: '2024-03-17 08:00',
+              endTime: '2024-03-17 09:30',
+              duration: 90
+            },
+            {
+              id: 2,
+              name: '杞亴缁凙-2',
+              status: 'irrigating', // 姝e湪鐏屾簤
+              statusText: '姝e湪鐏屾簤',
+              startTime: '2024-03-17 09:30',
+              endTime: '2024-03-17 11:00',
+              duration: 90
+            }
+          ]
+        },
+        {
+          id: 2,
+          name: '椤圭洰B',
+          expanded: false,
+          groups: [
+            {
+              id: 3,
+              name: '杞亴缁凚-1',
+              status: 'waiting', // 鏈亴婧�
+              statusText: '鏈亴婧�',
+              startTime: '2024-03-17 11:00',
+              endTime: '2024-03-17 12:30',
+              duration: 90
+            },
+            {
+              id: 4,
+              name: '杞亴缁凚-2',
+              status: 'waiting', // 鏈亴婧�
+              statusText: '鏈亴婧�',
+              startTime: '2024-03-17 12:30',
+              endTime: '2024-03-17 14:00',
+              duration: 90
+            }
+          ]
+        },
+        {
+          id: 3,
+          name: '椤圭洰C',
+          expanded: false,
+          groups: [
+            {
+              id: 5,
+              name: '杞亴缁凜-1',
+              status: 'waiting', // 鏈亴婧�
+              statusText: '鏈亴婧�',
+              startTime: '2024-03-17 14:00',
+              endTime: '2024-03-17 15:30',
+              duration: 90
+            }
+          ]
+        }
+      ]
+    };
+
+    // 璁$畻姣忎釜椤圭洰鐨勬�荤亴婧夋椂闀�
+    mockData.projects = this.calculateProjectTotalDuration(mockData.projects);
+
+    // 濡傛灉涓嶆槸棣栨鍔犺浇锛屾仮澶嶉」鐩殑灞曞紑鐘舵��
+    if (!isFirstLoad) {
+      mockData.projects.forEach(project => {
+        if (currentExpandStates[project.id] !== undefined) {
+          project.expanded = currentExpandStates[project.id];
+        }
+      });
+    }
+
+    // 妯℃嫙缃戠粶璇锋眰寤惰繜
+    setTimeout(() => {
+      // 璁剧疆椤甸潰鏁版嵁
+      this.setData({
+        planCode: mockData.planCode,
+        startTime: mockData.startTime,
+        projects: mockData.projects,
+        isRefreshing: false // 缁撴潫鍒锋柊鐘舵��
+      });
+    }, 1000);
+
+    // 瀹為檯椤圭洰涓簲璇ヤ娇鐢╳x.request鑾峰彇鏁版嵁
+    // wx.request({
+    //   url: 'https://your-api-url/irrigation/' + id,
+    //   method: 'GET',
+    //   success: (res) => {
+    //     if (res.data && res.data.code === 0) {
+    //       // 鑾峰彇鏂版暟鎹�
+    //       let projects = res.data.data.projects;
+    //       
+    //       // 濡傛灉鏄娆″姞杞斤紝璁剧疆榛樿灞曞紑鐘舵��
+    //       if (isFirstLoad) {
+    //         projects = projects.map((project, index) => {
+    //           return {
+    //             ...project,
+    //             expanded: index === 0 // 榛樿鍙睍寮�绗竴涓」鐩�
+    //           };
+    //         });
+    //       } else {
+    //         // 濡傛灉涓嶆槸棣栨鍔犺浇锛屾仮澶嶉」鐩殑灞曞紑鐘舵��
+    //         projects = projects.map(project => {
+    //           return {
+    //             ...project,
+    //             expanded: currentExpandStates[project.id] !== undefined 
+    //               ? currentExpandStates[project.id] 
+    //               : false
+    //           };
+    //         });
+    //       }
+    //       
+    //       // 璁$畻姣忎釜椤圭洰鐨勬�荤亴婧夋椂闀�
+    //       projects = this.calculateProjectTotalDuration(projects);
+    //       
+    //       this.setData({
+    //         planCode: res.data.data.planCode,
+    //         startTime: res.data.data.startTime,
+    //         projects: projects,
+    //         isRefreshing: false // 缁撴潫鍒锋柊鐘舵��
+    //       });
+    //     } else {
+    //       wx.showToast({
+    //         title: '鑾峰彇鏁版嵁澶辫触',
+    //         icon: 'none'
+    //       });
+    //       this.setData({
+    //         isRefreshing: false // 缁撴潫鍒锋柊鐘舵��
+    //       });
+    //     }
+    //   },
+    //   fail: () => {
+    //     wx.showToast({
+    //       title: '缃戠粶閿欒',
+    //       icon: 'none'
+    //     });
+    //     this.setData({
+    //       isRefreshing: false // 缁撴潫鍒锋柊鐘舵��
+    //     });
+    //   }
+    // });
+  },
+
+  /**
+   * 璁$畻姣忎釜椤圭洰鐨勬�荤亴婧夋椂闀�
+   */
+  calculateProjectTotalDuration: function(projects) {
+    return projects.map(project => {
+      // 璁$畻椤圭洰涓嬫墍鏈夎疆鐏岀粍鐨勬�绘椂闀�
+      const totalDuration = project.groups.reduce((total, group) => {
+        return total + (group.duration || 0);
+      }, 0);
+      
+      return {
+        ...project,
+        totalDuration: totalDuration
+      };
+    });
+  },
+
+  /**
+   * 鍒囨崲椤圭洰灞曞紑/鏀惰捣鐘舵��
+   */
+  toggleProject: function (e) {
+    const index = e.currentTarget.dataset.index;
+    const expanded = this.data.projects[index].expanded;
+    
+    // 鏇存柊椤圭洰鐨勫睍寮�鐘舵��
+    const key = `projects[${index}].expanded`;
+    this.setData({
+      [key]: !expanded
+    });
+  },
+
+  /**
+   * 瀵艰埅鍒拌疆鐏岀粍璇︽儏椤甸潰
+   */
+  navigateToGroupDetail: function (e) {
+    const projectName = e.currentTarget.dataset.projectName;
+    const groupName = e.currentTarget.dataset.groupName;
+    const groupId = e.currentTarget.dataset.groupId;
+    const status = e.currentTarget.dataset.status;
+    
+    console.log('璺宠浆鍒扮粍璇︽儏椤甸潰锛屽師濮嬬姸鎬�:', status);
+    
+    // 瀵艰埅鍒扮粍璇︽儏椤甸潰锛屽苟浼犻�掑弬鏁�
+    // 娉ㄦ剰锛氶渶瑕佸皢status杞崲涓篿sIrrigating鍙傛暟锛屼互渚垮湪缁勮鎯呴〉闈㈡纭樉绀哄懡浠ょ姸鎬�
+    wx.navigateTo({
+      url: `/pages/groupDetail/groupDetail?projectName=${projectName}&groupName=${groupName}&groupId=${groupId}&status=${status}&isIrrigating=${status === 'irrigating' ? 'true' : 'false'}`
+    });
+  },
+
+  /**
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 涓嬫媺鍒锋柊澶勭悊鍑芥暟
+   */
+  onPullDownRefresh: function () {
+    // 閲嶆柊鍔犺浇鏁版嵁锛屼絾淇濇寔灞曞紑鐘舵��
+    if (this.data.planId) {
+      this.loadIrrigationDetail(this.data.planId, false);
+    } else {
+      this.setData({
+        isRefreshing: false
+      });
+    }
+  },
+
+  /**
+   * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
+   */
+  onShareAppMessage: function () {
+
+  }
+}) 
\ No newline at end of file
diff --git a/pages/irrigationDetail/irrigationDetail.json b/pages/irrigationDetail/irrigationDetail.json
new file mode 100644
index 0000000..73e5515
--- /dev/null
+++ b/pages/irrigationDetail/irrigationDetail.json
@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationBarTitleText": "杞亴璇︽儏"
+} 
\ No newline at end of file
diff --git a/pages/irrigationDetail/irrigationDetail.wxml b/pages/irrigationDetail/irrigationDetail.wxml
new file mode 100644
index 0000000..eb682a5
--- /dev/null
+++ b/pages/irrigationDetail/irrigationDetail.wxml
@@ -0,0 +1,74 @@
+<view class="irrigation-detail-container">
+  <!-- 椤堕儴淇℃伅鍖哄煙 -->
+  <view class="header-section">
+    <view class="plan-info">
+      <view class="plan-code">
+        <text class="label">璁″垝缂栧彿锛�</text>
+        <text class="value">{{planCode}}</text>
+      </view>
+      <image class="status-icon" src="/images/progress.svg" mode="aspectFit"></image>
+    </view>
+    
+    <!-- 鐏屾簤鏃堕棿淇℃伅 -->
+    <view class="time-info">
+      <text class="label">鐏屾簤寮�濮嬫椂闂达細</text>
+      <text class="value">{{startTime}}</text>
+    </view>
+  </view>
+
+  <!-- 椤圭洰鍜岃疆鐏岀粍鍒楄〃 -->
+  <scroll-view 
+    scroll-y="true" 
+    class="project-list" 
+    refresher-enabled="{{true}}" 
+    refresher-threshold="50" 
+    refresher-triggered="{{isRefreshing}}" 
+    bindrefresherrefresh="onPullDownRefresh">
+    <view class="scroll-content">
+      <block wx:for="{{projects}}" wx:key="id" wx:for-item="project" wx:for-index="projectIndex">
+        <!-- 椤圭洰淇℃伅 -->
+        <view class="project-item {{project.expanded ? 'expanded' : 'collapsed'}}">
+          <view class="project-header" bindtap="toggleProject" data-index="{{projectIndex}}">
+            <image class="toggle-icon {{project.expanded ? 'expanded' : ''}}" src="/images/arrow-down.svg" mode="aspectFit"></image>
+            <view class="project-info">
+              <view class="project-name">{{project.name}}</view>
+              <view class="project-duration">鎬荤亴婧夋椂闀�: {{project.totalDuration || 0}}鍒嗛挓</view>
+            </view>
+          </view>
+          
+          <!-- 杞亴缁勫垪琛� -->
+          <view class="group-list {{project.expanded ? 'expanded' : 'collapsed'}}">
+            <block wx:for="{{project.groups}}" wx:key="id" wx:for-item="group">
+              <view class="group-item {{group.status}}" bindtap="navigateToGroupDetail" data-project-name="{{project.name}}" data-group-name="{{group.name}}" data-group-id="{{group.id}}" data-status="{{group.status}}">
+                <!-- 杞亴缁勭姸鎬佹爣璇� -->
+                <view class="group-status-indicator">
+                  <view class="status-dot"></view>
+                  <text class="status-text">{{group.statusText}}</text>
+                </view>
+                
+                <!-- 杞亴缁勪俊鎭� -->
+                <view class="group-info">
+                  <view class="group-name">{{group.name}}</view>
+                  <view class="group-time-info">
+                    <view class="time-row">
+                      <text class="time-label">寮�濮嬫椂闂达細</text>
+                      <text class="time-value">{{group.startTime}}</text>
+                    </view>
+                    <view class="time-row">
+                      <text class="time-label">缁撴潫鏃堕棿锛�</text>
+                      <text class="time-value">{{group.endTime}}</text>
+                    </view>
+                    <view class="time-row">
+                      <text class="time-label">鐏屾簤鏃堕暱锛�</text>
+                      <text class="time-value">{{group.duration}}鍒嗛挓</text>
+                    </view>
+                  </view>
+                </view>
+              </view>
+            </block>
+          </view>
+        </view>
+      </block>
+    </view>
+  </scroll-view>
+</view> 
\ No newline at end of file
diff --git a/pages/irrigationDetail/irrigationDetail.wxss b/pages/irrigationDetail/irrigationDetail.wxss
new file mode 100644
index 0000000..faa1876
--- /dev/null
+++ b/pages/irrigationDetail/irrigationDetail.wxss
@@ -0,0 +1,234 @@
+.irrigation-detail-container {
+  display: flex;
+  flex-direction: column;
+  height: 100vh;
+  background-color: #F5F5F5;
+}
+
+/* 椤堕儴淇℃伅鍖哄煙鏍峰紡 */
+.header-section {
+  background-color: #FFFFFF;
+  padding: 20rpx 30rpx;
+  margin-bottom: 20rpx;
+  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
+}
+
+.plan-info {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 20rpx;
+}
+
+.plan-code {
+  display: flex;
+  align-items: center;
+}
+
+.status-icon {
+  width: 68rpx;
+  height: 68rpx;
+}
+
+.time-info {
+  display: flex;
+  align-items: center;
+  padding: 10rpx 0;
+}
+
+.label {
+  color: #666666;
+  font-size: 28rpx;
+  margin-right: 10rpx;
+}
+
+.value {
+  color: #333333;
+  font-size: 28rpx;
+  font-weight: 500;
+}
+
+/* 椤圭洰鍒楄〃鏍峰紡 */
+.project-list {
+  flex: 1;
+  overflow: hidden;
+}
+
+.scroll-content {
+  padding: 0 30rpx 30rpx 30rpx;
+}
+
+.project-item {
+  margin-bottom: 30rpx;
+  border-radius: 12rpx;
+  overflow: hidden;
+  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
+  width: 100%;
+  box-sizing: border-box;
+}
+
+.project-header {
+  background-color: #FFFFFF;
+  padding: 20rpx 30rpx;
+  margin-bottom: 0;
+  display: flex;
+  align-items: flex-start;
+  width: 100%;
+  box-sizing: border-box;
+}
+
+/* 鎵�鏈夐」鐩爣棰橀兘鏈夊渾瑙� */
+.project-item .project-header {
+  border-radius: 12rpx;
+}
+
+/* 灞曞紑鐘舵�佺殑椤圭洰鏍囬鍙湁椤堕儴鍦嗚 */
+.project-item.expanded .project-header {
+  border-radius: 12rpx 12rpx 0 0;
+}
+
+.toggle-icon {
+  width: 32rpx;
+  height: 32rpx;
+  margin-right: 16rpx;
+  transition: transform 0.3s ease;
+  flex-shrink: 0;
+  margin-top: 6rpx;
+}
+
+.toggle-icon.expanded {
+  transform: rotate(180deg);
+}
+
+.project-info {
+  flex: 1;
+  width: calc(100% - 48rpx);
+}
+
+.project-name {
+  font-size: 32rpx;
+  font-weight: bold;
+  color: #333333;
+  word-break: break-all;
+}
+
+.project-duration {
+  font-size: 26rpx;
+  color: #666666;
+  margin-top: 10rpx;
+}
+
+/* 杞亴缁勫垪琛ㄦ牱寮� */
+.group-list {
+  background-color: #FFFFFF;
+  border-radius: 0 0 12rpx 12rpx;
+  padding: 0 20rpx;
+  overflow: hidden;
+  max-height: 0;
+  transition: all 0.3s ease-in-out;
+  width: 100%;
+  box-sizing: border-box;
+}
+
+.group-list.expanded {
+  max-height: 2000rpx; /* 瓒冲澶х殑楂樺害浠ュ绾冲唴瀹� */
+  padding: 0 20rpx 20rpx 20rpx;
+}
+
+.group-list.collapsed {
+  max-height: 0;
+  padding-top: 0;
+  padding-bottom: 0;
+}
+
+.group-item {
+  border-radius: 8rpx;
+  margin-top: 20rpx;
+  padding: 20rpx;
+  background-color: #F9F9F9;
+  position: relative;
+}
+
+/* 杞亴缁勭姸鎬佹牱寮� */
+.group-status-indicator {
+  display: flex;
+  align-items: center;
+  margin-bottom: 20rpx;
+}
+
+.status-dot {
+  width: 16rpx;
+  height: 16rpx;
+  border-radius: 50%;
+  margin-right: 10rpx;
+}
+
+.status-text {
+  font-size: 26rpx;
+  font-weight: 500;
+}
+
+/* 宸茬亴婧夌姸鎬� */
+.irrigated .status-dot {
+  background-color: #52C41A;
+}
+
+.irrigated .status-text {
+  color: #52C41A;
+}
+
+/* 姝e湪鐏屾簤鐘舵�� */
+.irrigating .status-dot {
+  background-color: #D43030;
+}
+
+.irrigating .status-text {
+  color: #D43030;
+}
+
+/* 鏈亴婧夌姸鎬� */
+.waiting .status-dot {
+  background-color: #FAAD14;
+}
+
+.waiting .status-text {
+  color: #FAAD14;
+}
+
+/* 杞亴缁勪俊鎭牱寮� */
+.group-info {
+  padding-left: 26rpx;
+}
+
+.group-name {
+  font-size: 30rpx;
+  font-weight: bold;
+  color: #333333;
+  margin-bottom: 20rpx;
+}
+
+.group-time-info {
+  background-color: #FFFFFF;
+  border-radius: 8rpx;
+  padding: 20rpx;
+}
+
+.time-row {
+  display: flex;
+  margin-bottom: 10rpx;
+}
+
+.time-row:last-child {
+  margin-bottom: 0;
+}
+
+.time-label {
+  color: #666666;
+  font-size: 26rpx;
+  width: 150rpx;
+}
+
+.time-value {
+  color: #333333;
+  font-size: 26rpx;
+} 
\ No newline at end of file
diff --git a/pages/login/login.js b/pages/login/login.js
index a4dd503..f7edc39 100644
--- a/pages/login/login.js
+++ b/pages/login/login.js
@@ -17,7 +17,9 @@
     countDown: 60,
     projectName: '鍢夊唱鍏抽」鐩�', // 榛樿椤圭洰鍚嶇О
     selectedProject: 'JYG', // 榛樿椤圭洰浠g爜
-    showErrorDialog: false
+    showErrorDialog: false,
+    fromBack: false,  // 鏍囪鏄惁鏄粠杩斿洖鎸夐挳杩斿洖鐨�
+    manualNavigate: false // 鏍囪鏄惁鏄�氳繃缂栫▼鏂瑰紡瀵艰埅鐨�
   },
 
   /**
@@ -61,8 +63,7 @@
       return;
     }
 
-    // 寮�濮嬪�掕鏃�
-    this.startCountDown();
+
 
     // 鍙戦�侀獙璇佺爜璇锋眰
     this.postCode();
@@ -140,40 +141,14 @@
       title: '鐧诲綍涓�...',
       mask: true
     });
-    this.wsLogin();
-
-
-    // 鍙戦�佺櫥褰曡姹�
-    post('/api/loginByCode', {
-      phone: phone,
-      code: verificationCode,
-      projectCode: this.data.selectedProject
-    }).then(res => {
-      wx.hideLoading();
-
-      if (res.code === 0 && res.data) {
-        // 淇濆瓨鐢ㄦ埛淇℃伅鍜宼oken
-        storage.setUserInfo(res.data);
-        storage.setToken(res.data.token);
-
-        // 璺宠浆鍒伴椤�
-        wx.switchTab({
-          url: '/pages/index/index'
-        });
-      } else {
-        wx.showToast({
-          title: res.msg || '鐧诲綍澶辫触锛岃閲嶈瘯',
-          icon: 'none'
-        });
-      }
-    }).catch(err => {
-      wx.hideLoading();
-      console.error('鐧诲綍澶辫触', err);
-      wx.showToast({
-        title: '缃戠粶寮傚父锛岃閲嶈瘯',
-        icon: 'none'
-      });
+    
+    // 鏍囪涓烘墜鍔ㄥ鑸紝纭繚涓嶄細瑙﹀彂杩斿洖閫昏緫
+    console.log('鐧诲綍鎸夐挳鐐瑰嚮锛岃缃甿anualNavigate=true');
+    this.setData({
+      manualNavigate: true
     });
+    
+    this.wsLogin();
   },
 
   /**
@@ -202,20 +177,63 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad: function (options) {
-    // 鑾峰彇閫夋嫨鐨勯」鐩�
-    if (options.project) {
+    console.log('login椤甸潰鍔犺浇锛宱ptions:', options);
+    
+    // 璁剧疆椤甸潰鏁版嵁
+    this.setData({
+      fromBack: false,  // 鏍囪鏄惁鏄粠杩斿洖鎸夐挳杩斿洖鐨�
+      manualNavigate: false // 鏍囪鏄惁鏄�氳繃缂栫▼鏂瑰紡瀵艰埅鐨�
+    });
+    
+    // 鑾峰彇閫夋嫨鐨勯」鐩� - 浼樺厛浣跨敤URL鍙傛暟
+    if (options && options.project) {
+      const project = options.project;
+      const projectName = project === 'JYG' ? '鍢夊唱鍏抽」鐩�' : '姘戝嫟椤圭洰';
+      
+      console.log(`浠嶶RL鍙傛暟鑾峰彇椤圭洰淇℃伅: ${project} (${projectName})`);
+      
       this.setData({
-        selectedProject: options.project,
-        projectName: options.project === 'JYG' ? '鍢夊唱鍏抽」鐩�' : '姘戝嫟椤圭洰'
+        selectedProject: project,
+        projectName: projectName
       });
+      
+      // 鍚屾鏇存柊鍏ㄥ眬椤圭洰璁剧疆
+      if (getApp().globalData) {
+        getApp().globalData.selectedProject = project;
+        
+        // 璁剧疆瀵瑰簲鐨則ag
+        if (project === 'JYG') {
+          getApp().globalData.tag = 'ym';
+        } else if (project === 'MQ') {
+          getApp().globalData.tag = 'mq';
+        }
+        
+        // 鏇存柊 BASEURL
+        try {
+          const { PROJECT_URLS } = require('../../api/config.js');
+          getApp().globalData.baseUrl = PROJECT_URLS[project];
+        } catch (e) {
+          console.error('璁剧疆baseUrl澶辫触:', e);
+        }
+      }
+      
+      // 淇濆瓨椤圭洰閫夋嫨鍒版湰鍦板瓨鍌紝纭繚椤圭洰淇℃伅涓�鑷�
+      storage.setItem('selectedProject', project)
+        .then(() => console.log('鎴愬姛淇濆瓨椤圭洰閫夋嫨鍒板瓨鍌�'))
+        .catch(err => console.error('淇濆瓨椤圭洰閫夋嫨鍒板瓨鍌ㄥけ璐�:', err));
     } else {
-      // 灏濊瘯浠庢湰鍦板瓨鍌ㄨ幏鍙栧凡閫夋嫨鐨勯」鐩�
-      storage.getItem('selectedProject').then(project => {
+      // 浠庢湰鍦板瓨鍌ㄨ幏鍙栧凡閫夋嫨鐨勯」鐩�
+      storage.getItemSafe('selectedProject').then(project => {
         if (project) {
+          const projectName = project === 'JYG' ? '鍢夊唱鍏抽」鐩�' : '姘戝嫟椤圭洰';
+          console.log(`浠庡瓨鍌ㄨ幏鍙栭」鐩俊鎭�: ${project} (${projectName})`);
+          
           this.setData({
             selectedProject: project,
-            projectName: project === 'JYG' ? '鍢夊唱鍏抽」鐩�' : '姘戝嫟椤圭洰'
+            projectName: projectName
           });
+        } else {
+          console.log('鏈壘鍒板凡閫夋嫨鐨勯」鐩紝浣跨敤榛樿椤圭洰');
         }
       }).catch(err => {
         console.error('鑾峰彇宸查�夋嫨椤圭洰澶辫触:', err);
@@ -241,7 +259,21 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
    */
   onHide() {
-
+    // 濡傛灉涓嶆槸閫氳繃缂栫▼鏂瑰紡瀵艰埅锛屽垯鍙兘鏄偣鍑讳簡杩斿洖鎸夐挳
+    // 娉ㄦ剰锛氬湪鏌愪簺鎯呭喌涓嬶紝寰俊鍙兘浼氱洿鎺ヨ皟鐢╫nUnload鑰岃烦杩噊nHide
+    if (!this.data.manualNavigate) {
+      console.log('椤甸潰闅愯棌锛屽彲鑳芥槸鐐瑰嚮浜嗚繑鍥炴寜閽�');
+      this.setData({
+        fromBack: true
+      });
+      
+      // 濡傛灉椤甸潰闅愯棌浣嗘湭鐧诲綍锛岃褰曚竴涓椂闂存埑锛屽府鍔╄瘑鍒槸鍚︽槸杩斿洖鎿嶄綔
+      if (!getApp().globalData.isLoggedIn) {
+        this.hideTimestamp = Date.now();
+      }
+    } else {
+      console.log('椤甸潰闅愯棌锛屾槸閫氳繃浠g爜瀵艰埅鐨�');
+    }
   },
 
   /**
@@ -253,6 +285,103 @@
       clearInterval(this.countDownTimer);
       this.countDownTimer = null;
     }
+    
+    // 璁板綍閫�鍑虹櫥褰曢〉闈㈢殑鎯呭喌
+    console.log('鐧诲綍椤甸潰鍗歌浇锛宖romBack:', this.data.fromBack, 'manualNavigate:', this.data.manualNavigate, '鐧诲綍鐘舵��:', !!getApp().globalData.isLoggedIn);
+    
+    // 濡傛灉鏄櫥褰曟垚鍔燂紝涓嶆墽琛岃繑鍥為�昏緫
+    if (getApp().globalData.isLoggedIn) {
+      console.log('鐢ㄦ埛宸茬櫥褰曪紝鏃犻渶鎵ц杩斿洖閫昏緫');
+      return;
+    }
+    
+    // 妫�鏌ユ槸鍚︽槸閫氳繃缂栫▼鏂瑰紡鏄庣‘璁剧疆浜嗗鑸�
+    // 濡傛灉娌℃湁鏄庣‘璁剧疆锛屽氨鍋囧畾鏄繑鍥炴搷浣�
+    if (!this.data.manualNavigate) {
+      console.log('椤甸潰鍗歌浇鏃舵湭璁剧疆manualNavigate锛屽亣瀹氭槸杩斿洖鎸夐挳鎿嶄綔');
+      
+      // 绔嬪嵆鍐欏叆涓存椂鏍囪锛屼互渚块椤垫娴嬪埌
+      try {
+        // 澶氱鏂瑰紡纭繚鍐欏叆鎴愬姛
+        wx.setStorageSync('_temp_from_login', 'true');
+        console.log('绔嬪嵆鍐欏叆_temp_from_login鏍囪涓簍rue');
+        
+        // 鍒涘缓涓�涓叏灞�瀵硅薄锛屼綔涓哄鐢ㄦ柟妗�
+        if (!getApp().globalData) {
+          getApp().globalData = {};
+        }
+        getApp().globalData._tempFromLogin = true;
+        console.log('鍚屾椂璁剧疆鍏ㄥ眬鍙橀噺_tempFromLogin=true');
+        
+        // 妫�鏌ュ啓鍏ユ槸鍚︽垚鍔�
+        const check = wx.getStorageSync('_temp_from_login');
+        console.log('妫�鏌ヤ复鏃舵爣璁版槸鍚﹀啓鍏ユ垚鍔�:', check);
+      } catch (e) {
+        console.error('鍐欏叆鏍囪澶辫触:', e);
+        // 澶囩敤鏂瑰紡鍐欏叆
+        wx.setStorage({
+          key: '_temp_from_login',
+          data: 'true'
+        });
+      }
+      
+      // 灏濊瘯浣跨敤wx.navigateBack杩斿洖涓婁竴椤碉紙濡傛灉鍙锛�
+      const pages = getCurrentPages();
+      if (pages.length > 1) {
+        console.log('妫�娴嬪埌鏈変笂涓�椤碉紝浣跨敤navigateBack杩斿洖');
+        wx.navigateBack({
+          delta: 1,
+          success: () => console.log('navigateBack鎴愬姛'),
+          fail: (err) => {
+            console.error('navigateBack澶辫触:', err);
+            // 濡傛灉navigateBack澶辫触锛屽皾璇時eLaunch
+            this.backupReturnToHome();
+          }
+        });
+      } else {
+        console.log('鏃犱笂涓�椤碉紝浣跨敤澶囩敤杩斿洖鏂瑰紡');
+        // 娌℃湁涓婁竴椤碉紝浣跨敤澶囩敤鏂规硶
+        this.backupReturnToHome();
+      }
+    } else {
+      console.log('閫氳繃缂栫▼鏂瑰紡绂诲紑鐧诲綍椤甸潰');
+    }
+  },
+  
+  // 澶囩敤鐨勮繑鍥為椤垫柟娉�
+  backupReturnToHome() {
+    console.log('浣跨敤澶囩敤鏂规硶杩斿洖棣栭〉');
+    
+    // 灏濊瘯浣跨敤switchTab锛堝鏋滈椤靛湪tabBar涓級
+    const useReLaunch = () => {
+      console.log('浣跨敤reLaunch杩斿洖棣栭〉');
+      wx.reLaunch({
+        url: '/pages/home/home?fromLogin=true',
+        success: () => console.log('reLaunch鎴愬姛杩斿洖棣栭〉'),
+        fail: (err) => {
+          console.error('reLaunch杩斿洖棣栭〉澶辫触:', err);
+          // 鏈�鍚庣殑澶囩敤鏂规锛氫娇鐢╮edirectTo
+          setTimeout(() => {
+            console.log('寤惰繜浣跨敤redirectTo灏濊瘯杩斿洖棣栭〉');
+            wx.redirectTo({
+              url: '/pages/home/home?fromLogin=true',
+              success: () => console.log('redirectTo鎴愬姛杩斿洖棣栭〉'),
+              fail: (err) => console.error('鎵�鏈夎繑鍥炴柟娉曢兘澶辫触:', err)
+            });
+          }, 100);
+        }
+      });
+    };
+    
+    // 鍏堝皾璇曚娇鐢╯witchTab锛堟煇浜涚増鏈彲鑳藉皢棣栭〉璁剧疆涓簍abBar锛�
+    wx.switchTab({
+      url: '/pages/home/home',
+      success: () => console.log('switchTab鎴愬姛杩斿洖棣栭〉'),
+      fail: (err) => {
+        console.log('switchTab澶辫触锛堝彲鑳介椤典笉鍦╰abBar涓級:', err);
+        useReLaunch();
+      }
+    });
   },
 
   /**
@@ -290,8 +419,8 @@
         this.setData({
           codeSent: true,
         });
-        // 鍚姩鍊掕鏃�
-        this.startCountdown();
+    // 寮�濮嬪�掕鏃�
+    this.startCountDown();
       })
       .catch((error) => {
         wx.showToast({
@@ -302,20 +431,39 @@
       });
   },
   wsLogin() {
+    // 鏍囪涓烘墜鍔ㄥ鑸�
+    console.log('wsLogin璋冪敤锛岃缃甿anualNavigate=true');
+    this.setData({
+      manualNavigate: true
+    });
+    
     wx.login({
       success: res => {
         if (res.code) {
-          console.log('鐧诲綍鎴愬姛锛岃幏鍙栧埌鐨刢ode:', res.code);
+          console.log('寰俊鐧诲綍鎴愬姛锛岃幏鍙栧埌鐨刢ode:', res.code);
           // 鍙戦�� res.code 鍒板悗鍙版湇鍔″櫒鎹㈠彇 openId, sessionKey, unionId
           this.verify(res.code)
         } else {
-          console.log('鐧诲綍澶辫触锛�' + res.errMsg);
+          console.log('寰俊鐧诲綍澶辫触锛�' + res.errMsg);
+          // 鐧诲綍澶辫触鏃堕噸缃姸鎬�
+          this.setData({
+            manualNavigate: false
+          });
         }
+      },
+      fail: err => {
+        console.error('寰俊鐧诲綍API璋冪敤澶辫触:', err);
+        // 鐧诲綍澶辫触锛岄噸缃鑸爣璁�
+        this.setData({
+          manualNavigate: false
+        });
       }
     });
   },
   //鐢ㄦ埛缁戝畾
   verify(wxCode) {
+    console.log('verify璋冪敤锛岀‘璁anualNavigate=', this.data.manualNavigate);
+    
     const params = {
       url: 'wx/client/verify',
       data: {
@@ -324,34 +472,115 @@
         code: wxCode
       }
     };
+    
     post(params)
       .then((data) => {
         wx.hideLoading();
-        getApp().globalData.sessionId = String(data.content.sessionId)
-        storage.setItem("sessionId", String(data.content.sessionId))
-        getApp().globalData.clientId = String(data.content.clientId)
-        storage.setItem("clientId", String(data.content.clientId))
-        this.bindSuccess();
+        
+        console.log('楠岃瘉鎴愬姛锛屽噯澶囦繚瀛樼敤鎴锋暟鎹�');
+        
+        // 纭繚鍏ㄥ眬瀵硅薄宸插垵濮嬪寲
+        if (!getApp().globalData) {
+          getApp().globalData = {};
+        }
+        
+        // 淇濆瓨浼氳瘽ID鍜屽鎴风ID
+        getApp().globalData.sessionId = String(data.content.sessionId);
+        storage.setItem("sessionId", String(data.content.sessionId));
+        getApp().globalData.clientId = String(data.content.clientId);
+        storage.setItem("clientId", String(data.content.clientId));
+        
+        // 璁剧疆褰撳墠椤圭洰鐨則ag
+        const tag = this.data.selectedProject === 'JYG' ? 'ym' : 'mq';
+        getApp().globalData.tag = tag;
+        
+        // 淇濆瓨鐢ㄦ埛淇℃伅
+        const userInfo = {
+          sessionId: String(data.content.sessionId),
+          clientId: String(data.content.clientId),
+          phone: this.data.phone,
+          token: data.content.token || '',
+          project: this.data.selectedProject,
+          tag: tag
+        };
+        
+        // 淇濆瓨鍒板叏灞�鍙橀噺
+        getApp().globalData.userInfo = userInfo;
+        getApp().globalData.isLoggedIn = true;
+        
+        // 淇濆瓨鍒版湰鍦板瓨鍌�
+        storage.setItem("userInfo", JSON.stringify(userInfo))
+          .then(() => {
+            console.log('鐢ㄦ埛淇℃伅淇濆瓨鎴愬姛');
+            return storage.setItem("isLoggedIn", "true");
+          })
+          .then(() => {
+            // 淇濆瓨userData淇℃伅锛屽寘鍚玸essionId鍜宼ag
+            const userData = JSON.stringify({
+              sessionId: String(data.content.sessionId),
+              tag: tag
+            });
+            return storage.setItem("userData", userData);
+          })
+          .then(() => {
+            console.log('鐧诲綍鐘舵�佸拰椤圭洰淇℃伅淇濆瓨鎴愬姛');
+            this.bindSuccess();
+          })
+          .catch(err => {
+            console.warn('淇濆瓨鐢ㄦ埛淇℃伅杩囩▼涓嚭閿欙紝浣嗕笉褰卞搷缁х画鎿嶄綔:', err);
+            this.bindSuccess();
+          });
       })
       .catch((error) => {
         wx.hideLoading();
+        console.error('楠岃瘉璇锋眰澶辫触:', error);
+        
+        // 楠岃瘉澶辫触锛岄渶瑕侀噸缃鑸爣璁�
+        console.log('楠岃瘉澶辫触锛岄噸缃甿anualNavigate=false');
+        this.setData({
+          manualNavigate: false
+        });
+        
         wx.showToast({
-          title: error.msg,
+          title: error.msg || '楠岃瘉澶辫触',
           icon: 'error',
           duration: 3000,
         });
-        console.error('Failed to add item:', error);
       });
   },
   bindSuccess: function () {
-    if (!this.data.isButtonEnabled) return;
+    // 璁剧疆鏍囪锛岃〃绀洪�氳繃缂栫▼鏂瑰紡瀵艰埅
+    console.log('缁戝畾鎴愬姛锛屾渶缁堢‘璁anualNavigate=true');
+    this.setData({
+      manualNavigate: true,
+      fromBack: false // 纭繚涓嶄細琚瘑鍒负杩斿洖鎿嶄綔
+    });
+    
+    // 璁剧疆鍏ㄥ眬鐧诲綍鐘舵��
+    getApp().globalData.isLoggedIn = true;
+    
+    // 纭繚娓呴櫎涓存椂鏍囪
+    try {
+      wx.removeStorageSync('_temp_from_login');
+    } catch(e) {
+      console.warn('娓呴櫎涓存椂鏍囪澶辫触', e);
+    }
+    
     wx.showToast({
       title: '缁戝畾鎴愬姛',
-      icon: 'success'
-    });
-    // 璺宠浆鍒� TabBar 椤甸潰
-    wx.redirectTo({
-      url: '/pages/home/home' // 杩欓噷濉啓浣犳兂瑕佽烦杞殑 TabBar 椤甸潰璺緞
+      icon: 'success',
+      duration: 1500,
+      mask: true,
+      success: () => {
+        // 寤惰繜璺宠浆锛岀‘淇漈oast鏄剧ず瀹屾垚
+        setTimeout(() => {
+          console.log('鐧诲綍鎴愬姛锛屽噯澶囪烦杞埌棣栭〉');
+          // 璺宠浆鍒伴椤碉紝浣跨敤reLaunch鑰屼笉鏄痳edirectTo
+          wx.reLaunch({
+            url: '/pages/home/home'
+          });
+        }, 1500);
+      }
     });
   },
 })
\ No newline at end of file
diff --git a/pages/login/login.wxml b/pages/login/login.wxml
index b45afd7..cef1f9f 100644
--- a/pages/login/login.wxml
+++ b/pages/login/login.wxml
@@ -25,7 +25,7 @@
     </view>
   </view>
   
-  <view class="project-info">
+  <view class="project-info {{selectedProject === 'MQ' ? 'mq' : 'jyg'}}">
     <text>褰撳墠椤圭洰: {{projectName}}</text>
   </view>
 
diff --git a/pages/login/login.wxss b/pages/login/login.wxss
index e44353a..2f94d3c 100644
--- a/pages/login/login.wxss
+++ b/pages/login/login.wxss
@@ -123,8 +123,25 @@
   bottom: 40rpx;
   width: 100%;
   text-align: center;
-  font-size: 28rpx;
-  color: #999;
+  font-size: 32rpx;
+  padding: 16rpx 0;
+  background-color: rgba(255, 255, 255, 0.8);
+  backdrop-filter: blur(5px);
+  box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
+}
+
+.project-info text {
+  display: inline-block;
+  padding: 8rpx 24rpx;
+  color: #fff;
+  border-radius: 30rpx;
+  font-weight: 500;
+  box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.2);
+  background: linear-gradient(45deg, #1890FF, #36a9fc);
+}
+
+.project-info.mq text {
+  background: linear-gradient(45deg, #18c063, #36d486);
 }
 
 image {
diff --git a/pages/waterIntake/waterIntake.js b/pages/waterIntake/waterIntake.js
index 7059ee3..22ec85b 100644
--- a/pages/waterIntake/waterIntake.js
+++ b/pages/waterIntake/waterIntake.js
@@ -102,7 +102,7 @@
     const data = {
       intakeId: intakeId, //鍙栨按鍙D
       // vcId: vcId, //铏氭嫙鍗D
-      operator: app.globalData.operator, //鎿嶄綔鍛�
+      operator: app.globalData.clientId, //鎿嶄綔鍛�
       forceOpen: !!isforce // 浣跨敤閫昏緫闈炴搷浣滅 !! 鏉ョ‘淇� isForce 鏄竷灏斿��  
     };
     post({
@@ -243,7 +243,7 @@
     get({
         url: 'wx/intake/used_intakes',
         data: {
-          operatorId: getApp().globalData.operator
+          operatorId: getApp().globalData.clientId
         }
       })
       .then((data) => {
diff --git a/utils/storage.js b/utils/storage.js
index 3ca562d..698b9ea 100644
--- a/utils/storage.js
+++ b/utils/storage.js
@@ -1,30 +1,79 @@
 const setItem = (key, data) => {
   return new Promise((resolve, reject) => {
+    if (!key) {
+      reject(new Error('瀛樺偍閿笉鑳戒负绌�'));
+      return;
+    }
+    
     wx.setStorage({
       key: key,
       data: data,
       success: resolve,
-      fail: reject
+      fail: (err) => {
+        console.error(`璁剧疆瀛樺偍椤� ${key} 澶辫触:`, err);
+        reject(err);
+      }
     });
   });
 };
 
 const getItem = (key) => {
   return new Promise((resolve, reject) => {
+    if (!key) {
+      reject(new Error('瀛樺偍閿笉鑳戒负绌�'));
+      return;
+    }
+    
     wx.getStorage({
       key: key,
       success: (res) => resolve(res.data),
-      fail: reject
+      fail: (err) => {
+        console.error(`鑾峰彇瀛樺偍椤� ${key} 澶辫触:`, err);
+        reject(err);
+      }
+    });
+  });
+};
+
+// 瀹夊叏鑾峰彇瀛樺偍椤癸紝澶辫触鏃惰繑鍥為粯璁ゅ�艰�屼笉鏄嫆缁漃romise
+const getItemSafe = (key, defaultValue = null) => {
+  return new Promise((resolve) => {
+    if (!key) {
+      resolve(defaultValue);
+      return;
+    }
+    
+    wx.getStorage({
+      key: key,
+      success: (res) => resolve(res.data),
+      fail: (err) => {
+        // 鍦ㄥ紑鍙戠幆澧冧笅璁板綍璀﹀憡锛屼絾涓嶄綔涓洪敊璇鐞�
+        // 鏁版嵁涓嶅瓨鍦ㄦ槸姝e父鎯呭喌锛屼笉闇�瑕佷綔涓鸿鍛婅緭鍑�
+        if (err.errMsg !== "getStorage:fail data not found") {
+          console.warn(`瀹夊叏鑾峰彇瀛樺偍椤� ${key} 澶辫触:`, err);
+        } else {
+          console.log(`瀛樺偍椤� ${key} 涓嶅瓨鍦紝杩斿洖榛樿鍊糮);
+        }
+        resolve(defaultValue);
+      }
     });
   });
 };
 
 const removeItem = (key) => {
   return new Promise((resolve, reject) => {
+    if (!key) {
+      reject(new Error('瀛樺偍閿笉鑳戒负绌�'));
+      return;
+    }
+    
     wx.removeStorage({
       key: key,
       success: resolve,
-      fail: reject
+      fail: (err) => {
+        console.error(`鍒犻櫎瀛樺偍椤� ${key} 澶辫触:`, err);
+        reject(err);
+      }
     });
   });
 };
@@ -33,21 +82,27 @@
   return new Promise((resolve, reject) => {
     wx.clearStorage({
       success: resolve,
-      fail: reject
+      fail: (err) => {
+        console.error('娓呴櫎瀛樺偍澶辫触:', err);
+        reject(err);
+      }
     });
   });
 };
 
 /**
  * 鍒ゆ柇鏈湴鏄惁淇濆瓨浜嗘煇涓猭ey
- * @param {} key 
+ * @param {String} key 瀛樺偍閿�
+ * @returns {Boolean} 鏄惁瀛樺湪璇ラ敭
  */
-const isHasKeySync= (key) => {
+const isHasKeySync = (key) => {
+  if (!key) return false;
+  
   try {
     const res = wx.getStorageInfoSync();
     return res.keys.includes(key);
   } catch (e) {
-    console.error('Failed to get storage info:', e);
+    console.error('鑾峰彇瀛樺偍淇℃伅澶辫触:', e);
     return false;
   }
 };
@@ -55,6 +110,7 @@
 module.exports = {
   setItem,
   getItem,
+  getItemSafe,
   removeItem,
   clear,
   isHasKeySync

--
Gitblit v1.8.0