|
|
|
@ -1,7 +1,11 @@ |
|
|
|
import { get } from "./pages/map2d/util"; |
|
|
|
import dataHelper from "./data-helper"; |
|
|
|
const baseUrl = "https://project-iot.test.1000my.com"; |
|
|
|
export const cdnUrl = "https://test-598d.1000my.com"; |
|
|
|
// dev
|
|
|
|
// const baseUrl = "https://iot-dev.123.1000my.com";
|
|
|
|
// export const code = "project-k5chc3vt0vkodjbmhl8rua";
|
|
|
|
// test
|
|
|
|
const baseUrl = "https://project-iot.test.1000my.com"; |
|
|
|
export const code = "project-skcn0gk6yb2xutkcsmjtra"; |
|
|
|
export const post = (url, data) => |
|
|
|
new Promise((resolve) => { |
|
|
|
@ -30,26 +34,26 @@ export const mall = { |
|
|
|
], |
|
|
|
}; |
|
|
|
const config = { |
|
|
|
mapDataUrl: `${baseUrl}/api/guide/v1/web/getMallMapData/${code}/Aeditor`, |
|
|
|
shopInfoUrl: `${baseUrl}/api/guide/v1/web/getMapInfo?projectCode=${code}`, |
|
|
|
mapDataUrl: `${cdnUrl}/ar/${code}/Aeditor/Aeditor.json?t=${new Date().getTime()}`, |
|
|
|
shopInfoUrl: `${cdnUrl}/ar/${code}/QueryShopListForMap/QueryShopListForMap.json?t=${new Date().getTime()}`, |
|
|
|
}; |
|
|
|
export const getMapData = async () => { |
|
|
|
if (mapDataAndShop) return mapDataAndShop; |
|
|
|
// try {
|
|
|
|
// const { mapUrl, shopUrl } = await get(
|
|
|
|
// `${cdnUrl}/test-projects/${code}/config.json?t=${new Date().getTime()}`
|
|
|
|
// );
|
|
|
|
// if (mapUrl) config.mapDataUrl = mapUrl;
|
|
|
|
// if (shopUrl) config.shopInfoUrl = shopUrl;
|
|
|
|
// } catch (error) {
|
|
|
|
// console.log("获取config失败");
|
|
|
|
// }
|
|
|
|
try { |
|
|
|
const { mapUrl, shopUrl } = await get( |
|
|
|
`${cdnUrl}/ar/${code}/config.json?t=${new Date().getTime()}` |
|
|
|
); |
|
|
|
if (mapUrl) config.mapDataUrl = mapUrl; |
|
|
|
if (shopUrl) config.shopInfoUrl = shopUrl; |
|
|
|
} catch (error) { |
|
|
|
console.log("获取config失败"); |
|
|
|
} |
|
|
|
let [ |
|
|
|
{ |
|
|
|
data: { mapData }, |
|
|
|
data: [{ mapData }], |
|
|
|
}, |
|
|
|
{ |
|
|
|
data: { buildingList, shopList: serverShopInfo }, |
|
|
|
data: [serverShopInfo], |
|
|
|
}, |
|
|
|
{ data: facs }, |
|
|
|
{ data: sdkMapList }, |
|
|
|
@ -99,23 +103,19 @@ export const getMapData = async () => { |
|
|
|
mall.floors.forEach((floor, i) => { |
|
|
|
floor[2] = map2dData[i]; |
|
|
|
}); |
|
|
|
serverShopInfo = serverShopInfo |
|
|
|
.filter(({ buildingOrder }) => buildingOrder === 0) |
|
|
|
.map((iot) => ({ |
|
|
|
serverShopInfo = serverShopInfo.map(({ floorOrd: floorOrder, shopList }) => ({ |
|
|
|
floorOrder, |
|
|
|
shopList: shopList.map((iot) => ({ |
|
|
|
...iot, |
|
|
|
name: iot.shopName, |
|
|
|
code: iot.shopCode, |
|
|
|
houseNum: iot.houseNumber, |
|
|
|
nameEn: iot.shopNameEn, |
|
|
|
logoPath: cdnUrl + iot.logoUrl, |
|
|
|
shopFormat: iot.industryFatherName, |
|
|
|
intro: true, |
|
|
|
})) |
|
|
|
.reduce((acc, nxt) => { |
|
|
|
if (!acc[nxt.floorOrder]) acc[nxt.floorOrder] = [nxt]; |
|
|
|
else acc[nxt.floorOrder] = [...acc[nxt.floorOrder], nxt]; |
|
|
|
return acc; |
|
|
|
}, []) |
|
|
|
.map((shopList, floorOrder) => ({ floorOrder, shopList })); |
|
|
|
formatColor: iot.color, |
|
|
|
floorOrder, |
|
|
|
})), |
|
|
|
})); |
|
|
|
mapData = JSON.parse(mapData)[0]; |
|
|
|
const facilityTypeMap = facs.reduce( |
|
|
|
(acc, nxt) => ({ |
|
|
|
|