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

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 {
onShow,
onUnload
onUnload,
onLoad
} from "@dcloudio/uni-app";
import * as map from "@/utils/usermap.js";
@ -182,10 +183,58 @@
let arrBikeData = [];
const showBikeInfo = ref(false);
const bikeData = ref({});
const onLoadData = ref(null)
let ismount = false;
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() {
map.getLoalcation(res => {
@ -468,8 +517,12 @@
}
function tologin() {
let url = '/pages/user/login/wx_login'
if (onLoadData.value) {
url += '?number=' + onLoadData.value['number'] + "&_tbScancodeApproach_=scan"
}
uni.navigateTo({
url: "/pages/user/login/wx_login"
url: url
})
}
@ -612,14 +665,6 @@
showTools.value = true;
}
onMounted(() => {
const instance = getCurrentInstance();
oMap = uni.createMapContext("mapRef", {
this: instance.proxy
});
ismount = true;
getLoalcationData();
})
onShow(() => {
if (uni.getStorageSync("wechat_user")) {
oUser = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user")));
@ -634,8 +679,7 @@
if (ismount) getLoalcationData();
});
onUnload(() => {
})
onUnload(() => {})
function parseDate(createTime) {
// iOS

View File

@ -63,6 +63,7 @@
const agreed = ref([{
value: true // true
}]);
const onLoadData = ref(null)
import {
onLoad
} from '@dcloudio/uni-app';
@ -76,6 +77,10 @@
})
onLoad((options) => {
if (options['number']) {
onLoadData.value['number'] = options['number']
onLoadData.value['_tbScancodeApproach_'] = options['_tbScancodeApproach_']
}
login();
})
@ -227,14 +232,18 @@
//
login();
let wechat_user = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user")));
if (!wechat_user.avatar) {
if (!wechat_user.avatar) {
setTimeout(() => {
uni.navigateTo({
url: "/pages/user/login/userphtoinfo"
})
}, 500);
} else {
let url = "/pages/user/home/home"
let q = "";
if (onLoadData.value) {
url += '?number=' + onLoadData.value['number'] + "&_tbScancodeApproach_=scan"
}
setTimeout(() => {
uni.navigateTo({
url: "/pages/user/home/home"

View File

@ -46,7 +46,8 @@
} from "@dcloudio/uni-app";
import {
showModelMessage,
getUrlParams,jkcBaseDecode
getUrlParams,
jkcBaseDecode
} from "@/utils/tools.js";
import {
@ -64,7 +65,7 @@
const showWorn = ref(false);
const oUser = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user")));
let type = null;
let errdata=null;
let errdata = null;
onLoad((options) => {
type = options["type"];
@ -81,8 +82,8 @@
result
} = res.detail;
if (!result || result.indexOf("number") == -1) {
if(errdata==result) return;
errdata=result;
if (errdata == result) return;
errdata = result;
showModelMessage("无效的车辆二维码");
return;
}