From 977e01fa07a6674dfcabf24309c294956a1bdf5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=B0=8F?= <736883394@qq.com> Date: Tue, 15 Apr 2025 10:19:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=BE=E7=89=87=E8=B7=AF?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ebike-maintenance/pages/user/home/home.vue | 212 ++++++++++++--------- ebike-maintenance/utils/config.js | 5 +- 2 files changed, 129 insertions(+), 88 deletions(-) diff --git a/ebike-maintenance/pages/user/home/home.vue b/ebike-maintenance/pages/user/home/home.vue index eb1501d..1a2adf0 100644 --- a/ebike-maintenance/pages/user/home/home.vue +++ b/ebike-maintenance/pages/user/home/home.vue @@ -1,27 +1,27 @@ @@ -123,9 +122,13 @@ callOrdereApi, callOperateApi } from "@/utils/api.js"; - - import { findIndex } from 'lodash'; - + + import { + findIndex + } from 'lodash'; + import config from '@/utils/config'; + + const imgPath = config.imgPath; const location = ref({ longitude: "", @@ -162,10 +165,10 @@ //车辆 let arrBikeData = []; - const showBikeInfo=ref(false); + const showBikeInfo = ref(false); //加载数据 - function getLoalcationData () { + function getLoalcationData() { uni.getLocation({ type: 'gcj02', geocode: true, @@ -175,28 +178,43 @@ longitude } = res; location.value = { - longitude:103.975457,latitude:30.633199 + longitude: 103.975457, + latitude: 30.633199 }; - const params={longitude:103.975457,latitude:30.633199}; - callOrdereApi("userOrders/bikeList",params,"post").then(res=>{ - console.log("11111111111111111","userOrders/bikeList",res); - const{code,data,message}=res; - if(code!=200){ + const params = { + longitude: 103.975457, + latitude: 30.633199 + }; + callOrdereApi("userOrders/bikeList", params, "post").then(res => { + console.log("11111111111111111", "userOrders/bikeList", res); + const { + code, + data, + message + } = res; + if (code != 200) { showModelMessage(message); return; } - arrBikeData=data||[]; - const arrData=markers.value||[]; + 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]=addMarker(index, longitude, latitude, "mapbike.png",true); + const { + longitude, + latitude + } = item; + let index = findIndex(arrData, { + longitude, + latitude + }); + index = index == -1 ? arrData.length : index; + arrData[index] = addMarker(index, longitude, latitude, "mapbike.png", + true); }) - markers.value =arrData ; - + markers.value = arrData; + }) - + }, fail(res) { @@ -204,41 +222,45 @@ }); } - function clickMess () { + function clickMess() { uni.setStorageSync("kbike-mess", 1); showMess.value = 1; } //刷新 - function refresh () { + function refresh() { getLoalcationData(); } //故障上报 - function reportFault () { + function reportFault() { if (!oUser) { tologin(); return; } - showModelMessage("该功能暂未实现!"); + uni.navigateTo({ + url: "/pages/user/login/TroubleReportUser" + }) } //站点 - function getSite () { + function getSite() { showModelMessage("该功能暂未实现!"); } //个人中心 - function getMine () { + function getMine() { if (!oUser) { tologin(); return; } - showModelMessage("该功能暂未实现!"); + uni.navigateTo({ + url: "/pages/user/mine/MePage" + }) } //扫描 - function scanBike () { + function scanBike() { if (!oUser) { tologin(); return; @@ -247,14 +269,14 @@ userId } = oUser; uni.navigateTo({ - url:"/pages/user/scan/scancode?type=ride" + url: "/pages/user/scan/scancode?type=ride" }) - + } - + //添加点 - function addMarker (id, longitude, latitude, icon,joinCluster) { + function addMarker(id, longitude, latitude, icon, joinCluster) { return { id: id, latitude, @@ -263,12 +285,12 @@ height: 30, zIndex: "100", iconPath: "/static/userui/home/" + icon, - joinCluster: joinCluster?true:false + joinCluster: joinCluster ? true : false }; } //添加线 - function addLine(scolor, arrPoints) { + function addLine(scolor, arrPoints) { return { points: arrPoints, color: scolor, @@ -276,7 +298,7 @@ } } //显示订单 - function showOrderInfo () { + function showOrderInfo() { showOrder.value = true; } @@ -314,12 +336,11 @@ //0-进行中 1-已取消 2-待支付 3-已支付 4-退款中 5-已退款 orderState.value = tempLock ? 1 : 0; orderData = data; - if(status==2){ + if (status == 2) { completeRiding(); - hasOrder.value = true; + hasOrder.value = true; return; - } - else if(status!=0){ + } else if (status != 0) { completeRiding(); return; } @@ -330,12 +351,14 @@ } }) } - + //轨迹 function getTracking() { const { bikeCode, - createdAt,ridePoint, returnPoint + createdAt, + ridePoint, + returnPoint } = orderData; const params = { ebikeCode: bikeCode, @@ -350,8 +373,8 @@ } = res; if (code != 200) { return; - } - const arrPoints =!data?[]: data.map(item => { + } + const arrPoints = !data ? [] : data.map(item => { const { lngGCJ02, latGCJ02 @@ -361,37 +384,39 @@ latitude: latGCJ02 } }) - const lng= startPoint[0]; - const lat=startPoint[1]; - const start={ - longitude:lng, - latitude: lat - } + const lng = startPoint[0]; + const lat = startPoint[1]; + const start = { + longitude: lng, + latitude: lat + } // const end={ // longitude: endPoint[0], // latitude: endPoint[1] // } - arrPoints.splice(0,0,start); + arrPoints.splice(0, 0, start); // arrPoints.push(end); - - const arrMakers=markers.value||[]; - const id=10000000; - let index=findIndex(arrMakers,{id}); - index=index==-1?arrMakers.length:index; - arrMakers[index]=addMarker(id,lng,lat,"mapstart.png"); - markers.value=arrMakers[index]; - polylines.value=[addLine("#168DED",arrPoints)]; + + const arrMakers = markers.value || []; + const id = 10000000; + let index = findIndex(arrMakers, { + id + }); + index = index == -1 ? arrMakers.length : index; + arrMakers[index] = addMarker(id, lng, lat, "mapstart.png"); + markers.value = arrMakers[index]; + polylines.value = [addLine("#168DED", arrPoints)]; }) } - + //完成骑行 - function completeRiding(){ - if(!orderTimer) return; + function completeRiding() { + if (!orderTimer) return; clearInterval(orderTimer); - orderTimer=null; + orderTimer = null; showOrder.value = false; hasOrder.value = false; - orderState.value=0; + orderState.value = 0; } function tologin() { @@ -409,21 +434,30 @@ //结束用车 function endRiding() { showModelMessage("该功能暂未实现!"); - const {userId}=oUser; + const { + userId + } = oUser; const { bikeCode } = orderData; - const params={userId,bikeCode} - callOrdereApi("userOrders/doneRide",params,"post").then(res=>{ - const{code,data,message}=res; - console.log("111111111111111111111111","endRiding",res); - if(code!=200){ + const params = { + userId, + bikeCode + } + callOrdereApi("userOrders/doneRide", params, "post").then(res => { + const { + code, + data, + message + } = res; + console.log("111111111111111111111111", "endRiding", res); + if (code != 200) { showModelMessage(message); return; } completeRiding(); }) - + } //继续骑行 需要开锁 @@ -433,7 +467,13 @@ //getOrder(); } - + //查看车辆信息 + function fnshowBikeInfo() { + showModelMessage("该功能暂未实现!"); + showBikeInfo.value = true; + } + + getLoalcationData(); onMounted(() => { diff --git a/ebike-maintenance/utils/config.js b/ebike-maintenance/utils/config.js index 0df8c89..36fd07c 100644 --- a/ebike-maintenance/utils/config.js +++ b/ebike-maintenance/utils/config.js @@ -1,7 +1,8 @@ const config = { - apiUrl: "https://attiya.fun/ebike/", + apiUrl: "http://192.168.2.156:10010/", cdnPath: "/", ERR_OK: 200, - sm2PublicKey: "04f5084ee12767d932f293508e30e3b0100185042ec0f061dedaf92b793b93f79fd6179d5e47e25b7aec98e00cf90dd56df1f8191012537187e7bbfd2d1de299fc" //f8209a2ebe6691e41e1f2b667bfe71f0b511716cc0f7c4452502fc12ec3957e4 + sm2PublicKey: "04f5084ee12767d932f293508e30e3b0100185042ec0f061dedaf92b793b93f79fd6179d5e47e25b7aec98e00cf90dd56df1f8191012537187e7bbfd2d1de299fc", //f8209a2ebe6691e41e1f2b667bfe71f0b511716cc0f7c4452502fc12ec3957e4 + imgPath:"https://attiya.fun/ebike-file/cdn-bucket/maintenance/" } export default config;