Procházet zdrojové kódy

1.站点列表详情逻辑调整
2.TODO 充电详情页

zuypeng před 11 měsíci
rodič
revize
231c2213d7

+ 4 - 4
src/api/charge.ts

@@ -292,7 +292,7 @@ export function fetchStationByIds(ids: number[]) {
     });
 }
 
-export function fetchStationByConnectorIdOrShortId(id: string) {
+export function fetchStationByConnectorIdOrShortId(sn: string) {
     let equipment = -1;
     return fetchAllStations()
         .then((res) => {
@@ -302,9 +302,9 @@ export function fetchStationByConnectorIdOrShortId(id: string) {
                 if (!station && item.equipmentInfos && item.equipmentInfos) {
                     item.equipmentInfos.forEach(
                         (equipmentInfo: any, equipmentIndex: number) => {
-                            if (id.length <= 16) {
+                            if (sn.length <= 16) {
                                 // 此处传入的是 shortId
-                                if (equipmentInfo.shortId === id) {
+                                if (equipmentInfo.shortId === sn) {
                                     station = item;
                                     equipment = equipmentIndex;
                                 }
@@ -315,7 +315,7 @@ export function fetchStationByConnectorIdOrShortId(id: string) {
                                 ) {
                                     // connectorId
                                     equipmentInfo.connectorInfos.forEach((connectorInfo: any) => {
-                                        if (connectorInfo.connectorId === id) {
+                                        if (connectorInfo.connectorId === sn) {
                                             station = item;
                                             equipment = equipmentIndex;
                                         }

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

@@ -69,15 +69,14 @@
           >
           <view
               class="top-right-bound flex-align-center lh-32"
-              v-if="slow "
           >
             <charge-icon type="slow"></charge-icon>
             <view class="ml-6 fs-22 color-666"
-            >{{ freeLength(slow) }} / {{ slow.length }}
+            >{{ availableParkingNum }} / {{ parkingNum }}
             </view
             >
           </view>
-          <view
+<!--          <view
               class="top-right-bound flex-align-center lh-32"
               v-if="fast && fast.length"
           >
@@ -86,7 +85,7 @@
             >{{ freeLength(fast) }} / {{ fast.length }}
             </view
             >
-          </view>
+          </view>-->
         </block>
       </view>
       <view
@@ -130,6 +129,8 @@ export default {
     slow: Array,
     latitude: Number,
     longitude: Number,
+    availableParkingNum: Number,
+    parkingNum: Number,
     distance: String,
     border: Boolean,
     fromMap: Boolean,

+ 4 - 0
src/pages-charge/appointment/appointment.vue

@@ -835,6 +835,10 @@ onLoad((_options: any) => {
   // sn=SN100523042860091 测试环境
   console.log("options", _options);
   let sn = _options.sn;
+  let stationId = _options.stationId;
+  if(stationId){
+    stationId.value =stationId;
+  }
   uni.showLoading({
     title: "加载中",
   });

+ 1 - 1
src/pages-charge/machines/charge-machine/charge-machine.vue

@@ -94,7 +94,7 @@ export default {
           success: (res) => {
             if (res.tapIndex === 0) {
               uni.navigateTo({
-                url: `/pages-charge/appointment/appointment?sn=${list[index].connectorId}`,
+                url: `/pages-charge/appointment/appointment?sn=${list[index].connectorId}&stationId=${list[index].stationId}`,
               });
             }
           },

+ 9 - 13
src/pages-charge/machines/machines.vue

@@ -325,7 +325,7 @@ const changeStatus = function (index: number) {
   }
   status.value = index;
   if (index === 0) {
-    stationEquipmentInfos.value = station.value.equipmentInfos.map(
+    stationEquipmentInfos.value = station.value.connectInfoList?.map(
         (item: any) => {
           return {
             ...item,
@@ -337,20 +337,16 @@ const changeStatus = function (index: number) {
   }
   const STATUS_MAP = [-1, 1, 3];
   let newStationEquipmentInfos: any[] = [];
-  station.value.equipmentInfos.forEach((item: any) => {
+  station.value.connectInfoList?.forEach((connect: any) => {
     let check = false;
-    if (item.connectorInfos && item.connectorInfos.length) {
-      item.connectorInfos.forEach((con: any) => {
-        if (
-            con.connectorStatusInfo &&
-            Number(con.connectorStatusInfo.status) === STATUS_MAP[status.value]
-        ) {
-          check = true;
-        }
-      });
+    if (
+        connect.status &&
+        Number(connect.status) === STATUS_MAP[status.value]
+    ) {
+      check = true;
     }
     if (check) {
-      newStationEquipmentInfos.push(item);
+      newStationEquipmentInfos.push(connect);
     }
   });
   stationEquipmentInfos.value = newStationEquipmentInfos;
@@ -364,7 +360,7 @@ const previewImage = (url: string) => {
 };
 
 const showStationCoupon = () => {
-  console.log(station.value)
+  // console.log(station.value)
   station_coupon_ref.value?.open(station.value.StationID);
 }
 </script>

+ 27 - 16
src/pages/map/map.vue

@@ -193,6 +193,8 @@
               :distance="item.stationLatDistance"
               :latitude="item.location.stationLat"
               :longitude="item.location.stationLng"
+              :availableParkingNum="item.availableParkingNum"
+              :parkingNum="item.parkingNum"
               :activity-list="item.activityList"
               :fromMap="true"
             ></charge-station>
@@ -213,6 +215,8 @@
               :distance="station[markersIndex].stationLatDistance"
               :latitude="station[markersIndex].location.stationLat"
               :longitude="station[markersIndex].location.stationLng"
+              :availableParkingNum="station[markersIndex].availableParkingNum"
+              :parkingNum="station[markersIndex].parkingNum"
               :activity-list="station[markersIndex].activityList"
               :fromMap="true"
             ></charge-station>
@@ -267,7 +271,7 @@
 </template>
 
 <script setup lang="ts">
-import {throttle} from "@/utils/util";
+import {debounce, throttle} from "@/utils/util";
 
 const defaulDistance = 3;
 const defaultScale = 12;
@@ -294,6 +298,7 @@ import { to } from "@/utils/navigate";
 import { onLoad, onShow } from "@dcloudio/uni-app";
 import { ref } from "vue";
 
+const currentLocation = ref(null)
 const isIOS = ref(false);
 const token = ref<string>();
 const ready = ref(false);
@@ -410,7 +415,7 @@ const refreshStation = (location: any) => {
     }
   ).then((res) => {
     const _markersIndex = stationPage.value.page === 1 ? 0 : markersIndex.value;
-    console.log("xxxxx",res)
+    // console.log("xxxxx",res)
     const _markers: any[] = res.map((item, index) => {
       item.totalFee =(Number(item.serviceFee)+Number(item.electricityFee)).toFixed(2)
       length = 0;
@@ -428,10 +433,8 @@ const refreshStation = (location: any) => {
       //         }
       //       });
       //   });
-      console.log(item.serviceFee,item.StationID)
       return {
         id: Number(item.StationID),
-        totalFee:"12",
         // (Number()+Number(item.electricityFee)||0).toFixed(2),
         latitude: item.location.stationLat,
         longitude: item.location.stationLng,
@@ -450,7 +453,8 @@ const refreshStation = (location: any) => {
             index === _markersIndex
               ? pointSize.currentFontSize
               : pointSize.fontSize,
-          textAlign: isIOS.value ? "center" : "left",
+          textAlign: "center" ,
+          // textAlign: isIOS.value ? "center" : "left",
           anchorX: isIOS.value
             ? 0
             : index === _markersIndex
@@ -481,7 +485,6 @@ const refreshStation = (location: any) => {
       stationPage.value.page === 1 ? res : [...station.value, ...res];
     markersIndex.value = _markersIndex;
     markers.value = _markers;
-    console.log(">>>>>>>>>>>>>",stationPage.value,station.value,mapMode.value,markersIndex.value)
     return res;
   });
 };
@@ -682,21 +685,29 @@ const mapChange = (e: any) => {
   }
   if (e.type === "end" && markers.value.length) {
     //TODO 防抖500ms触发一次
-    throttle(()=>{
-      const current = e.target.centerLocation;
-      const { latitude, longitude } = current;
-      stationPage.value.page = 1;
-      refreshStation({
-        latitude,
-        longitude,
-      });
-    },500)
+    console.log("throttle")
+    currentLocation.value = e.target.centerLocation
+    // throttle(()=>{
+    //
+    // },500)
     // console.log("map change end", {
     //   ...e.detail.centerLocation,
     // });
-
+    debounceRefreshStation()
   }
 };
+
+
+const debounceRefreshStation = debounce(() => {
+  const { latitude, longitude } = currentLocation.value;
+  stationPage.value.page = 1;
+  console.log("debounceRefreshStation run...")
+  refreshStation({
+    latitude,
+    longitude,
+  });
+}, 500)
+
 const _changeMarker = (current: number) => {
   const _markers = JSON.parse(JSON.stringify(markers.value));
   const markersNewIndex = current;