Browse Source

feat: init

dev
jiannibang 3 years ago
parent
commit
25766a7762
  1. 30
      app.js
  2. 2
      app.json
  3. 96
      getMapData.js
  4. 20
      pages/h5map/index.js
  5. 2
      pages/h5map/index.json
  6. 4
      pages/index/index.js
  7. 4
      pages/index/index.wxml
  8. 2
      project.config.json
  9. 2
      project.private.config.json

30
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() {

2
app.json

@ -9,7 +9,7 @@
"window": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#F0F0F0",
"navigationBarTitleText": "沈阳K11",
"navigationBarTitleText": "成都SKP",
"navigationBarTextStyle": "black"
},
"style": "v2",

96
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,

20
pages/h5map/index.js

@ -27,30 +27,12 @@ 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",
});
},
/**

2
pages/h5map/index.json

@ -1 +1 @@
{ "navigationBarTitleText": "沈阳K11", "usingComponents": {} }
{ "navigationBarTitleText": "成都SKP", "usingComponents": {} }

4
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,

4
pages/index/index.wxml

@ -24,7 +24,7 @@
<view class="meta2"> 请选择您当前所在楼层</view>
<scroll-view class="list" scroll-x>
<view class="list-container">
<view class="item {{item.floorId===floorId?'active':''}}" id="{{index}}" wx:for="{{selectMall? filteredMallFloors:filteredParkFloors}}" wx:key="floorId" bindtap="setFloor">
<view class="item {{item.floorId===floorId?'active':''}}" id="{{index}}" wx:for="{{floors}}" wx:key="floorId" bindtap="setFloor">
<text>{{item.name}}</text>
</view>
</view>
@ -33,7 +33,7 @@
<button bindtap="requestLocation" loading="{{!inited}}" class="btn {{(inited && floorOrder!==null)? '' : 'disabled'}}">开始导航</button>
</view>
</view>
<view wx:if="{{false&&(floorId==='B3'||floorId==='B2'||floorId==='B1')&&(state===states.startScan||state===states.fail5s)}}" class="zzcImg">
<view wx:if="{{false&&(state===states.startScan||state===states.fail5s)}}" class="zzcImg">
<image src="/pages/index/mask.png" class="zzcimg_ys"></image>
<cover-view wx:if="{{flash_isFilter}}" class="scan_lo_tow" style="width:{{parkWidth}}px;height:{{parkHeight-10}}px;top:{{parkTop}}px;left:{{parkLeft}}px;">
<cover-image class="scan_img trans-y" src="https://ar-fm.cdn.bcebos.com/lktools/880c9ef27944354288b11f2abed8fba7cb82d559"></cover-image>

2
project.config.json

@ -68,5 +68,5 @@
"ignore": [],
"include": []
},
"appid": "wxb013aa2df3b70893"
"appid": "wx95d4c760e41298dd"
}

2
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"
}
Loading…
Cancel
Save