浏览代码

搜索、收藏列表页距离取值改为接口返回

zuypeng 11 月之前
父节点
当前提交
2ca6a09521

+ 2 - 1
src/api/charge.ts

@@ -398,7 +398,8 @@ export function searchStation(keyword: string) {
         ).map(k => k.stationId+"");
         // console.log("serach>>>>>",list)
         if (stationIdList) {
-            return _fetchStations(1, 100, 0, 0,  stationIdList)
+            let {latitude, longitude} = getApp<any>().globalData.fetchLocation
+            return _fetchStations(1, 100, latitude, longitude,  stationIdList)
         } else {
             return Promise.reject([])
         }

+ 4 - 1
src/components/charge-station/charge-station.vue

@@ -25,7 +25,7 @@
           <view class="flex-center tag">{{ tagMap[tag] }}</view>
         </view>
         <view v-else @click.stop="detail" class="fs-22" style="color: rgba(0, 0, 0, 0.5)"
-        >{{ address }} | {{ distance }}km
+        >{{ address }} | {{ fmtDistance(distance) }}km
         </view
         >
       </view>
@@ -214,6 +214,9 @@ export default {
         address,
       });
     },
+    fmtDistance(distance:string|number){
+      return (distance/1000).toFixed(2)
+    },
     freeLength(infos: any[]) {
       var length = 0;
       infos.forEach(function (item) {

+ 1 - 1
src/pages-charge/search/search.vue

@@ -52,7 +52,7 @@
             :address="item.address"
             :latitude="item.location.stationLat"
             :longitude="item.location.stationLng"
-            :distance="item.stationLatDistance"
+            :distance="item.distance"
             :availableParkingNum="item.availableParkingNum"
             :parkingNum="item.parkingNum"
             :border="true"

+ 3 - 2
src/pages-user/collect/collect.vue

@@ -11,7 +11,7 @@
         :address="item.address"
         :latitude="item.location.stationLat"
         :longitude="item.location.stationLng"
-        :distance="item.stationLatDistance"
+        :distance="item.distance"
         :availableParkingNum="item.availableParkingNum"
         :parkingNum="item.parkingNum"
       ></charge-station>
@@ -39,7 +39,8 @@ const list = ref<any[]>();
 onLoad(() => {
   fetchCollectList().then((stationIdList) => {
     if (stationIdList) {
-      return _fetchStations(1, 100, 0, 0,  stationIdList)
+      let {latitude, longitude} = getApp<any>().globalData.fetchLocation
+      return _fetchStations(1, 100, latitude, longitude,  stationIdList)
     } else {
       return Promise.reject([])
     }

+ 3 - 1
src/pages/list/list.vue

@@ -14,6 +14,7 @@
           :fast="item.fastEquipmentInfos"
           :slow="item.slowEquipmentInfos"
           :sId="item.StationID"
+          :distance="item.distance"
           :address="item.address"
           :latitude="item.location.stationLat"
           :longitude="item.location.stationLng"
@@ -42,7 +43,8 @@ import { fetchCollectList } from "../../api/user";
 import { useInfiniteScroll } from "../../utils/infinite-scroll";
 import { onLoad, onReachBottom } from "@dcloudio/uni-app";
 const infiniteScroller = useInfiniteScroll(6, (page) => {
-  return fetchStations(page, 6);
+  let {latitude, longitude} = getApp<any>().globalData.fetchLocation
+  return fetchStations(page, 6,latitude, longitude);
 });
 onLoad(() => {
   fetchCollectList().then(() => {