|
|
@@ -3,14 +3,14 @@ import {host, isDebug} from "../utils/constant";
|
|
|
|
|
|
const cHttp = new Http(host);
|
|
|
|
|
|
-export function startCharge(sn: string, query?: string) {
|
|
|
+export function startCharge(connectorId: string, query?: string) {
|
|
|
return cHttp.get<{
|
|
|
ConnectorID: string;
|
|
|
FailReason: number;
|
|
|
StartChargeSeq: string;
|
|
|
StartChargeSeqStat: number;
|
|
|
SuccStat: number;
|
|
|
- }>(`/charge/startCharge/${sn}?${query}`, {
|
|
|
+ }>(`/charge/startCharge/${connectorId}?${query}`, {
|
|
|
statusCodeHandle: false,
|
|
|
});
|
|
|
}
|
|
|
@@ -97,8 +97,8 @@ export function fetchStationPriceDesc(ConnectorID: string, StationID?: string) {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-export function cancelCharge(sn: string) {
|
|
|
- return cHttp.get(`/charge/stopCharge/${sn}`, {
|
|
|
+export function cancelCharge(connectorId: string) {
|
|
|
+ return cHttp.get(`/charge/stopCharge/${connectorId}`, {
|
|
|
statusCodeHandle: false,
|
|
|
});
|
|
|
}
|
|
|
@@ -128,7 +128,7 @@ export function fetchChargeStatus(
|
|
|
success(modal) {
|
|
|
if (modal.confirm) {
|
|
|
uni.redirectTo({
|
|
|
- url: `/pages-charge/appointment/appointment?sn=${res.connectorId}`,
|
|
|
+ url: `/pages-charge/appointment/appointment?connectorId=${res.connectorId}`,
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
@@ -145,7 +145,7 @@ export function fetchChargeStatus(
|
|
|
success(modal) {
|
|
|
if (modal.confirm) {
|
|
|
uni.redirectTo({
|
|
|
- url: `/pages-charge/ordering/ordering?sn=${res.connectorId}&start=1`,
|
|
|
+ url: `/pages-charge/ordering/ordering?connectorId=${res.connectorId}&start=1`,
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
@@ -167,7 +167,7 @@ export function fetchStations(
|
|
|
status?: number;
|
|
|
}
|
|
|
): Promise<any[]> {
|
|
|
- return fetchAllStations(latitude,longitude)
|
|
|
+ return fetchAllStations(latitude, longitude)
|
|
|
.then((res) => {
|
|
|
// console.log(latitude, longitude);
|
|
|
// let list = JSON.parse(JSON.stringify(res));
|
|
|
@@ -285,6 +285,51 @@ export function fetchStationDetail(stationId: string) {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+/**
|
|
|
+ * 根据shortId或connectorId或equipmentId 查询站点信息(因前期为查询全部站点后前端过滤,特此进行性能优化)
|
|
|
+ * @param shortId
|
|
|
+ * @param connectorId
|
|
|
+ * @param equipmentId
|
|
|
+ */
|
|
|
+export function fetchStationDetailByShortIdOrConnectorIdOrEquipmentId(shortId?: string, connectorId?: string, equipmentId?: string) {
|
|
|
+ if (shortId) {
|
|
|
+ return fetchStationDetailByShortId(shortId);
|
|
|
+ } else if (connectorId) {
|
|
|
+ return fetchStationDetailByConnectorId(connectorId)
|
|
|
+ } else if (equipmentId) {
|
|
|
+ return fetchStationDetailByByEquipmentId(equipmentId)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export function fetchStationDetailByShortId(shortId: string) {
|
|
|
+ return cHttp
|
|
|
+ .get(`/charge/stationInfoByShortId/${shortId}`)
|
|
|
+ .then((res) => {
|
|
|
+ return res;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+export function fetchStationDetailByConnectorId(connectorId: string) {
|
|
|
+ return cHttp
|
|
|
+ .get(`/charge/stationInfoByConnectorId/${connectorId}`)
|
|
|
+ .then((res) => {
|
|
|
+ return res;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * equipmentId 可能不唯一,慎重使用
|
|
|
+ * @param equipmentId
|
|
|
+ */
|
|
|
+export function fetchStationDetailByByEquipmentId(equipmentId: string) {
|
|
|
+ return cHttp
|
|
|
+ .get(`/charge/stationInfoByEquipmentId/${equipmentId}`)
|
|
|
+ .then((res) => {
|
|
|
+ return res;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
export function fetchStationByIds(ids: number[]) {
|
|
|
return fetchAllStations().then((res) => {
|
|
|
const list = res.filter((item) => ids.includes(Number(item.StationID)));
|
|
|
@@ -346,22 +391,29 @@ export function fetchStationByConnectorIdOrShortId(sn: string) {
|
|
|
|
|
|
export function searchStation(keyword: string) {
|
|
|
return fetchAllStations().then((res) => {
|
|
|
- const reg = new RegExp(keyword, "ig");
|
|
|
- const list = res.filter(
|
|
|
- (item) => reg.test(item.stationName) || reg.test(item.address)
|
|
|
- );
|
|
|
- return _fetchStationStatus(list);
|
|
|
+ // const reg = new RegExp(keyword.trim(), "ig");
|
|
|
+ // console.log(res)
|
|
|
+ const stationIdList = res.filter(
|
|
|
+ (item) => item.stationName.includes(keyword) || item.address.includes(keyword)
|
|
|
+ ).map(k => k.stationId+"");
|
|
|
+ // console.log("serach>>>>>",list)
|
|
|
+ if (stationIdList) {
|
|
|
+ return _fetchStations(1, 100, 0, 0, stationIdList)
|
|
|
+ } else {
|
|
|
+ return Promise.reject([])
|
|
|
+ }
|
|
|
+
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-export function fetchAllStations(latitude?:number,longitude?:number): Promise<any[]> {
|
|
|
+export function fetchAllStations(latitude?: number, longitude?: number): Promise<any[]> {
|
|
|
if (getApp<any>().globalData.stations.length > 0) {
|
|
|
return Promise.resolve(getApp<any>().globalData.stations);
|
|
|
}
|
|
|
const page = 1;
|
|
|
const page_size = 99;
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- _fetchAllStations(page, page_size, [],latitude,longitude)
|
|
|
+ _fetchAllStations(page, page_size, [], latitude, longitude)
|
|
|
.then((list) => {
|
|
|
// if (!isProduction) {
|
|
|
// list.push({
|
|
|
@@ -399,11 +451,12 @@ function _fetchAllStations(
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-function _fetchStations(page: number, pageSize: number, latitude?: number, longitude?: number) {
|
|
|
+export function _fetchStations(page: number, pageSize: number,
|
|
|
+ latitude?: number, longitude?: number, stationIdList?: Array<string>) {
|
|
|
return cHttp
|
|
|
- .get(`/charge/listStation?pageNum=${page}&pageSize=${pageSize}&latitude=${latitude}&longitude=${longitude}`)
|
|
|
+ .get(`/charge/listStation?pageNum=${page}&pageSize=${pageSize}&latitude=${latitude||22.696779}&longitude=${longitude||114.044805}&stationIdList=${stationIdList||[]}`)
|
|
|
.then((res) => {
|
|
|
- console.log("xxxxx", res)
|
|
|
+ // console.log("xxxxx", res)
|
|
|
const data = res.list || [];
|
|
|
data.forEach((item: any) => {
|
|
|
item.StationID = item.stationId;
|
|
|
@@ -423,7 +476,7 @@ function _fetchStations(page: number, pageSize: number, latitude?: number, longi
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-function _getDistance(lat1: number, lng1: number, lat2: number, lng2: number) {
|
|
|
+export function _getDistance(lat1: number, lng1: number, lat2: number, lng2: number) {
|
|
|
var radLat1 = (lat1 * Math.PI) / 180.0;
|
|
|
var radLat2 = (lat2 * Math.PI) / 180.0;
|
|
|
var a = radLat1 - radLat2;
|