Przeglądaj źródła

feat:充电接口

needcode 2 lat temu
rodzic
commit
abab1a0881

+ 1 - 3
README.md

@@ -1,3 +1 @@
-## apifox 待调试接口
-* 钱包明细列表
-* 收藏列表
+## apifox 待调试接口

+ 17 - 15
src/api/charge.ts

@@ -9,38 +9,38 @@ export function startCharge(sn: string) {
     StartChargeSeq: string;
     StartChargeSeqStat: number;
     SuccStat: number;
-  }>(`/charge/startCharge?connector_id=${sn}`, {
+  }>(`/charge/startCharge/${sn}`, {
     statusCodeHandle: false,
   });
 }
 
 export function fetchStationPriceDesc(ConnectorID: string, StationID?: string) {
   return cHttp
-    .get(`/charge/businessPolicy?connector_id=${ConnectorID}`)
+    .get(`/charge/businessPolicy/${ConnectorID}`)
     .then((res) => {
       const nowHour = new Date().getHours();
       let currentPrice = 0;
       let currentTime = "00:00~24:00";
-      if (res && res.PolicyInfos && res.PolicyInfos.length) {
-        res.PolicyInfos.forEach((item: any, index: number) => {
-          const hour = item.StartTime.substring(0, 2);
-          const min = item.StartTime.substring(2, 4);
-          if (index >= res.PolicyInfos.length - 1) {
+      if (res && res.policyInfoss && res.policyInfoss.length) {
+        res.policyInfoss.forEach((item: any, index: number) => {
+          const hour = item.startTime.substring(0, 2);
+          const min = item.startTime.substring(3, 5);
+          if (index >= res.policyInfoss.length - 1) {
             // 最后一个
-            item.StartTimeFormat = `${hour}:${min}~24:00`;
+            item.startTimeFormat = `${hour}:${min}~24:00`;
             if (Number(hour) <= nowHour) {
               currentPrice = Number(
-                Number(item.ElecPrice + item.SevicePrice).toFixed(2)
+                Number(item.elecPrice + item.sevicePrice).toFixed(2)
               );
               currentTime = `${hour}:${min}~24:00`;
             }
           } else {
-            const nhour = res.PolicyInfos[index + 1].StartTime.substring(0, 2);
-            const nmin = res.PolicyInfos[index + 1].StartTime.substring(2, 4);
-            item.StartTimeFormat = `${hour}:${min}~${nhour}:${nmin}`;
+            const nhour = res.policyInfoss[index + 1].startTime.substring(0, 2);
+            const nmin = res.policyInfoss[index + 1].startTime.substring(3, 5);
+            item.startTimeFormat = `${hour}:${min}~${nhour}:${nmin}`;
             if (nowHour >= Number(hour) && nowHour < Number(nhour)) {
               currentPrice = Number(
-                Number(item.ElecPrice + item.SevicePrice).toFixed(2)
+                Number(item.elecPrice + item.sevicePrice).toFixed(2)
               );
               currentTime = `${hour}:${min}~${nhour}:${nmin}`;
             }
@@ -57,7 +57,7 @@ export function fetchStationPriceDesc(ConnectorID: string, StationID?: string) {
 }
 
 export function cancelCharge(sn: string) {
-  return cHttp.get(`/charge/stopCharge?connector_id=${sn}`, {
+  return cHttp.get(`/charge/stopCharge/${sn}`, {
     statusCodeHandle: false,
   });
 }
@@ -301,9 +301,11 @@ function _fetchStationStatus(list: any[]) {
             if (StationStatusInfo) {
               const connectorStatusInfo =
                 StationStatusInfo.connectorStatusInfos.find(
-                  (costatus: any) => costatus.connectorId === coInfo.connectorId
+                  (costatus: any) => costatus.connectorId === coInfo.connectorID
                 );
               if (connectorStatusInfo) {
+                console.log(connectorStatusInfo);
+                
                 coInfo.connectorStatusInfo = connectorStatusInfo;
               }
             }

+ 12 - 12
src/api/user.ts

@@ -15,18 +15,18 @@ export function fetchCollectList() {
     return Promise.resolve(getApp<any>().globalData.collectIds);
   }
   return userHttp
-    .get<{
-      data: {
+    .get<
+      {
         status: number;
-        station_id: number;
-      }[];
-    }>("/user/collectList?page=1&page_size=999")
+        stationId: number;
+      }[]
+    >("/user/collectList?page=1&page_size=999")
     .then((res) => {
-      getApp<any>().globalData.collectIds = res.data
-        ? res.data
+      getApp<any>().globalData.collectIds = res
+        ? res
             .filter((item) => Number(item.status) === 1)
             .map((item) => {
-              return Number(item.station_id);
+              return Number(item.stationId);
             })
         : [];
       return getApp<any>().globalData.collectIds;
@@ -37,11 +37,11 @@ export function addCollectList(sid: number) {
   let ids = getApp<any>().globalData.collectIds
     ? (getApp<any>().globalData.collectIds as number[])
     : [];
-  const status = ids.includes(sid) ? 2 : 1;
+  const status = ids.includes(sid) ? 0 : 1;
   return userHttp
-    .post("/user/addCollect", {
+    .post("/user/collect", {
       data: {
-        station_id: sid,
+        stationId: sid,
         status,
       },
     })
@@ -111,7 +111,7 @@ export function fetchWallet(type: number, page: number, pageSize: number) {
   return userHttp
     .get<{
       data: any[];
-    }>(`/account/wallet?page=${page}&page_size=${pageSize}&type=${type}`)
+    }>(`/account/walletDetail?page=${page}&page_size=${pageSize}&type=${type}`)
     .then((res) => {
       return res.data;
     });

+ 1 - 1
src/custom-tab-bar/index.js

@@ -53,7 +53,7 @@ Component({
     switchTab(e) {
       fetchChargeStatus().then(res => {
         this.setData({
-          charging: [1, 2].includes(res.StartChargeSeqStat) ? res.ConnectorID : ''
+          charging: [1, 2].includes(res.chargeStatus) ? res.connectorId : ''
         })
       }).catch(() => {
         this.setData({

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

@@ -32,15 +32,15 @@
       @click="toOrdering(index)"
     >
       <charge-icon
-        :type="item.ConnectorType === 1 ? 'fast' : 'slow'"
+        :type="item.connectorType === 1 ? 'fast' : 'slow'"
       ></charge-icon>
-      <view class="ml-16 fs-26 color-000">{{ item.ConnectorName }}</view>
+      <view class="ml-16 fs-26 color-000">{{ item.connectorName }}</view>
       <view class="ml-10 fs-26 color-0004"
-        >{{ item.ConnectorType === 1 ? "直流" : "交流"
-        }}{{ item.Power }}kw</view
+        >{{ item.connectorType === 1 ? "直流" : "交流"
+        }}{{ item.power }}kw</view
       >
       <view class="ml-auto fs-22 flex-center pl-12 pr-12 status-tag">{{
-        (statusMap as any)[item.ConnectorStatusInfo.Status]
+        (statusMap as any)[item.connectorStatusInfo.status]
       }}</view>
     </view>
   </view>
@@ -75,9 +75,9 @@ export default {
       const { list } = this;
       if (
         list &&
-        list[index].ConnectorStatusInfo &&
-        list[index].ConnectorStatusInfo.Status &&
-        list[index].ConnectorStatusInfo.Status === 1
+        list[index].connectorStatusInfo &&
+        list[index].connectorStatusInfo.status &&
+        list[index].connectorStatusInfo.status === 1
       ) {
         uni.showActionSheet({
           itemList: ["去充电"],

+ 17 - 17
src/pages-charge/machines/machines.vue

@@ -44,14 +44,14 @@
     <view
       class="mt-20"
       v-if="station"
-      v-for="(item, index) in station.EquipmentInfos"
+      v-for="(item, index) in station.equipmentInfos"
       :key="index"
     >
       <ChargeMachine
-        :title="item.EquipmentID"
-        :price="station.TotalFee"
+        :title="item.equipmentId"
+        :price="station.totalFee"
         :time="currentTime"
-        :list="item.ConnectorInfos"
+        :list="item.connectorInfos"
       ></ChargeMachine>
     </view>
     <view class="dialog flex-center" v-if="descDialog">
@@ -91,9 +91,9 @@
                 }`,
               }"
             >
-              <view class="td flex-center">{{ item.StartTimeFormat }}</view>
-              <view class="td flex-center">{{ item.ElecPrice }}</view>
-              <view class="td flex-center">{{ item.SevicePrice }}</view>
+              <view class="td flex-center">{{ item.startTimeFormat }}</view>
+              <view class="td flex-center">{{ item.elecPrice }}</view>
+              <view class="td flex-center">{{ item.servicePrice }}</view>
             </view>
           </view>
         </view>
@@ -141,16 +141,16 @@ onLoad((options: any) => {
   fetchStation(Number(options.id))
     .then((res) => {
       let ConnectorID = "";
-      if (res.EquipmentInfos && res.EquipmentInfos.length) {
-        res.EquipmentInfos.forEach((item: any) => {
-          if (item.ConnectorInfos && item.ConnectorInfos.length) {
-            item.ConnectorInfos.forEach((con: any) => {
+      if (res.equipmentInfos && res.equipmentInfos.length) {
+        res.equipmentInfos.forEach((item: any) => {
+          if (item.connectorInfos && item.connectorInfos.length) {
+            item.connectorInfos.forEach((con: any) => {
               if (!ConnectorID) {
-                ConnectorID = con.ConnectorID;
+                ConnectorID = con.connectorID;
               }
               if (
-                con.ConnectorStatusInfo &&
-                con.ConnectorStatusInfo.Status === 1
+                con.connectorStatusInfo &&
+                con.connectorStatusInfo.status === 1
               ) {
                 canUseCount.value++;
               }
@@ -164,14 +164,14 @@ onLoad((options: any) => {
       } else {
         // eslint-disable-next-line promise/no-return-wrap
         return Promise.resolve({
-          PolicyInfos: [],
+          policyInfoss: [],
         });
       }
     })
     .then((res) => {
       uni.hideLoading();
-      currentTime.value = res.CurrentTime;
-      desc.value = res.PolicyInfos || [];
+      currentTime.value = res.currentTime;
+      desc.value = res.policyInfoss || [];
     })
     .catch((err) => {
       // eslint-disable-next-line no-console

+ 25 - 23
src/pages-charge/ordering/ordering.vue

@@ -68,13 +68,14 @@ import { ref } from "vue";
 import { format } from "../../utils/date";
 
 let timer: any;
+let statusTimer: any;
 const step = ref(0);
 const options = ref<any>();
 const status = ref({
   time: 30,
   start: false,
   cancel: false,
-  error: false
+  error: false,
 });
 const chargeInfo = ref<any[]>([]);
 const startStartTimer = () => {
@@ -101,13 +102,13 @@ const startStartTimer = () => {
   }, 1000);
 };
 const startStatusTimer = () => {
-  setTimeout(() => {
+  statusTimer = setTimeout(() => {
     fetchChargeStatus()
       .then((res) => {
         if (status.value.cancel) {
           return;
         }
-        if ([1, 2].includes(res.StartChargeSeqStat)) {
+        if ([1, 2].includes(res.chargeStatus)) {
           setChargeData(res);
         }
         startStatusTimer();
@@ -126,7 +127,7 @@ const start = () => {
     })
     .catch((err) => {
       setTimeout(() => {
-        status.value.error = true
+        status.value.error = true;
         timer && clearTimeout(timer);
         uni.showModal({
           content: `${err.errMsg}`,
@@ -196,9 +197,9 @@ const finish = () => {
   });
   fetchChargeStatus()
     .then((res) => {
-      if ([1, 2].includes(res.StartChargeSeqStat)) {
+      if ([1, 2].includes(res.chargeStatus)) {
         // 当前充电中
-        const start = new Date(res.StartTime.replace(/-/g, "/"));
+        const start = new Date(res.startTime.replace(/-/g, "/"));
         const end = new Date();
         const diff = parseInt(`${(end.getTime() - start.getTime()) / 1000}`);
         const min = parseInt(`${diff / 60}`);
@@ -212,15 +213,15 @@ const finish = () => {
         const _chargeInfo = [
           {
             label: "累计充电量",
-            value: `${res.TotalPower}度`,
+            value: `${res.totalPower}度`,
           },
           {
             label: "累计费用",
-            value: `${res.ElecMoney}元`,
+            value: `${res.elecMoney}元`,
           },
           {
             label: "开始时间",
-            value: res.StartTime,
+            value: res.startTime,
           },
           {
             label: "结束时间",
@@ -231,19 +232,19 @@ const finish = () => {
             value: time,
           },
         ];
-        if (res.Soc) {
+        if (res.soc) {
           _chargeInfo.unshift({
             label: "剩余电量",
-            value: `${res.Soc}%`,
+            value: `${res.soc}%`,
           });
         }
         chargeInfo.value = _chargeInfo;
         cancelCharge(options.value && options.value.sn ? options.value.sn : "")
           .then(() => {
             uni.hideLoading();
-            if (res.FailReason) {
+            if (res.failReason) {
               uni.showModal({
-                content: res.FailReason,
+                content: res.failReason,
                 showCancel: false,
                 success() {
                   uni.navigateBack();
@@ -282,7 +283,7 @@ const finish = () => {
     });
 };
 const setChargeData = (res: any) => {
-  const start = new Date(res.StartTime.replace(/-/g, "/"));
+  const start = new Date(res.startTime.replace(/-/g, "/"));
   const end = new Date();
   const diff = parseInt(`${(end.getTime() - start.getTime()) / 1000}`);
   const min = parseInt(`${diff / 60}`);
@@ -295,25 +296,25 @@ const setChargeData = (res: any) => {
   const _chargeInfo = [
     {
       label: "累计充电量",
-      value: `${res.TotalPower}度`,
+      value: `${res.totalPower}度`,
     },
     {
       label: "累计费用",
-      value: `${res.ElecMoney}元`,
+      value: `${res.elecMoney}元`,
     },
     {
       label: "开始时间",
-      value: res.StartTime,
+      value: res.startTime,
     },
     {
       label: "累计用时",
       value: time,
     },
   ];
-  if (res.Soc) {
+  if (res.soc) {
     _chargeInfo.unshift({
       label: "剩余电量",
-      value: `${res.Soc}%`,
+      value: `${res.soc}%`,
     });
   }
   chargeInfo.value = _chargeInfo;
@@ -322,10 +323,10 @@ const fetchStatus = (data?: any) => {
   if (status.value.cancel) {
     return;
   }
-  const promise = status ? Promise.resolve(data) : fetchChargeStatus();
+  const promise = data ? Promise.resolve(data) : fetchChargeStatus();
   promise
     .then((res) => {
-      if ([1, 2].includes(res.StartChargeSeqStat)) {
+      if ([1, 2].includes(res.chargeStatus)) {
         // 当前充电中
         status.value.start = true;
         step.value = 2;
@@ -343,8 +344,8 @@ const fetchStatus = (data?: any) => {
 const onImgLoad = () => {
   fetchChargeStatus()
     .then((res) => {
-      if ([1, 2].includes(res.StartChargeSeqStat)) {
-        if (options.value && options.value.sn === res.ConnectorID) {
+      if ([1, 2].includes(res.chargeStatus)) {
+        if (options.value && options.value.sn === res.connectorId) {
           fetchStatus(res);
           return;
         }
@@ -374,6 +375,7 @@ onLoad((_options: any) => {
 });
 onHide(() => {
   timer && clearTimeout(timer);
+  statusTimer && clearTimeout(statusTimer);
 });
 onShow(() => {
   startStartTimer();

+ 9 - 9
src/pages-user/profile/profile.vue

@@ -69,23 +69,23 @@ const refresh = () => {
     },
     {
       title: "VIN码",
-      key: "",
-      value: "",
-    },
-    {
-      title: "充电卡",
-      key: "",
+      key: "vin",
       value: "",
     },
+    // {
+    //   title: "充电卡",
+    //   key: "",
+    //   value: "",
+    // },
   ];
   fetchProfile().then(() => {
     const user = getApp<any>().globalData.user;
     if (user) {
       _menu[0].value = user.nickname;
-      _menu[1].value = user.phone;
-      _menu[2].value = user.license_plate;
+      _menu[1].value = user.mobilePhone;
+      _menu[2].value = user.defaultPlateNo;
       _menu[3].value = user.vin;
-      _menu[4].value = user.card_no;
+      // _menu[4].value = user.card_no;
       avatar.value =
         user.avatar ||
         "https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0";

+ 2 - 2
src/pages-user/wallet-detail/wallet-detail.vue

@@ -39,7 +39,7 @@
           <text class="fs-24 ml-6">元</text>
         </view>
         <view class="fs-24" style="color: rgba(0, 0, 0, 0.4)">{{
-          item.transaction_time
+          item.transactionTime
         }}</view>
       </view>
       <view class="ml-32" v-if="item.type === 3">
@@ -97,7 +97,7 @@ const detail = (index: number) => {
   }
   if (infiniteScroller.list[index].type === 3) {
     uni.navigateTo({
-      url: `/pages-charge/order/order?id=${infiniteScroller.list[index].transaction_id}`,
+      url: `/pages-charge/order/order?id=${infiniteScroller.list[index].transactionId}`,
     });
   }
 };