修改解密优化,对接实时计费接口

This commit is contained in:
小朱 2025-05-13 17:06:32 +08:00
parent 09073efae7
commit ec77c6dd50

View File

@ -51,11 +51,11 @@
<label>计时</label> <label>计时</label>
<label style="color: #61D246;">{{order.time}}</label> <label style="color: #61D246;">{{order.time}}</label>
</div> </div>
<div class="divOrderCell2"> <!-- <div class="divOrderCell2">
<image class="divOrderImg" :src='imgPath+"static/userui/home/bike.png"' /> <image class="divOrderImg" :src='imgPath+"static/userui/home/bike.png"' />
<label>骑行</label> <label>骑行</label>
<label style="color: #61D246;">{{order.mileage}}</label> <label style="color: #61D246;">{{order.mileage}}</label>
</div> </div> -->
</div> </div>
<div class="divOderBtn"> <div class="divOderBtn">
<image v-if="orderState==0" style="width: 120px;height: 40px;" :src='imgPath+"static/userui/home/lock.png"' <image v-if="orderState==0" style="width: 120px;height: 40px;" :src='imgPath+"static/userui/home/lock.png"'
@ -121,7 +121,8 @@
} from 'vue'; } from 'vue';
import { import {
showModelMessage, showModelMessage,
getUrlParams,jkcBaseDecode getUrlParams,
jkcBaseDecode
} from "@/utils/tools.js"; } from "@/utils/tools.js";
import { import {
callOrdereApi, callOrdereApi,
@ -149,8 +150,8 @@
const polygons = ref([]); // const polygons = ref([]); //
const polylines = ref([]); //线 const polylines = ref([]); //线
const circles = ref([]); // const circles = ref([]); //
const pointStart=100000000000; const pointStart = 100000000000;
const pointEnd=100000000001; const pointEnd = 100000000001;
let oMap = null; let oMap = null;
@ -181,11 +182,11 @@
// //
let arrBikeData = []; let arrBikeData = [];
const showBikeInfo = ref(false); const showBikeInfo = ref(false);
const bikeData=ref({}); const bikeData = ref({});
// //
function getLoalcationData() { function getLoalcationData() {
map.getLoalcation(res=>{ map.getLoalcation(res => {
const { const {
latitude, latitude,
longitude longitude
@ -213,12 +214,12 @@
} }
arrBikeData = data || []; arrBikeData = data || [];
const arrData = markers.value || []; const arrData = markers.value || [];
arrBikeData.map((item,index) => { arrBikeData.map((item, index) => {
const { const {
longitude, longitude,
latitude latitude
} = item; } = item;
arrData.push( map.addMarker(index, longitude, latitude, "mapbike.png", arrData.push(map.addMarker(index, longitude, latitude, "mapbike.png",
true)); true));
}) })
markers.value = arrData; markers.value = arrData;
@ -353,17 +354,42 @@
return; return;
} }
showOrder.value = true; showOrder.value = true;
if(tempLock==1){ if (status == 0) {
//
getOrderInfo(bikeCode);
order.value.bikecode = bikeCode;
// intervalId ID
const intervalId = setInterval(() => {
//
order.value.time = timeDifference(createdAt);
console.log(order.value.time); //
if (!showOrder.value) { // showOrder false
clearInterval(intervalId); // 使 intervalId
}
}, 1000);
}
if (tempLock == 1) {
getTracking(); getTracking();
return; return;
} }
getTracking(); getTracking();
// if (!orderTimer) { // if (!orderTimer) {
// orderTimer = setInterval(getTracking, 100000); // orderTimer = setInterval(getTracking, 100000);
// } // }
}) })
} }
const getOrderInfo = (bikeCode) => {
const params = {
"userId": oUser.userId,
"bikeCode": bikeCode
}
callOrdereApi("userOrders/costCalculation", params).then(res => {
if (res.code == 200) {
order.value.money = res.data;
}
})
}
// //
function getTracking() { function getTracking() {
const { const {
@ -413,7 +439,9 @@
} }
const arrMakers = markers.value || []; const arrMakers = markers.value || [];
arrPoints.splice(0, 0, start); arrPoints.splice(0, 0, start);
let indexStart = findIndex(arrMakers, {pointStart}); let indexStart = findIndex(arrMakers, {
pointStart
});
indexStart = indexStart == -1 ? arrMakers.length : indexStart; indexStart = indexStart == -1 ? arrMakers.length : indexStart;
arrMakers[indexStart] = map.addMarker(pointStart, lng, lat, "start.png"); arrMakers[indexStart] = map.addMarker(pointStart, lng, lat, "start.png");
if (data && data.length > 0) { if (data && data.length > 0) {
@ -465,10 +493,10 @@
data data
} = res; } = res;
showModelMessage(message) showModelMessage(message)
if(code==200){ if (code == 200) {
if(orderTimer) { if (orderTimer) {
clearInterval(orderTimer); clearInterval(orderTimer);
orderTimer=null; orderTimer = null;
} }
orderState.value = 1; orderState.value = 1;
} }
@ -480,21 +508,23 @@
checkBikeEnding(); checkBikeEnding();
} }
function checkBikeEnding(callback){ function checkBikeEnding(callback) {
const { const {
bikeCode bikeCode
} = orderData; } = orderData;
const params={bikeCode} const params = {
bikeCode
}
// //
const arrMethod=[callOrdereApi("userOrders/checkBikeInOperation", params, "get") const arrMethod = [callOrdereApi("userOrders/checkBikeInOperation", params, "get"), callOrdereApi(
,callOrdereApi("userOrders/checkBikeInParking", params, "get")] "userOrders/checkBikeInParking", params, "get")]
Promise.all(arrMethod).then(([res1,res2])=>{ Promise.all(arrMethod).then(([res1, res2]) => {
if(res1.code!=200){ if (res1.code != 200) {
showModelMessage(res1.message); showModelMessage(res1.message);
return; return;
} }
if(res2.code!=200){ if (res2.code != 200) {
showModelMessage(res2.message); showModelMessage(res2.message);
return; return;
} }
@ -503,7 +533,7 @@
} }
// //
function doneRide(){ function doneRide() {
const { const {
userId userId
} = oUser; } = oUser;
@ -548,10 +578,10 @@
data data
} = res; } = res;
showModelMessage(message) showModelMessage(message)
if(code==200){ if (code == 200) {
if(orderTimer) { if (orderTimer) {
clearInterval(orderTimer); clearInterval(orderTimer);
orderTimer=null; orderTimer = null;
} }
orderState.value = 0; orderState.value = 0;
} }
@ -568,13 +598,13 @@
const { const {
markerId markerId
} = e.detail; } = e.detail;
if(markerId==pointEnd || markerId==pointStart){ if (markerId == pointEnd || markerId == pointStart) {
return; return;
} }
bikeData.value=arrBikeData[markerId]; bikeData.value = arrBikeData[markerId];
showBikeInfo.value = true; showBikeInfo.value = true;
showTools.value = false; showTools.value = false;
showOrderPay.value=false; showOrderPay.value = false;
} }
// //
@ -583,7 +613,7 @@
showTools.value = true; showTools.value = true;
} }
onMounted(()=>{ onMounted(() => {
const instance = getCurrentInstance(); const instance = getCurrentInstance();
oMap = uni.createMapContext("mapRef", { oMap = uni.createMapContext("mapRef", {
this: instance.proxy this: instance.proxy
@ -591,9 +621,9 @@
getLoalcationData(); getLoalcationData();
}) })
onShow(() => { onShow(() => {
if (uni.getStorageSync("wechat_user")) {
oUser = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user"))); oUser = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user")));
console.log("7777777777777777777777","oUser", oUser) }
const { const {
userId userId
} = oUser; } = oUser;
@ -604,8 +634,39 @@
}); });
onUnload(() => { onUnload(() => {
console.log("9999999999999999999", "onUnload",orderTimer); console.log("9999999999999999999", "onUnload", orderTimer);
}) })
function parseDate(createTime) {
// iOS
createTime = createTime.replace(" ", "T"); // "T"使 "yyyy-MM-ddTHH:mm:ss"
return new Date(createTime); // Date
}
function timeDifference(createTime) {
const currentTime = new Date();
const createDate = parseDate(createTime); // 使
const diffInSeconds = Math.floor((currentTime - createDate) / 1000);
if (diffInSeconds < 60) return `${diffInSeconds}`;
const diffInMinutes = Math.floor(diffInSeconds / 60);
if (diffInMinutes < 60) {
const remainingSeconds = diffInSeconds % 60;
return `${diffInMinutes}分钟 ${remainingSeconds}`;
}
const diffInHours = Math.floor(diffInMinutes / 60);
if (diffInHours < 24) {
const remainingMinutes = diffInMinutes % 60;
const remainingSeconds = diffInSeconds % 60;
return `${diffInHours}小时 ${remainingMinutes}分钟 ${remainingSeconds}`;
}
const diffInDays = Math.floor(diffInHours / 24);
return `${diffInDays}${diffInHours % 24}小时 ${diffInMinutes % 60}分钟 ${diffInSeconds % 60}`;
}
</script> </script>
<style scoped> <style scoped>