修改解密优化,对接实时计费接口
This commit is contained in:
parent
09073efae7
commit
ec77c6dd50
@ -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,
|
||||||
@ -353,17 +354,42 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showOrder.value = true;
|
showOrder.value = true;
|
||||||
|
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) {
|
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) {
|
||||||
@ -484,10 +512,12 @@
|
|||||||
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);
|
||||||
@ -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;
|
||||||
@ -606,6 +636,37 @@
|
|||||||
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>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user