二维码扫码进入小程序开锁功能实现

This commit is contained in:
dzl 2025-05-28 18:03:25 +08:00
parent 12844b406c
commit 1c2e09ab2c
3 changed files with 73 additions and 19 deletions

View File

@ -133,7 +133,8 @@
import config from '@/utils/config'; import config from '@/utils/config';
import { import {
onShow, onShow,
onUnload onUnload,
onLoad
} from "@dcloudio/uni-app"; } from "@dcloudio/uni-app";
import * as map from "@/utils/usermap.js"; import * as map from "@/utils/usermap.js";
@ -182,10 +183,58 @@
let arrBikeData = []; let arrBikeData = [];
const showBikeInfo = ref(false); const showBikeInfo = ref(false);
const bikeData = ref({}); const bikeData = ref({});
const onLoadData = ref(null)
let ismount = false; let ismount = false;
let arrSiteData = [] let arrSiteData = []
onLoad((query) => {
if (query.q) {
const q = decodeURIComponent(query.q) //
const scancode_time = parseInt(query.scancode_time) // UNIX
const queryString = q.split('?')[1];
const params = queryString.split('&');
let p = {};
params.forEach(param => {
const [key, value] = param.split('=');
p[key] = value;
});
console.log("p===>" + JSON.stringify(p))
onLoadData.value = p;
} else if (query.number) {
onLoadData.value['number'] = query.number;
onLoadData.value['_tbScancodeApproach_'] = query._tbScancodeApproach_;
}
})
onMounted(() => {
const instance = getCurrentInstance();
oMap = uni.createMapContext("mapRef", {
this: instance.proxy
});
ismount = true;
getLoalcationData();
console.log("loadValue===>" + JSON.stringify(onLoadData.value))
if (onLoadData.value) {
if (onLoadData.value['_tbScancodeApproach_'] == 'scan') {
if (!oUser) {
tologin();
}
map.addOrder(onLoadData.value["number"], (res) => {
console.log("00000000000000000000", res);
if (!res) {
setTimeout(() => {
bikeCode = null;
getOrder();
}, 1000);
return;
} else {
showWorn.value = true;
}
})
}
}
})
// //
function getLoalcationData() { function getLoalcationData() {
map.getLoalcation(res => { map.getLoalcation(res => {
@ -468,8 +517,12 @@
} }
function tologin() { function tologin() {
let url = '/pages/user/login/wx_login'
if (onLoadData.value) {
url += '?number=' + onLoadData.value['number'] + "&_tbScancodeApproach_=scan"
}
uni.navigateTo({ uni.navigateTo({
url: "/pages/user/login/wx_login" url: url
}) })
} }
@ -612,14 +665,6 @@
showTools.value = true; showTools.value = true;
} }
onMounted(() => {
const instance = getCurrentInstance();
oMap = uni.createMapContext("mapRef", {
this: instance.proxy
});
ismount = true;
getLoalcationData();
})
onShow(() => { onShow(() => {
if (uni.getStorageSync("wechat_user")) { if (uni.getStorageSync("wechat_user")) {
oUser = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user"))); oUser = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user")));
@ -634,8 +679,7 @@
if (ismount) getLoalcationData(); if (ismount) getLoalcationData();
}); });
onUnload(() => { onUnload(() => {})
})
function parseDate(createTime) { function parseDate(createTime) {
// iOS // iOS

View File

@ -63,6 +63,7 @@
const agreed = ref([{ const agreed = ref([{
value: true // true value: true // true
}]); }]);
const onLoadData = ref(null)
import { import {
onLoad onLoad
} from '@dcloudio/uni-app'; } from '@dcloudio/uni-app';
@ -76,6 +77,10 @@
}) })
onLoad((options) => { onLoad((options) => {
if (options['number']) {
onLoadData.value['number'] = options['number']
onLoadData.value['_tbScancodeApproach_'] = options['_tbScancodeApproach_']
}
login(); login();
}) })
@ -234,7 +239,11 @@
}) })
}, 500); }, 500);
} else { } else {
let url = "/pages/user/home/home"
let q = "";
if (onLoadData.value) {
url += '?number=' + onLoadData.value['number'] + "&_tbScancodeApproach_=scan"
}
setTimeout(() => { setTimeout(() => {
uni.navigateTo({ uni.navigateTo({
url: "/pages/user/home/home" url: "/pages/user/home/home"

View File

@ -46,7 +46,8 @@
} from "@dcloudio/uni-app"; } from "@dcloudio/uni-app";
import { import {
showModelMessage, showModelMessage,
getUrlParams,jkcBaseDecode getUrlParams,
jkcBaseDecode
} from "@/utils/tools.js"; } from "@/utils/tools.js";
import { import {