From 2199bc1e53fd28df7334c36cd7e6e5dad060591e Mon Sep 17 00:00:00 2001 From: jiannibang <271381693@qq.com> Date: Mon, 10 Apr 2023 16:45:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AF=B9=E6=8E=A5obs=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- getMapData.js | 52 +++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/getMapData.js b/getMapData.js index f803173..ad6fc61 100644 --- a/getMapData.js +++ b/getMapData.js @@ -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) => ({