Ver código fonte

修复占位订单相关页面

jiuling 1 mês atrás
pai
commit
6cceb03c97

+ 8 - 9
components/parking-info/parking-info.js

@@ -6,10 +6,10 @@ Component({
       type: Object,
         value:{
           costCycle:0,
-          maxFeeTime:0,
+          maxFee:0,
           costTimePeriod:'',
           freeTime:0,
-          capping:0
+          // capping:0
         }
     }
   },
@@ -24,16 +24,15 @@ Component({
   methods: {
     // 组件的方法
     initData() {
-      let occupyFee = this.data.occupyFee;
+      // let occupyFee = this.data.occupyFee;
 
-      // let costCycle = occupyFee.costCycle / occupyFee.costCycleFee;
-      let capping = (Math.floor((occupyFee.maxFeeTime / occupyFee.costCycle)) * occupyFee.costCycleFee);
+      // let capping = (Math.floor((occupyFee.maxFeeTime / occupyFee.costCycle)) * occupyFee.costCycleFee);
 
       // 更新数据
-      this.setData({
-          'occupyFee.capping': capping
-      });
-      console.log("this.occupyFee",this.data);
+      // this.setData({
+      //     'occupyFee.capping': capping
+      // });
+      // console.log("this.occupyFee",this.data);
     }
   }
 })

+ 3 - 1
components/parking-info/parking-info.wxml

@@ -8,7 +8,9 @@
     </view>
     <!-- 费用信息 -->
     <view class="fee-info">
-      <view class="fee-rate">{{occupyFee.costCycleFee}}元/{{occupyFee.costCycle}}分钟 单次封顶{{occupyFee.capping}}元/次</view>
+      <view class="fee-rate">{{occupyFee.costCycleFee}}元/{{occupyFee.costCycle}}分钟
+          <text style="display: inline; font-size: 22rpx; font-family: none;" wx:if='{{occupyFee.maxFee > 0}}'>单次封顶{{occupyFee.maxFee}}元/次</text>
+      </view>
     </view>
     <!-- 时间信息 -->
     <view class="time-info">

+ 63 - 65
components/parking-order/parking-order.js

