扫码
This commit is contained in:
parent
4f2d57153e
commit
ea8deaeb67
@ -182,15 +182,13 @@
|
||||
}
|
||||
arrBikeData=data||[];
|
||||
const arrData=markers.value||[];
|
||||
debugger;
|
||||
arrBikeData.map((item) => {
|
||||
const{longitude,latitude}=item;
|
||||
let index=findIndex(arrData,{longitude,latitude});
|
||||
index==index==-1?arrData.length:index;
|
||||
arrData[index]=addMarker(index, item[1], item[0], "mapbike.png",true);
|
||||
index=index==-1?arrData.length:index;
|
||||
arrData[index]=addMarker(index, longitude, latitude, "mapbike.png",true);
|
||||
})
|
||||
markers.value =arrData ;
|
||||
console.log("555555555555555555555555555",arrData)
|
||||
|
||||
})
|
||||
|
||||
@ -246,48 +244,9 @@
|
||||
uni.navigateTo({
|
||||
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) {
|
||||
@ -352,7 +311,7 @@
|
||||
orderData = data;
|
||||
if(status==2){
|
||||
completeRiding();
|
||||
// hasOrder.value = true;
|
||||
hasOrder.value = true;
|
||||
return;
|
||||
}
|
||||
else if(status!=0){
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
<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="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" />
|
||||
</div>
|
||||
<div class="divData">
|
||||
<input v-for="(item,index) in inputData" :key="index" :focus="index==focus" @input="(e)=>{changeInput(index,e)}"
|
||||
adjust-position="false"
|
||||
type="number" cursor-color="#61D246" maxlength="1"/>
|
||||
<div class="divDataTab" v-for="(item,index) in inputData" :key="index" @click="clickTab">{{item}}</div>
|
||||
</div>
|
||||
|
||||
<div class="divBottom">
|
||||
<image style="width: 60px;height: 60px;" src="/static/userui/scan/light.png" />
|
||||
<div style="font-size: 12px;color: gray;">轻触点亮</div>
|
||||
<div :class="(btnDis?'divBtnDis ':'')+'divBtn'" @click="clickBtn">确认</div>
|
||||
<div style="font-size: 12px;color: gray;" @click="onTorch">轻触点亮</div>
|
||||
<div :class="(btnDis?'divBtnDis ':'')+'divBtn'" @click="addRide">确认</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -23,53 +23,139 @@
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
ref,onMounted,getCurrentInstance
|
||||
ref,
|
||||
onMounted
|
||||
} from 'vue';
|
||||
import {
|
||||
showModelMessage,
|
||||
getUrlParams
|
||||
} from "@/utils/tools.js";
|
||||
import {
|
||||
callOrdereApi
|
||||
} from "@/utils/api.js";
|
||||
const len = 6;
|
||||
const arrData = [];
|
||||
for (let i = 0; i < 6; i++) {
|
||||
arrData.push("")
|
||||
}
|
||||
const inputData = ref(arrData);
|
||||
const focus=ref(0);
|
||||
const btnDis=ref(true);
|
||||
|
||||
const instance = getCurrentInstance();
|
||||
const oUser = uni.getStorageSync("wechat_user");
|
||||
const inputData = ref(new Array(len).fill(""));
|
||||
const focus = ref(true);
|
||||
const btnDis = ref(true);
|
||||
let data = null;
|
||||
|
||||
|
||||
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;
|
||||
// if(index==len-1){
|
||||
// btnDis.value=false;
|
||||
// }
|
||||
|
||||
function changeInput(e) {
|
||||
const {
|
||||
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() {
|
||||
console.log("555555555555555", inputData)
|
||||
|
||||
function clickTab() {
|
||||
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>
|
||||
|
||||
<style scoped>
|
||||
.divInfo {}
|
||||
.divInfo {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.divTitle {
|
||||
margin-top: 60px;
|
||||
margin-top: 40px;
|
||||
font-size: 14px;
|
||||
color: #000;
|
||||
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 {
|
||||
width: 220px;
|
||||
height: 100px;
|
||||
@ -79,34 +165,38 @@
|
||||
.divData {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
position: relative;
|
||||
top: 130px;
|
||||
}
|
||||
|
||||
.divData input {
|
||||
.divDataTab {
|
||||
width: 28px;
|
||||
height: 40px;
|
||||
border: 1px solid #80808038;
|
||||
border-radius: 5px;
|
||||
background: #f5f2f2b8;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.divBottom {
|
||||
margin-top: 30px;
|
||||
position: relative;
|
||||
margin-top: 150px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.divBtnDis {
|
||||
|
||||
pointer-events: none;
|
||||
background: #b9b7b7 !important;
|
||||
opacity: 0.3;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.divBtn {
|
||||
background: #61D246 ;
|
||||
background: #61D246;
|
||||
margin-top: 10px;
|
||||
line-height: 35px;
|
||||
border-radius: 5px;
|
||||
|
||||
@ -44,6 +44,14 @@
|
||||
import {
|
||||
onLoad
|
||||
} from "@dcloudio/uni-app";
|
||||
import {
|
||||
showModelMessage,
|
||||
getUrlParams
|
||||
} from "@/utils/tools.js";
|
||||
|
||||
import {
|
||||
callOrdereApi
|
||||
} from "@/utils/api.js";
|
||||
|
||||
let bikeCode = null;
|
||||
const openLight = ref("off");
|
||||
@ -51,17 +59,15 @@
|
||||
const oUser = uni.getStorageSync("wechat_user");
|
||||
let type = null;
|
||||
|
||||
onLoad((options)=>{
|
||||
onLoad((options) => {
|
||||
type = options["type"];
|
||||
});
|
||||
|
||||
function openCode(){
|
||||
|
||||
function openCode() {
|
||||
uni.navigateTo({
|
||||
url:"/pages/user/scan/inputcode"
|
||||
url: "/pages/user/scan/inputcode"
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
function scanCode(res) {
|
||||
const {
|
||||
@ -71,45 +77,49 @@
|
||||
showModelMessage("无效的车辆二维码");
|
||||
return;
|
||||
}
|
||||
if(bikeCode) return;
|
||||
const options = getUrlParams(result);
|
||||
bikeCode = options["number"];
|
||||
|
||||
if(type=="ride"){
|
||||
addRide(bikeCode)
|
||||
showModelMessage(bikeCode)
|
||||
if (type == "ride") {
|
||||
addRide()
|
||||
}
|
||||
console.log("11111111111111111111", "scanCode", options);
|
||||
}
|
||||
|
||||
|
||||
//订单
|
||||
function addRide(bikeId){
|
||||
function addRide() {
|
||||
const {
|
||||
userId
|
||||
} = oUser;
|
||||
const params = {
|
||||
userId,
|
||||
bikeId
|
||||
bikeCode
|
||||
}
|
||||
callOrdereApi("userOrders/saveRide", params, "post").then(res => {
|
||||
const {
|
||||
code,
|
||||
message
|
||||
} = res;
|
||||
console.log("11111111111111111111", "addRide", res);
|
||||
if (code != 200) {
|
||||
showModelMessage(message);
|
||||
} else {
|
||||
showWorn.value = true;
|
||||
setTimeout(()=>{
|
||||
uni.navigateTo({
|
||||
url:"/pages/user/home/home"
|
||||
})
|
||||
},1000)
|
||||
}
|
||||
bikeCode=null;
|
||||
},1000);
|
||||
|
||||
return;
|
||||
}
|
||||
showWorn.value = true;
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({
|
||||
url: "/pages/user/home/home"
|
||||
})
|
||||
}, 1000);
|
||||
})
|
||||
}
|
||||
|
||||
function clickLight() {
|
||||
openLight.value = !openLight.value;
|
||||
openLight.value = openLight.value === "off" ? "on" : "off";
|
||||
uni.vibrateShort();
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user