From 25766a77621910a167c91c66c06533fc3a9cb85e Mon Sep 17 00:00:00 2001 From: jiannibang <271381693@qq.com> Date: Tue, 25 Jul 2023 14:07:35 +0800 Subject: [PATCH] feat: init --- app.js | 30 +++++++++++- app.json | 2 +- getMapData.js | 96 +++++++++++++++++++++---------------- pages/h5map/index.js | 28 ++--------- pages/h5map/index.json | 2 +- pages/index/index.js | 4 +- pages/index/index.wxml | 4 +- project.config.json | 2 +- project.private.config.json | 2 +- 9 files changed, 95 insertions(+), 75 deletions(-) diff --git a/app.js b/app.js index 59fb686..6803358 100644 --- a/app.js +++ b/app.js @@ -2,12 +2,40 @@ import { getMapData, post, code } from "./getMapData"; const floors = [ { - name: "L1", + name: "B3", + floorOrder: 0, + url: true, + floorId: "B3", + isPark: false, + }, + { + name: "B2", + floorOrder: 1, + url: true, + floorId: "B2", + isPark: false, + }, + { + name: "B1", + floorOrder: 2, + url: true, + floorId: "B1", + isPark: false, + }, + { + name: "1F", floorOrder: 3, url: true, floorId: "F1", isPark: false, }, + { + name: "2F", + floorOrder: 5, + url: true, + floorId: "F2", + isPark: true, + }, ]; App({ async onLaunch() { diff --git a/app.json b/app.json index e8927c0..9d1085b 100644 --- a/app.json +++ b/app.json @@ -9,7 +9,7 @@ "window": { "navigationStyle": "custom", "navigationBarBackgroundColor": "#F0F0F0", - "navigationBarTitleText": "沈阳K11", + "navigationBarTitleText": "成都SKP", "navigationBarTextStyle": "black" }, "style": "v2", diff --git a/getMapData.js b/getMapData.js index 32a1b01..8d3911d 100644 --- a/getMapData.js +++ b/getMapData.js @@ -2,7 +2,7 @@ import { get } from "./pages/map2d/util"; import dataHelper from "./data-helper"; const baseUrl = "https://iot.1000my.com"; export const cdnUrl = "https://qianmu-iot.1000my.com"; -export const code = "project-dshd7pel_ogpcdect930ja"; +export const code = "project-ey_fpaur6s6fkgvszywana"; export const post = (url, data) => new Promise((resolve) => { wx.request({ @@ -25,39 +25,34 @@ export const mall = { cdnUrl, code, floors: [ + [true, "B3"], [true, "B2"], [true, "B1"], - [true, "B1M"], - [true, "L1"], - [true, "L2"], - [true, "L3"], - [true, "L4"], - [true, "L5"], - [true, "L6"], + [true, "1F"], + [true, "1MF"], + [true, "2F"], + [false, "景观层"], ], }; 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: { buildingList, shopList: serverShopInfo }, - }, + mapData, + serverShopInfo, { data: facs }, { data: sdkMapList }, { @@ -66,18 +61,39 @@ export const getMapData = async () => { { data: pois }, ...rest ] = await Promise.all([ - get(config.mapDataUrl), - get(config.shopInfoUrl), + (async () => { + try { + const { + data: [{ mapData }], + } = await get(config.mapDataUrl); + return mapData; + } catch (error) { + console.error(error); + return {}; + } + })(), + (async () => { + try { + const { + data: [serverShopInfo], + } = await get(config.shopInfoUrl); + return serverShopInfo; + } catch (error) { + console.error(error); + return {}; + } + })(), get( - `${baseUrl}/api/guide/v1/web/getProjectUsedIconList?projectCode=${code}` + `${baseUrl}/api/guidance/v1/web/getProjectUsedIconList?projectCode=${code}` ), post(`/api/ar/v1/applet/GetSdkConfigList`, { mallCode: code }), post(`/api/ar/v1/applet/ProjectConfig`, { mallCode: code }), post(`/api/ar/v1/applet/GetPoiList`, { mallCode: code }), ...mall.floors.map((_, i) => - get(`${baseUrl}/api/guide/v1/web/getMallMapData/${code}/${i}`) + get(`${baseUrl}/api/guidance/v1/web/getMallMapData/${code}/${i}`) ), ]); + const poiMap = pois.reduce((acc, nxt) => ({ ...acc, [nxt.code]: nxt }), {}); const sdkMap = sdkMapList.map( ({ @@ -106,23 +122,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) => ({ @@ -148,7 +160,7 @@ export const getMapData = async () => { shopMap[shop.houseNum] = shop; }); }); - + console.log(shopMap); const dataHelperResponse = await dataHelper({ serverShopInfo, mapData, diff --git a/pages/h5map/index.js b/pages/h5map/index.js index 62b8ee0..ccd9443 100644 --- a/pages/h5map/index.js +++ b/pages/h5map/index.js @@ -27,29 +27,11 @@ Page({ const openid = app.globalData.openid ? app.globalData.openid : await new Promise((resolve) => app.onOpenid(resolve)); - const { memberID, isShopMember } = app.globalData; - if (memberID) { - return this.setData({ - url: `${baseUrl}?t=${new Date().getTime()}#/?openid=${openid}&memberID=${memberID}${ - isShopMember ? "&isShop=true" : "" - }${e ? "&e=" + e : ""}${e && s ? "&s=" + s : ""}${ - plate ? "&plate=" + plate : "" - }`, - }); - } - if (!openid) { - console.warn("获取openid失败"); - app.globalData.userDeny = true; - } - if (app.globalData.userDeny) { - return this.setData({ - url: `${baseUrl}?t=${new Date().getTime()}#/?openid=${openid}${ - e ? "&e=" + e : "" - }${e && s ? "&s=" + s : ""}${plate ? "&plate=" + plate : ""}`, - }); - } - return wx.redirectTo({ - url: "/pages/login/index", + + return this.setData({ + url: `${baseUrl}?t=${new Date().getTime()}#/?openid=${openid}${ + e ? "&e=" + e : "" + }${e && s ? "&s=" + s : ""}${plate ? "&plate=" + plate : ""}`, }); }, diff --git a/pages/h5map/index.json b/pages/h5map/index.json index d8f6a7a..de99a90 100644 --- a/pages/h5map/index.json +++ b/pages/h5map/index.json @@ -1 +1 @@ -{ "navigationBarTitleText": "沈阳K11", "usingComponents": {} } +{ "navigationBarTitleText": "成都SKP", "usingComponents": {} } diff --git a/pages/index/index.js b/pages/index/index.js index 6299488..ee0df33 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -412,9 +412,7 @@ Page({ } }, setFloor({ currentTarget: { id } }) { - const floor = this.data[ - this.data.selectMall ? "filteredMallFloors" : "filteredParkFloors" - ][id]; + const floor = this.data.floors[id]; this.setData({ floorOrder: floor.floorOrder, point: null, diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 2741194..762e95a 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -24,7 +24,7 @@ 请选择您当前所在楼层 - + {{item.name}} @@ -33,7 +33,7 @@ - + diff --git a/project.config.json b/project.config.json index 4d2113e..8c80c18 100644 --- a/project.config.json +++ b/project.config.json @@ -68,5 +68,5 @@ "ignore": [], "include": [] }, - "appid": "wxb013aa2df3b70893" + "appid": "wx95d4c760e41298dd" } \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json index 13f8959..65a0a85 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -23,6 +23,6 @@ } }, "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", - "projectname": "syk11_ar_miniprogram", + "projectname": "cdskp_ar_miniprogram", "libVersion": "2.26.0" } \ No newline at end of file