From bdfdd6140841419dfb8374177289666bc0b77d05 Mon Sep 17 00:00:00 2001 From: jiannibang <271381693@qq.com> Date: Mon, 14 Oct 2024 09:30:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AF=BC=E8=88=AA=E7=BB=93=E6=9D=9F?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.js | 57 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/pages/index/index.js b/pages/index/index.js index dc5920e..f55a156 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -4,6 +4,7 @@ import { registerGLTFLoader } from "../../loader/gltfLoader"; var THREE; import configData from "./config"; import { STATES, promptStateMap } from "./index-helper"; +import { post } from "../../app"; var _canvas; let map; let locationOption; @@ -71,6 +72,55 @@ Page({ point: null, resolution: null, }, + async sendArriveMsg() { + try { + const userId = getApp().globalData.openid; + if (!map) return; + let shop = map.shopMap[this.data.e] + ? map.shopMap[this.data.e] + : map.facilityMap[this.data.e] + ? map.facilityMap[this.data.e] + : map.pMap[this.data.e]; + const isShop = !!map.shopMap[this.data.e]; + const isP = !!map.pMap[this.data.e]; + const isFac = !!map.facilityMap[this.data.e]; + const isDevice = !shop; + if (!shop) { + const endParamList = this.data.e.split("_"); + if (endParamList.length === 3) { + let [efloororder, epoint, ename] = endParamList; + efloororder = Number(efloororder); + epoint = Number(epoint); + shop = { + isDevice: true, + name: ename, + navPoint: epoint, + yaxis: epoint, + floorOrder: efloororder, + floorName: map.mall.floors[efloororder][1], + }; + } + } + const body = { + userId, + navType: 2, + pointType: isShop || isDevice ? "1" : isP ? "3" : "2", + objectCode: isShop + ? shop.code + : isP + ? shop.name + : isFac + ? shop.Type + : shop.name, + objectName: shop.name, + floorName: shop.floorName, + }; + const res = await post("/Api/Statistics/CompleteUpload", body); + console.log("AR导航结束上报返回", body, res); + } catch (error) { + console.log("AR导航结束上报报错", error); + } + }, clickScreen(e) { let detail = e.detail; if (this.SDK) this.SDK.getScreenCoordinate({ x: detail.x, y: detail.y }); @@ -87,6 +137,7 @@ Page({ * 生命周期函数--监听页面加载 */ async onLoad({ e, searchType = 0 }) { + this.hasArriveMsgSent = false; this.frameIndex = 0; this.getSystemInfo(); wx.setKeepScreenOn({ @@ -95,7 +146,7 @@ Page({ const { globalData: { floors }, } = getApp(); - const { windowHeight } = wx.getSystemInfoSync(); + const { windowHeight } = wx.getWindowInfo(); this.setData({ floors, filteredMallFloors: floors.filter( @@ -226,6 +277,10 @@ Page({ type: nextPointType, orientation: theta, } = res; + if (!this.hasArriveMsgSent && distance < 50 && !this.data.nextFloor) { + this.hasArriveMsgSent = true; + this.sendArriveMsg(); + } if (!this.data.totalDistance) this.setData({ totalDistance: distance }); this.setData({ theta,