needcode преди 2 години
родител
ревизия
bbf5cc6cf1

+ 3 - 0
README.md

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

+ 6 - 4
src/api/auth.ts

@@ -75,22 +75,24 @@ export function login(e: any): Promise<string> {
     uni.login({
       success: (res) => {
         uni.request<any>({
-          url: `${host}/user/login`,
+          url: `${host}/user/wxLogin`,
           method: "POST",
           dataType: "json",
           data: {
-            phone_code: e.detail.code,
+            phoneCode: e.detail.code,
             code: res.code,
+            avatar: "",
+            nickname: "",
           },
           success: (res: any) => {
             const { statusCode, data } = res;
             if (
               statusCode === 200 &&
               data &&
-              data.msg === "OK" &&
+              data.message === "ok" &&
               data.code === 200
             ) {
-              _resolveTokenQueue(data.data.access_token);
+              _resolveTokenQueue(data.data.satoken);
             } else {
               _resolveTokenQueue({
                 errMsg: data.msg ? data.msg : `${JSON.stringify(res)}`,

+ 48 - 50
src/api/charge.ts

@@ -47,8 +47,8 @@ export function fetchStationPriceDesc(ConnectorID: string, StationID?: string) {
           }
         });
       }
-      res.CurrentPrice = currentPrice;
-      res.CurrentTime = currentTime;
+      res.currentPrice = currentPrice;
+      res.currentTime = currentTime;
       if (StationID) {
         res.StationID = StationID;
       }
@@ -89,21 +89,21 @@ export function fetchStations(
       const end = start + pageSize;
       if (latitude && longitude) {
         list.forEach((item: any) => {
-          item.StationLatDistance = _getDistance(
+          item.stationLatDistance = _getDistance(
             latitude,
             longitude,
-            item.StationLat,
-            item.StationLng
+            item.location.stationLat,
+            item.location.stationLng
           );
         });
         list.sort((item1: any, item2: any) => {
-          return item1.StationLatDistance - item2.StationLatDistance;
+          return item1.stationLatDistance - item2.stationLatDistance;
         });
       }
       if (options) {
         if (options.distance) {
           list = list.filter(
-            (item: any) => item.StationLatDistance <= (options.distance || 20)
+            (item: any) => item.stationLatDistance <= (options.distance || 20)
           );
         }
       }
@@ -114,11 +114,11 @@ export function fetchStations(
       });
       if (baseLatitude && baseLongitude) {
         data.forEach((item: any) => {
-          item.StationLatDistance = _getDistance(
+          item.stationLatDistance = _getDistance(
             baseLatitude,
             baseLongitude,
-            item.StationLat,
-            item.StationLng
+            item.location.stationLat,
+            item.location.stationLng
           );
         });
       }
@@ -129,21 +129,21 @@ export function fetchStations(
         let res = false;
         list = list.filter((item: any) => {
           res = false;
-          item.EquipmentInfos.forEach((eqInfo: any) => {
-            eqInfo.ConnectorInfos.forEach((coInfo: any) => {
+          item.equipmentInfos.forEach((eqInfo: any) => {
+            eqInfo.connectorInfos.forEach((coInfo: any) => {
               if (
                 !res &&
                 options.status === 1 &&
-                coInfo.ConnectorStatusInfo &&
-                coInfo.ConnectorStatusInfo.Status === 1
+                coInfo.connectorStatusInfo &&
+                coInfo.connectorStatusInfo.status === 1
               ) {
                 res = true;
               }
               if (
                 !res &&
                 options.status === 2 &&
-                coInfo.ConnectorStatusInfo &&
-                coInfo.ConnectorStatusInfo.Status !== 1
+                coInfo.connectorStatusInfo &&
+                coInfo.connectorStatusInfo.status !== 1
               ) {
                 res = true;
               }
@@ -190,8 +190,8 @@ export function searchStation(keyword: string) {
 }
 
 export function fetchAllStations(): Promise<any[]> {
-  if (getApp().globalData.stations.length > 0) {
-    return Promise.resolve(getApp().globalData.stations);
+  if (getApp<any>().globalData.stations.length > 0) {
+    return Promise.resolve(getApp<any>().globalData.stations);
   }
   const page = 1;
   const page_size = 99;
@@ -208,7 +208,8 @@ export function fetchAllStations(): Promise<any[]> {
         //     StationID: '0000'
         //   })
         // }
-        getApp().globalData.stations = list;
+        console.log("所有电站数据", list);
+        getApp<any>().globalData.stations = list;
         resolve(list);
       })
       .catch(reject);
@@ -233,24 +234,22 @@ function _fetchAllStations(
 
 function _fetchStations(page: number, pageSize: number) {
   return cHttp
-    .get<{
-      StationInfos: any[];
-    }>(`/charge/stationList?page_no=${page}&page_size=${pageSize}`)
+    .get(`/charge/listStation?pageNum=${page}&pageSize=${pageSize}`)
     .then((res) => {
-      res.StationInfos &&
-        res.StationInfos.forEach((item) => {
-          item.fastEquipmentInfos = [];
-          item.slowEquipmentInfos = [];
-          item.TotalFee = Number(
-            Number(
-              Number(item.ElectricityFee) +
-                Number(item.ParkFee) +
-                Number(item.ServiceFee)
-            ).toFixed(2)
-          );
-        });
-
-      return (res.StationInfos || []).filter((item: any) => {
+      const data = res || [];
+      data.forEach((item: any) => {
+        item.StationID = item.stationId;
+        item.fastEquipmentInfos = [];
+        item.slowEquipmentInfos = [];
+        item.totalFee = Number(
+          Number(
+            Number(item.electricityFee) +
+              Number(item.parkFee) +
+              Number(item.serviceFee)
+          ).toFixed(2)
+        );
+      });
+      return data.filter((item: any) => {
         return !["1657"].includes(item.StationID);
       });
     });
@@ -281,38 +280,38 @@ function _fetchStationStatus(list: any[]) {
   let _list: any[] = [];
   return cHttp
     .get(
-      `/charge/stationStatus?station_ids=${list
+      `/charge/stationStatus?stationIds=${list
         .filter((item) => item.StationID !== "0000")
         .map((item) => item.StationID)
         .join(",")}`
     )
     .then((res) => {
-      const StationStatusInfos = res.StationStatusInfos || [];
+      const StationStatusInfos = res || [];
       const ConnectorIDs: string[] = [];
       const StationIDs: string[] = [];
       list.forEach((item: any) => {
         item.fastEquipmentInfos = [];
         item.slowEquipmentInfos = [];
         const StationStatusInfo = StationStatusInfos.find(
-          (status: any) => status.StationID === Number(item.StationID)
+          (status: any) => Number(status.stationId) === Number(item.StationID)
         );
         let ConnectorID = "";
-        item.EquipmentInfos.forEach((eqInfo: any) => {
-          eqInfo.ConnectorInfos.forEach((coInfo: any) => {
+        item.equipmentInfos.forEach((eqInfo: any) => {
+          eqInfo.connectorInfos.forEach((coInfo: any) => {
             if (StationStatusInfo) {
-              const ConnectorStatusInfo =
-                StationStatusInfo.ConnectorStatusInfos.find(
-                  (costatus: any) => costatus.ConnectorID === coInfo.ConnectorID
+              const connectorStatusInfo =
+                StationStatusInfo.connectorStatusInfos.find(
+                  (costatus: any) => costatus.connectorId === coInfo.connectorId
                 );
-              if (ConnectorStatusInfo) {
-                coInfo.ConnectorStatusInfo = ConnectorStatusInfo;
+              if (connectorStatusInfo) {
+                coInfo.connectorStatusInfo = connectorStatusInfo;
               }
             }
             if (!ConnectorID) {
-              ConnectorID = coInfo.ConnectorID;
+              ConnectorID = coInfo.connectorId;
             }
           });
-          if ([1].includes(Number(eqInfo.EquipmentType))) {
+          if ([1].includes(Number(eqInfo.equipmentType))) {
             item.fastEquipmentInfos.push(eqInfo);
           } else {
             item.slowEquipmentInfos.push(eqInfo);
@@ -331,12 +330,11 @@ function _fetchStationStatus(list: any[]) {
       );
     })
     .then((res) => {
-      // console.log('我要看的数据', res)
       if (res && res.length) {
         _list.forEach((item) => {
           const i = res.findIndex((r) => r.StationID === item.StationID);
           if (i >= 0) {
-            item.TotalFee = res[i].CurrentPrice;
+            item.totalFee = res[i].currentPrice;
           }
         });
       }

+ 2 - 8
src/api/user.ts

@@ -56,14 +56,8 @@ export function addCollectList(sid: number) {
     });
 }
 
-export function updateProfile(data: {
-  nick_name?: string;
-  avatar?: string;
-  vin?: string;
-  license_plate?: string;
-  card_no?: string;
-}) {
-  return userHttp.post("/user/update", {
+export function updateProfile(data: any) {
+  return userHttp.put("/user", {
     data,
   });
 }

+ 22 - 23
src/components/charge-station/charge-station.vue

@@ -32,14 +32,14 @@
         </view>
         <view class="flex-align-center lh-0 mt-auto" v-if="!fromMap">
           <charge-icon type="fast"></charge-icon>
-          <view class="fs-22 ml-8" style="color: var(--color-gray)"
-            >空闲:{{ statuswxs.freeLength(fast) }}|共:{{ fast.length }}</view
+          <view class="fs-22 ml-8" style="color: var(--color-gray)" v-if="fast"
+            >空闲:{{ freeLength(fast) }}|共:{{ fast.length }}</view
           >
           <view class="ml-60">
             <charge-icon type="slow"></charge-icon>
           </view>
-          <view class="fs-22 ml-8" style="color: var(--color-gray)"
-            >空闲:{{ statuswxs.freeLength(slow) }}|共:{{ slow.length }}</view
+          <view class="fs-22 ml-8" style="color: var(--color-gray)" v-if="slow"
+            >空闲:{{ freeLength(slow) }}|共:{{ slow.length }}</view
           >
         </view>
         <block v-else>
@@ -48,20 +48,20 @@
           >
           <view
             class="top-right-bound flex-align-center lh-32"
-            v-if="slow.length"
+            v-if="slow && slow.length"
           >
             <charge-icon type="slow"></charge-icon>
             <view class="ml-6 fs-22" style="color: var(--color-gray)"
-              >{{ statuswxs.freeLength(slow) }} / {{ slow.length }}</view
+              >{{ freeLength(slow) }} / {{ slow.length }}</view
             >
           </view>
           <view
             class="top-right-bound flex-align-center lh-32"
-            v-if="fast.length"
+            v-if="fast && fast.length"
           >
             <charge-icon type="fast"></charge-icon>
             <view class="ml-6 fs-22" style="color: var(--color-gray)"
-              >{{ statuswxs.freeLength(fast) }} / {{ fast.length }}</view
+              >{{ freeLength(fast) }} / {{ fast.length }}</view
             >
           </view>
         </block>
@@ -169,24 +169,23 @@ export default {
         address,
       });
     },
+    freeLength(infos: any[]) {
+      var length = 0;
+      infos.forEach(function (item) {
+        item.connectorInfos.forEach(function (conItem: any) {
+          if (
+            conItem.connectorStatusInfo &&
+            conItem.connectorStatusInfo.status === 1
+          ) {
+            length += 1;
+          }
+        });
+      });
+      return length;
+    },
   },
 };
 </script>
-<script module="statuswxs" lang="wxs">
-	module.exports = {
-  freeLength: function (infos) {
-    var length = 0
-    infos.forEach(function (item) {
-      item.ConnectorInfos.forEach(function (conItem) {
-        if (conItem.ConnectorStatusInfo && conItem.ConnectorStatusInfo.Status === 1) {
-          length += 1
-        }
-      })
-    })
-    return length
-  }
-}
-</script>
 
 <style lang="scss">
 .charge-station {

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

@@ -43,15 +43,15 @@
     <view class="pl-20 pr-20" v-if="list.length">
       <view class="mt-20" v-for="(item, index) in list" :key="index">
         <charge-station
-          :title="item.StationName"
-          :tag="item.Construction"
-          :price="item.TotalFee"
+          :title="item.stationName"
+          :tag="item.construction"
+          :price="item.totalFee"
           :fast="item.fastEquipmentInfos"
           :slow="item.slowEquipmentInfos"
           :sId="item.StationID"
-          :address="item.Address"
-          :latitude="item.StationLat"
-          :longitude="item.StationLng"
+          :address="item.address"
+          :latitude="item.location.stationLat"
+          :longitude="item.location.stationLng"
           :border="true"
         ></charge-station>
       </view>

+ 6 - 6
src/pages-user/collect/collect.vue

@@ -2,15 +2,15 @@
   <view class="pl-20 pr-20" v-if="list && list.length">
     <view class="mt-20" v-for="(item, index) in list" :key="index">
       <charge-station
-        :title="item.StationName"
-        :tag="item.Construction"
-        :price="item.TotalFee"
+        :title="item.stationName"
+        :tag="item.construction"
+        :price="item.totalFee"
         :fast="item.fastEquipmentInfos"
         :slow="item.slowEquipmentInfos"
         :sId="item.StationID"
-        :address="item.Address"
-        :latitude="item.StationLat"
-        :longitude="item.StationLng"
+        :address="item.address"
+        :latitude="item.location.stationLat"
+        :longitude="item.location.stationLng"
       ></charge-station>
     </view>
   </view>

+ 13 - 6
src/pages-user/profile/profile.vue

@@ -54,27 +54,27 @@ const refresh = () => {
   const _menu = [
     {
       title: "昵称",
-      key: "nick_name",
+      key: "nickname",
       value: "",
     },
     {
       title: "电话",
-      key: "phone",
+      key: "",
       disabled: true,
     },
     {
       title: "车牌号",
-      key: "license_plate",
+      key: "defaultPlateNo",
       value: "",
     },
     {
       title: "VIN码",
-      key: "vin",
+      key: "",
       value: "",
     },
     {
       title: "充电卡",
-      key: "card_no",
+      key: "",
       value: "",
     },
   ];
@@ -155,11 +155,18 @@ const edit = (index: number) => {
   if (menuItem.disabled) {
     return;
   }
+  if (!menuItem.key) {
+    uni.showToast({
+      icon: "none",
+      title: "暂不支持修改",
+    });
+    return;
+  }
   if (/车牌/.test(menuItem.title)) {
     uni.chooseLicensePlate({
       success: (res) => {
         save({
-          license_plate: res.plateNumber,
+          defaultPlateNo: res.plateNumber,
         });
       },
       fail: (err) => {

+ 9 - 6
src/pages/list/index.vue

@@ -8,15 +8,15 @@
         :key="index"
       >
         <charge-station
-          :title="item.StationName"
-          :tag="item.Construction"
-          :price="item.TotalFee"
+          :title="item.stationName"
+          :tag="item.construction"
+          :price="item.totalFee"
           :fast="item.fastEquipmentInfos"
           :slow="item.slowEquipmentInfos"
           :sId="item.StationID"
-          :address="item.Address"
-          :latitude="item.StationLat"
-          :longitude="item.StationLng"
+          :address="item.address"
+          :latitude="item.location.stationLat"
+          :longitude="item.location.stationLng"
         ></charge-station>
       </view>
     </view>
@@ -29,6 +29,9 @@
         >暂无充电站信息</view
       >
     </view>
+    <view class="flex-center flex-column pt-30" v-if="!infiniteScroller.list">
+      <view class="fs-28 mt-14" style="color: rgba(0, 0, 0, 0.5)">加载中</view>
+    </view>
   </view>
 </template>
 

+ 13 - 9
src/pages/map/index.vue

@@ -25,15 +25,15 @@
           <swiper-item v-for="(item, index) in station" :key="index">
             <view class="station">
               <charge-station
-                :title="item.StationName"
-                :address="item.Address"
-                :price="item.TotalFee"
+                :title="item.stationName"
+                :address="item.address"
+                :price="item.totalFee"
                 :fast="item.fastEquipmentInfos"
                 :slow="item.slowEquipmentInfos"
                 :sId="item.StationID"
-                :distance="item.StationLatDistance"
-                :latitude="item.StationLat"
-                :longitude="item.StationLng"
+                :distance="item.stationLatDistance"
+                :latitude="item.location.stationLat"
+                :longitude="item.location.stationLng"
                 :fromMap="true"
               ></charge-station>
             </view>
@@ -247,6 +247,9 @@ const refreshStation = (location: any) => {
   let length = 0;
   let available = 0;
   const { latitude, longitude } = location;
+  if (!token.value) {
+    return
+  }
   return fetchStations(
     stationPage.value.page,
     stationPage.value.pageSize,
@@ -278,8 +281,8 @@ const refreshStation = (location: any) => {
         });
       return {
         id: Number(item.StationID),
-        latitude: item.StationLat,
-        longitude: item.StationLng,
+        latitude: item.location.stationLat,
+        longitude: item.location.stationLng,
         iconPath:
           index === _markersIndex
             ? pointSize.currentIconPath
@@ -331,7 +334,7 @@ const refreshStation = (location: any) => {
 };
 
 const refresh = () => {
-  // console.log('刷新电站')
+  console.log('刷新电站')
   uni.showLoading({
     title: "加载中",
   });
@@ -384,6 +387,7 @@ onLoad((query: any) => {
   setTimeout(() => {
     token.value = getApp<any>().globalData.token || "";
     if (!token.value) {
+      isIgnoreChangeLocation = true;
       fetchLocation().then((res: any) => {
         mapProps.value.latitude = res.latitude;
         mapProps.value.longitude = res.longitude;

+ 4 - 4
src/pages/user/index.vue

@@ -3,7 +3,7 @@
 
   <image src="/static/images/user-bg.png" mode="widthFix" class="bg" />
 
-  <block v-if="user && user.phone">
+  <block v-if="user && user.mobilePhone">
     <view class="container" :style="containerStyle">
       <view class="header flex-column">
         <view class="flex-grow flex-center">
@@ -21,7 +21,7 @@
               'background-image': `url(${user.avatar})`,
             }"
           ></view>
-          <view class="phone fs-40 fw-500">{{ user.phone }}</view>
+          <view class="phone fs-40 fw-500">{{ user.mobilePhone }}</view>
           <view class="money flex-align-center">
             <view class="fs-40 fw-500" style="margin-top: 10rpx">¥</view>
             <view class="fw-500 ml-12" style="font-size: 60rpx">{{
@@ -153,8 +153,8 @@ onLoad(() => {
     if (res && res.mobile) {
       menu.value[4].mobile = res.mobile;
     }
-    if (res && res.code_url) {
-      menu.value[4].code = res.code_url;
+    if (res && res.codeUrl) {
+      menu.value[4].code = res.codeUrl;
     }
   });
 });

+ 1 - 1
src/utils/constant.ts

@@ -1 +1 @@
-export const host = 'https://www.kuaiyuman.cn/api'
+export const host = 'https://dev.kuaiyuman.cn/api' // 'https://www.kuaiyuman.cn/api'

+ 35 - 42
src/utils/http.ts

@@ -1,4 +1,4 @@
-import { setToken, clearToken } from "../api/auth";
+import { clearToken } from "../api/auth";
 
 interface IOptions {
   data?: any;
@@ -10,7 +10,7 @@ interface IOptions {
 interface IResponse<T> {
   code: number;
   data: T;
-  msg: string;
+  message: string;
 }
 
 class Http {
@@ -25,7 +25,7 @@ class Http {
   }
 
   request<R = any>(
-    method: "GET" | "POST",
+    method: "GET" | "POST" | "PUT",
     api: string,
     options?: IOptions
   ): Promise<R> {
@@ -39,7 +39,7 @@ class Http {
       const urlHasParams = url.indexOf("?") >= 0;
       const header = {
         // 'content-type': 'application/json',
-        Authorization: getApp<any>().globalData.token || "",
+        satoken: getApp<any>().globalData.token || "",
         ...(this.header || {}),
         ...(options.header || {}),
       };
@@ -59,19 +59,21 @@ class Http {
         header,
       })
         .then((res) => {
-          if (res.code === 888) {
-            // eslint-disable-next-line promise/no-nesting
-            return WxRequest<IResponse<R>>({
-              url: `${url}${query ? (urlHasParams ? "&" : "?") : ""}${query}`,
-              method,
-              data,
-              header: {
-                ...header,
-                Authorization: getApp<any>().globalData.token || "",
-              },
-            });
-          }
-          if (res.code === 21005 || res.code === 21000) {
+          // console.log(res)
+          // 刷新token 已废弃
+          // if (res.code === 888) {
+          //   // eslint-disable-next-line promise/no-nesting
+          //   return WxRequest<IResponse<R>>({
+          //     url: `${url}${query ? (urlHasParams ? "&" : "?") : ""}${query}`,
+          //     method,
+          //     data,
+          //     header: {
+          //       ...header,
+          //       Authorization: getApp<any>().globalData.token || "",
+          //     },
+          //   });
+          // }
+          if ([21005, 21000, 10001].includes(Number(res.code))) {
             clearToken();
             setTimeout(() => {
               uni.reLaunch({
@@ -81,33 +83,20 @@ class Http {
             throw {
               errMsg: "请重新登录",
             };
-            // Token过期 废弃
-            // eslint-disable-next-line promise/no-nesting
-            // return refresh().then((token) => {
-            //   return WxRequest<IResponse<R>>({
-            //     url: `${url}${query ? (urlHasParams ? '&' : '?') : ''}${query}`,
-            //     method,
-            //     data,
-            //     header: {
-            //       ...header,
-            //       Authorization: token
-            //     }
-            //   })
-            // })
           }
           return res;
         })
         .then((res) => {
           // eslint-disable-next-line no-console
-          // console.log("接口返回", res);
-          const { msg } = res || {
+          console.log("接口返回", res);
+          const { message = '' } = res || {
             msg: "出现错误",
           };
-          if (res && msg === "OK") {
+          if (res && message === "ok") {
             resolve(res.data);
           } else {
             throw {
-              errMsg: msg,
+              errMsg: message,
             };
           }
         })
@@ -130,6 +119,10 @@ class Http {
   post<R = any>(api: string, options?: IOptions) {
     return this.request<R>("POST", api, options);
   }
+
+  put<R = any>(api: string, options?: IOptions) {
+    return this.request<R>("PUT", api, options);
+  }
 }
 
 export function WxRequest<T = any>(
@@ -141,14 +134,14 @@ export function WxRequest<T = any>(
       success(res: any) {
         // console.log('微信返回', res)
         const { statusCode, header } = res;
-        if (header["Authorization"]) {
-          setToken(header["Authorization"]);
-          resolve({
-            ...res.data,
-            code: 888,
-          });
-          return;
-        }
+        // if (header["Authorization"]) {
+        //   setToken(header["Authorization"]);
+        //   resolve({
+        //     ...res.data,
+        //     code: 888,
+        //   });
+        //   return;
+        // }
         if (statusCode > 200) {
           reject({
             errMsg: `${option.url}:${statusCode}`,