Przeglądaj źródła

占位费V1.0.0

jiuling 1 tydzień temu
rodzic
commit
1c64564a19

+ 14 - 5
components/parking-info/parking-info.js

@@ -5,10 +5,11 @@ Component({
     occupyFee:{
       type: Object,
         value:{
-          cost_cycle:0,
-          max_fee_time:0,
-          cost_time_period:'',
-          free_time:0
+          costCycle:0,
+          maxFeeTime:0,
+          costTimePeriod:'',
+          freeTime:0,
+          capping:0
         }
     }
   },
@@ -23,7 +24,15 @@ Component({
   methods: {
     // 组件的方法
     initData() {
-      const { cost_cycle, max_fee_time, cost_time_period, free_time } = this.data.occupyFee;
+      let occupyFee = this.data.occupyFee;
+
+      // let costCycle = 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);
     }
   }

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

@@ -8,16 +8,16 @@
     </view>
     <!-- 费用信息 -->
     <view class="fee-info">
-      <view class="fee-rate">{{occupyFee.cost_cycle}}元/分钟 单次封顶{{occupyFee.max_fee_time}}元/次</view>
+      <view class="fee-rate">{{occupyFee.costCycleFee}}元/{{occupyFee.costCycle}}分钟 单次封顶{{occupyFee.capping}}元/次</view>
     </view>
     <!-- 时间信息 -->
     <view class="time-info">
       <view class="time-label">收费时段:</view>
-      <view class="time-value">{{occupyFee.cost_time_period}}</view>
+      <view class="time-value">{{occupyFee.costTimePeriod}}</view>
     </view>
     <!-- 提示信息 -->
     <view class="notice-block">
-      <view class="notice-text">充电结束{{occupyFee.free_time}}分钟未挪车,将按占用时长收取超时占位费</view>
+      <view class="notice-text">充电结束{{occupyFee.freeTime}}分钟未挪车,将按占用时长收取超时占位费</view>
     </view>
   </view>
   <!-- 费用说明 -->

+ 147 - 23
components/parking-order/parking-order.js

@@ -16,39 +16,150 @@ Component({
   },
   lifetimes:{
     attached(){
+      console.log("加载占位中订单组件");
       // this.loadOccupyOrder();
       // 页面加载时显示弹窗
       let isLogin = wx.getStorageSync('isLogin');
       if (isLogin) {
-        this.loadOccupyOrder();
+        this.loadOccupyOrder().then(data => {
+          this.startPolling();
+        })
+        .catch(error => {
+          console.error("数据加载失败", error);
+        });
+        
       }
     },
+    detached: function() {
+      // 在组件实例被从页面节点树移除时执行
+      this.stopPolling();
+    },
   },
   pageLifetimes:{
     // 组件所在页面的生命周期函数
     show: function () {
-      // let isLogin = wx.getStorageSync('isLogin');
-      // if (isLogin) {
-      //   this.loadOccupyOrder();
-      // }
+  
      },
+     hide: function() {
+      // 页面被隐藏
+      this.stopPolling();
+    },
   },
   /**
    * 组件的初始数据
    */
   data: {
     showPopup: false,
-    occupyFeeOrderList:[]
+    occupyFeeOrderList:[],
+    pollingInterval: null, // 定时器,
+    costCycleFee:0
   },
 
   /**
    * 组件的方法列表
    */
   methods: {
-    loadOccupyOrder(){
-      let that = this;
+  // 第一版
+  // 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);
+},
+  calculate(occupyFeeOrder,data) {
+    let { occupyBeginTime ="" ,occupyTime =""} = occupyFeeOrder;
+      // 将时间字符串转换为 Date 对象
+      occupyBeginTime = new Date(occupyBeginTime.replace(/-/g, "/")); // 替换为兼容 iOS 的格式
+  
+      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:", 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);
+          occupyFeeOrder.occupyTime = minutesDifference;
+        } else {
+          console.log("达到最大时长");
+          let cycle = Math.floor(data.maxFeeTime / data.costCycle)
+          occupyFeeOrder.occupyFee = (cycle * data.costCycleFee).toFixed(2);
+          occupyFeeOrder.occupyTime =minutesDifference;
+        }
+      } else {
+        console.log("处于免费时长");
+        occupyFeeOrder.occupyFee = 0.00;
+        occupyFeeOrder.occupyTime = minutesDifference;
+      }
+      
+      console.log("触发定时器",occupyFeeOrder);
+      // 根据返回的结果去调用微服务查询模版信息接口,根据模版信息 重新动态计算占位费模版
+      this.setData({
+        "occupyFeeOrderList[0]": occupyFeeOrder 
+      });
+  },
+
+  // Stop polling
+  stopPolling: function() {
+    if (this.data.pollingInterval) {
+      console.log('清除占位中定时器');
+      clearInterval(this.data.pollingInterval);
+      this.data.pollingInterval = null;
+    }
+  },
+  loadOccupyOrder() {
+    let that = this;
+    return new Promise((resolve, reject) => {
       wx.request({
-        url: getApp().globalData.postHeadAgreement +'/restapi/wechat/queryOccupyFeeOrder',
+        url: getApp().globalData.postHeadAgreement + '/restapi/wechat/queryOccupyFeeOrder',
         data: {
           userId: wx.getStorageSync('userInfo').userId,
           searchIndex: 2,
@@ -57,24 +168,24 @@ Component({
         },
         method: 'POST',
         success(res) {
-          console.log("占位费",res);
-          // if (res.data.result.total > 0) {
-          //   that.setData({
-          //     showPopup:true
-          //   })
-          // }
+          console.log("占位费", res);
           if (res.data.result) {
-            let {
-              rows: occupyFeeOrderList,
-            } = res.data.result;
-
+            let { rows: occupyFeeOrderList } = res.data.result;
             that.setData({
               occupyFeeOrderList: that.data.occupyFeeOrderList.concat(occupyFeeOrderList),
             });
-          }
+            resolve(res.data.result);
+          } 
+          // else {
+          //   reject(new Error("No result data"));
+          // }
+        },
+        fail(err) {
+          reject(err);
         }
       });
-    },
+    });
+  },
     handleConfirm() {
       // 点击确认按钮
       this.setData({
@@ -84,8 +195,21 @@ Component({
   
     handleContact() {
       // 联系客服
-      wx.makePhoneCall({
-        phoneNumber: '18888888888' // 替换为实际的客服电话
+      // wx.makePhoneCall({
+      //   phoneNumber: '4009608068' // 替换为实际的客服电话
+      // });
+      wx.showModal({
+        title: '提示',
+        confirmColor: '#00AADD',
+        content: '若对当前占位费订单有疑问,请拨打客服电话4009608068,工作时间:08:00-18:00',
+        complete: (res) => {
+          // 可以在这里添加回调逻辑
+          if (res.confirm) {
+            console.log('用户点击了确认按钮');
+          }else{
+            console.log('用户点击了取消按钮');
+          }
+        }
       });
     },
   }

+ 2 - 2
components/parking-order/parking-order.wxml

@@ -24,13 +24,13 @@
       </view>
       <view class="info-row">
         <text class="label occupyTest">已占位时长:</text>
-        <text class="value occupyTest">{{item.occupyTime || 0}}</text>
+        <text class="value occupyTest">{{item.occupyTime || 0}}</text>
       </view>
     </view>
     <!-- 费用信息 -->
     <view class="info-row fee-info">
       <text class="label occupyTest">已产生占位费:</text>
-      <text class="value occupyTest">{{item.occupyFee || 0}}</text>
+      <text class="value occupyTest">{{item.occupyFee || 0}}</text>
     </view>
     <!-- 警告文字 -->
     <view class="warning-text">

+ 73 - 17
pages/charginfo/charginfo.js

@@ -153,7 +153,7 @@ Page({
     let { name, address, chargprice, serviceprice, chargid,brandName } = e;
 
     name =  name=='null'?null:name;
-    brandName =  brandName=='null'?null:brandName;
+    brandName =  brandName=='null' || 'undefined' ?null:brandName;
     address =  address=='null'?null:address;
     // stationTagList = !stationTagList?null:stationTagList;
     chargprice =  chargprice=='null'?null:chargprice;
@@ -218,20 +218,76 @@ Page({
     }
   },
   getOccupyFee(){
-    // test对象对接后端服务传递过来的数据
-    var test = {
-      cost_cycle:2,
-      max_fee_time:120,
-      cost_time_period:'00:00-08:00,12:00-14:00,18:00-21:00,22:00-23:00,22:00-23:00',
-      free_time:10
+    this.selectStationOccupyFee()
+    .then(result => {
+      console.log("查询结果:", result);
+        this.setData({
+          occupyFee:result[0],
+          showOccupyFee:true
+        })
+    })
+    .catch(error => {
+      console.error("查询失败:", error);
+    });
+  },
+  async selectStationOccupyFee() {
+    try {
+      const res = await new Promise((resolve, reject) => {
+        wx.request({
+          url: `${getApp().globalData.postHeadAgreement}/restapi/wechat/queryStationOccupyFee`,
+          data: {
+            chargStation: {
+              id:this.data.chargid
+            }
+          },
+          method: 'POST',
+          success: (response) => {          
+            resolve(response.data);
+          },
+          fail: (error) => {
+            reject(error);
+          }
+        });
+      });
+      if (res.code == 200) {
+        return res.result;
+      } else {
+        throw new Error(`Error: ${res.code}`);
+      }
+    } catch (e) {
+      console.log("查询占位费模版信息异常", e);
+      log.info('[扫码]', '[查询占位费模版信息]', '[fail]', e);
+      throw e;
+    }
+  },
+  async selectPileOccupyFee(chargPileId) {
+    console.log("启动chargPileId",chargPileId);
+    try {
+      const res = await new Promise((resolve, reject) => {
+        wx.request({
+          url: `${getApp().globalData.postHeadAgreement}/restapi/wechat/queryOccupyFee`,
+          data: {
+             chargPileId: chargPileId
+          },            
+          method: 'POST',
+          success: (response) => {          
+            resolve(response.data);
+          },
+          fail: (error) => {
+            reject(error);
+          }
+        });
+      });
+      if (res.code == 200) {
+        return res.result;
+      } else {
+        throw new Error(`Error: ${res.code}`);
+      }
+    } catch (e) {
+      console.log("查询充电桩占位费模版信息异常", e);
+      log.info( '[查询充电桩占位费模版信息]', '[fail]', e);
+      throw e;
     }
-    if (Object.keys(test).length > 0) { // 判断对象数据是否为空
-      this.setData({
-        occupyFee:test,
-        showOccupyFee:true
-      })
-    }  
-    console.log("occupyFee",Object.keys(this.data.occupyFee).length > 0);
   },
 
   ori_getPage(){
@@ -474,11 +530,11 @@ Page({
                   let url = `/pages/ucenter/zhanw/zhanw`;
                   wx.navigateTo({
                     url
-                  })
-                  return;
+                  })                 
                 }
               }
             });
+            return;
       }
     }
     const result = await wechat.request(api, path, params);
@@ -623,7 +679,7 @@ Page({
                       data: res.data
                     });
                     log.info('[首页]', '[扫一扫充电桩空闲跳转去充电界面]');
-                    let url = `/pages/scan_result/scan_result`;
+                    let url = `/pages/scan_result/scan_result?chargPileId=` + chargid;
                     wx.hideLoading();
                     wx.navigateTo({
                       url

+ 32 - 26
pages/index/index.js

@@ -834,33 +834,34 @@ Page({
   },
 
   async click_scan_control(scanResult,inner) {
-    this.queryParkOrder(3).then(res=>{
-      console.log("查询未支付成功",res);
-      if (res.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;
+    if (this.data.isLogin) {
+      this.queryParkOrder(3).then(res=>{
+        console.log("查询未支付成功",res);
+        if (res.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
+                })
+              }
             }
-          }
-        });
-      }
-    })
-    const result = await this.queryParkOrder(2);
-    if (result.total > 0) { // 有占位费订单不启动扫码充电
-      this.setData({
-        showPopup:true
+          });
+        }
       })
-      return;
+      const result = await this.queryParkOrder(2);
+      if (result.total > 0) { // 有占位费订单不启动扫码充电
+        this.setData({
+          showPopup:true
+        })
+        return;
+      }
     }
     if(this.data.scanFlag){
       return;
@@ -884,6 +885,10 @@ Page({
       });
       return;
     } else {
+      if (this.data.userInfo.flag) {// 运维人员不作操作,直接返回首页
+        wx.hideLoading(); 
+        return false;
+      }
       if(!this.phoneCheck()){
         return;
       }
@@ -1083,7 +1088,7 @@ Page({
               data: res.data
             });
             log.info('[首页]', '[扫一扫充电桩空闲跳转去充电界面]');
-            let url = `/pages/scan_result/scan_result`;
+            let url = `/pages/scan_result/scan_result?chargPileId=${scanResult}`;
             that.data.scanFlag = false;
             wx.hideLoading();
             wx.navigateTo({
@@ -1390,6 +1395,7 @@ Page({
             })
             // 查询占位中订单
           this.queryParkOrder(2).then(res=>{
+            // 30s查询一次,动态返回数据
             // console.log("我被调用了");
             if (res.total > 0) { // 有占位费订单不启动扫码充电
               this.setData({

+ 40 - 14
pages/scan_result/scan_result.js

@@ -109,23 +109,49 @@ Page({
 
       }
     });
-    this.getOccupyFee();
+    this.getOccupyFee(options.chargPileId);
   },
-  getOccupyFee(){
+  getOccupyFee(chargPileId){
     // test对象对接后端服务传递过来的数据
-    var test = {
-      cost_cycle:2,
-      max_fee_time:120,
-      cost_time_period:'00:00-08:00,12:00-14:00,18:00-21:00,22:00-23:00,22:00-23:00',
-      free_time:10
+    this.selectOccupyFee(chargPileId)
+    .then(result => {
+      console.log("查询结果:", result);
+        this.setData({
+          occupyFee:result,
+          showOccupyFee:true
+        })
+    })
+    .catch(error => {
+      console.error("查询失败:", error);
+    });
+  },
+  async selectOccupyFee(chargPileId) {
+    try {
+      const res = await new Promise((resolve, reject) => {
+        wx.request({
+          url: `${getApp().globalData.postHeadAgreement}/restapi/wechat/queryOccupyFee`,
+          data: {
+            chargPileId: chargPileId
+          },
+          method: 'POST',
+          success: (response) => {          
+            resolve(response.data);
+          },
+          fail: (error) => {
+            reject(error);
+          }
+        });
+      });
+      if (res.code == 200) {
+        return res.result;
+      } else {
+        throw new Error(`Error: ${res.code}`);
+      }
+    } catch (e) {
+      console.log("查询占位费模版信息异常", e);
+      log.info('[扫码]', '[查询占位费模版信息]', '[fail]', e);
+      throw e;
     }
-    if (Object.keys(test).length > 0) { // 判断对象数据是否为空
-      this.setData({
-        occupyFee:test,
-        showOccupyFee:true
-      })
-    }  
-    console.log("occupyFee我草",Object.keys(this.data.occupyFee).length > 0);
   },
   execParking(that,chargPile){
     let stationId = chargPile.chargStationId;

+ 151 - 175
pages/ucenter/zhanw/zhanw.js

@@ -1,5 +1,6 @@
 // pages/ucenter/zhanw/zhanw.js
 let Util = require("../../../utils/util");
+let log = require('../../../utils/log.js');
 Page({
 
   /**
@@ -15,16 +16,12 @@ Page({
     dataLoading: false,
     finishedLoadTap: 0,
     finishedLoadShowTimes: 0,
-    chongdianzhuangmingcheng: false,
-    chongdianzhuangbianhao: false,
-    chongdianshichang: false,
-    chongdiankaishijieshu: false,
     customerServiceFlag: false,
     cancleBtnFlag: false,
     servicetel: getApp().globalData.helpPhoneNum,
     orderid: null,
     userId: null,
-    order: null,
+    order: {},
   },
   switchBar(e){
     let searchIndex = e.currentTarget.dataset.idx;
@@ -97,9 +94,11 @@ Page({
     wx.showLoading({
       title: '数据加载中....',
     })
+    this.queryOccupyFeeOrder();
+  },
 
-  let that = this;
-
+  queryOccupyFeeOrder(){
+    let that = this;
     wx.request({
       url: getApp().globalData.postHeadAgreement +'/restapi/wechat/queryOccupyFeeOrder',
       data: {
@@ -129,15 +128,13 @@ Page({
       }
     });
   },
-
-
   formatCharginglogs(formatCharginglogs) {
     formatCharginglogs.forEach((item, index) => {
       try {
         console.log("item",item);
           // 时间截取
-          item.occupyBeginTime = item.occupyBeginTime.substr(0,16)
-          item.occupyEndTime = item.occupyEndTime.substr(0,16)
+          item.occupyBeginTime = item.occupyBeginTime.substr(0,19)
+          item.occupyEndTime = item.occupyEndTime.substr(0,19)
           // 状态翻译
           if(item.status==3){
             item.occupyStatusCN = '未支付'
@@ -148,12 +145,6 @@ Page({
           }else if(item.status==7){
             item.occupyStatusCN = '已退款'
           };
-          // 判断标记为  chongdianzhuangmingcheng chongdianzhuangbianhao chongdianshichang chongdiankaishijieshu
-          // let chongdianzhuangmingcheng =  false
-          // let chongdianzhuangbianhao =  false
-          // let chongdianshichang =  false
-          // let chongdiankaishijieshu =  false
-          // let chongdianfeiyong =  false
           let customerServiceFlag = false;
           let cancleBtnFlag= false;
           let height= 'h3';
@@ -164,11 +155,6 @@ Page({
           if(item.status==3 || item.status == 4){
             cancleBtnFlag = true;
           }
-          // item.chongdianzhuangmingcheng = chongdianzhuangmingcheng;
-          // item.chongdianzhuangbianhao = chongdianzhuangbianhao;
-          // item.chongdianshichang = chongdianshichang;
-          // item.chongdiankaishijieshu = chongdiankaishijieshu;
-          // item.chongdianfeiyong = chongdianfeiyong;
           item.customerServiceFlag = customerServiceFlag;
           item.cancleBtnFlag = cancleBtnFlag;
           item.height = height;
@@ -176,29 +162,6 @@ Page({
       } catch (err) {
         //在这里处理错误
       }
-      try {
-        let chargePile = item.pileLog;
-        console.info(chargePile)
-        let startDate = Util.parseDate(chargePile.chargstarttime);
-        let endDate = Util.parseDate(chargePile.chargendtime)
-        let totalTime = Math.round((endDate.getTime() - startDate.getTime()) / 60000);
-        let totalTimeHour = Math.floor(totalTime / 60);
-        let totalTimeMinute = totalTime % 60;
-        let startTime = startDate.getFullYear() + "年" + Util.formatNumber(startDate.getMonth() + 1) + '月' + Util.formatNumber(startDate.getDate()) + '日  ' + Util.formatNumber(startDate.getHours()) + ':' + Util.formatNumber(startDate.getMinutes()) + ':' + Util.formatNumber(startDate.getSeconds());
-        let endTime = endDate.getFullYear() + "年" + Util.formatNumber(endDate.getMonth() + 1) + '月' + Util.formatNumber(endDate.getDate()) + '日  ' + Util.formatNumber(endDate.getHours()) + ':' + Util.formatNumber(endDate.getMinutes()) + ':' + Util.formatNumber(endDate.getSeconds());
-        totalTime = Util.formatNumber(totalTimeHour) + "时" + Util.formatNumber(totalTimeMinute) + "分";
-        chargePile.startTime = startTime;
-        chargePile.endTime = endTime;
-        chargePile.totalTime = totalTime;
-        chargePile.chargallmoney = chargePile.chargallmoney.toFixed(2);
-        chargePile.chargservice = chargePile.chargservice.toFixed(2);
-        chargePile.chargmoney = chargePile.chargmoney.toFixed(2);
-        //console.log(chargePile.chargPile);
-      } catch (err) {
-        //在这里处理错误
-      }
-
-
     });
 
   },
@@ -210,145 +173,161 @@ Page({
     }
   },
   customerServiceBtn(e){
-    console.log("拿纸",e.currentTarget.dataset.idx);
     let parkId = e.currentTarget.dataset.idx;
     wx.makePhoneCall({
       phoneNumber: this.data.servicetel
     })
   },
   payOrder(e) {
-    // log.info('[订单支付]', '[用户触发支付订单]');
-    // wx.showLoading({
-    //   title: '支付中...',
-    //   mask: true
-    // });
+    log.info('[订单支付]', '[用户触发支付订单]');
+    wx.showLoading({
+      title: '支付中...',
+      mask: true
+    });
     let parkId = e.currentTarget.dataset.idx;
     let that = this;
     let userId = wx.getStorageSync('userInfo').userId
-    wx.request({
-      url: getApp().globalData.postHeadAgreement +'/restapi/wechat/queryOccupyFeeOrder',
-      data: {
-        userId: userId,
-        orderId:parkId,
-        searchIndex: null,
-        pagenum: that.data.pagenum++,
-        pagesize: 10,
-      },
-      method: 'POST',
+    this.queryOccupyById(userId,parkId).then(res=> {
+      wx.hideLoading();
+      let {
+        order,
+      } = that.data;
+      log.info('[订单支付]', '[用户触发支付订单]', '[wx.login请求]');
+    wx.login({
       success(res) {
-        console.log("更具订单号插叙",res);
-        // this.setData({
-        //   order:res.data
-        // })
+        console.log(res);
+        log.info('[订单支付]', '[用户触发支付订单]', '[wx.login响应]',res);
+        if (res.code) {
+          // 发起网络请求
+          log.info('[订单支付]', '[服务端订单支付]', '[请求]', {
+            outTradeNo: order.orderId, //订单号
+            totalFee: order.occupyFee, //钱
+            code: res.code,
+            user_id: userId
+          });
+          wx.request({
+            url: getApp().globalData.postHeadAgreement +'/restapi/wechatpay/occupyFeeOrderPayfor',
+            data: {
+              outTradeNo: order.orderId, //订单号
+              totalFee: order.occupyFee, //钱
+              code: res.code,
+              user_id: userId
+            },
+            method: 'POST',
+            header: {
+              'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
+            },
+            success(res1) {
+              let {
+                data
+              } = res1;
+              log.info('[订单支付]', '[服务端订单支付]', '[响应]', data);
+              console.log(res1);
+              if (data && data.code == 200) {
+                if (data.result) {
+                  //wx.showModal({
+                  //  showCancel: false,
+                  //  content: '请微信支付'
+                  // });
+                  log.info('[订单支付]', '[余额不足微信支付]','[请求]',{
+                    timeStamp: data.result.timeStamp,
+                    nonceStr: data.result.nonceStr,
+                    package: data.result.package,
+                    signType: data.result.signType,
+                    paySign: data.result.paySign});
+                  wx.requestPayment({
+                    timeStamp: data.result.timeStamp,
+                    nonceStr: data.result.nonceStr,
+                    package: data.result.package,
+                    signType: data.result.signType,
+                    paySign: data.result.paySign,
+                    success(res2) {
+                      log.info('[订单支付]', '[余额不足微信支付成功]', '[响应]', res2);
+                      log.info('[订单支付]', '[微信支付成功回调服务端]', '[请求]', {
+                        //chargPileId,
+                        //userId,
+                        orderid: order.orderId
+                      });
+                      wx.hideLoading();
+                      wx.showModal({
+                        showCancel: false,
+                        content: '支付订单成功',
+                        confirmColor:'#00AADD',
+                        success(res) {
+                          if (res.confirm) {
+                            that.resetListZero(); 
+                            that.getPage();
+                          }
+                        }
+                      });
+                     
+                    },
+                    fail(res3) {
+                      wx.hideLoading();
+                      log.info('[订单支付]', '[余额不足微信支付]', '[fail]', res3);
+                      console.log(res3);
+                    }
+                  });
+                } else {
+                  wx.hideLoading();
+                  that.setData({
+                    orderFlag: true
+                  });
+                  wx.showModal({
+                    showCancel: false,
+                    content: data.msg,
+                    confirmColor:'#00AADD',
+                  });
+                }
+                log.info('[订单支付]', '[服务端订单支付]', '[余额支付成功]', data);
+              } else {
+                wx.hideLoading();
+                wx.showModal({
+                  showCancel: false,
+                  content: data.msg,
+                  confirmColor:'#00AADD',
+                });
+                log.info('[订单支付]', '[服务端订单支付]', '[失败data null||data.code<>200]', data);
+              }
+            }
+          });
+        } else {
+          wx.hideLoading();
+          console.log('登录失败!' + res.errMsg);
+          log.info('[订单支付]', '[用户触发支付订单]', '[wx.login响应失败code null]', res);
+        }
       }
     });
-    // let {
-    //   order,
-    // } = this.data;
-    // log.info('[订单支付]', '[用户触发支付订单]', '[wx.login请求]');
-    // wx.login({
-    //   success(res) {
-    //     console.log(res);
-    //     log.info('[订单支付]', '[用户触发支付订单]', '[wx.login响应]',res);
-    //     if (res.code) {
-    //       // 发起网络请求
-    //       log.info('[订单支付]', '[服务端订单支付]', '[请求]', {
-    //         outTradeNo: order.orderid, //订单号
-    //         totalFee: order.chargallmoney, //钱
-    //         code: res.code,
-    //         user_id: userId
-    //       });
-    //       wx.request({
-    //         url: getApp().globalData.postHeadAgreement +'/restapi/wechatpay/chargpayfor',
-    //         data: {
-    //           outTradeNo: order.orderid, //订单号
-    //           totalFee: order.chargallmoney, //钱
-    //           code: res.code,
-    //           user_id: userId
-    //         },
-    //         method: 'POST',
-    //         header: {
-    //           'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
-    //         },
-    //         success(res1) {
-    //           let {
-    //             data
-    //           } = res1;
-    //           log.info('[订单支付]', '[服务端订单支付]', '[响应]', data);
-    //           console.log(res1);
-    //           if (data && data.code == 200) {
-    //             if (data.result) {
-    //               //wx.showModal({
-    //               //  showCancel: false,
-    //               //  content: '请微信支付'
-    //               // });
-    //               log.info('[订单支付]', '[余额不足微信支付]','[请求]',{
-    //                 timeStamp: data.result.timeStamp,
-    //                 nonceStr: data.result.nonceStr,
-    //                 package: data.result.package,
-    //                 signType: data.result.signType,
-    //                 paySign: data.result.paySign});
-    //               wx.requestPayment({
-    //                 timeStamp: data.result.timeStamp,
-    //                 nonceStr: data.result.nonceStr,
-    //                 package: data.result.package,
-    //                 signType: data.result.signType,
-    //                 paySign: data.result.paySign,
-    //                 success(res2) {
-    //                   log.info('[订单支付]', '[余额不足微信支付成功]', '[响应]', res2);
-    //                   log.info('[订单支付]', '[微信支付成功回调服务端]', '[请求]', {
-    //                     //chargPileId,
-    //                     //userId,
-    //                     orderid: order.orderid
-    //                   });
-    //                   wx.hideLoading();
-    //                   wx.showModal({
-    //                     showCancel: false,
-    //                     content: '支付订单成功',
-    //                     confirmColor:'#00AADD',
-    //                   });
-
-    //                   that.setData({
-    //                     orderFlag:true 
-    //                   });
-    //                 },
-    //                 fail(res3) {
-    //                   wx.hideLoading();
-    //                   log.info('[订单支付]', '[余额不足微信支付]', '[fail]', res3);
-    //                   console.log(res3);
-    //                 }
-    //               });
-    //             } else {
-    //               wx.hideLoading();
-    //               that.setData({
-    //                 orderFlag: true
-    //               });
-    //               wx.showModal({
-    //                 showCancel: false,
-    //                 content: data.msg,
-    //                 confirmColor:'#00AADD',
-    //               });
-    //             }
-    //             log.info('[订单支付]', '[服务端订单支付]', '[余额支付成功]', data);
-    //           } else {
-    //             wx.hideLoading();
-    //             wx.showModal({
-    //               showCancel: false,
-    //               content: data.msg,
-    //               confirmColor:'#00AADD',
-    //             });
-    //             log.info('[订单支付]', '[服务端订单支付]', '[失败data null||data.code<>200]', data);
-    //           }
-    //         }
-    //       });
-    //     } else {
-    //       wx.hideLoading();
-    //       console.log('登录失败!' + res.errMsg);
-    //       log.info('[订单支付]', '[用户触发支付订单]', '[wx.login响应失败code null]', res);
-    //     }
-    //   }
-    // });
-
+    })
+  },
+  queryOccupyById(userId,parkId) {
+    return new Promise((resolve, reject) => {
+      let that = this;
+      wx.request({
+        url: getApp().globalData.postHeadAgreement +'/restapi/wechat/queryOccupyById',
+        data: {
+          userId: userId,
+          id:parkId,
+          searchIndex: 3 // 未支付
+        },
+        method: 'POST',
+        success(res) {
+          if (res.data.code == 200) {
+            console.log("更具订单号插叙",res.data.result);
+            that.setData({
+            order:res.data.result
+          })
+          resolve(res.data.result);
+          }else{
+            resolve(res.data);
+          }
+        },
+        fail(err) {
+          console.error('请求失败', err);
+          reject(err);
+        }   
+      });
+    });
   },
   cancleBtn(e){
     let  that = this
@@ -377,9 +356,6 @@ Page({
     })
  },
 
- confirmM: function (e) {
-    console.log("姓名:" + this.data.name + "  电话:" + this.data.phoneNum);
- },
 
  iName: function (e) {
     this.setData({