From 310633feef20e9b77d44fd25e0b41778e033b33b Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期二, 11 十一月 2025 21:48:46 +0800
Subject: [PATCH] feat: 车辆GPS统计,并修改了一些变更任务状态的逻辑

---
 app/pages/task/create-emergency.vue |  232 +++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 143 insertions(+), 89 deletions(-)

diff --git a/app/pages/task/create-emergency.vue b/app/pages/task/create-emergency.vue
index 4ad6a63..8154fcb 100644
--- a/app/pages/task/create-emergency.vue
+++ b/app/pages/task/create-emergency.vue
@@ -342,6 +342,7 @@
           type="digit" 
           placeholder="璇疯緭鍏ヨ浆杩愬叕閲屾暟" 
           v-model="taskForm.transferDistance"
+          @blur="onDistanceChange"
         />
       </view>
       
@@ -506,9 +507,11 @@
 import { addTask } from "@/api/task"
 import { listAvailableVehicles, getUserBoundVehicle } from "@/api/vehicle"
 import { calculateDistance, baiduDistanceByAddress, baiduPlaceSuggestion } from "@/api/map"
-import { searchHospitals, getFrequentOutHospitals, getFrequentInHospitals } from "@/api/hospital"
-import { listUser } from "@/api/system/user"
+import { searchHospitals, getFrequentOutHospitals, getFrequentInHospitals, searchHospitalsByDeptRegion } from "@/api/hospital"
+import { listBranchUsers } from "@/api/system/user"
 import { searchIcd10 } from "@/api/icd10"
+import { calculateTransferPrice } from "@/api/price"
+import { checkVehicleActiveTasks } from "@/api/task"
 
 import { getDicts } from "@/api/dict"
 import { getServiceOrdAreaTypes, getServiceOrderTypes, getHospitalDepartments } from "@/api/dictionary"
@@ -720,11 +723,14 @@
       this.selectedOrganizationServiceOrderClass = selected.serviceOrderClass || '' // 淇濆瓨鏈嶅姟鍗曠紪鐮�
       // 浠庡綊灞炴満鏋勪腑鎻愬彇鍦板煙鍏抽敭璇嶏紙鍘婚櫎鈥滃垎鍏徃鈥濆悗缂�锛�
       // 渚嬪锛氣�滃箍宸炲垎鍏徃鈥� -> 鈥滃箍宸炩��
-      this.selectedRegion = selected.deptName.replace(/鍒嗗叕鍙�$/g, '').trim()
+      //濡傛灉鍑虹幇骞垮窞鎬诲叕鍙革紝涔熻鍘婚櫎鈥滄�诲叕鍙糕�濆悗缂�
+      this.selectedRegion = this.replaceRegion(selected.deptName);
       // 閲嶆柊鍔犺浇鍖婚櫌鍒楄〃锛堝甫鍦板煙杩囨护锛�
       this.loadDefaultHospitals()
     },
