|
@@ -211,7 +211,12 @@ Page({
|
|
|
}
|
|
|
for(let i=0;i<resultList.length;i++){
|
|
|
if(resultList[i].currentTime){
|
|
|
- data.chargprice = resultList[i].elecPrice
|
|
|
+ if(resultList[i].elecPrice == '暂无费用'){
|
|
|
+ data.chargprice = '暂无费用'
|
|
|
+ }else{
|
|
|
+ const elecPrice = parseFloat(resultList[i].elecPrice); // 将字符串转换为数字
|
|
|
+ data.chargprice = elecPrice.toFixed(8).replace(/\.?0+$/, ""); // 格式化为8位小数
|
|
|
+ }
|
|
|
data.serviceprice = resultList[i].servicePrice
|
|
|
}
|
|
|
}
|
|
@@ -769,6 +774,12 @@ Page({
|
|
|
// 终点
|
|
|
markers.forEach((item, index) => {
|
|
|
if (markerId && markerId == item.id) {
|
|
|
+ let that = this
|
|
|
+ item.resultList.forEach(item=>{
|
|
|
+ item["sumPrice"] = that.resetResultListSumPrice(item)
|
|
|
+ item.elecPrice = item.elecPrice.toFixed(8).replace(/\.?0+$/, "")
|
|
|
+ item.servicePrice = item.servicePrice.toFixed(8).replace(/\.?0+$/, "")
|
|
|
+ })
|
|
|
let {
|
|
|
name: latitude2,
|
|
|
longitude: longitude2
|
|
@@ -786,6 +797,18 @@ Page({
|
|
|
});
|
|
|
|
|
|
},
|
|
|
+ resetResultListSumPrice(item){
|
|
|
+
|
|
|
+ if(!item.elecPrice && item.elecPrice!=0){
|
|
|
+ return '暂无费用'
|
|
|
+ }
|
|
|
+ if(!item.servicePrice && item.servicePrice!=0){
|
|
|
+ return '暂无费用'
|
|
|
+ }
|
|
|
+ return (Number(item.elecPrice || 0) + Number(item.servicePrice || 0))
|
|
|
+ .toFixed(8)
|
|
|
+ .replace(/\.?0+$/, "");
|
|
|
+ },
|
|
|
//导航
|
|
|
getRoute(e) {
|
|
|
//console.log(e);
|
|
@@ -1291,6 +1314,28 @@ Page({
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
+ // 处理页面跳转回来导致费率字段类型为字符串,处理为数值类型避免报错
|
|
|
+ let that = this;
|
|
|
+ for (let i = 0; i < that.data.markers.length; i++) {
|
|
|
+ let marker = that.data.markers[i]; // 直接获取 marker,减少 that.data 访问
|
|
|
+ let resultList = marker.resultList;
|
|
|
+
|
|
|
+ if (!resultList) continue;
|
|
|
+ for (let j = 0; j < resultList.length; j++) {
|
|
|
+ let item = resultList[j];
|
|
|
+ if (item.elecPrice === '暂无费用') {
|
|
|
+ item.chargprice = '暂无费用';
|
|
|
+ } else {
|
|
|
+ item.elecPrice = parseFloat(parseFloat(item.elecPrice).toFixed(8).replace(/\.?0+$/, ""));
|
|
|
+ }
|
|
|
+ if (item.servicePrice === '暂无费用') {
|
|
|
+ item.servicePrice = '暂无费用';
|
|
|
+ } else {
|
|
|
+ item.servicePrice = parseFloat(parseFloat(item.servicePrice).toFixed(8).replace(/\.?0+$/, ""));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ marker.resultList = resultList; // 直接赋值给 marker
|
|
|
+ }
|
|
|
this.data.scanFlag = false;
|
|
|
let userInfo = wx.getStorageSync('userInfo');
|
|
|
let isLogin = wx.getStorageSync('isLogin');
|