@@ -22,7 +22,7 @@ Component({
       let isLogin = wx.getStorageSync('isLogin');
       if (isLogin) {
         this.loadOccupyOrder().then(data => {
-          this.startPolling();
+           this.fetchData();
         })
         .catch(error => {
           console.error("数据加载失败", error);
@@ -38,8 +38,29 @@ Component({
   pageLifetimes:{
     // 组件所在页面的生命周期函数
     show: function () {
+      if (this.data.pollingInterval) {
+          this.stopPolling();
+      }
+  
+      const executePolling = () => {
+          console.log("执行定时器");
+          this.loadOccupyOrder().then(data => {
+              console.log("hhhh", data);
+              if (data.code === 500) {
+                  // 无占位费订单
+                  this.stopPolling();
+                  return;
+              }
+              this.fetchData();
+          });
+      };
   
-     },
+      // 立即执行一次
+      executePolling();
+  
+      // 设置定时器
+      this.data.pollingInterval = setInterval(executePolling, 30000);
+  },
      hide: function() {
       // 页面被隐藏
       this.stopPolling();
@@ -59,79 +80,53 @@ Component({
    * 组件的方法列表
    */
   methods: {
-  // 第一版
-  // startPolling: function() {
-  //   let that = this
-  //   // Set up interval for subsequent loads
-  //   this.data.pollingInterval = setInterval(() => {
-  //     let occupyFeeOrder = this.data.occupyFeeOrderList[0];
-  //      // 如果 occupyFeeOrder 不存在,直接返回
-  //       if (!occupyFeeOrder) {
-  //         console.warn("occupyFeeOrder 不存在,跳过本次轮询");
-  //         return;
-  //       }
-  //       wx.request({
-  //         url: 'https://jqcs.pjnes.com/cloud/occupyfee/evcs/occupyfee/template',
-  //         data: occupyFeeOrder.chargpileids,
-  //         method: 'POST',
-  //         success(res) {
-  //           that.calculate(occupyFeeOrder,res.data)
-  //         }})
-  //   }, 30000);
-  // },
-  startPolling: function() {
-    let that = this;
-
-    function fetchData() {
-        let occupyFeeOrder = that.data.occupyFeeOrderList[0];
-        console.log("occupyFeeOrder",occupyFeeOrder);
-        // 如果 occupyFeeOrder 不存在,直接返回
-        if (!occupyFeeOrder) {
-            console.warn("occupyFeeOrder 不存在,跳过本次轮询");
-            return;
-        }
-
-        wx.request({
-            url: 'https://jqcs.pjnes.com/cloud/occupyfee/evcs/occupyfee/template',
-            data: occupyFeeOrder.orderId,
-            method: 'POST',
-            success(res) {
-                that.calculate(occupyFeeOrder, res.data);
-            }
-        });
-    }
-
-    // **立即执行一次**
-    fetchData();
-
-    // **设置轮询**
-    this.data.pollingInterval = setInterval(fetchData, 30000);
+ fetchData() {
+  let that = this;
+  let occupyFeeOrder = that.data.occupyFeeOrderList[0];
+  console.log("occupyFeeOrder",occupyFeeOrder);
+  // 如果 occupyFeeOrder 不存在,直接返回
+  if (!occupyFeeOrder) {
+      console.warn("occupyFeeOrder 不存在,跳过本次轮询");
+      return;
+  }
+  wx.request({
+      url: 'https://jqcs.pjnes.com/cloud/occupyfee/evcs/occupyfee/template',
+      data: occupyFeeOrder.orderId,
+      method: 'POST',
+      success(res) {
+          that.calculate(occupyFeeOrder, res.data);
+      }
+  });
 },
   calculate(occupyFeeOrder,data) {
-    let { occupyBeginTime ="" ,occupyTime =""} = occupyFeeOrder;
+    // let { occupyBeginTime ="" ,occupyTime =""} = occupyFeeOrder;
       // 将时间字符串转换为 Date 对象
-      occupyBeginTime = new Date(occupyBeginTime.replace(/-/g, "/")); // 替换为兼容 iOS 的格式
+      // occupyBeginTime = new Date(occupyBeginTime.replace(/-/g, "/")); // 替换为兼容 iOS 的格式
   
-      let currentTime = new Date();
+      // let currentTime = new Date();
 
       // 计算时间差(分)
       // let minutesDifference = Math.floor((currentTime - occupyBeginTime) / (1000 * 60));
       let minutesDifference = data.params.occupyTime;
       let freeTime = Number(data.freeTime) || 0;
       console.log("免费时长:",freeTime);
-      console.log("最大占位时长:", data.maxFeeTime);
+      console.log("封顶费用:", data.maxFee);
       console.log("data:", data);
       console.log("分钟:", minutesDifference);
       if (minutesDifference >= freeTime +1) { 
-        if (minutesDifference <= data.maxFeeTime) {
-          console.log("未达到最大时长");
-          let Nocycle = Math.floor(minutesDifference / data.costCycle)
-          occupyFeeOrder.occupyFee = (Nocycle * data.costCycleFee).toFixed(2);
+        let cycle =((Math.floor(minutesDifference / data.costCycle))* data.costCycleFee).toFixed(2)
+        let max = data.maxFee
+        if (cycle <= max || max == null ) {
+          console.log("未达到最大时长",cycle);
+          // let Nocycle = Math.floor(minutesDifference / data.costCycle)
+          // occupyFeeOrder.occupyFee = (Nocycle * data.costCycleFee).toFixed(2);
+          occupyFeeOrder.occupyFee = cycle
           occupyFeeOrder.occupyTime = minutesDifference;
         } else {
           console.log("达到最大时长");
-          let cycle = Math.floor(data.maxFeeTime / data.costCycle)
-          occupyFeeOrder.occupyFee = (cycle * data.costCycleFee).toFixed(2);
+          // let cycle = Math.floor(data.maxFee / data.costCycle)
+          // occupyFeeOrder.occupyFee = (cycle * data.costCycleFee).toFixed(2);
+          occupyFeeOrder.occupyFee = data.maxFee
           occupyFeeOrder.occupyTime =minutesDifference;
         }
       } else {
@@ -172,13 +167,12 @@ Component({
           if (res.data.result) {
             let { rows: occupyFeeOrderList } = res.data.result;
             that.setData({
-              occupyFeeOrderList: that.data.occupyFeeOrderList.concat(occupyFeeOrderList),
+              occupyFeeOrderList: occupyFeeOrderList,
             });
             resolve(res.data.result);
-          } 
-          // else {
-          //   reject(new Error("No result data"));
-          // }
+          } else {
+            resolve(res.data);
+          }
         },
         fail(err) {
           reject(err);
@@ -201,10 +195,14 @@ Component({
       wx.showModal({
         title: '提示',
         confirmColor: '#00AADD',
-        content: '若对当前占位费订单有疑问,请拨打客服电话4009608068,工作时间:08:00-18:00',
+        confirmText: '联系客服', 
+        content: '若对当前占位费订单有疑问,请拨打客服电话4009608068,工作时间:08:00-17:00',
         complete: (res) => {
           // 可以在这里添加回调逻辑
           if (res.confirm) {
+            wx.makePhoneCall({
+              phoneNumber: '4009608068' // 替换为实际的客服电话
+            });
             console.log('用户点击了确认按钮');
           }else{
             console.log('用户点击了取消按钮');

+ 16 - 9
components/parking-order/parking-order.wxss

@@ -63,6 +63,7 @@
   color: #333;
   padding: 0 10rpx;
   font-weight: 600;
+  margin-bottom: 8rpx;
 }
 
 .time-info {
@@ -70,10 +71,11 @@
 }
 
 .info-row {
-  font-size: 28rpx;
+  font-size: 24rpx;
   color: #333;
   padding: 0 10rpx;
   text-align: left;
+  margin-bottom: 8rpx;
 }
 
 .label {
@@ -87,7 +89,7 @@
 }
 
 .fee-info {
-  margin-bottom: 10rpx;
+  /* margin-bottom: 10rpx; */
 }
 
 .warning-text {
@@ -124,12 +126,9 @@
   text-align: center;
 }
 .chargpile {
-  font-size: 22rpx;
-  line-height: 42rpx;
-  height: 42rpx;
-  min-height: 42rpx;
-  color: #9d9d9d;
-  /* margin-left: -50rpx; */
+  display: block;
+  font-size: 24rpx;
+  font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
 }
 .charging {
   width: 62rpx;
@@ -170,12 +169,20 @@ text .occupyTest {
   color: #545253;
   text-overflow: ellipsis;
   white-space: nowrap;
-  overflow: hidden;
+  overflow: hidden; 
   line-height: 24rpx;
   height: 24rpx;
   min-height: 24rpx;
 }
 text.bold {
+  font-family: 'Lucida Sans',
+                 'Lucida Sans Regular',
+                 'Lucida Grande',
+                 'Lucida Sans Unicode',
+                 Geneva,
+                 Verdana,
+                 sans-serif;
+  color: #545253;
   font-weight: bold;
   line-height: 50rpx;
   height: 50rpx;

+ 32 - 21
pages/index/index.js

@@ -777,8 +777,8 @@ Page({
         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+$/, "")
+          item.elecPrice = item.elecPrice || item.elecPrice.toFixed(8).replace(/\.?0+$/, "")
+          item.servicePrice = item.elecPrice||  item.servicePrice.toFixed(8).replace(/\.?0+$/, "")
         })
         let {
           name: latitude2,
@@ -805,9 +805,18 @@ Page({
     if(!item.servicePrice && item.servicePrice!=0){
       return '暂无费用'
     }
-    return (Number(item.elecPrice || 0) + Number(item.servicePrice || 0))
-    .toFixed(8)
-    .replace(/\.?0+$/, "");
+    // return (Number(item.elecPrice || 0) + Number(item.servicePrice || 0))
+    // .toFixed(8)
+    // .replace(/\.?0+$/, "");修改暂无费用报错问题
+    const elecPrice = Number(item.elecPrice);
+    const servicePrice = Number(item.servicePrice);
+
+    if (isNaN(elecPrice) || isNaN(servicePrice)) {
+      return '暂无费用';
+    }
+    return (elecPrice + servicePrice)
+      .toFixed(8)
+      .replace(/\.?0+$/, '');
   },
   //导航
   getRoute(e) {
@@ -860,23 +869,25 @@ Page({
     if (this.data.isLogin) {
       const resultOrder = await this.queryParkOrder(3);
         console.log("查询未支付成功",resultOrder);
-        if (resultOrder.total > 0) {
-          wx.showModal({
-            showCancel: false,
-            confirmText: '去支付',
-            content: '您有未支付的占位费订单,请先支付',
-            confirmColor:'#00AADD',
-            success: function (res) {
-              if (!res.cancel) {
-                //点击确定
-                let url = `/pages/ucenter/zhanw/zhanw`;
-                wx.navigateTo({
-                  url
-                })
+        if (resultOrder.code == 0) {
+          if(resultOrder.total > 0){
+            wx.showModal({
+              showCancel: false,
+              confirmText: '去支付',
+              content: '您有未支付的占位费订单,请先支付',
+              confirmColor:'#00AADD',
+              success: function (res) {
+                if (!res.cancel) {
+                  //点击确定
+                  let url = `/pages/ucenter/zhanw/zhanw`;
+                  wx.navigateTo({
+                    url
+                  })
+                }
               }
-            }
-          });
-          return;
+            });
+            return;
+          }
         }
       const result = await this.queryParkOrder(2);
       if (result.total > 0) { // 有占位费订单不启动扫码充电

+ 2 - 2
pages/search_result/search_result.js

@@ -170,7 +170,7 @@ Page({
                   slowfreenum: item.slowfreenum,
                   breaknum: item.breaknum,
                   /** 电费 */
-                  chargprice: item.chargprice.toFixed(8).replace(/\.?0+$/, ""),
+                  chargprice: item.chargprice || item.chargprice.toFixed(8).replace(/\.?0+$/, ""),
                   /** 服务费 */
                   serviceprice: item.serviceprice,
                   /** 停车费 */
@@ -237,7 +237,7 @@ Page({
               slowfreenum: item.slowfreenum,
               breaknum: item.breaknum,
               /** 电费 */
-              chargprice: item.chargprice.toFixed(8).replace(/\.?0+$/, ""),
+              chargprice: item.chargprice || item.chargprice.toFixed(8).replace(/\.?0+$/, ""),
               /** 服务费 */
               serviceprice: item.serviceprice,
               /** 停车费 */

+ 6 - 2
pages/ucenter/zhanw/zhanw.js

@@ -131,7 +131,7 @@ Page({
   formatCharginglogs(formatCharginglogs) {
     formatCharginglogs.forEach((item, index) => {
       try {
-        console.log("item",item);
+        // console.log("item",item);
           // 时间截取
           item.occupyBeginTime = item.occupyBeginTime.substr(0,19)
           item.occupyEndTime = item.occupyEndTime.substr(0,19)
@@ -343,10 +343,14 @@ Page({
     wx.showModal({
       title: '提示',
       confirmColor: '#00AADD',
-      content: '若对当前占位费订单有疑问,请拨打客服电话4009608068,工作时间:08:00-18:00',
+      confirmText: '联系客服', 
+      content: '若对当前占位费订单有疑问,请拨打客服电话4009608068,工作时间:08:00-17:00',
       complete: (res) => {
         // 可以在这里添加回调逻辑
         if (res.confirm) {
+          wx.makePhoneCall({
+            phoneNumber: '4009608068' // 替换为实际的客服电话
+          });
           console.log('用户点击了确认按钮');
         }else{
           console.log('用户点击了取消按钮');

+ 1 - 1
project.private.config.json

@@ -4,5 +4,5 @@
   "setting": {
     "compileHotReLoad": true
   },
-  "libVersion": "3.3.5"
+  "libVersion": "3.6.6"
 }