From ec43e87c75ac193eaf9b5cdac6f272b27efa24b1 Mon Sep 17 00:00:00 2001
From: 13404089107 <puwei@sinata.cn>
Date: 星期五, 14 二月 2025 18:08:46 +0800
Subject: [PATCH] 咸宁上架及维护

---
 pages/home/home.js |  285 ++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 210 insertions(+), 75 deletions(-)

diff --git a/pages/home/home.js b/pages/home/home.js
index 1f2e04e..a09bf4b 100644
--- a/pages/home/home.js
+++ b/pages/home/home.js
@@ -456,6 +456,7 @@
             longitude: this.transformFromGCJToBaidu(res.latitude, res.longitude).longitude,
           })
           that.getLocal(res.latitude, res.longitude)
+          console.log('2222222222222222222222222222222222');
           that.getCarNum(res.latitude, res.longitude, that.data.busId)
         }
       })
@@ -790,7 +791,8 @@
     mapCtx.moveToLocation({
       success: (res) => {
         console.log('adsadsad', res);
-        this.getLocal(wx.getStorageSync('latitude'), wx.getStorageSync('longitude'))
+        // this.getLocal(wx.getStorageSync('latitude'), wx.getStorageSync('longitude'),true)
+        this.getLocationApi()
 
         this.setData({
           newCityName: "",
@@ -1377,6 +1379,7 @@
                             // longitude: res.originalData.result.location.lng,
                             adcode: res.originalData.result.addressComponent.adcode,
                             cityNameStart: res.originalData.result.formatted_address,
+                            changeStartName:res.originalData.result.formatted_address,
                             district: res.originalData.result.addressComponent.district,
                             province: res.originalData.result.addressComponent.province,
                             formatted_address: res.originalData.result.formatted_address
@@ -2170,7 +2173,7 @@
             latitude: res.latitude,
             longitude: res.longitude,
           })
-          that.getLocal(res.latitude, res.longitude)
+          that.getLocal(res.latitude, res.longitude, true)
           that.getCarNum(res.latitude, res.longitude, that.data.busId)
         }
       })
@@ -2186,27 +2189,33 @@
     }
   },
   // 获取当前地理位置
