|
|
@ -2,11 +2,11 @@ import axios from "axios"; |
|
|
import icons from "./image-helper"; |
|
|
import icons from "./image-helper"; |
|
|
let mallInfos = new Map(); |
|
|
let mallInfos = new Map(); |
|
|
// dev
|
|
|
// dev
|
|
|
// export const code = "project-k5chc3vt0vkodjbmhl8rua";
|
|
|
|
|
|
// export const baseUrl = "https://iot-dev.123.1000my.com";
|
|
|
|
|
|
|
|
|
export const code = "project-k5chc3vt0vkodjbmhl8rua"; |
|
|
|
|
|
export const baseUrl = "https://iot-dev.123.1000my.com"; |
|
|
// test
|
|
|
// test
|
|
|
export const code = "project-skcn0gk6yb2xutkcsmjtra"; |
|
|
|
|
|
export const baseUrl = "https://project-iot.test.1000my.com"; |
|
|
|
|
|
|
|
|
// export const code = "project-skcn0gk6yb2xutkcsmjtra";
|
|
|
|
|
|
// export const baseUrl = "https://project-iot.test.1000my.com";
|
|
|
export const post = async (url = "", data = {}) => { |
|
|
export const post = async (url = "", data = {}) => { |
|
|
const response = await fetch(baseUrl + url, { |
|
|
const response = await fetch(baseUrl + url, { |
|
|
method: "POST", |
|
|
method: "POST", |
|
|
@ -36,10 +36,6 @@ const getMallInfo = async ({ memberID }) => { |
|
|
offsetToNorth, |
|
|
offsetToNorth, |
|
|
}; |
|
|
}; |
|
|
const floorMap = { 1: true }; |
|
|
const floorMap = { 1: true }; |
|
|
const config = { |
|
|
|
|
|
mapDataUrl: `${baseUrl}/api/guide/v1/web/getMallMapData/${code}/Aeditor`, |
|
|
|
|
|
shopInfoUrl: `${baseUrl}/api/guide/v1/web/getMapInfo?projectCode=${code}`, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let cdnUrl; |
|
|
let cdnUrl; |
|
|
try { |
|
|
try { |
|
|
@ -51,27 +47,27 @@ const getMallInfo = async ({ memberID }) => { |
|
|
console.error(error); |
|
|
console.error(error); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// const config = {
|
|
|
|
|
|
// mapDataUrl: `${cdnUrl}/ar/${code}/Aeditor/Aeditor.json?t=${new Date().getTime()}`,
|
|
|
|
|
|
// shopInfoUrl: `${cdnUrl}/ar/${code}/QueryShopListForMap/QueryShopListForMap.json?t=${new Date().getTime()}`,
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
const config = { |
|
|
|
|
|
mapDataUrl: `${cdnUrl}/ar/${code}/Aeditor/Aeditor.json?t=${new Date().getTime()}`, |
|
|
|
|
|
shopInfoUrl: `${cdnUrl}/ar/${code}/QueryShopListForMap/QueryShopListForMap.json?t=${new Date().getTime()}`, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
// const {
|
|
|
|
|
|
// data: { mapUrl, shopUrl },
|
|
|
|
|
|
// } = await axios.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失败");
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
const { |
|
|
|
|
|
data: { mapUrl, shopUrl }, |
|
|
|
|
|
} = await axios.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失败"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const [ |
|
|
const [ |
|
|
{ cityName, projectName }, |
|
|
{ cityName, projectName }, |
|
|
mapDataJSON, |
|
|
mapDataJSON, |
|
|
[buildingList, serverShopInfo], |
|
|
|
|
|
|
|
|
serverShopInfo, |
|
|
facs, |
|
|
facs, |
|
|
activities, |
|
|
activities, |
|
|
pois, |
|
|
pois, |
|
|
@ -95,7 +91,7 @@ const getMallInfo = async ({ memberID }) => { |
|
|
try { |
|
|
try { |
|
|
const { |
|
|
const { |
|
|
data: { |
|
|
data: { |
|
|
data: { mapData: mapDataJSON }, |
|
|
|
|
|
|
|
|
data: [{ mapData: mapDataJSON }], |
|
|
}, |
|
|
}, |
|
|
} = await axios.get(config.mapDataUrl); |
|
|
} = await axios.get(config.mapDataUrl); |
|
|
return mapDataJSON; |
|
|
return mapDataJSON; |
|
|
@ -108,10 +104,10 @@ const getMallInfo = async ({ memberID }) => { |
|
|
try { |
|
|
try { |
|
|
const { |
|
|
const { |
|
|
data: { |
|
|
data: { |
|
|
data: { buildingList, shopList: serverShopInfo }, |
|
|
|
|
|
|
|
|
data: [serverShopInfo], |
|
|
}, |
|
|
}, |
|
|
} = await axios.get(config.shopInfoUrl); |
|
|
} = await axios.get(config.shopInfoUrl); |
|
|
return [buildingList, serverShopInfo]; |
|
|
|
|
|
|
|
|
return serverShopInfo; |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error(error); |
|
|
console.error(error); |
|
|
return {}; |
|
|
return {}; |
|
|
@ -194,29 +190,26 @@ const getMallInfo = async ({ memberID }) => { |
|
|
}), |
|
|
}), |
|
|
{} |
|
|
{} |
|
|
); |
|
|
); |
|
|
mall.floors = buildingList[0].floorList.map(({ floor, floorOrder }) => ({ |
|
|
|
|
|
|
|
|
mall.floors = serverShopInfo.map(({ floor }, floorOrder) => ({ |
|
|
name: floor, |
|
|
name: floor, |
|
|
floorOrder, |
|
|
floorOrder, |
|
|
url: floorMap[floorOrder] ? true : null, |
|
|
url: floorMap[floorOrder] ? true : null, |
|
|
})); |
|
|
})); |
|
|
const shopInfo = serverShopInfo |
|
|
|
|
|
.filter(({ buildingOrder }) => buildingOrder === 0) |
|
|
|
|
|
.map((iot) => ({ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const shopInfo = serverShopInfo.map(({ floorOrd: floorOrder, shopList }) => ({ |
|
|
|
|
|
floorOrder, |
|
|
|
|
|
shopList: shopList.map((iot) => ({ |
|
|
...iot, |
|
|
...iot, |
|
|
code: iot.shopCode, |
|
|
code: iot.shopCode, |
|
|
name: iot.shopName, |
|
|
|
|
|
houseNum: iot.houseNumber, |
|
|
houseNum: iot.houseNumber, |
|
|
nameEn: iot.shopNameEn, |
|
|
|
|
|
logoPath: cdnUrl + iot.logoUrl, |
|
|
logoPath: cdnUrl + iot.logoUrl, |
|
|
shopFormat: iot.industryFatherName, |
|
|
shopFormat: iot.industryFatherName, |
|
|
intro: true, |
|
|
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, |
|
|
|
|
|
})), |
|
|
|
|
|
})); |
|
|
|
|
|
|
|
|
shopInfo.forEach(({ shopList }) => |
|
|
shopInfo.forEach(({ shopList }) => |
|
|
shopList.forEach((shop) => { |
|
|
shopList.forEach((shop) => { |
|
|
if (shopCouponMap[shop.code]) shop.hasCoupon = true; |
|
|
if (shopCouponMap[shop.code]) shop.hasCoupon = true; |
|
|
@ -246,7 +239,7 @@ const getMallInfo = async ({ memberID }) => { |
|
|
mapData.buildArr.forEach(({ mapData: { parkArea } }) => { |
|
|
mapData.buildArr.forEach(({ mapData: { parkArea } }) => { |
|
|
parkArea.forEach(({ parkNum }) => mall.lots.push(parkNum)); |
|
|
parkArea.forEach(({ parkNum }) => mall.lots.push(parkNum)); |
|
|
}); |
|
|
}); |
|
|
console.log(mapData); |
|
|
|
|
|
|
|
|
console.log(mapData, shopInfo); |
|
|
Object.assign(mall, { |
|
|
Object.assign(mall, { |
|
|
floorData: mall.floors, |
|
|
floorData: mall.floors, |
|
|
shopInfo, |
|
|
shopInfo, |
|
|
@ -254,7 +247,7 @@ const getMallInfo = async ({ memberID }) => { |
|
|
floors: mall.floors.reduce((acc, { name, floorOrder, url }) => { |
|
|
floors: mall.floors.reduce((acc, { name, floorOrder, url }) => { |
|
|
acc[floorOrder] = [url, name]; |
|
|
acc[floorOrder] = [url, name]; |
|
|
return acc; |
|
|
return acc; |
|
|
}, new Array()), |
|
|
|
|
|
|
|
|
}, []), |
|
|
poiMap, |
|
|
poiMap, |
|
|
menu, |
|
|
menu, |
|
|
}); |
|
|
}); |
|
|
|