骑行端桌面
This commit is contained in:
parent
a9d9a42a1a
commit
c7f263fb13
@ -5,18 +5,17 @@
|
||||
padding-left: 10px;
|
||||
font-size: 16px;
|
||||
color: #d8d3d3db;
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
|
||||
.divHead label {
|
||||
margin-right: 20px;
|
||||
margin-right: 30px;
|
||||
padding-bottom: 3px;
|
||||
border-bottom: 2px solid #bdb9b9a1;
|
||||
}
|
||||
|
||||
.divHeadSel {
|
||||
margin-right: 20px;
|
||||
padding-bottom: 3px;
|
||||
border-bottom: 2px solid white;
|
||||
|
||||
border-bottom: 2px solid white !important;
|
||||
font-weight: bold;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
@ -62,7 +62,8 @@
|
||||
@click="lockRiding" />
|
||||
<image v-if="orderState==1" style="width: 120px;height: 40px;" :src=' imgPath+"static/userui/home/run.png"'
|
||||
@click="continueRiding" />
|
||||
<image style="width: 160px;height: 40px;" :src='imgPath+"static/userui/home/end.png"' @click="endRiding" />
|
||||
<image style="width: 160px;height: 40px;" :src='imgPath+"static/userui/home/endride.png"'
|
||||
@click="endRiding" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="showMess!=1" class="divMess">
|
||||
@ -103,11 +104,11 @@
|
||||
</uni-card>
|
||||
</div>
|
||||
<div v-if="showBikeInfo" style="position: absolute;z-index: 2000;bottom: 0;width: 100vw;">
|
||||
|
||||
<bike-info bikecode="123456" @close="closeBikeInfo"/>
|
||||
|
||||
<bike-info bikecode="123456" @close="closeBikeInfo" />
|
||||
</div>
|
||||
<div v-if="showOrderPay" style="position: absolute;z-index: 2000;bottom: 0;width: 100vw;">
|
||||
<bike-pay :orderid="orderData.orderId"/>
|
||||
<bike-pay :orderid="orderData.orderId" />
|
||||
</div>
|
||||
|
||||
</template>
|
||||
@ -131,7 +132,10 @@
|
||||
findIndex
|
||||
} from 'lodash';
|
||||
import config from '@/utils/config';
|
||||
import {onShow} from "@dcloudio/uni-app";
|
||||
import {
|
||||
onShow,
|
||||
onUnload
|
||||
} from "@dcloudio/uni-app";
|
||||
import * as map from "@/utils/usermap.js";
|
||||
|
||||
const imgPath = config.imgPath;
|
||||
@ -145,10 +149,12 @@
|
||||
const polygons = ref([]); //面
|
||||
const polylines = ref([]); //线
|
||||
const circles = ref([]); //圆
|
||||
const pointStart=100000000000;
|
||||
const pointEnd=100000000001;
|
||||
|
||||
let oMap = null;
|
||||
|
||||
const showTools=ref(true);
|
||||
|
||||
const showTools = ref(true);
|
||||
let oUser = null;
|
||||
const showMess = ref(uni.getStorageSync("kbike-mess"));
|
||||
const hasOrder = ref(false); //是否有订单
|
||||
@ -168,7 +174,8 @@
|
||||
};
|
||||
let orderTimer = null;
|
||||
const orderState = ref(0);
|
||||
const showOrderPay=ref(false);
|
||||
const showOrderPay = ref(false);
|
||||
|
||||
|
||||
|
||||
//车辆
|
||||
@ -177,57 +184,65 @@
|
||||
|
||||
//加载数据
|
||||
function getLoalcationData() {
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
geocode: true,
|
||||
success(res) {
|
||||
map.getLoalcation(res=>{
|
||||
const {
|
||||
latitude,
|
||||
longitude
|
||||
} = res;
|
||||
location.value = {
|
||||
latitude,
|
||||
longitude
|
||||
};
|
||||
oMap.moveToLocation({})
|
||||
const params = {
|
||||
latitude,
|
||||
longitude,
|
||||
radius: 20
|
||||
};
|
||||
callOrdereApi("userOrders/bikeList", params, "post").then(res => {
|
||||
console.log("11111111111111111", "userOrders/bikeList", res);
|
||||
const {
|
||||
latitude,
|
||||
longitude
|
||||
code,
|
||||
data,
|
||||
message
|
||||
} = res;
|
||||
location.value = {
|
||||
latitude,
|
||||
longitude
|
||||
};
|
||||
const params = {
|
||||
latitude,
|
||||
longitude,
|
||||
radius:20
|
||||
};
|
||||
callOrdereApi("userOrders/bikeList", params, "post").then(res => {
|
||||
console.log("11111111111111111", "userOrders/bikeList", res);
|
||||
if (code != 200) {
|
||||
showModelMessage(message);
|
||||
return;
|
||||
}
|
||||
arrBikeData = data || [];
|
||||
const arrData = markers.value || [];
|
||||
arrBikeData.map((item) => {
|
||||
const {
|
||||
code,
|
||||
data,
|
||||
message
|
||||
} = res;
|
||||
if (code != 200) {
|
||||
showModelMessage(message);
|
||||
return;
|
||||
}
|
||||
arrBikeData = data || [];
|
||||
const arrData = markers.value || [];
|
||||
arrBikeData.map((item) => {
|
||||
const {
|
||||
longitude,
|
||||
latitude
|
||||
} = item;
|
||||
let index = findIndex(arrData, {
|
||||
longitude,
|
||||
latitude
|
||||
});
|
||||
index = index == -1 ? arrData.length : index;
|
||||
arrData[index] = map.addMarker(index, longitude, latitude, "mapbike.png",
|
||||
true);
|
||||
})
|
||||
markers.value = arrData;
|
||||
longitude,
|
||||
latitude
|
||||
} = item;
|
||||
let index = findIndex(arrData, {
|
||||
longitude,
|
||||
latitude
|
||||
});
|
||||
index = index == -1 ? arrData.length : index;
|
||||
arrData[index] = map.addMarker(index, longitude, latitude, "mapbike.png",
|
||||
true);
|
||||
})
|
||||
markers.value = arrData;
|
||||
});
|
||||
})
|
||||
// uni.getLocation({
|
||||
// type: 'gcj02',
|
||||
// geocode: true,
|
||||
// success(res) {
|
||||
// location.value = {
|
||||
// latitude,
|
||||
// longitude
|
||||
// };
|
||||
|
||||
|
||||
},
|
||||
fail(res) {
|
||||
// },
|
||||
// fail(res) {
|
||||
|
||||
}
|
||||
});
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
function clickMess() {
|
||||
@ -258,7 +273,7 @@
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url:"/pages/user/scan/applysite"
|
||||
url: "/pages/user/scan/applysite"
|
||||
})
|
||||
}
|
||||
|
||||
@ -289,12 +304,12 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//显示订单
|
||||
function openOrderPay() {
|
||||
showTools.value=false;
|
||||
showOrderPay.value=true;
|
||||
showTools.value = false;
|
||||
showOrderPay.value = true;
|
||||
}
|
||||
|
||||
//获取订单
|
||||
@ -342,9 +357,14 @@
|
||||
return;
|
||||
}
|
||||
showOrder.value = true;
|
||||
if (!orderTimer) {
|
||||
orderTimer = setInterval(getTracking, 10000);
|
||||
if(tempLock==1){
|
||||
getTracking();
|
||||
return;
|
||||
}
|
||||
getTracking();
|
||||
// if (!orderTimer) {
|
||||
// orderTimer = setInterval(getTracking, 100000);
|
||||
// }
|
||||
})
|
||||
}
|
||||
|
||||
@ -361,10 +381,14 @@
|
||||
ebikeCode: bikeCode,
|
||||
startTime: createdAt
|
||||
}
|
||||
if(endTime) params={...params,endTime}
|
||||
|
||||
console.log("7777777777777",params);
|
||||
if (endTime) params = {
|
||||
...params,
|
||||
endTime
|
||||
}
|
||||
|
||||
console.log("7777777777777", params);
|
||||
callOperateApi("ebikeTracking/query", params, "post").then(res => {
|
||||
console.log("7777777777777", "ebikeTracking/query", res);
|
||||
const {
|
||||
code,
|
||||
data,
|
||||
@ -373,7 +397,7 @@
|
||||
if (code != 200) {
|
||||
return;
|
||||
}
|
||||
const arrPoints = !data ? [] : data.map(item => {
|
||||
const arrPoints = (!data || data.length == 0) ? [] : data.map(item => {
|
||||
const {
|
||||
lngGCJ02,
|
||||
latGCJ02
|
||||
@ -382,29 +406,29 @@
|
||||
longitude: lngGCJ02,
|
||||
latitude: latGCJ02
|
||||
}
|
||||
})
|
||||
if(data){
|
||||
let {lngGCJ02:endlng,latGCJ02:endlat}=data[data.length-1];
|
||||
arrMakers[index+1] = map.addMarker(id, endlng, endlat, "end.png");
|
||||
}
|
||||
const startPoint=ridePoint.split(",");
|
||||
});
|
||||
|
||||
const startPoint = ridePoint.split(",");
|
||||
const lng = startPoint[0];
|
||||
const lat = startPoint[1];
|
||||
const start = {
|
||||
longitude: lng,
|
||||
latitude: lat
|
||||
}
|
||||
arrPoints.splice(0, 0, start);
|
||||
|
||||
const arrMakers = markers.value || [];
|
||||
const id = 10000000;
|
||||
let index = findIndex(arrMakers, {
|
||||
id
|
||||
});
|
||||
index = index == -1 ? arrMakers.length : index;
|
||||
arrMakers[index] = map.addMarker(id, lng, lat, "start.png");
|
||||
markers.value =arrMakers;
|
||||
if(arrPoints.length>1){
|
||||
arrPoints.splice(0, 0, start);
|
||||
let indexStart = findIndex(arrMakers, {pointStart});
|
||||
indexStart = indexStart == -1 ? arrMakers.length : indexStart;
|
||||
arrMakers[indexStart] = map.addMarker(pointStart, lng, lat, "start.png");
|
||||
if (data && data.length > 0) {
|
||||
let {
|
||||
lngGCJ02: endlng,
|
||||
latGCJ02: endlat
|
||||
} = data[data.length - 1];
|
||||
arrMakers[indexStart + 1] = map.addMarker(pointEnd, endlng, endlat, "end.png");
|
||||
}
|
||||
markers.value = arrMakers;
|
||||
if (arrPoints.length > 1) {
|
||||
polylines.value = [map.addLine("#168DED", arrPoints)];
|
||||
}
|
||||
})
|
||||
@ -428,25 +452,35 @@
|
||||
|
||||
//临时锁车
|
||||
function lockRiding() {
|
||||
showModelMessage("该功能暂未实现!");
|
||||
const {
|
||||
userId
|
||||
} = oUser;
|
||||
const{bikeCode}=orderData;
|
||||
const params={
|
||||
const {
|
||||
bikeCode
|
||||
} = orderData;
|
||||
const params = {
|
||||
userId,
|
||||
bikeCode
|
||||
}
|
||||
callOrdereApi("userOrders/tempLock",params,"post").then(res=>{
|
||||
const{code,message,data}=res;
|
||||
console.log("6666666666666666","lockRiding",res);
|
||||
callOrdereApi("userOrders/tempLock", params, "post").then(res => {
|
||||
const {
|
||||
code,
|
||||
message,
|
||||
data
|
||||
} = res;
|
||||
showModelMessage(message)
|
||||
if(code==200){
|
||||
if(orderTimer) {
|
||||
clearInterval(orderTimer);
|
||||
orderTimer=null;
|
||||
}
|
||||
orderState.value = 1;
|
||||
}
|
||||
});
|
||||
orderState.value = 1;
|
||||
}
|
||||
|
||||
//结束用车
|
||||
function endRiding() {
|
||||
showModelMessage("该功能暂未实现!");
|
||||
const {
|
||||
userId
|
||||
} = oUser;
|
||||
@ -463,50 +497,75 @@
|
||||
data,
|
||||
message
|
||||
} = res;
|
||||
console.log("111111111111111111111111", "endRiding", res);
|
||||
if (code != 200) {
|
||||
showModelMessage(message);
|
||||
return;
|
||||
}
|
||||
completeRiding();
|
||||
openOrderPay();
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
//继续骑行 需要开锁
|
||||
function continueRiding() {
|
||||
showModelMessage("该功能暂未实现!");
|
||||
orderState.value = 0;
|
||||
const {
|
||||
userId
|
||||
} = oUser;
|
||||
const {
|
||||
bikeCode
|
||||
} = orderData;
|
||||
const params = {
|
||||
userId,
|
||||
bikeCode
|
||||
}
|
||||
callOrdereApi("userOrders/continueCycling", params, "post").then(res => {
|
||||
const {
|
||||
code,
|
||||
message,
|
||||
data
|
||||
} = res;
|
||||
showModelMessage(message)
|
||||
if(code==200){
|
||||
if(orderTimer) {
|
||||
clearInterval(orderTimer);
|
||||
orderTimer=null;
|
||||
}
|
||||
orderState.value = 0;
|
||||
}
|
||||
});
|
||||
//getOrder();
|
||||
}
|
||||
|
||||
//查看车辆信息
|
||||
function openBikeInfo(e) {
|
||||
showModelMessage("该功能暂未实现!");
|
||||
if(!oUser){
|
||||
if (!oUser) {
|
||||
tologin();
|
||||
return;
|
||||
}
|
||||
console.log("33333333333333333",e);
|
||||
console.log("33333333333333333", e);
|
||||
showBikeInfo.value = true;
|
||||
showTools.value=false;
|
||||
showTools.value = false;
|
||||
}
|
||||
|
||||
//关闭车辆信息
|
||||
function closeBikeInfo(){
|
||||
showBikeInfo.value =false;
|
||||
showTools.value=true;
|
||||
function closeBikeInfo() {
|
||||
showBikeInfo.value = false;
|
||||
showTools.value = true;
|
||||
}
|
||||
|
||||
getLoalcationData();
|
||||
|
||||
onShow(() => {
|
||||
oUser=uni.getStorageSync("wechat_user");
|
||||
console.log("7777777777777777777777",oUser)
|
||||
onMounted(()=>{
|
||||
const instance = getCurrentInstance();
|
||||
oMap = uni.createMapContext("mapRef", {
|
||||
this: instance.proxy
|
||||
});
|
||||
})
|
||||
onShow(() => {
|
||||
oUser = uni.getStorageSync("wechat_user");
|
||||
console.log("7777777777777777777777","oUser", oUser)
|
||||
getLoalcationData();
|
||||
|
||||
const {
|
||||
userId
|
||||
} = oUser;
|
||||
@ -515,6 +574,10 @@
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
onUnload(() => {
|
||||
console.log("9999999999999999999", "onUnload",orderTimer);
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<image class="img" :src="`${imgPath}static/userui/scan/back.png`" />
|
||||
<image class="img" :src="`${imgPath}static/userui/scan/back.png`" />
|
||||
<div class="divBox">
|
||||
<div class="divScan">
|
||||
<div class="divScanTitle">请扫码车身的二维码进行解锁</div>
|
||||
@ -23,11 +23,11 @@
|
||||
</div>
|
||||
<div class="divBottom">
|
||||
<div class="divBtn" @click="openCode">
|
||||
<image :src="`${imgPath}static/userui/scan/code.png`" />
|
||||
<image :src="`${imgPath}static/userui/scan/code.png`" />
|
||||
<div>输入车辆编号</div>
|
||||
</div>
|
||||
<div class="divBtn" @click="clickLight">
|
||||
<image :src="`${imgPath}static/userui/scan/light.png`" />
|
||||
<image :src="`${imgPath}static/userui/scan/light.png`" />
|
||||
<div>{{openLight=="off"?"打开":"关闭"}}手电筒</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -48,13 +48,15 @@
|
||||
showModelMessage,
|
||||
getUrlParams
|
||||
} from "@/utils/tools.js";
|
||||
|
||||
|
||||
import {
|
||||
callOrdereApi
|
||||
} from "@/utils/api.js";
|
||||
import config from '@/utils/config';
|
||||
import {addOrder} from "@/utils/usermap.js";
|
||||
|
||||
import {
|
||||
addOrder
|
||||
} from "@/utils/usermap.js";
|
||||
|
||||
const imgPath = config.imgPath;
|
||||
|
||||
let bikeCode = null;
|
||||
@ -81,25 +83,25 @@
|
||||
showModelMessage("无效的车辆二维码");
|
||||
return;
|
||||
}
|
||||
if(bikeCode) return;
|
||||
if (bikeCode) return;
|
||||
const options = getUrlParams(result);
|
||||
bikeCode = options["number"];
|
||||
if (type == "ride") {
|
||||
addOrder(bikeCode,(res)=>{
|
||||
if(!res){
|
||||
setTimeout(()=>{
|
||||
bikeCode=null;
|
||||
},1000);
|
||||
addOrder(bikeCode, (res) => {
|
||||
console.log("00000000000000000000", res);
|
||||
if (!res) {
|
||||
setTimeout(() => {
|
||||
bikeCode = null;
|
||||
}, 1000);
|
||||
return;
|
||||
}
|
||||
else{
|
||||
showWorn.value=true;
|
||||
} else {
|
||||
showWorn.value = true;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function clickLight() {
|
||||
openLight.value = openLight.value === "off" ? "on" : "off";
|
||||
uni.vibrateShort();
|
||||
|
||||
@ -72,7 +72,7 @@ export function addLine(scolor, arrPoints) {
|
||||
}
|
||||
|
||||
//创建订单
|
||||
export function addOrder(bikeCode, icnt, callback) {
|
||||
export function addOrder(bikeCode, callback) {
|
||||
const oUser = uni.getStorageSync("wechat_user");
|
||||
if (!oUser) {
|
||||
uni.navigateTo({
|
||||
@ -102,14 +102,15 @@ function saveRide(params, icnt, callback) {
|
||||
return;
|
||||
}
|
||||
showModelMessage(message);
|
||||
callback(false);
|
||||
if(callback) callback(false);
|
||||
return;
|
||||
}
|
||||
callback(true);
|
||||
if(callback)callback(true);
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({
|
||||
uni.switchTab({
|
||||
url: "/pages/user/home/home"
|
||||
})
|
||||
}, 1000);
|
||||
}, 1000)
|
||||
|
||||
})
|
||||
}
|
||||
@ -1,26 +1,26 @@
|
||||
export function getCache(name) {
|
||||
if (name == undefined || name == "") {
|
||||
return "";
|
||||
}
|
||||
let result = localStorage.getItem(name);
|
||||
if (result!= null) {
|
||||
if ((result.startsWith("{") && result.endsWith("}")) || (result.startsWith("[") && result.endsWith("]"))) {
|
||||
result = JSON.parse(result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
if (name == undefined || name == "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
export function setCache(name, value) {
|
||||
if (name == undefined || name == "") {
|
||||
return false;
|
||||
let result = sessionStorage.getItem(name);
|
||||
if (result != null) {
|
||||
if ((result.startsWith("{") && result.endsWith("}")) || (result.startsWith("[") && result.endsWith("]"))) {
|
||||
result = JSON.parse(result);
|
||||
}
|
||||
if(typeof value === 'object') {
|
||||
value = JSON.stringify(value);
|
||||
}
|
||||
let result = localStorage.setItem(name, value);
|
||||
return result;
|
||||
}
|
||||
export function clearStorage() {
|
||||
localStorage.clear();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function setCache(name, value) {
|
||||
if (name == undefined || name == "") {
|
||||
return false;
|
||||
}
|
||||
if (typeof value === 'object') {
|
||||
value = JSON.stringify(value);
|
||||
}
|
||||
let result = sessionStorage.setItem(name, value);
|
||||
return result;
|
||||
}
|
||||
export function clearStorage() {
|
||||
sessionStorage.clear();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user