-    
+    replaceRegion(region){
+		return region.replace(/(鍒嗗叕鍙竱鎬诲叕鍙竱鎬婚儴)$/g, '').trim();
+	},
     // 鍔犺浇鍒嗗叕鍙告暟鎹紙parent_id=100鐨勯儴闂級
     loadBranchCompanies() {
       listBranchCompany().then(response => {
@@ -744,7 +750,7 @@
             this.selectedOrganizationId = this.organizationOptions[index].deptId // 淇濆瓨閮ㄩ棬ID
             this.selectedOrganizationServiceOrderClass = this.organizationOptions[index].serviceOrderClass || '' // 淇濆瓨鏈嶅姟鍗曠紪鐮�
             // 鎻愬彇鍦板煙鍏抽敭璇�
-            this.selectedRegion = this.selectedOrganization.replace(/鍒嗗叕鍙�$/g, '').trim()
+            this.selectedRegion =this.replaceRegion(this.selectedOrganization);
             console.log('榛樿閫変腑褰掑睘鏈烘瀯:', this.selectedOrganization, '閮ㄩ棬ID:', this.selectedOrganizationId, '鏈嶅姟鍗曠紪鐮�:', this.selectedOrganizationServiceOrderClass, '鍦板煙:', this.selectedRegion)
             // 鍔犺浇鍖婚櫌鍒楄〃锛堝甫鍦板煙杩囨护锛�
             this.loadDefaultHospitals()
@@ -807,7 +813,7 @@
       switch(staffType){
         case "nurse":
           return "鎶ゅ+";
-        case "doctor":
+        case "doctor":          
           return "鍖荤敓";
         case "driver":
           return "鍙告満";
@@ -865,57 +871,17 @@
     
     // 鍔犺浇榛樿鍖婚櫌鍒楄〃锛堝父鐢ㄥ尰闄級
     loadDefaultHospitals() {
-      // 妫�鏌ユ槸鍚︽湁鏈嶅姟鍗曠紪鐮�
-      if (!this.selectedOrganizationServiceOrderClass) {
-        console.warn('鏈壘鍒版湇鍔″崟缂栫爜锛屾棤娉曞姞杞藉父鐢ㄥ尰闄�')
-        // 濡傛灉娌℃湁鏈嶅姟鍗曠紪鐮侊紝闄嶇骇涓烘櫘閫氭悳绱紙鎸夊湴鍩熻繃婊わ級
-        this.loadDefaultHospitalsByRegion()
+      // 妫�鏌ユ槸鍚︽湁褰掑睘鏈烘瀯ID
+      if (!this.selectedOrganizationId) {
+        console.warn('鏈�夋嫨褰掑睘鏈烘瀯锛屾棤娉曞姞杞藉尰闄㈠垪琛�')
         return
       }
       
-      // 杞嚭鍖婚櫌锛氬姞杞藉綋鍓嶅垎鍏徃鐨勫父鐢ㄨ浆鍑哄尰闄�
-      getFrequentOutHospitals(this.selectedOrganizationServiceOrderClass, this.selectedRegion).then(response => {
-        this.hospitalOutResults = response.data || []
-        console.log('鍔犺浇甯哥敤杞嚭鍖婚櫌锛�', this.selectedOrganizationServiceOrderClass, '鍦板煙:', this.selectedRegion, '鏁伴噺:', this.hospitalOutResults.length)
-        
-        // 濡傛灉娌℃湁甯哥敤鍖婚櫌锛岄檷绾т负鏅�氭悳绱�
-        if (this.hospitalOutResults.length === 0) {
-          console.log('鏈壘鍒板父鐢ㄨ浆鍑哄尰闄紝闄嶇骇涓哄湴鍩熸悳绱�')
-          searchHospitals('', this.selectedRegion).then(res => {
-            this.hospitalOutResults = res.data || []
-          })
-        }
-      }).catch(error => {
-        console.error('鍔犺浇甯哥敤杞嚭鍖婚櫌澶辫触:', error)
-        // 澶辫触鍚庨檷绾т负鏅�氭悳绱�
-        searchHospitals('', this.selectedRegion).then(res => {
-          this.hospitalOutResults = res.data || []
-        })
-      })
+      // 杞嚭鍖婚櫌锛氭牴鎹綊灞炴満鏋勭殑鍖哄煙閰嶇疆鍔犺浇
+      this.loadHospitalsByDeptRegion('out')
       
-      // 杞叆鍖婚櫌锛氬姞杞藉綋鍓嶅垎鍏徃鐨勫父鐢ㄨ浆鍏ュ尰闄紙鏈湴鍖哄煙浼樺厛锛�
-      getFrequentInHospitals(this.selectedOrganizationServiceOrderClass, '').then(response => {
-        const allHospitals = response.data || []
-        // 灏嗗尰闄㈡寜鍦板煙鎺掑簭锛氭湰鍦板尯鍩熶紭鍏�
-        this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
-        console.log('鍔犺浇甯哥敤杞叆鍖婚櫌锛�', this.selectedOrganizationServiceOrderClass, '鏁伴噺:', this.hospitalInResults.length)
-        
-        // 濡傛灉娌℃湁甯哥敤鍖婚櫌锛岄檷绾т负鏅�氭悳绱�
-        if (this.hospitalInResults.length === 0) {
-          console.log('鏈壘鍒板父鐢ㄨ浆鍏ュ尰闄紝闄嶇骇涓哄叏閮ㄥ尰闄�')
-          searchHospitals('', '').then(res => {
-            const allHospitals = res.data || []
-            this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
-          })
-        }
-      }).catch(error => {
-        console.error('鍔犺浇甯哥敤杞叆鍖婚櫌澶辫触:', error)
-        // 澶辫触鍚庨檷绾т负鏅�氭悳绱�
-        searchHospitals('', '').then(res => {
-          const allHospitals = res.data || []
-          this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
-        })
-      })
+      // 杞叆鍖婚櫌锛氭牴鎹綊灞炴満鏋勭殑鍖哄煙閰嶇疆鍔犺浇
+      this.loadHospitalsByDeptRegion('in')
     },
     
     // 闄嶇骇鍔犺浇鍖婚櫌锛堟寜鍦板煙杩囨护锛�
@@ -938,6 +904,33 @@
       }).catch(error => {
         console.error('鍔犺浇杞叆鍖婚櫌鍒楄〃澶辫触:', error)
         this.hospitalInResults = []
+      })
+    },
+    
+    // 鏍规嵁閮ㄩ棬鍖哄煙閰嶇疆鍔犺浇鍖婚櫌
+    loadHospitalsByDeptRegion(type) {
+      const deptId = this.selectedOrganizationId
+      if (!deptId) {
+        console.warn('閮ㄩ棬ID涓嶅瓨鍦�')
+        return
+      }
+      
+      // 璋冪敤鍚庣鎺ュ彛锛屾牴鎹儴闂ㄧ殑鍖哄煙閰嶇疆鏌ヨ鍖婚櫌
+      searchHospitalsByDeptRegion('', deptId).then(response => {
+        const hospitals = response.data || []
+        
+        if (type === 'out') {
+          this.hospitalOutResults = hospitals
+          console.log('鍔犺浇杞嚭鍖婚櫌锛堝尯鍩熼厤缃級锛氶儴闂�', deptId, '鏁伴噺:', this.hospitalOutResults.length)
+        } else if (type === 'in') {
+          // 杞叆鍖婚櫌鎸夊湴鍩熸帓搴�
+          this.hospitalInResults = this.sortHospitalsByRegion(hospitals)
+          console.log('鍔犺浇杞叆鍖婚櫌锛堝尯鍩熼厤缃級锛氶儴闂�', deptId, '鏁伴噺:', this.hospitalInResults.length)
+        }
+      }).catch(error => {
+        console.error('鍔犺浇鍖婚櫌澶辫触锛堝尯鍩熼厤缃級:', error)
+        // 澶辫触鍚庨檷绾т负鏅�氭悳绱�
+        this.loadDefaultHospitalsByRegion()
       })
     },
     
@@ -995,21 +988,21 @@
             this.hospitalOutResults = this.sortHospitalsByRegion(hospitals)
             // 濡傛灉娌℃湁甯哥敤鍖婚櫌锛岄檷绾т负鏅�氭悳绱�
             if (this.hospitalOutResults.length === 0) {
-              searchHospitals('', this.selectedRegion).then(res => {
+              searchHospitals('', this.selectedOrganizationId).then(res => {
                 const hospitals = res.data || []
                 this.hospitalOutResults = this.sortHospitalsByRegion(hospitals)
               })
             }
           }).catch(error => {
             console.error('鍔犺浇甯哥敤杞嚭鍖婚櫌澶辫触:', error)
-            searchHospitals('', this.selectedRegion).then(res => {
+            searchHospitals('', this.selectedOrganizationId).then(res => {
               const hospitals = res.data || []
               this.hospitalOutResults = this.sortHospitalsByRegion(hospitals)
             })
           })
         } else {
           // 娌℃湁鏈嶅姟鍗曠紪鐮侊紝浣跨敤鏅�氭悳绱�
-          searchHospitals('', this.selectedRegion).then(response => {
+          searchHospitals('', this.selectedOrganizationId).then(response => {
             const hospitals = response.data || []
             this.hospitalOutResults = this.sortHospitalsByRegion(hospitals)
           }).catch(error => {
@@ -1033,7 +1026,7 @@
       
       // 濡傛灉鍏抽敭璇嶄负绌猴紝鏄剧ず褰撳墠鍖哄煙鐨勫尰闄�
       if (!keyword || keyword.trim() === '') {
-        searchHospitals('', this.selectedRegion).then(response => {
+        searchHospitals('', this.selectedOrganizationId).then(response => {
           const hospitals = response.data || []
           // 纭繚"瀹朵腑"鍦ㄦ渶鍓嶉潰
           this.hospitalOutResults = this.sortHospitalsByRegion(hospitals)
@@ -1053,13 +1046,13 @@
     
     // 鎼滅储杞嚭鍖婚櫌锛堜粎闄愬綋鍓嶅尯鍩燂級
     searchHospitalOut(keyword) {
-      // 浼犲叆鍏抽敭璇嶅拰鍦板煙杩囨护锛屽彧鎼滅储褰撳墠鍖哄煙鐨勫尰闄�
-      searchHospitals(keyword, this.selectedRegion).then(response => {
+      // 浼犲叆鍏抽敭璇嶅拰閮ㄩ棬ID锛屽彧鎼滅储褰撳墠鍖哄煙鐨勫尰闄�
+      searchHospitals(keyword, this.selectedOrganizationId).then(response => {
         const hospitals = response.data || []
         // 纭繚"瀹朵腑"鍦ㄦ渶鍓嶉潰
         this.hospitalOutResults = this.sortHospitalsByRegion(hospitals)
         this.showHospitalOutResults = true
-        console.log('鎼滅储杞嚭鍖婚櫌:', keyword, '鍖哄煙:', this.selectedRegion, '缁撴灉鏁�:', this.hospitalOutResults.length)
+        console.log('鎼滅储杞嚭鍖婚櫌:', keyword, '閮ㄩ棬ID:', this.selectedOrganizationId, '缁撴灉鏁�:', this.hospitalOutResults.length)
       }).catch(error => {
         console.error('鎼滅储杞嚭鍖婚櫌澶辫触:', error)
         this.hospitalOutResults = []
@@ -1123,21 +1116,21 @@
             this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
             // 濡傛灉娌℃湁甯哥敤鍖婚櫌锛岄檷绾т负鏅�氭悳绱�
             if (this.hospitalInResults.length === 0) {
-              searchHospitals('', '').then(res => {
+              searchHospitals('', null).then(res => {
                 const allHospitals = res.data || []
                 this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
               })
             }
           }).catch(error => {
             console.error('鍔犺浇甯哥敤杞叆鍖婚櫌澶辫触:', error)
-            searchHospitals('', '').then(res => {
+            searchHospitals('', null).then(res => {
               const allHospitals = res.data || []
               this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
             })
           })
         } else {
           // 娌℃湁鏈嶅姟鍗曠紪鐮侊紝浣跨敤鏅�氭悳绱�
-          searchHospitals('', '').then(response => {
+          searchHospitals('', null).then(response => {
             const allHospitals = response.data || []
             // 鎸夊湴鍩熸帓搴忥細鏈湴鍖哄煙浼樺厛
             this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
@@ -1162,7 +1155,7 @@
       
       // 濡傛灉鍏抽敭璇嶄负绌猴紝鏄剧ず鎵�鏈夊尰闄紙鏈湴鍖哄煙浼樺厛锛�
       if (!keyword || keyword.trim() === '') {
-        searchHospitals('', '').then(response => {
+        searchHospitals('', null).then(response => {
           const allHospitals = response.data || []
           // 鎸夊湴鍩熸帓搴忥細"瀹朵腑"鏈�鍓嶏紝鏈湴鍖哄煙浼樺厛
           this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
@@ -1182,8 +1175,8 @@
     
     // 鎼滅储杞叆鍖婚櫌锛堜笉闄愬尯鍩燂紝浣嗘湰鍦板尯鍩熶紭鍏堬級
     searchHospitalIn(keyword) {
-      // 浼犲叆鍏抽敭璇嶏紝涓嶄紶鍦板煙杩囨护锛堟悳绱㈡墍鏈夊尯鍩燂級
-      searchHospitals(keyword, '').then(response => {
+      // 浼犲叆鍏抽敭璇嶏紝涓嶄紶閮ㄩ棬ID锛堟悳绱㈡墍鏈夊尯鍩燂級
+      searchHospitals(keyword, null).then(response => {
         const allHospitals = response.data || []
         // 鎸夊湴鍩熸帓搴忥細"瀹朵腑"鏈�鍓嶏紝鏈湴鍖哄煙浼樺厛
         this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
@@ -1256,24 +1249,14 @@
     
     // 鍔犺浇褰撳墠鐢ㄦ埛鎵�鍦ㄥ垎鍏徃鐨勬墍鏈変汉鍛�
     loadDeptStaff() {
-      const deptId = this.currentUser.deptId
-      if (!deptId) {
-        console.error('鏃犳硶鑾峰彇褰撳墠鐢ㄦ埛鎵�鍦ㄩ儴闂�')
-        this.$modal.showToast('鏃犳硶鑾峰彇鎵�鍦ㄩ儴闂ㄤ俊鎭�')
-        return
-      }
+      console.log('寮�濮嬪姞杞戒汉鍛樺垪琛�')
       
-      // 鐩存帴鏌ヨ褰撳墠鐢ㄦ埛閮ㄩ棬涓嬬殑鎵�鏈夌敤鎴�
-      // 鍚庣SQL浼氳嚜鍔ㄥ鐞嗭細濡傛灉浼犲叆鐨勬槸瀛愰儴闂紝浼氭煡鎵惧叾鎵�灞炵殑鍒嗗叕鍙稿強鍏舵墍鏈夊瓙閮ㄩ棬鐨勭敤鎴�
-      const queryParams = {
-        deptId: deptId,
-        status: '0', // 鍙煡璇㈡甯哥姸鎬佺殑鐢ㄦ埛
-        pageNum: 1,
-        pageSize: 10000 // 璁剧疆瓒冲澶х殑椤甸潰澶у皬锛岃幏鍙栨墍鏈夌敤鎴�
-      }
-      
-      listUser(queryParams).then(response => {
-        const userList = response.rows || response.data || []
+      // 璋冪敤鏂版帴鍙o紝鑷姩鏍规嵁褰撳墠鐢ㄦ埛鐨刼aOrderClass鑾峰彇鍒嗗叕鍙镐笅鐨勭敤鎴�
+      listBranchUsers().then(response => {
+        console.log('浜哄憳鍒楄〃API鍝嶅簲:', response)
+        const userList = response.data || []
+        console.log('瑙f瀽鍑虹殑鐢ㄦ埛鍒楄〃:', userList, '鏁伴噺:', userList.length)
+        
         this.allStaffList = userList.map(user => ({
           userId: user.userId,
           nickName: user.nickName,
@@ -1284,6 +1267,8 @@
           // 鏍规嵁宀椾綅鍚嶇О鎴栬鑹插悕绉板垽鏂被鍨�
           type: this.getUserType(user)
         }))
+        
+        console.log('澶勭悊鍚庣殑浜哄憳鍒楄〃:', this.allStaffList, '鏁伴噺:', this.allStaffList.length)
         
         // 鍒濆鍖栬繃婊ゅ垪琛�
         this.filterStaffList()
@@ -1303,14 +1288,18 @@
       if (postName.includes('鍙告満') || roleName.includes('鍙告満') || deptName.includes('杞﹂槦') || deptName.includes('鍙告満')) {
         return 'driver'
       }
-      // 鍒ゆ柇鏄惁涓哄尰鐢�
-      if (postName.includes('鍖荤敓') || roleName.includes('鍖荤敓') || deptName.includes('鍖荤敓')) {
-        return 'doctor'
-      }
       // 鍒ゆ柇鏄惁涓烘姢澹�
       if (postName.includes('鎶ゅ+') || roleName.includes('鎶ゅ+') || deptName.includes('鎶ゅ+')) {
         return 'nurse'
       }
+      // 鍒ゆ柇鏄惁涓哄尰鐢�
+      if (postName.includes('鍖荤敓') || roleName.includes('鍖荤敓') || deptName.includes('鍖荤敓') ) {
+        return 'doctor'
+      }
+      if( deptName.includes("鍖绘姢")){
+        return 'doctor'
+      }
+      
       // 鍏朵粬绫诲瀷锛岄粯璁や负鍙告満
       return 'driver'
     },
@@ -1342,6 +1331,7 @@
     
     // 杩囨护浜哄憳鍒楄〃
     filterStaffList() {
+      console.log('寮�濮嬭繃婊や汉鍛樺垪琛紝鍘熷鏁伴噺:', this.allStaffList.length)
       let list = [...this.allStaffList]
       
       // 鎸夌被鍨嬭繃婊�
@@ -1353,6 +1343,8 @@
         list = list.filter(staff => staff.type === 'nurse')
       }
       
+      console.log('鎸夌被鍨嬭繃婊ゅ悗:', this.staffFilterType, '鏁伴噺:', list.length)
+      
       // 鎸夊叧閿瘝鎼滅储
       if (this.staffSearchKeyword && this.staffSearchKeyword.trim() !== '') {
         const keyword = this.staffSearchKeyword.trim().toLowerCase()
@@ -1362,7 +1354,10 @@
         })
       }
       
+      console.log('鎸夊叧閿瘝杩囨护鍚庯紝鏁伴噺:', list.length)
+      
       this.filteredStaffList = list
+      console.log('鏈�缁堣繃婊ょ粨鏋�:', this.filteredStaffList)
     },
     
     // 鍒囨崲浜哄憳閫変腑鐘舵��
@@ -1600,6 +1595,9 @@
             
             console.log('璺濈璁$畻鎴愬姛:', distanceInKm, 'km')
             this.$modal.showToast(`璺濈: ${distanceInKm}鍏噷`)
+            
+            // 璺濈璁$畻鎴愬姛鍚庯紝鑷姩璁$畻鎴愪氦浠�
+            this.calculatePrice()
           } else {
             console.error('璺濈璁$畻澶辫触:', response.msg)
             this.$modal.showToast('璺濈璁$畻澶辫触,璇锋墜鍔ㄨ緭鍏�')
@@ -1610,6 +1608,52 @@
           console.error('璺濈璁$畻澶辫触:', error)
           this.$modal.showToast('璺濈璁$畻澶辫触,璇锋墜鍔ㄨ緭鍏�')
         })
+    },
+    
+    // 璺濈杈撳叆妗嗗け鐒︽椂瑙﹀彂鎴愪氦浠疯绠�
+    onDistanceChange() {
+      this.calculatePrice()
+    },
+    
+    // 璁$畻鎴愪氦浠�
+    calculatePrice() {
+      const fromAddress = this.taskForm.hospitalOut.address
+      const toAddress = this.taskForm.hospitalIn.address
+      const distance = this.taskForm.transferDistance
+      
+      // 濡傛灉鍦板潃鎴栬窛绂讳笉瀹屾暣锛屼笉杩涜璁$畻
+      if (!fromAddress || !toAddress || !distance || parseFloat(distance) <= 0) {
+        console.log('鍦板潃鎴栬窛绂讳俊鎭笉瀹屾暣锛岃烦杩囨垚浜や环璁$畻')
+        return
+      }
+      
+      console.log('寮�濮嬭绠楁垚浜や环:', fromAddress, '->', toAddress, '璺濈:', distance)
+      
+      // 璋冪敤鎴愪氦浠疯绠楁帴鍙�
+      calculateTransferPrice({
+        fromAddress: fromAddress,
+        toAddress: toAddress,
+        distance: parseFloat(distance),
+        region: this.selectedRegion || ''
+      }).then(response => {
+        if (response.code === 200 && response.data) {
+          const price = response.data.price
+          
+          // 鍙湁褰撹繑鍥炵殑浠锋牸澶т簬0鏃讹紝鎵嶈嚜鍔ㄥ~鍏呮垚浜や环
+          if (price && price > 0) {
+            this.taskForm.price = price.toFixed(2)
+            console.log('鎴愪氦浠疯绠楁垚鍔�:', price)
+            this.$modal.showToast(`鎴愪氦浠�: 楼${price.toFixed(2)}`)
+          } else {
+            console.log('鎴愪氦浠蜂负0锛屼笉鑷姩濉厖')
+          }
+        } else {
+          console.log('鎴愪氦浠疯绠楀け璐ワ紝淇濇寔鎵嬪姩杈撳叆')
+        }
+      }).catch(error => {
+        console.error('鎴愪氦浠疯绠楀け璐�:', error)
+        // 璁$畻澶辫触鏃朵笉鎻愮ず鐢ㄦ埛锛屽厑璁哥敤鎴锋墜鍔ㄨ緭鍏�
+      })
     },
     
     // ==================== 鐥呮儏閫夋嫨鐩稿叧鏂规硶 ====================
@@ -1888,11 +1932,18 @@
         addTask(submitData).then(response => {
           this.loading = false
           this.$modal.showToast('浠诲姟鍒涘缓鎴愬姛')
+          
+          // 寤惰繜璺宠浆锛岃鐢ㄦ埛鐪嬪埌鎴愬姛鎻愮ず
           setTimeout(() => {
+            // 璺宠浆鍒颁换鍔″垪琛ㄥ苟瑙﹀彂鍒锋柊
             uni.switchTab({
-              url: '/pages/task/index'
+              url: '/pages/task/index',
+              success: () => {
+                // 浣跨敤浜嬩欢鎬荤嚎閫氱煡浠诲姟鍒楄〃椤甸潰鍒锋柊
+                uni.$emit('refreshTaskList')
+              }
             })
-          }, 1500)
+          }, 1000)
         }).catch(error => {
           this.loading = false
           console.error('浠诲姟鍒涘缓澶辫触:', error)
@@ -1955,6 +2006,9 @@
             
             console.log('璺濈璁$畻鎴愬姛:', distanceInKm, 'km')
             // this.$modal.showToast(`璺濈璁$畻鎴愬姛: ${distanceInKm}鍏噷`)
+            
+            // 璺濈璁$畻鎴愬姛鍚庯紝鑷姩璁$畻鎴愪氦浠�
+            this.calculatePrice()
           } else {
             console.error('璺濈璁$畻澶辫触:', response.msg)
             this.$modal.showToast('璺濈璁$畻澶辫触锛岃鎵嬪姩杈撳叆')

--
Gitblit v1.9.1