This commit is contained in:
LHG 2025-04-25 18:04:50 +08:00
commit e4adbe3a0a
6 changed files with 304 additions and 178 deletions

View File

@ -5,18 +5,17 @@
padding-left: 10px; padding-left: 10px;
font-size: 16px; font-size: 16px;
color: #d8d3d3db; color: #d8d3d3db;
display: flex;
justify-content: space-evenly;
} }
.divHead label { .divHead label {
margin-right: 20px; margin-right: 30px;
padding-bottom: 3px;
border-bottom: 2px solid #bdb9b9a1;
} }
.divHeadSel { .divHeadSel {
margin-right: 20px;
padding-bottom: 3px; border-bottom: 2px solid white !important;
border-bottom: 2px solid white;
font-weight: bold; font-weight: bold;
color: white !important; color: white !important;
} }

View File

@ -1,6 +1,6 @@
<template> <template>
<view class="uni-common-mt container"> <view class="uni-common-mt container">
<view class="title">欢迎使用乐享运维</view> <view class="title">欢迎使用景上运维</view>
<!-- 用户名输入框 --> <!-- 用户名输入框 -->
<view class="input-group"> <view class="input-group">
@ -135,7 +135,7 @@
<style scoped> <style scoped>
.container { .container {
padding: 20px; padding: 10px;
} }
.container .title { .container .title {

View File

@ -62,7 +62,8 @@
@click="lockRiding" /> @click="lockRiding" />
<image v-if="orderState==1" style="width: 120px;height: 40px;" :src=' imgPath+"static/userui/home/run.png"' <image v-if="orderState==1" style="width: 120px;height: 40px;" :src=' imgPath+"static/userui/home/run.png"'
@click="continueRiding" /> @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> </div>
<div v-if="showMess!=1" class="divMess"> <div v-if="showMess!=1" class="divMess">
@ -104,10 +105,10 @@
</div> </div>
<div v-if="showBikeInfo" style="position: absolute;z-index: 2000;bottom: 0;width: 100vw;"> <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>
<div v-if="showOrderPay" style="position: absolute;z-index: 2000;bottom: 0;width: 100vw;"> <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> </div>
</template> </template>
@ -131,7 +132,10 @@
findIndex findIndex
} from 'lodash'; } from 'lodash';
import config from '@/utils/config'; 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"; import * as map from "@/utils/usermap.js";
const imgPath = config.imgPath; const imgPath = config.imgPath;
@ -145,10 +149,12 @@
const polygons = ref([]); // const polygons = ref([]); //
const polylines = ref([]); //线 const polylines = ref([]); //线
const circles = ref([]); // const circles = ref([]); //
const pointStart=100000000000;
const pointEnd=100000000001;
let oMap = null; let oMap = null;
const showTools=ref(true); const showTools = ref(true);
let oUser = null; let oUser = null;
const showMess = ref(uni.getStorageSync("kbike-mess")); const showMess = ref(uni.getStorageSync("kbike-mess"));
const hasOrder = ref(false); // const hasOrder = ref(false); //
@ -168,7 +174,8 @@
}; };
let orderTimer = null; let orderTimer = null;
const orderState = ref(0); const orderState = ref(0);
const showOrderPay=ref(false); const showOrderPay = ref(false);
// //
@ -177,57 +184,65 @@
// //
function getLoalcationData() { function getLoalcationData() {
uni.getLocation({ map.getLoalcation(res=>{
type: 'gcj02', const {
geocode: true, latitude,
success(res) { 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 { const {
latitude, code,
longitude data,
message
} = res; } = res;
location.value = { if (code != 200) {
latitude, showModelMessage(message);
longitude return;
}; }
const params = { arrBikeData = data || [];
latitude, const arrData = markers.value || [];
longitude, arrBikeData.map((item) => {
radius:20
};
callOrdereApi("userOrders/bikeList", params, "post").then(res => {
console.log("11111111111111111", "userOrders/bikeList", res);
const { const {
code, longitude,
data, latitude
message } = item;
} = res; let index = findIndex(arrData, {
if (code != 200) { longitude,
showModelMessage(message); latitude
return; });
} index = index == -1 ? arrData.length : index;
arrBikeData = data || []; arrData[index] = map.addMarker(index, longitude, latitude, "mapbike.png",
const arrData = markers.value || []; true);
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;
}) })
markers.value = arrData;
});
})
// uni.getLocation({
// type: 'gcj02',
// geocode: true,
// success(res) {
// location.value = {
// latitude,
// longitude
// };
},
fail(res) {
} // },
}); // fail(res) {
// }
// });
} }
function clickMess() { function clickMess() {
@ -258,7 +273,7 @@
return; return;
} }
uni.navigateTo({ uni.navigateTo({
url:"/pages/user/scan/applysite" url: "/pages/user/scan/applysite"
}) })
} }
@ -293,8 +308,8 @@
// //
function openOrderPay() { function openOrderPay() {
showTools.value=false; showTools.value = false;
showOrderPay.value=true; showOrderPay.value = true;
} }
// //
@ -342,9 +357,14 @@
return; return;
} }
showOrder.value = true; showOrder.value = true;
if (!orderTimer) { if(tempLock==1){
orderTimer = setInterval(getTracking, 10000); getTracking();
return;
} }
getTracking();
// if (!orderTimer) {
// orderTimer = setInterval(getTracking, 100000);
// }
}) })
} }
@ -361,10 +381,14 @@
ebikeCode: bikeCode, ebikeCode: bikeCode,
startTime: createdAt startTime: createdAt
} }
if(endTime) params={...params,endTime} if (endTime) params = {
...params,
endTime
}
console.log("7777777777777",params); console.log("7777777777777", params);
callOperateApi("ebikeTracking/query", params, "post").then(res => { callOperateApi("ebikeTracking/query", params, "post").then(res => {
console.log("7777777777777", "ebikeTracking/query", res);
const { const {
code, code,
data, data,
@ -373,7 +397,7 @@
if (code != 200) { if (code != 200) {
return; return;
} }
const arrPoints = !data ? [] : data.map(item => { const arrPoints = (!data || data.length == 0) ? [] : data.map(item => {
const { const {
lngGCJ02, lngGCJ02,
latGCJ02 latGCJ02
@ -382,29 +406,29 @@
longitude: lngGCJ02, longitude: lngGCJ02,
latitude: latGCJ02 latitude: latGCJ02
} }
}) });
if(data){
let {lngGCJ02:endlng,latGCJ02:endlat}=data[data.length-1]; const startPoint = ridePoint.split(",");
arrMakers[index+1] = map.addMarker(id, endlng, endlat, "end.png");
}
const startPoint=ridePoint.split(",");
const lng = startPoint[0]; const lng = startPoint[0];
const lat = startPoint[1]; const lat = startPoint[1];
const start = { const start = {
longitude: lng, longitude: lng,
latitude: lat latitude: lat
} }
arrPoints.splice(0, 0, start);
const arrMakers = markers.value || []; const arrMakers = markers.value || [];
const id = 10000000; arrPoints.splice(0, 0, start);
let index = findIndex(arrMakers, { let indexStart = findIndex(arrMakers, {pointStart});
id indexStart = indexStart == -1 ? arrMakers.length : indexStart;
}); arrMakers[indexStart] = map.addMarker(pointStart, lng, lat, "start.png");
index = index == -1 ? arrMakers.length : index; if (data && data.length > 0) {
arrMakers[index] = map.addMarker(id, lng, lat, "start.png"); let {
markers.value =arrMakers; lngGCJ02: endlng,
if(arrPoints.length>1){ 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)]; polylines.value = [map.addLine("#168DED", arrPoints)];
} }
}) })
@ -428,25 +452,35 @@
// //
function lockRiding() { function lockRiding() {
showModelMessage("该功能暂未实现!");
const { const {
userId userId
} = oUser; } = oUser;
const{bikeCode}=orderData; const {
const params={ bikeCode
} = orderData;
const params = {
userId, userId,
bikeCode bikeCode
} }
callOrdereApi("userOrders/tempLock",params,"post").then(res=>{ callOrdereApi("userOrders/tempLock", params, "post").then(res => {
const{code,message,data}=res; const {
console.log("6666666666666666","lockRiding",res); code,
message,
data
} = res;
showModelMessage(message)
if(code==200){
if(orderTimer) {
clearInterval(orderTimer);
orderTimer=null;
}
orderState.value = 1;
}
}); });
orderState.value = 1;
} }
// //
function endRiding() { function endRiding() {
showModelMessage("该功能暂未实现!");
const { const {
userId userId
} = oUser; } = oUser;
@ -463,50 +497,75 @@
data, data,
message message
} = res; } = res;
console.log("111111111111111111111111", "endRiding", res);
if (code != 200) { if (code != 200) {
showModelMessage(message); showModelMessage(message);
return; return;
} }
completeRiding(); completeRiding();
openOrderPay();
}) })
} }
// //
function continueRiding() { function continueRiding() {
showModelMessage("该功能暂未实现!"); const {
orderState.value = 0; 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(); //getOrder();
} }
// //
function openBikeInfo(e) { function openBikeInfo(e) {
showModelMessage("该功能暂未实现!"); showModelMessage("该功能暂未实现!");
if(!oUser){ if (!oUser) {
tologin(); tologin();
return; return;
} }
console.log("33333333333333333",e); console.log("33333333333333333", e);
showBikeInfo.value = true; showBikeInfo.value = true;
showTools.value=false; showTools.value = false;
} }
// //
function closeBikeInfo(){ function closeBikeInfo() {
showBikeInfo.value =false; showBikeInfo.value = false;
showTools.value=true; showTools.value = true;
} }
getLoalcationData(); onMounted(()=>{
onShow(() => {
oUser=uni.getStorageSync("wechat_user");
console.log("7777777777777777777777",oUser)
const instance = getCurrentInstance(); const instance = getCurrentInstance();
oMap = uni.createMapContext("mapRef", { oMap = uni.createMapContext("mapRef", {
this: instance.proxy this: instance.proxy
}); });
})
onShow(() => {
oUser = uni.getStorageSync("wechat_user");
console.log("7777777777777777777777","oUser", oUser)
getLoalcationData();
const { const {
userId userId
} = oUser; } = oUser;
@ -515,6 +574,10 @@
} }
}); });
onUnload(() => {
console.log("9999999999999999999", "onUnload",orderTimer);
})
</script> </script>
<style scoped> <style scoped>

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <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="divBox">
<div class="divScan"> <div class="divScan">
<div class="divScanTitle">请扫码车身的二维码进行解锁</div> <div class="divScanTitle">请扫码车身的二维码进行解锁</div>
@ -23,11 +23,11 @@
</div> </div>
<div class="divBottom"> <div class="divBottom">
<div class="divBtn" @click="openCode"> <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>
</div> </div>
<div class="divBtn" @click="clickLight"> <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>{{openLight=="off"?"打开":"关闭"}}手电筒</div>
</div> </div>
</div> </div>
@ -53,7 +53,9 @@
callOrdereApi callOrdereApi
} from "@/utils/api.js"; } from "@/utils/api.js";
import config from '@/utils/config'; import config from '@/utils/config';
import {addOrder} from "@/utils/usermap.js"; import {
addOrder
} from "@/utils/usermap.js";
const imgPath = config.imgPath; const imgPath = config.imgPath;
@ -81,19 +83,19 @@
showModelMessage("无效的车辆二维码"); showModelMessage("无效的车辆二维码");
return; return;
} }
if(bikeCode) return; if (bikeCode) return;
const options = getUrlParams(result); const options = getUrlParams(result);
bikeCode = options["number"]; bikeCode = options["number"];
if (type == "ride") { if (type == "ride") {
addOrder(bikeCode,(res)=>{ addOrder(bikeCode, (res) => {
if(!res){ console.log("00000000000000000000", res);
setTimeout(()=>{ if (!res) {
bikeCode=null; setTimeout(() => {
},1000); bikeCode = null;
}, 1000);
return; return;
} } else {
else{ showWorn.value = true;
showWorn.value=true;
} }
}) })
} }

