Browse Source

feat: 支持扫普通二维码跳转

master
jiannibang 2 years ago
parent
commit
7b9bf75d57
  1. 43
      pages/index/index.js
  2. 21
      project.private.config.json

43
pages/index/index.js

@ -72,6 +72,7 @@ Page({
point: null,
resolution: null,
showBannerToast: false,
initCbs: [],
},
async sendArriveMsg() {
try {
@ -137,9 +138,24 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
async onLoad({ e, searchType = 0 }) {
async onLoad({ e, searchType = 0, q, floorId }) {
this.hasArriveMsgSent = false;
this.frameIndex = 0;
if (q) {
console.log(q);
try {
q = decodeURIComponent(q);
console.log(q);
const kvs = q
.split("?")
.pop()
.split("&")
.map((kv) => kv.split("="));
e = kvs.find(([k]) => k === "e")[1];
floorId = kvs.find(([k]) => k === "floorId")[1];
} catch (error) {
console.log("处理二维码参数失败", error);
}
}
this.getSystemInfo();
wx.setKeepScreenOn({
keepScreenOn: true,
@ -161,6 +177,27 @@ Page({
searchType: Number(searchType),
});
this.initSDK();
if (floorId) {
const floor = floors.find((floor) => floorId === floor.floorId);
console.log("初始floorId:", floorId);
if (!this.data.inited) {
console.log("等待地图初始化");
await new Promise((resolve) => {
this.setData({ initCbs: [...this.data.initCbs, resolve] });
});
}
console.log("地图初始化完成");
this.setData({
gettingFloor: false,
floorOrder: floor.floorOrder,
point: null,
floorId: floor.floorId,
floorName: floor.name,
state: STATES.startScan,
});
return this.requestLocation(true);
}
if (this.data.floorId) this.requestLocation(true);
},
initSDK() {
this.SDK = new VPASSDK.SDKWrapper(configData);
@ -632,8 +669,10 @@ Page({
},
handleMap({ detail }) {
map = detail;
this.data.initCbs.forEach((cb) => cb(map));
this.setData({
inited: true,
initCbs: [],
});
},
handleTabChange({ detail }) {

21
project.private.config.json

@ -3,7 +3,26 @@
"compileHotReLoad": true,
"urlCheck": true
},
"condition": {},
"condition": {
"miniprogram": {
"list": [
{
"name": "pages/index/index",
"pathName": "pages/index/index",
"query": "q=https%3A%2F%2Fbj.bcebos.com%2Fhjcdn%2Fchatcheck%2Fwx%2F%3Fe%3DL2201%26floorId%3DF4",
"launchMode": "default",
"scene": null
},
{
"name": "pages/index/index",
"pathName": "pages/index/index",
"query": "e=L2201&floorId=F2",
"launchMode": "default",
"scene": null
}
]
}
},
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "%E6%97%A0%E9%94%A1%E8%8D%9F%E8%81%9A",
"libVersion": "2.33.0"

Loading…
Cancel
Save