二维码扫码进入小程序开锁功能实现
This commit is contained in:
parent
12844b406c
commit
1c2e09ab2c
@ -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 支持的格式
|
||||||
|
|||||||
@ -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();
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -227,14 +232,18 @@
|
|||||||
//如果头像为空 弹出设置头像页面
|
//如果头像为空 弹出设置头像页面
|
||||||
login();
|
login();
|
||||||
let wechat_user = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user")));
|
let wechat_user = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user")));
|
||||||
if (!wechat_user.avatar) {
|
if (!wechat_user.avatar) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/user/login/userphtoinfo"
|
url: "/pages/user/login/userphtoinfo"
|
||||||
})
|
})
|
||||||
}, 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"
|
||||||
|
|||||||
@ -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 {
|
||||||
@ -64,7 +65,7 @@
|
|||||||
const showWorn = ref(false);
|
const showWorn = ref(false);
|
||||||
const oUser = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user")));
|
const oUser = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user")));
|
||||||
let type = null;
|
let type = null;
|
||||||
let errdata=null;
|
let errdata = null;
|
||||||
|
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
type = options["type"];
|
type = options["type"];
|
||||||
@ -81,8 +82,8 @@
|
|||||||
result
|
result
|
||||||
} = res.detail;
|
} = res.detail;
|
||||||
if (!result || result.indexOf("number") == -1) {
|
if (!result || result.indexOf("number") == -1) {
|
||||||
if(errdata==result) return;
|
if (errdata == result) return;
|
||||||
errdata=result;
|
errdata = result;
|
||||||
showModelMessage("无效的车辆二维码");
|
showModelMessage("无效的车辆二维码");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user