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

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 style="color: #61D246;">{{order.time}}</label>
</div>
<div class="divOrderCell2">
<!-- <div class="divOrderCell2">
<image class="divOrderImg" :src='imgPath+"static/userui/home/bike.png"' />
<label>骑行</label>
<label style="color: #61D246;">{{order.mileage}}</label>
</div>
</div> -->
</div>
<div class="divOderBtn">
<image v-if="orderState==0" style="width: 120px;height: 40px;" :src='imgPath+"static/userui/home/lock.png"'
@ -121,7 +121,8 @@
} from 'vue';
import {
showModelMessage,
getUrlParams,jkcBaseDecode
getUrlParams,
jkcBaseDecode
} from "@/utils/tools.js";
import {
callOrdereApi,
@ -149,8 +150,8 @@
const polygons = ref([]); //
const polylines = ref([]); //线
const circles = ref([]); //
const pointStart=100000000000;
const pointEnd=100000000001;
const pointStart = 100000000000;
const pointEnd = 100000000001;
let oMap = null;
@ -175,17 +176,17 @@
let orderTimer = null;
const orderState = ref(0);
const showOrderPay = ref(false);
//
let arrBikeData = [];
const showBikeInfo = ref(false);
const bikeData=ref({});
const bikeData = ref({});
//
function getLoalcationData() {
map.getLoalcation(res=>{
map.getLoalcation(res => {
const {
latitude,
longitude
@ -213,12 +214,12 @@
}
arrBikeData = data || [];
const arrData = markers.value || [];
arrBikeData.map((item,index) => {
arrBikeData.map((item, index) => {
const {
longitude,
latitude
} = item;
arrData.push( map.addMarker(index, longitude, latitude, "mapbike.png",
arrData.push(map.addMarker(index, longitude, latitude, "mapbike.png",
true));
})
markers.value = arrData;
@ -232,7 +233,7 @@
// latitude,
// longitude
// };
// },
// fail(res) {
@ -353,17 +354,42 @@
return;
}
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();
return;
}
getTracking();
// if (!orderTimer) {
// 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() {
const {
@ -403,7 +429,7 @@
latitude: latGCJ02
}
});
const startPoint = ridePoint.split(",");
const lng = startPoint[0];
const lat = startPoint[1];
@ -413,7 +439,9 @@
}
const arrMakers = markers.value || [];
arrPoints.splice(0, 0, start);
let indexStart = findIndex(arrMakers, {pointStart});
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) {
@ -465,10 +493,10 @@
data
} = res;
showModelMessage(message)
if(code==200){
if(orderTimer) {
if (code == 200) {
if (orderTimer) {
clearInterval(orderTimer);
orderTimer=null;
orderTimer = null;
}
orderState.value = 1;
}
@ -479,31 +507,33 @@
function endRiding() {
checkBikeEnding();
}
function checkBikeEnding(callback){
function checkBikeEnding(callback) {
const {
bikeCode
} = orderData;
const params={bikeCode}
const params = {
bikeCode
}
//
const arrMethod=[callOrdereApi("userOrders/checkBikeInOperation", params, "get")
,callOrdereApi("userOrders/checkBikeInParking", params, "get")]
Promise.all(arrMethod).then(([res1,res2])=>{
if(res1.code!=200){
const arrMethod = [callOrdereApi("userOrders/checkBikeInOperation", params, "get"), callOrdereApi(
"userOrders/checkBikeInParking", params, "get")]
Promise.all(arrMethod).then(([res1, res2]) => {
if (res1.code != 200) {
showModelMessage(res1.message);
return;
}
if(res2.code!=200){
if (res2.code != 200) {
showModelMessage(res2.message);
return;
}
doneRide();
});
}
//
function doneRide(){
function doneRide() {
const {
userId
} = oUser;
@ -548,10 +578,10 @@
data
} = res;
showModelMessage(message)
if(code==200){
if(orderTimer) {
if (code == 200) {
if (orderTimer) {
clearInterval(orderTimer);
orderTimer=null;
orderTimer = null;
}
orderState.value = 0;
}
@ -568,13 +598,13 @@
const {
markerId
} = e.detail;
if(markerId==pointEnd || markerId==pointStart){
if (markerId == pointEnd || markerId == pointStart) {
return;
}
bikeData.value=arrBikeData[markerId];
bikeData.value = arrBikeData[markerId];
showBikeInfo.value = true;
showTools.value = false;
showOrderPay.value=false;
showOrderPay.value = false;
}
//
@ -583,7 +613,7 @@
showTools.value = true;
}
onMounted(()=>{
onMounted(() => {
const instance = getCurrentInstance();
oMap = uni.createMapContext("mapRef", {
this: instance.proxy
@ -591,9 +621,9 @@
getLoalcationData();
})
onShow(() => {
oUser = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user")));
console.log("7777777777777777777777","oUser", oUser)
if (uni.getStorageSync("wechat_user")) {
oUser = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user")));
}
const {
userId
} = oUser;
@ -604,8 +634,39 @@
});
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>
<style scoped>