Procházet zdrojové kódy

完善占位费功能

jiuling před 2 dny
rodič
revize
7014b64fec

+ 51 - 6
components/parking-order/parking-order.js

@@ -8,28 +8,73 @@ Component({
     occupyOrder:{
       type: Array,
       value: [] 
+    },
+    showPopup:{
+      type: Boolean,
+      value: false 
     }
   },
   lifetimes:{
     attached(){
+      // this.loadOccupyOrder();
       // 页面加载时显示弹窗
-      this.setData({
-        showPopup: true
-      });
-    }
+      let isLogin = wx.getStorageSync('isLogin');
+      if (isLogin) {
+        this.loadOccupyOrder();
+      }
+    },
+  },
+  pageLifetimes:{
+    // 组件所在页面的生命周期函数
+    show: function () {
+      // let isLogin = wx.getStorageSync('isLogin');
+      // if (isLogin) {
+      //   this.loadOccupyOrder();
+      // }
+     },
   },
-
   /**
    * 组件的初始数据
    */
   data: {
-    showPopup: true,
+    showPopup: false,
+    occupyFeeOrderList:[]
   },
 
   /**
    * 组件的方法列表
    */
   methods: {
+    loadOccupyOrder(){
+      let that = this;
+      wx.request({
+        url: getApp().globalData.postHeadAgreement +'/restapi/wechat/queryOccupyFeeOrder',
+        data: {
+          userId: wx.getStorageSync('userInfo').userId,
+          searchIndex: 2,
+          pagenum: this.data.pagenum++,
+          pagesize: 10,
+        },
+        method: 'POST',
+        success(res) {
+          console.log("占位费",res);
+          // if (res.data.result.total > 0) {
+          //   that.setData({
+          //     showPopup:true
+          //   })
+          // }
+          if (res.data.result) {
+            let {
+              rows: occupyFeeOrderList,
+            } = res.data.result;
+
+            that.setData({
+              occupyFeeOrderList: that.data.occupyFeeOrderList.concat(occupyFeeOrderList),
+            });
+          }
+        }
+      });
+    },
     handleConfirm() {
       // 点击确认按钮
       this.setData({

+ 10 - 9
components/parking-order/parking-order.wxml

@@ -1,5 +1,6 @@
 <!--components/parking-order.wxml-->
-<view class="popup-mask" wx:if="{{showPopup}}" wx:for="{{occupyOrder}}" wx:key="id">
+<view class="popup-mask" wx:if="{{showPopup}}" wx:for="{{occupyFeeOrderList}}" wx:key="id">
+  <!-- <view class="popup-mask" wx:for="{{occupyFeeOrderList}}" wx:key="id"> -->
   <view class="popup-content">
     <!-- 标题 -->
     <view class="popup-title">占位提醒</view>
@@ -9,8 +10,8 @@
           <image src='/images/zhangweifei.png'></image>
         </view>
         <view class='charging_text_title1'>
-          <text class='bold'>{{item.chargstationname}}</text>
-          <text class="chargpile">{{item.chargpileids}} </text>
+          <text class='bold occupyTest'>{{item.chargstationname}}</text>
+          <text class="chargpile occupyTest">{{item.chargpileids}} </text>
         </view>
       </view>
     <!-- 充电桩名称 -->
@@ -18,18 +19,18 @@
     <!-- 时间信息 -->
     <view class="time-info">
       <view class="info-row">
-        <text class="label">占位开始时间:</text>
-        <text class="value">{{item.occupyBeginTime || 0}}</text>
+        <text class="label occupyTest">占位开始时间:</text>
+        <text class="value occupyTest">{{item.occupyBeginTime || 0}}</text>
       </view>
       <view class="info-row">
-        <text class="label">已占位时长:</text>
-        <text class="value">{{item.occupyTime || 0}}</text>
+        <text class="label occupyTest">已占位时长:</text>
+        <text class="value occupyTest">{{item.occupyTime || 0}}</text>
       </view>
     </view>
     <!-- 费用信息 -->
     <view class="info-row fee-info">
-      <text class="label">已产生占位费:</text>
-      <text class="value">{{item.occupyFee || 0}}</text>
+      <text class="label occupyTest">已产生占位费:</text>
+      <text class="value occupyTest">{{item.occupyFee || 0}}</text>
     </view>
     <!-- 警告文字 -->
     <view class="warning-text">

+ 1 - 1
components/parking-order/parking-order.wxss

@@ -156,7 +156,7 @@
   white-space: nowrap;
   overflow: hidden;
 }
-text {
+text .occupyTest {
   margin: 0 0 20rpx 0;
   display: block;
   font-size: 24rpx;

+ 63 - 5
pages/charginfo/charginfo.js

@@ -3,7 +3,7 @@ import * as lf from '../../ec-canvas/echarts-liquidfill';
 
 
 let log = require('../../utils/log.js');
-
+let wechat = require("../../utils/wechat");
 Page({
 
   /**
@@ -47,9 +47,9 @@ Page({
     // 停车时间
     parkTime: 0,
     activeTab: '0',
-    scrollTop:0
+    scrollTop:0,
     occupyFee:{},
-    showOccupyFee:false
+    showOccupyFee:false,
   },
   execParking(that,stationId){
     wx.request({
@@ -442,9 +442,67 @@ Page({
         url
     });
   },
-  goScanResult(e){
+  async goScanResult(e){
     // scan_result
-
+    
+    let api = getApp().globalData.postHeadAgreement
+    let path = 'restapi/wechat/queryOccupyFeeOrder'
+    let params = {
+      userId: wx.getStorageSync('userInfo').userId,
+      searchIndex: 2,
+      pagenum: this.data.pagenum++,
+      pagesize: 10,
+  }
+  let paramsNew = {
+    userId: wx.getStorageSync('userInfo').userId,
+    searchIndex: 3,
+    pagenum: this.data.pagenum++,
+    pagesize: 10,
+}
+  try{
+    const resultOrder = await wechat.request(api, path, paramsNew);
+      if (resultOrder.data.code == 200) {
+          if (resultOrder.data.result.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;
+                }
+              }
+            });
+      }
+    }
+    const result = await wechat.request(api, path, params);
+    if (result.data.code == 200) {
+      if (result.data.result.total > 0) { // 有占位费订单不启动扫码充电
+        this.setData({
+          showPopup:true
+        })
+        return;
+      }
+    } 
+  }catch (error) {
+    console.error('查询占位费订单失败', error);
+    wx.showModal({
+      showCancel: false,
+      content: '查询占位费订单失败',
+      confirmColor:'#00AADD',
+      success: function (res) {
+        if (!res.cancel) {
+          //点击确定
+        }
+      }
+    });
+  }
   console.info('xxxxxxxxxxxxxx')
     let {
       keywords

+ 2 - 1
pages/charginfo/charginfo.json

@@ -1,6 +1,7 @@
 {
   "usingComponents": {
-    "parking-info": "/components/parking-info/parking-info"
+    "parking-info": "/components/parking-info/parking-info",
+    "parking-order": "/components/parking-order/parking-order"
   },
   "navigationBarTitleText": "充电站详情"
 }

+ 2 - 2
pages/charginfo/charginfo.wxml

@@ -75,7 +75,7 @@
     </view>
 --> <text class="parkingfee" wx:if="{{carParkingRate}}">充电即减免 <text>{{parkTime}}</text> 小时停车费</text>
 <!-- 占位费模版信息 -->
-<!-- <parking-info wx:if="{{showOccupyFee}}"  occupyFee="{{occupyFee}}"></parking-info> -->
+<parking-info wx:if="{{showOccupyFee}}"  occupyFee="{{occupyFee}}"></parking-info>
     <scroll-view class='pictureScroll' scroll-x='true'>
       <view wx:for="{{chargfeatureList}}" wx:key="unique" data-index="{{index}}" bindtap="previewImage" class="chargfeatureImage">
       <image src="{{item}}" ></image>
@@ -147,6 +147,6 @@
 
     <view class = "bottomm"></view>
   </scroll-view>
-
+  <parking-order showPopup="{{showPopup}}"></parking-order> 
 </view>
 </view >

+ 125 - 35
pages/index/index.js

@@ -80,7 +80,8 @@ Page({
     notice: null,
     carParkingRate: false,
     showPrivacy:false,
-    occupyFeeOrderList:[]
+    occupyFeeOrderList:[],
+    load:-1
   },
   howtouse(){
     wx.navigateTo({
@@ -551,39 +552,39 @@ Page({
           getApp().showNetworkError();
         }
       });
+    //   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) {
+    //             console.log("res",res);
+    //             //点击确定
+    //             let url = `/pages/ucenter/zhanw/zhanw`;
+    //             wx.navigateTo({
+    //               url
+    //             })
+    //             return;
+    //           }
+    //         }
+    //       });
+    //     }
+    //   })
+    //   // 查询占位中订单
+    // this.queryParkOrder(2).then(res=>{
+    //   // console.log("我被调用了");
+    //   if (res.total > 0) { // 有占位费订单不启动扫码充电
+    //     this.setData({
+    //       showPopup:true
+    //     })
+    //     return;
+    //   }
+    // });
     }
-    // 占位费查询
-    // that.loadOccupyOrder()
-
-  },
-  loadOccupyOrder(){
-    let that = this;
-    wx.request({
-      url: getApp().globalData.postHeadAgreement +'/restapi/wechat/queryOccupyFeeOrder',
-      data: {
-        userId: wx.getStorageSync('userInfo').userId,
-        searchIndex: 2,
-        pagenum: this.data.pagenum++,
-        pagesize: 10,
-      },
-      method: 'POST',
-      success(res) {
-        console.log("占位费",res);
-        if (res.data.result.rows) {
-          let {
-            rows: occupyFeeOrderList
-          } = res.data.result;
-          // that.startTimeOrder(charginglogs);
-          // that.formatCharginglogs(occupyFeeOrderList);
-          // wx.hideLoading()
-          that.setData({
-            occupyFeeOrderList: that.data.occupyFeeOrderList.concat(occupyFeeOrderList),
-            // total: res.data.result.total,
-            // dataLoading: false
-          });
-        }
-      }
-    });
   },
   //跳转个人中心
   bindUserAvatarUrl() {
@@ -832,7 +833,35 @@ Page({
     this.click_scan_control("",true)
   },
 
-  click_scan_control(scanResult,inner) {
+  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;
+            }
+          }
+        });
+      }
+    })
+    const result = await this.queryParkOrder(2);
+    if (result.total > 0) { // 有占位费订单不启动扫码充电
+      this.setData({
+        showPopup:true
+      })
+      return;
+    }
     if(this.data.scanFlag){
       return;
     }
@@ -1222,6 +1251,36 @@ Page({
       return true;
     }
   },
+  // 根据状态查询占位费订单
+  queryParkOrder(status) {
+    return new Promise((resolve, reject) => {
+      let that = this;
+      wx.request({
+        url: getApp().globalData.postHeadAgreement + '/restapi/wechat/queryOccupyFeeOrder',
+        data: {
+          userId: wx.getStorageSync('userInfo').userId,
+          searchIndex: status,
+          pagenum: that.data.pagenum++,
+          pagesize: 10,
+        },
+        method: 'POST',
+        success(res) {
+          console.log('请求成功,处理数据');
+          if(res.data.code==200){
+            if (res.data.result.total > 0) {
+              resolve(res.data.result);
+            }
+        }else{
+          resolve(res.data);
+        }
+        },
+        fail(err) {
+          console.error('请求失败', err);
+          reject(err);
+        }
+      });
+    });
+  },
 
   /**
    * 生命周期函数--监听页面显示
@@ -1307,7 +1366,38 @@ Page({
             getApp().showNetworkError();
         }
     });
-
+            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) {
+                      console.log("res",res);
+                      //点击确定
+                      let url = `/pages/ucenter/zhanw/zhanw`;
+                      wx.navigateTo({
+                        url
+                      })
+                      return;
+                    }
+                  }
+                });
+              }
+            })
+            // 查询占位中订单
+          this.queryParkOrder(2).then(res=>{
+            // console.log("我被调用了");
+            if (res.total > 0) { // 有占位费订单不启动扫码充电
+              this.setData({
+                showPopup:true
+              })
+              return;
+            }
+          });     
     } else {
       //未登录信息
       this.setData({

+ 1 - 1
pages/index/index.wxml

@@ -71,7 +71,7 @@
   </view>
 </view>
 <!-- 占位费订单 -->
-<!-- <parking-order occupyOrder="{{occupyFeeOrderList}}"></parking-order>  -->
+<parking-order showPopup="{{showPopup}}"></parking-order> 
 <!-- 通知 -->
 <van-dialog custom-class="privacy_box" 
 use-slot

+ 1 - 1
pages/outmoney/outmoney.js

@@ -143,7 +143,7 @@ Page({
                   confirmColor:'#00AADD',
                 });
                 log.info('[提现]', '[服务端提现]', '[提现成功]', data);
-              } else {
+              } else {// 查询用户是否有占位中的占位费订单
                 wx.showModal({
                   showCancel: false,
                   content: data.msg,

+ 5 - 4
pages/scan_result/scan_result.js

@@ -109,14 +109,15 @@ Page({
 
       }
     });
+    this.getOccupyFee();
   },
   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
+      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
     }
     if (Object.keys(test).length > 0) { // 判断对象数据是否为空
       this.setData({

+ 1 - 1
pages/scan_result/scan_result.wxml

@@ -90,7 +90,7 @@
     <rich-text style='line-height:36rpx;color:#1D9BF7;font-size:30rpx;word-break:break-all;font-weight: bold;'>充电即减免 <text class="richHourNum">{{parkTime}}</text>小时停车费。请您确认入场车辆与启动充电时录入的车牌信息保持一致,如录入不一致将无法享受充电减免停车费优惠。</rich-text>
   </view>
   <!-- 占位费模版信息 -->
-<!-- <parking-info wx:if="{{showOccupyFee}}"  occupyFee="{{occupyFee}}"></parking-info> -->
+<parking-info wx:if="{{showOccupyFee}}"  occupyFee="{{occupyFee}}"></parking-info>
   <!-- <block wx:if="{{authStatus==0}}"> -->
   <block wx:if="{{false}}">
   <image class="scan_img" src="{{url}}" data-src="{{url}}" bindtap="previewImage"></image>

+ 3 - 3
pages/ucenter/index/index.wxml

@@ -82,9 +82,9 @@
           <image src='/images/enter.png'></image>
         </view>
       </view>   
-      <!-- <view class="zan-cell" wx:if='{{!userInfo.flag}}' hover-class="active" bindtap="gozhanw">
+      <view class="zan-cell" wx:if='{{!userInfo.flag}}' hover-class="active" bindtap="gozhanw">
         <view class="zan-icon">
-          <!-- <image src='/images/purse.png'></image>
+          <!-- <image src='/images/purse.png'></image> -->
           <image src='/images/column.png'></image>
         </view>
         <view class="zan-text">
@@ -93,7 +93,7 @@
         <view class="zan-ft">
           <image src='/images/enter.png'></image>
         </view>
-      </view>    -->
+      </view>   
       <view class="zan-cell" wx:if='{{!userInfo.flag}}' hover-class="active" bindtap="goPurse">
         <view class="zan-icon">
           <!-- <image src='/images/purse.png'></image> -->

+ 144 - 3
pages/ucenter/zhanw/zhanw.js

@@ -22,6 +22,9 @@ Page({
     customerServiceFlag: false,
     cancleBtnFlag: false,
     servicetel: getApp().globalData.helpPhoneNum,
+    orderid: null,
+    userId: null,
+    order: null,
   },
   switchBar(e){
     let searchIndex = e.currentTarget.dataset.idx;
@@ -101,14 +104,14 @@ Page({
       url: getApp().globalData.postHeadAgreement +'/restapi/wechat/queryOccupyFeeOrder',
       data: {
         userId: wx.getStorageSync('userInfo').userId,
-        searchIndex: that.data.searchIndex<0?null:that.data.searchIndex,
+        searchIndex: that.data.searchIndex<0?-1:that.data.searchIndex,
         pagenum: this.data.pagenum++,
         pagesize: 10,
       },
       method: 'POST',
       success(res) {
         console.log("占位费",res);
-        if (res.data.result.rows) {
+        if (res.data.code == 200) {
           let {
             rows: occupyFeeOrderList
           } = res.data.result;
@@ -120,6 +123,8 @@ Page({
             total: res.data.result.total,
             dataLoading: false
           });
+        }else{
+          wx.hideLoading()
         }
       }
     });
@@ -204,11 +209,147 @@ Page({
       });
     }
   },
-  customerServiceBtn(){
+  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
+    // });
+    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',
+      success(res) {
+        console.log("更具订单号插叙",res);
+        // this.setData({
+        //   order:res.data
+        // })
+      }
+    });
+    // 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);
+    //     }
+    //   }
+    // });
+
+  },
   cancleBtn(e){
     let  that = this
     let reservId = e.currentTarget.dataset.idx;

+ 1 - 1
pages/ucenter/zhanw/zhanw.wxml

@@ -43,7 +43,7 @@
       </view>
       <view class="button-container">
   <!-- 使用 wx:if 动态控制按钮显示 -->
-  <view  class="downBtn" wx:if="{{item.customerServiceFlag}}" bindtap="customerServiceBtn" data-idx="{{item.id}}">去支付</view>
+  <view  class="downBtn" wx:if="{{item.customerServiceFlag}}" bindtap="payOrder" data-idx="{{item.id}}">去支付</view>
   <view  class="downBtn" wx:if="{{item.cancleBtnFlag}}" bindtap="cancleBtn">联系客服</view>
   <!-- <modal hidden="{{hiddenmodalput}}" title="完善资料" confirm-text="提交" cancel-text="取消" bindcancel="cancelM" bindconfirm="confirmM">
       <input bindinput='iName' type='text' placeholder="请输入姓名..." auto-focus/>