扫码
This commit is contained in:
parent
4f2d57153e
commit
ea8deaeb67
@ -182,15 +182,13 @@
|
|||||||
}
|
}
|
||||||
arrBikeData=data||[];
|
arrBikeData=data||[];
|
||||||
const arrData=markers.value||[];
|
const arrData=markers.value||[];
|
||||||
debugger;
|
|
||||||
arrBikeData.map((item) => {
|
arrBikeData.map((item) => {
|
||||||
const{longitude,latitude}=item;
|
const{longitude,latitude}=item;
|
||||||
let index=findIndex(arrData,{longitude,latitude});
|
let index=findIndex(arrData,{longitude,latitude});
|
||||||
index==index==-1?arrData.length:index;
|
index=index==-1?arrData.length:index;
|
||||||
arrData[index]=addMarker(index, item[1], item[0], "mapbike.png",true);
|
arrData[index]=addMarker(index, longitude, latitude, "mapbike.png",true);
|
||||||
})
|
})
|
||||||
markers.value =arrData ;
|
markers.value =arrData ;
|
||||||
console.log("555555555555555555555555555",arrData)
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -246,48 +244,9 @@
|
|||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url:"/pages/user/scan/scancode?type=ride"
|
url:"/pages/user/scan/scancode?type=ride"
|
||||||
})
|
})
|
||||||
/*
|
|
||||||
uni.scanCode({
|
|
||||||
onlyFromCamera: true, //只能扫码
|
|
||||||
scanType: ["qrCode"],
|
|
||||||
success: function(res) {
|
|
||||||
const {
|
|
||||||
result
|
|
||||||
} = res;
|
|
||||||
if (!result || result.indexOf("number") == -1) {
|
|
||||||
showModelMessage("无效的车辆二维码");
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const options = getUrlParams(result);
|
|
||||||
console.log("11111111111111111111","scanBike",options);
|
|
||||||
const bikeId = options["number"];
|
|
||||||
addRide(bikeId)
|
|
||||||
}
|
|
||||||
}) */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* //订单
|
|
||||||
function addRide(bikeId){
|
|
||||||
const {
|
|
||||||
userId
|
|
||||||
} = oUser;
|
|
||||||
const params = {
|
|
||||||
userId,
|
|
||||||
bikeId
|
|
||||||
}
|
|
||||||
callOrdereApi("userOrders/saveRide", params, "post").then(res => {
|
|
||||||
const {
|
|
||||||
code,
|
|
||||||
message
|
|
||||||
} = res;
|
|
||||||
console.log("11111111111111111111", "addRide", res);
|
|
||||||
if (code != 200) {
|
|
||||||
showModelMessage(message);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} */
|
|
||||||
|
|
||||||
//添加点
|
//添加点
|
||||||
function addMarker (id, longitude, latitude, icon,joinCluster) {
|
function addMarker (id, longitude, latitude, icon,joinCluster) {
|
||||||
@ -352,7 +311,7 @@
|
|||||||
orderData = data;
|
orderData = data;
|
||||||
if(status==2){
|
if(status==2){
|
||||||
completeRiding();
|
completeRiding();
|
||||||
// hasOrder.value = true;
|
hasOrder.value = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(status!=0){
|
else if(status!=0){
|
||||||
|
|||||||
@ -1,20 +1,20 @@
|
|||||||
<template>
|
<template>
|
||||||
<div style="width:100vw;height:100vh;display: flex;justify-content: center;">
|
<div style="width:100vw;height:100vh;display: flex;justify-content: center;background: white;">
|
||||||
<div class="divInfo">
|
<div class="divInfo">
|
||||||
<div class="divTitle">请输入车辆二维码下方6位编号开锁</div>
|
<div class="divTitle">请输入车辆二维码下方6位编号开锁</div>
|
||||||
<div>
|
<div><input :focus="focus" @input="changeInput" type="number" maxlength="6" style="height: 0;width: 0;" />
|
||||||
|
</div>
|
||||||
|
<div class="divImgP">
|
||||||
<image class="divImg" src="/static/userui/scan/bike.png" />
|
<image class="divImg" src="/static/userui/scan/bike.png" />
|
||||||
</div>
|
</div>
|
||||||
<div class="divData">
|
<div class="divData">
|
||||||
<input v-for="(item,index) in inputData" :key="index" :focus="index==focus" @input="(e)=>{changeInput(index,e)}"
|
<div class="divDataTab" v-for="(item,index) in inputData" :key="index" @click="clickTab">{{item}}</div>
|
||||||
adjust-position="false"
|
|
||||||
type="number" cursor-color="#61D246" maxlength="1"/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="divBottom">
|
<div class="divBottom">
|
||||||
<image style="width: 60px;height: 60px;" src="/static/userui/scan/light.png" />
|
<image style="width: 60px;height: 60px;" src="/static/userui/scan/light.png" />
|
||||||
<div style="font-size: 12px;color: gray;">轻触点亮</div>
|
<div style="font-size: 12px;color: gray;" @click="onTorch">轻触点亮</div>
|
||||||
<div :class="(btnDis?'divBtnDis ':'')+'divBtn'" @click="clickBtn">确认</div>
|
<div :class="(btnDis?'divBtnDis ':'')+'divBtn'" @click="addRide">确认</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -23,53 +23,139 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
ref,onMounted,getCurrentInstance
|
ref,
|
||||||
|
onMounted
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
|
import {
|
||||||
|
showModelMessage,
|
||||||
|
getUrlParams
|
||||||
|
} from "@/utils/tools.js";
|
||||||
|
import {
|
||||||
|
callOrdereApi
|
||||||
|
} from "@/utils/api.js";
|
||||||
const len = 6;
|
const len = 6;
|
||||||
const arrData = [];
|
const oUser = uni.getStorageSync("wechat_user");
|
||||||
for (let i = 0; i < 6; i++) {
|
const inputData = ref(new Array(len).fill(""));
|
||||||
arrData.push("")
|
const focus = ref(true);
|
||||||
}
|
const btnDis = ref(true);
|
||||||
const inputData = ref(arrData);
|
let data = null;
|
||||||
const focus=ref(0);
|
|
||||||
const btnDis=ref(true);
|
|
||||||
|
|
||||||
const instance = getCurrentInstance();
|
|
||||||
|
|
||||||
|
|
||||||
function changeInput(index,e){
|
|
||||||
// inputData.value[index]=e.detail.value;
|
|
||||||
console.log("555555555555555",instance)
|
|
||||||
debugger;
|
|
||||||
// if(index<len-1){
|
|
||||||
// focus.value=index+1;
|
|
||||||
// }
|
|
||||||
// else{
|
|
||||||
// btnDis.value=false;
|
|
||||||
// }
|
|
||||||
console.log("3333333333333333",e,index);
|
|
||||||
|
|
||||||
// focus.value=index;
|
function changeInput(e) {
|
||||||
// if(index==len-1){
|
const {
|
||||||
// btnDis.value=false;
|
value
|
||||||
// }
|
} = e.detail;
|
||||||
|
const arrVal = value.split("");
|
||||||
|
const arrData = [];
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
arrData[i] = arrVal[i] || '';
|
||||||
|
};
|
||||||
|
data = value;
|
||||||
|
inputData.value = arrData;
|
||||||
|
if (arrVal.length == 6) {
|
||||||
|
btnDis.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clickBtn() {
|
function clickTab() {
|
||||||
console.log("555555555555555", inputData)
|
focus.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开闪光灯
|
||||||
|
function onTorch() {
|
||||||
|
try {
|
||||||
|
var os = plus.os.name;
|
||||||
|
if ('iOS' == os) {
|
||||||
|
// 获取iOS设备的默认摄像头设备
|
||||||
|
var device = plus.ios.invoke('AVCaptureDevice', 'defaultDeviceWithMediaType:', 'vide');
|
||||||
|
// 锁定设备配置
|
||||||
|
plus.ios.invoke(device, 'lockForConfiguration:', null);
|
||||||
|
// 设置手电筒模式为打开
|
||||||
|
plus.ios.invoke(device, 'setTorchMode:', 1);
|
||||||
|
// 设置闪光灯模式为打开
|
||||||
|
plus.ios.invoke(device, 'setFlashMode:', 1);
|
||||||
|
// 解锁设备配置
|
||||||
|
plus.ios.invoke(device, 'unlockForConfiguration');
|
||||||
|
} else {
|
||||||
|
// 获取安卓系统的主Activity
|
||||||
|
var main = plus.android.runtimeMainActivity();
|
||||||
|
// 获取摄像头服务
|
||||||
|
var camera = main.getSystemService('camera');
|
||||||
|
// 获取摄像头ID列表
|
||||||
|
var ids = plus.android.invoke(camera, 'getCameraIdList');
|
||||||
|
for (var i = 0; i < ids.length; i++) {
|
||||||
|
// 获取摄像头特性
|
||||||
|
var c = plus.android.invoke(camera, 'getCameraCharacteristics', ids[i]);
|
||||||
|
// 检查闪光灯是否可用
|
||||||
|
var available = plus.android.invoke(c, 'get', plus.android.getAttribute(c, 'FLASH_INFO_AVAILABLE'));
|
||||||
|
// 检查摄像头是否为后置摄像头
|
||||||
|
var facing = plus.android.invoke(c, 'get', plus.android.getAttribute(c, 'LENS_FACING'));
|
||||||
|
if (null != facing && 1 == facing) {
|
||||||
|
// 打开后置摄像头的手电筒
|
||||||
|
plus.android.invoke(camera, 'setTorchMode', ids[i], true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('error @onTorch!!', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//订单
|
||||||
|
function addRide() {
|
||||||
|
const {
|
||||||
|
userId
|
||||||
|
} = oUser;
|
||||||
|
const params = {
|
||||||
|
userId,
|
||||||
|
bikeCode: data
|
||||||
|
}
|
||||||
|
console.log("44444444444444444",params)
|
||||||
|
callOrdereApi("userOrders/saveRide", params, "post").then(res => {
|
||||||
|
const {
|
||||||
|
code,
|
||||||
|
message
|
||||||
|
} = res;
|
||||||
|
if (code != 200) {
|
||||||
|
showModelMessage(message);
|
||||||
|
} else {
|
||||||
|
showWorn.value = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: "/pages/user/home/home"
|
||||||
|
})
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.divInfo {}
|
.divInfo {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.divTitle {
|
.divTitle {
|
||||||
margin-top: 60px;
|
margin-top: 40px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #000;
|
color: #000;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.divImgP {
|
||||||
|
position: absolute;
|
||||||
|
left: 0px;
|
||||||
|
right: 0px;
|
||||||
|
height: 120px;
|
||||||
|
top: 60px;
|
||||||
|
background: white;
|
||||||
|
z-index: 100000;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
.divImg {
|
.divImg {
|
||||||
width: 220px;
|
width: 220px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
@ -79,26 +165,30 @@
|
|||||||
.divData {
|
.divData {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-evenly;
|
justify-content: space-evenly;
|
||||||
|
position: relative;
|
||||||
|
top: 130px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.divData input {
|
.divDataTab {
|
||||||
width: 28px;
|
width: 28px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
border: 1px solid #80808038;
|
border: 1px solid #80808038;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
background: #f5f2f2b8;
|
background: #f5f2f2b8;
|
||||||
text-align: center;
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.divBottom {
|
.divBottom {
|
||||||
margin-top: 30px;
|
position: relative;
|
||||||
|
margin-top: 150px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.divBtnDis {
|
.divBtnDis {
|
||||||
|
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
background: #b9b7b7 !important;
|
background: #b9b7b7 !important;
|
||||||
opacity: 0.3;
|
opacity: 0.3;
|
||||||
@ -106,7 +196,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.divBtn {
|
.divBtn {
|
||||||
background: #61D246 ;
|
background: #61D246;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
line-height: 35px;
|
line-height: 35px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
|||||||
@ -44,6 +44,14 @@
|
|||||||
import {
|
import {
|
||||||
onLoad
|
onLoad
|
||||||
} from "@dcloudio/uni-app";
|
} from "@dcloudio/uni-app";
|
||||||
|
import {
|
||||||
|
showModelMessage,
|
||||||
|
getUrlParams
|
||||||
|
} from "@/utils/tools.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
callOrdereApi
|
||||||
|
} from "@/utils/api.js";
|
||||||
|
|
||||||
let bikeCode = null;
|
let bikeCode = null;
|
||||||
const openLight = ref("off");
|
const openLight = ref("off");
|
||||||
@ -51,18 +59,16 @@
|
|||||||
const oUser = uni.getStorageSync("wechat_user");
|
const oUser = uni.getStorageSync("wechat_user");
|
||||||
let type = null;
|
let type = null;
|
||||||
|
|
||||||
onLoad((options)=>{
|
onLoad((options) => {
|
||||||
type = options["type"];
|
type = options["type"];
|
||||||
});
|
});
|
||||||
|
|
||||||
function openCode(){
|
function openCode() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url:"/pages/user/scan/inputcode"
|
url: "/pages/user/scan/inputcode"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function scanCode(res) {
|
function scanCode(res) {
|
||||||
const {
|
const {
|
||||||
result
|
result
|
||||||
@ -71,45 +77,49 @@
|
|||||||
showModelMessage("无效的车辆二维码");
|
showModelMessage("无效的车辆二维码");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(bikeCode) return;
|
||||||
const options = getUrlParams(result);
|
const options = getUrlParams(result);
|
||||||
bikeCode = options["number"];
|
bikeCode = options["number"];
|
||||||
|
showModelMessage(bikeCode)
|
||||||
if(type=="ride"){
|
if (type == "ride") {
|
||||||
addRide(bikeCode)
|
addRide()
|
||||||
}
|
}
|
||||||
console.log("11111111111111111111", "scanCode", options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//订单
|
//订单
|
||||||
function addRide(bikeId){
|
function addRide() {
|
||||||
const {
|
const {
|
||||||
userId
|
userId
|
||||||
} = oUser;
|
} = oUser;
|
||||||
const params = {
|
const params = {
|
||||||
userId,
|
userId,
|
||||||
bikeId
|
bikeCode
|
||||||
}
|
}
|
||||||
callOrdereApi("userOrders/saveRide", params, "post").then(res => {
|
callOrdereApi("userOrders/saveRide", params, "post").then(res => {
|
||||||
const {
|
const {
|
||||||
code,
|
code,
|
||||||
message
|
message
|
||||||
} = res;
|
} = res;
|
||||||
console.log("11111111111111111111", "addRide", res);
|
|
||||||
if (code != 200) {
|
if (code != 200) {
|
||||||
showModelMessage(message);
|
showModelMessage(message);
|
||||||
} else {
|
|
||||||
showWorn.value = true;
|
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
uni.navigateTo({
|
bikeCode=null;
|
||||||
url:"/pages/user/home/home"
|
},1000);
|
||||||
})
|
|
||||||
},1000)
|
return;
|
||||||
}
|
}
|
||||||
|
showWorn.value = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: "/pages/user/home/home"
|
||||||
|
})
|
||||||
|
}, 1000);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function clickLight() {
|
function clickLight() {
|
||||||
openLight.value = !openLight.value;
|
openLight.value = openLight.value === "off" ? "on" : "off";
|
||||||
|
uni.vibrateShort();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user