修改解密优化,对接实时计费接口
This commit is contained in:
parent
09073efae7
commit
ec77c6dd50
@ -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;
|
||||
|
||||
@ -181,11 +182,11 @@
|
||||
//车辆
|
||||
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;
|
||||
@ -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 {
|
||||
@ -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;
|
||||
}
|
||||
@ -480,21 +508,23 @@
|
||||
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;
|
||||
}
|
||||
@ -503,7 +533,7 @@
|
||||
}
|
||||
|
||||
//完成骑行
|
||||
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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user