-  getLocal: function (latitude, longitude) {
+  getLocal: function (latitude, longitude, move) {
     var bmap = new BaiduMap.BMapWX({
       ak: 'fi3HGJjW153NCNsaTb9FekxeX1Lj3auo' // 必填,您的key
     })
     let that = this;
     wx.request({
-      url: `https://api.map.baidu.com/geoconv/v2/?coords=${longitude},${latitude}&model=1&ak=3mHKIXMArjgIkgADzOlTYp4XssNSNkwr`,
-      success: (res) => {
+      url: `https://api.map.baidu.com/geoconv/v2/?coords=${longitude},${latitude}&model=5&ak=3mHKIXMArjgIkgADzOlTYp4XssNSNkwr`,
+      success: (resp) => {
+        console.log('获取当前地理位置 获取当前地理位置', resp, 'longitude', longitude, 'latitude', latitude, 'move move move', move)
         bmap.regeocoding({
-          location: res.data.result[0].y + ',' + res.data.result[0].x,
-          success: function (res) {
+          location:move?(latitude+ ',' +longitude):(resp.data.result[0].y + ',' + resp.data.result[0].x),
+          // location:latitude+ ',' +longitude,
+          // location: '30.657469'+','+'104.06669',
+          success:  (res)=> {
             //这里的res参数里有具体的城市数据
+            console.log('这里的res参数里有具体的城市数据', res)
             var name = res.originalData.result.addressComponent
             that.setData({
               changeStartName: res.originalData.result.formatted_address,
-              startLat: '',
-              startLon: '',
+              startLat: move?'':resp.data.result[0].y,
+              startLon: move?'':resp.data.result[0].x,
               cityNameStart: res.originalData.result.formatted_address,
               adcode: res.originalData.result.addressComponent.adcode,
-              latitude,
-              longitude
+              latitude:move?latitude:resp.data.result[0].y,
+              longitude:move?longitude:resp.data.result[0].x
+              // latitude:'30.657469',
+              // longitude:"104.06669"
             })
             that.queryBusiness(name.city, name.district, name.province)
             that.openCity(res.originalData.result.addressComponent.adcode)
@@ -2254,29 +2263,209 @@
       let startLon = that.data.startLon || that.data.longitude
       wx.request({
         url: `https://api.map.baidu.com/geoconv/v2/?coords=${startLon},${startLat};${that.data.nextLongitude},${that.data.nextLatitude}&model=1&ak=3mHKIXMArjgIkgADzOlTYp4XssNSNkwr`,
-        success: (res) => {
+        success: (resp) => {
+          console.log('that.data.nextLongitud,that.data.nextLongitudee', that.data.nextLongitude)
+          // wx.request({
+          //   url: `https://api.map.baidu.com/directionlite/v1/driving?origin=${resp.data.result[0].y},${resp.data.result[0].x}&destination=${that.data.nextLatitude},${that.data.nextLongitude}&ak=WQhfsluNzEeUHUxoH4jc4JiCQOXw4Mnx&ret_coordtype=gcj02`,
+          //   success: (res) => {
+          //     var coors = res.data.result.routes[0].steps
+          //     var polyline = [];
+          //     coors.forEach(function (step, index) {
+          //       // if (index == 0) {
+          //       //   polyline.push({
+          //       //     latitude: step.end_location.lat,
+          //       //     longitude: step.end_location.lng
+          //       //   });
+          //       // } else {
+          //       //   polyline.push({
+          //       //     latitude: step.start_location.lat,
+          //       //     longitude: step.start_location.lng
+          //       //   });
+          //       // }
+          //       // return
+          //       let list = step.path.split(';')
+          //       if (index == 0) {
+          //         polyline.push({
+          //           latitude: step.start_location.lat,
+          //           longitude: step.start_location.lng
+          //         });
+          //       }
+          //       list.forEach(function (item, ind) {
+          //         if (item) {
+          //           let lng = item.split(',')[0]
+          //           let lat = item.split(',')[1]
+          //           polyline.push({
+          //             latitude: lat,
+          //             longitude: lng
+          //           });
+          //         }
+          //       })
+          //       // }
+          //       if (coors.length == index + 1) {
+          //         unit.post(app.globalData.Url + '/base/taxi/queryExpectedTime', {
+          //             // slat:that.data.latitude,
+          //             // slon:that.data.longitude,
+          //             slat: that.data.startLat || that.data.latitude,
+          //             slon: that.data.startLon || that.data.longitude,
+          //             elat: that.data.nextLatitude,
+          //             elon: that.data.nextLongitude
+          //           })
+          //           .then((res) => {
+          //             if (res.data.code == 200) {
+          //               // let markers1 = that.data.markers[0]
+          //               // let markers2 = 
+          //               //   that.data.markers[1]+ that.data.markers[1][callout]
+
+          //               // this.setData({
+          //               // markers:[markers1,markers2]
+          //               // })
+          //               console.log(list, '2222222222222222222222');
+
+          //               var markers = [{
+          //                   iconPath: "../../img/start_icon.png",
+          //                   id: 1,
+          //                   latitude: that.data.startLat || that.data.latitude,
+          //                   longitude: that.data.startLon || that.data.longitude,
+          //                   width: 26,
+          //                   height: 34,
+          //                 },
+          //                 {
+          //                   iconPath: "../../img/end_icon.png",
+          //                   id: 2,
+          //                   latitude: list[list.length - 2].split(',')[1],
+          //                   longitude: list[list.length - 2].split(',')[0],
+          //                   width: 26,
+          //                   height: 34,
+          //                   callout: {
+          //                     content: '大约行驶' + res.data.data.minute + '分钟',
+          //                     color: '#333333',
+          //                     fontSize: 13,
+          //                     borderRadius: 1,
+          //                     display: 'ALWAYS',
+          //                     borderRadius: 13,
+          //                     padding: 10,
+          //                     textAlign: 'center'
+          //                   }
+          //                 },
+          //               ]
+          //               that.setData({
+          //                 markers,
+          //                 points
+          //               })
+          //             }
+          //           })
+          //       }
+          //     });
+          //     that.setData({
+          //       polyline: [{
+          //         points: polyline,
+          //         arrowLine: true,
+          //         color: '#00C47A',
+          //         width: 4,
+          //         borderWidth: 1,
+          //         borderColor: '#00C47A'
+          //       }],
+          //     });
+
+          //   }
+          // })
+          // return
           unit.post(app.globalData.Url + '/base/loadLine', {
-              startLat: res.data.result[0].y,
-              startLon: res.data.result[0].x,
-              nextLatitude: res.data.result[1]?.y,
-              nextLongitude: res.data.result[1]?.x,
+              startLat: resp.data.result[0].y,
+              startLon: resp.data.result[0].x,
+              nextLatitude: that.data.nextLatitude,
+              nextLongitude: that.data.nextLongitude,
             })
             .then((res) => {
               var coors = res.data.data
               var polyline = [];
               coors.forEach(function (step, index) {
+                // if (index == 0) {
+                //   polyline.push({
+                //     latitude: step.end_location.lat,
+                //     longitude: step.end_location.lng
+                //   });
+                // } else {
+                //   polyline.push({
+                //     latitude: step.start_location.lat,
+                //     longitude: step.start_location.lng
+                //   });
+                // }
+                // return
+                let list = step.path.split(';')
                 if (index == 0) {
                   polyline.push({
                     latitude: step.start_location.lat,
                     longitude: step.start_location.lng
                   });
-                } else {
-                  polyline.push({
-                    latitude: step.end_location.lat,
-                    longitude: step.end_location.lng
-                  });
                 }
+                list.forEach(function (item, ind) {
+                  if (item) {
+                    let lng = item.split(',')[0]
+                    let lat = item.split(',')[1]
+                    polyline.push({
+                      latitude: lat,
+                      longitude: lng
+                    });
 
+                    if (coors.length == index + 1 && list.length==ind+1) {
+                      unit.post(app.globalData.Url + '/base/taxi/queryExpectedTime', {
+                          // slat:that.data.latitude,
+                          // slon:that.data.longitude,
+                          slat: that.data.startLat || that.data.latitude,
+                          slon: that.data.startLon || that.data.longitude,
+                          elat: that.data.nextLatitude,
+                          elon: that.data.nextLongitude
+                        })
+                        .then((res) => {
+                          if (res.data.code == 200) {
+                            // let markers1 = that.data.markers[0]
+                            // let markers2 = 
+                            //   that.data.markers[1]+ that.data.markers[1][callout]
+    
+                            // this.setData({
+                            // markers:[markers1,markers2]
+                            // })
+                            console.log(list, '2222222222222222222222');
+    
+                            var markers = [{
+                                iconPath: "../../img/start_icon.png",
+                                id: 1,
+                                latitude: that.data.startLat || that.data.latitude,
+                                longitude: that.data.startLon || that.data.longitude,
+                                width: 26,
+                                height: 34,
+                              },
+                              {
+                                iconPath: "../../img/end_icon.png",
+                                id: 2,
+                                latitude: lat,
+                                longitude: lng,
+                                width: 26,
+                                height: 34,
+                                callout: {
+                                  content: '大约行驶' + res.data.data.minute + '分钟',
+                                  color: '#333333',
+                                  fontSize: 13,
+                                  borderRadius: 1,
+                                  display: 'ALWAYS',
+                                  borderRadius: 13,
+                                  padding: 10,
+                                  textAlign: 'center'
+                                }
+                              },
+                            ]
+                            that.setData({
+                              markers,
+                              points
+                            })
+                          }
+                        })
+                    }
+                  }
+                })
+                // }
+                
               });
               that.setData({
                 polyline: [{
@@ -2327,10 +2516,6 @@
       //       app.showToastSuccess('路线规划失败', null, "none", 1500)
       //     }
       //   })
-
-
-
-
       // wx.request({
       //   url: `https://api.map.baidu.com/directionlite/v1/driving?origin=${startLat},${startLon}&destination=${ that.data.nextLatitude},${that.data.nextLongitude}&ak=WQhfsluNzEeUHUxoH4jc4JiCQOXw4Mnx`,
       //   success: function (res) {
@@ -2342,57 +2527,7 @@
       //     app.showToastSuccess('路线规划失败', null, "none", 1500)
       //   }
       // })
-      unit.post(app.globalData.Url + '/base/taxi/queryExpectedTime', {
-          // slat:that.data.latitude,
-          // slon:that.data.longitude,
-          slat: that.data.startLat || that.data.latitude,
-          slon: that.data.startLon || that.data.longitude,
-          elat: that.data.nextLatitude,
-          elon: that.data.nextLongitude
-        })
-        .then((res) => {
-          if (res.data.code == 200) {
-            // let markers1 = that.data.markers[0]
-            // let markers2 = 
-            //   that.data.markers[1]+ that.data.markers[1][callout]
 
-            // this.setData({
-            // markers:[markers1,markers2]
-            // })
-
-            var markers = [{
-                iconPath: "../../img/start_icon.png",
-                id: 1,
-                latitude: that.data.startLat || that.data.latitude,
-                longitude: that.data.startLon || that.data.longitude,
-                width: 26,
-                height: 34,
-              },
-              {
-                iconPath: "../../img/end_icon.png",
-                id: 2,
-                latitude: that.data.nextLatitude,
-                longitude: that.data.nextLongitude,
-                width: 26,
-                height: 34,
-                callout: {
-                  content: '大约行驶' + res.data.data.minute + '分钟',
-                  color: '#333333',
-                  fontSize: 13,
-                  borderRadius: 1,
-                  display: 'ALWAYS',
-                  borderRadius: 13,
-                  padding: 10,
-                  textAlign: 'center'
-                }
-              },
-            ]
-            that.setData({
-              markers,
-              points
-            })
-          }
-        })
 
 
       //  var polyline =[{  

--
Gitblit v1.7.1