View File

@ -1,75 +1,136 @@
<template> <template>
<view class="container"> <view class="container">
<view class="cu-btn bg-blue" @click="getInfoList">
调度 <view>
<uni-forms>
<uni-forms-item label="车辆编号">
<bikeCodeScan ref="childComponent" @scan-change="bikeCodeScanChange" :codeValue="newbikeCode" />
</uni-forms-item>
</uni-forms>
</view>
<view class="button-container">
<view class="button-group flex justify-between padding">
<button class="cu-btn bg-blue margin-tb-sm lg">开锁</button>
<button class="cu-btn bg-blue margin-tb-sm lg"><strong>推车</strong></button>
</view>
</view>
<view class="table-container">
<uni-table>
<uni-tr>
<uni-th width="100" align="center">车辆编号</uni-th>
<uni-th width="50" align="center">状态</uni-th>
<uni-th width="80" align="center">响铃</uni-th>
<uni-th width="80" align="center">操作</uni-th>
</uni-tr>
<uni-tr v-for="(item, index) in dispatchRecords" :key="index">
<uni-td>{{ item.bikeCode }}</uni-td>
<uni-td>
<view class="name">离线</view>
</uni-td>
<uni-td align="center">
<view class="cu-tag line-blue">
<uni-icons type="plus" color="rgb(102,179,255)" size="20"></uni-icons>
</view>
</uni-td>
<uni-td align="center">
<uni-icons type="minus-filled" color="black" size="30"
@click="deleteDispatchRecord(item.id,index)"></uni-icons>
</uni-td>
</uni-tr>
</uni-table>
</view>
<view class="dispatch-btn-container">
<view class="cu-btn bg-blue" @click="getInfoList">
调度
</view>
</view> </view>
</view> </view>
</template> </template>
<script setup> <script setup>
import { import {
ref ref
} from 'vue'; } from 'vue';
import * as api from '@/utils/api.js'; import * as api from '@/utils/api.js';
import {onLoad} from '@dcloudio/uni-app'; import {
onLoad
} from '@dcloudio/uni-app';
import {
showModelMessage
} from '@/utils/tools.js';
const orderId=ref(""); const orderId = ref("");
onLoad((options)=>{
debugger; const newbikeCode = ref("");
orderId.value=options.orderId;;
const dispatchRecords = ref([]);
onLoad((options) => {
orderId.value = options.orderId;;
}) })
const getInfoList =()=>{ const getInfoList = () => {
debugger; api.callEbikeInfo("getDispatchVehicleByOrderId?orderId=" + orderId.value, {}, "get").then(
api.callEbikeInfo("getDispatchVehicleByOrderId?orderId="+orderId.value, {}, "get").then(
res => { res => {
if (res.code == 200) { if (res.code == 200) {
debugger;
dispatchRecords.value = res.data.dispatchRecords;
} }
}) })
} }
const deleteDispatchRecord = (recordId,index) => {
// 使 splice
dispatchRecords.value.splice(index, 1);
// api.callEbikeInfo("deleteDispatchRecord?recordId=" + recordId, {}, "get").then(res=>{
// if(res.code==200){
// dispatchRecords.value.slice(index,1)
// }
// })
}
const bikeCodeScanChange = (bikeCode) => {
api.callEbikeInfo("getBikeINfoData?bikeCode=" + bikeCode).then((res) => {
if (res.code == 200) {
const params = {
"orderId": orderId.value,
"bikeCode": bikeCode,
"dispatchState": 0
}
debugger;
newbikeCode.value = bikeCode;
api.callEbikeInfo("createDispatchRecord", params)
.then(re => {
if (re.code == "200") {
dispatchRecords.value.push(re.data)
} else {
showModelMessage(re.msg)
}
})
} else {
showModelMessage("车辆不存在!")
}
});
};
</script> </script>
<style scoped> <style scoped>
.dispatch-container { .container {
text-align: center; padding: 10px
margin-top: 20px;
} }
.dispatch-button { .button-group button {
padding: 10px 20px; width: 48%;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
} }
.dispatch-button:hover { .table-container {
background-color: #45a049; height: 400px;
} width: 100%;
padding: 5px;
.loading {
margin-top: 10px;
font-size: 18px;
color: #888;
}
.data-display {
margin-top: 20px;
background-color: #f4f4f4;
padding: 15px;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.error-message {
margin-top: 10px;
color: red;
} }
</style> </style>

View File

@ -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"); const oUser = uni.getStorageSync("wechat_user");
if (!oUser) { if (!oUser) {
uni.navigateTo({ uni.navigateTo({
@ -102,14 +102,15 @@ function saveRide(params, icnt, callback) {
return; return;
} }
showModelMessage(message); showModelMessage(message);
callback(false); if(callback) callback(false);
return; return;
} }
callback(true); if(callback)callback(true);
setTimeout(() => { setTimeout(() => {
uni.navigateTo({ uni.switchTab({
url: "/pages/user/home/home" url: "/pages/user/home/home"
}) })
}, 1000); }, 1000)
}) })
} }