Browse Source

我的预约

XWookey 1 year ago
parent
commit
a48803b239

+ 1 - 2
pages/charginfo/charginfo.wxml

@@ -101,8 +101,7 @@
       <view class="chargInfo_v">
       <view class="chargInfo_v_name">{{item.chargPileName}}</view>
       <!-- GUYUTEST -->
-      <view class="chargInfo_v_id">{{item.chargPileId}}  <text wx:if="{{item.openStatus}}" class="seeReservation" bindtap="seeReservation">查看预约</text></view>
-      <view class="chargInfo_v_id">{{item.chargPileId}}  <text wx:if="true" class="seeReservation" bindtap="seeReservation"  data-idx="{{item}}">查看预约</text></view>
+      <view class="chargInfo_v_id">{{item.chargPileId}}  <text wx:if="{{item.openStatus}}" class="seeReservation" bindtap="seeReservation" bindtap="seeReservation"  data-idx="{{item}}">查看预约</text></view>
       </view>
       <view class="iconleft" >
         <view class="icon {{item.pileType=='慢充'?'slowBar':'fastBar'}}">{{item.pileType=='慢充'?'慢':'快'}}</view>

+ 30 - 14
pages/reservation/reservation.js

@@ -27,6 +27,7 @@ Page({
     dayFlag2:'',
     dayFlag3:'',
     dayFlag4:'',
+    reservationBtn: false,
   },
   goReservation(){
     let {
@@ -100,12 +101,41 @@ Page({
       }
     )
 
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+    let that = this;
+    let {
+      chargStationId,
+      chargPileName,
+      chargPileId,
+      chargPileIdId,
+      userId,
+      chargStationName
+    } = this.data;
     wx.request({
       url: getApp().globalData.postHeadAgreement +'/restapi/wechat/ReservOrder?userId=' + userId + '&reservPileNo=' + chargPileId,
       data: {
       },
       method: 'POST',
       success(res) {
+        if(res?.data?.result?.reservationConfig){
+          that.setData({
+            reservationBtn: true
+          })
+        }
+
         let earliestReservTime = res?.data?.result?.reservationConfig?.earliestReservTime
         earliestReservTime = earliestReservTime?earliestReservTime:0;
         let advanceReservDays = res?.data?.result?.reservationConfig?.advanceReservDays
@@ -172,20 +202,6 @@ Page({
   },
 
   /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow() {
-
-  },
-
-  /**
    * 生命周期函数--监听页面隐藏
    */
   onHide() {

+ 1 - 1
pages/reservation/reservation.wxml

@@ -40,4 +40,4 @@
 <view class="scrollView" wx:if="{{timeList.length == 0}}">
   <view class="noList">暂无已预约时段</view>
 </view>
-<button class='login_button' bindtap="goReservation" >预约充电</button>
+<button class='login_button' bindtap="goReservation" wx:if="{{reservationBtn}}" >预约充电</button>

+ 52 - 58
pages/reservation/reservationEdit.js

@@ -148,67 +148,61 @@ Page({
       return;
     }
     reservChargeEndTime = reservChargeEndTime + ':00'
-    wx.request({
-      // url: getApp().globalData.postHeadAgreement +'/restapi/wechat/reserv2?reservChargeStartTime=' + reservChargeStartTime +
-      // '&reservChargeEndTime=' + reservChargeEndTime + 
-      // '&reservPile.id=' + reservPileId + 
-      // '&reservStation.id=' + reservStationId + 
-      // '&sysUser.id=' + sysUserId,
-      url: getApp().globalData.postHeadAgreement +'/restapi/wechat/reserv2',
-      data: {
-        reservChargeStartTime:reservChargeStartTime,
-        reservChargeEndTime:reservChargeEndTime,
-        reservPile:{
-          id:reservPileId
-        },
-        reservStation:{
-          id:reservStationId
-        },
-        sysUser:{
-          userId:sysUserId
-        },
-      },
-      method: 'POST',
-      success(res) {
-        console.info(res)
-        if(res?.data?.msg=="操作成功"){
-          wx.showModal({
-            title: '提示',
-            content: '预约成功',
-            showCancel:false,
-            confirmColor:'#00AADD',
-            complete: (res) => {
-              if (res.cancel) {
-                
-              }
-          
-              if (res.confirm) {
-                wx.requestSubscribeMessage({
-                  tmplIds: ['DA80dlHRpvYMfZVICp-SVPPKuZOKtUd8PT0Rl7PZzuI'],
-                  success (res) { 
-                    console.info(res)
+    wx.requestSubscribeMessage({
+      tmplIds: ['DA80dlHRpvYMfZVICp-SVPPKuZOKtUd8PT0Rl7PZzuI'],
+      success (res) { 
+        wx.request({
+          // url: getApp().globalData.postHeadAgreement +'/restapi/wechat/reserv2?reservChargeStartTime=' + reservChargeStartTime +
+          // '&reservChargeEndTime=' + reservChargeEndTime + 
+          // '&reservPile.id=' + reservPileId + 
+          // '&reservStation.id=' + reservStationId + 
+          // '&sysUser.id=' + sysUserId,
+          url: getApp().globalData.postHeadAgreement +'/restapi/wechat/reserv',
+          data: {
+            reservChargeStartTime:reservChargeStartTime,
+            reservChargeEndTime:reservChargeEndTime,
+            reservPile:{
+              id:reservPileId
+            },
+            reservStation:{
+              id:reservStationId
+            },
+            sysUser:{
+              userId:sysUserId
+            },
+          },
+          method: 'POST',
+          success(res) {
+            console.info(res)
+            if(res?.data?.msg=="操作成功"){
+              wx.showModal({
+                title: '提示',
+                content: '预约成功',
+                showCancel:false,
+                confirmColor:'#00AADD',
+                complete: (res) => {
+                  if (res.cancel) {
+                    
                   }
-                })
-              }
-            }
-          });
-        }else{
-          wx.showModal({
-            title: '提示',
-            content: '预约失败',
-            showCancel:false,
-            confirmColor:'#00AADD',
-          });
-          wx.requestSubscribeMessage({
-            tmplIds: ['DA80dlHRpvYMfZVICp-SVPPKuZOKtUd8PT0Rl7PZzuI'],
-            success (res) { 
-              console.info(res)
+              
+                  if (res.confirm) {
+                    wx.navigateBack()
+                  }
+                }
+              });
+            }else{
+              wx.showModal({
+                title: '提示',
+                content: '预约失败',
+                showCancel:false,
+                confirmColor:'#00AADD',
+              });
             }
-          })
-        }
-
+          }
+        });
       }
-    });
+    })
+
   },
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 1 - 6
pages/ucenter/charginglog/charginglog.wxml

@@ -32,12 +32,7 @@
       <text class='inline red'>{{charginglog.chargmoney}}</text>
       <text class='inline gray1'>元</text>
     </view>
-    <text class='gray' wx:if="{{charginglog.paytype==1}}" decode='true'>支付方式:余额</text>
-    <text class='gray' wx:if="{{charginglog.paytype==2}}" decode='true'>支付方式:信用欠款</text>
-    <text class='gray' wx:if="{{charginglog.paytype==3}}" decode='true'>支付方式:支付宝</text>
-    <text class='gray' wx:if="{{charginglog.paytype==4}}" decode='true'>支付方式:微信支付</text>
-    <text class='gray' wx:if="{{charginglog.paytype==5}}" decode='true'>支付方式:银联卡</text>
-    <text class='gray' wx:if="{{charginglog.paytype==6}}" decode='true'>支付方式:虚拟货币</text>
+    
   </view>
 
   

+ 145 - 24
pages/ucenter/yuyt/yuyt.js

@@ -6,7 +6,8 @@ Page({
    * 页面的初始数据
    */
   data: {
-    charginglogs: [],
+    searchIndex:-1,
+    reservUserOrderList: [],
     pagesize:10,
     pagenum:1,
     total:-1,
@@ -14,8 +15,22 @@ Page({
     dataLoading: false,
     finishedLoadTap: 0,
     finishedLoadShowTimes: 0,
+    chongdianzhuangmingcheng: false,
+    chongdianzhuangbianhao: false,
+    chongdianshichang: false,
+    chongdiankaishijieshu: false,
+    customerServiceFlag: false,
+    cancleBtnFlag: false,
+    servicetel: getApp().globalData.helpPhoneNum,
+  },
+  switchBar(e){
+    let searchIndex = e.currentTarget.dataset.idx;
+    this.setData({
+      searchIndex
+    })
+    this.resetListZero();
+    this.getPage();
   },
-
   /**
    * 生命周期函数--监听页面加载
    */
@@ -25,13 +40,35 @@ Page({
     let that = this;
     // 页面显示
     if (userInfo && isLogin) {
+      this.resetListZero();
       this.getPage();
     }
+    
+  },
+  resetListZero(){
+    let reservUserOrderList =  []
+    let pagesize = 10
+    let pagenum = 1
+    let total = -1
+    let loadTotal =  0
+    let dataLoading =  false
+    let finishedLoadTap =  0
+    let finishedLoadShowTimes =  0
+    this.setData({
+      reservUserOrderList,
+      pagesize,
+      pagenum,
+      total,
+      loadTotal,
+      dataLoading,
+      finishedLoadTap,
+      finishedLoadShowTimes,
+    })
   },
   getPage(){
-    console.info(this.data.charginglogs.length + " MMM " + this.data.total)
+    // console.info(this.data.reservUserOrderList.length + " MMM " + this.data.total)
     
-    if(this.data.charginglogs.length == this.data.total){
+    if(this.data.reservUserOrderList.length == this.data.total){
       this.setData({
         finishedLoadTap:this.data.finishedLoadTap+1
       })
@@ -61,9 +98,10 @@ Page({
   let that = this;
 
     wx.request({
-      url: getApp().globalData.postHeadAgreement +'/restapi/pileLog/wechatuserallcharglog',
+      url: getApp().globalData.postHeadAgreement +'/restapi/wechat/ReservUserOrder',
       data: {
         userId: wx.getStorageSync('userInfo').userId,
+        searchIndex: that.data.searchIndex<0?null:that.data.searchIndex,
         pagenum: this.data.pagenum++,
         pagesize: 10,
       },
@@ -72,13 +110,13 @@ Page({
         console.log(res);
         if (res.data.result.rows) {
           let {
-            rows: charginglogs
+            rows: reservUserOrderList
           } = res.data.result;
           // that.startTimeOrder(charginglogs);
-          that.formatCharginglogs(charginglogs);
+          that.formatCharginglogs(reservUserOrderList);
           wx.hideLoading()
           that.setData({
-            charginglogs: that.data.charginglogs.concat(charginglogs),
+            reservUserOrderList: that.data.reservUserOrderList.concat(reservUserOrderList),
             total: res.data.result.total,
             dataLoading: false
           });
@@ -88,27 +126,76 @@ Page({
   },
 
 
-  formatCharginglogs(charginglogs) {
-    charginglogs.forEach((item, index) => {
+  formatCharginglogs(formatCharginglogs) {
+    formatCharginglogs.forEach((item, index) => {
       try {
-        var startDate = Util.parseDate(item.chargstarttime);
-        var endDate = Util.parseDate(item.chargendtime)
-        var totalTime = Math.round((endDate.getTime() - startDate.getTime()) / 60000);
-        var totalTimeHour = Math.floor(totalTime / 60);
-        var totalTimeMinute = totalTime % 60;
-        var startTime = startDate.getFullYear() + "年" + Util.formatNumber(startDate.getMonth() + 1) + '月' + Util.formatNumber(startDate.getDate()) + '日  ' + Util.formatNumber(startDate.getHours()) + ':' + Util.formatNumber(startDate.getMinutes()) + ':' + Util.formatNumber(startDate.getSeconds());
-        var 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) + "分";
-        item.startTime = startTime;
-        item.endTime = endTime;
-        item.totalTime = totalTime;
-        item.chargallmoney = item.chargallmoney.toFixed(2);
-        item.chargservice = item.chargservice.toFixed(2);
-        item.chargmoney = item.chargmoney.toFixed(2);
+          // 时间截取
+          item.reservChargeStartTime = item.reservChargeStartTime.substr(0,16)
+          item.reservChargeEndTime = item.reservChargeEndTime.substr(0,16)
+          // 状态翻译
+          if(item.reservStatus==0){
+            item.reservStatusCN = '待履约'
+          }else if(item.reservStatus==1){
+            item.reservStatusCN = '已取消'
+          }else if(item.reservStatus==2){
+            item.reservStatusCN = '已履约'
+          }else if(item.reservStatus==3){
+            item.reservStatusCN = '已违约'
+          }else if(item.reservStatus==4){
+            item.reservStatusCN = '已纠正'
+          };
+          // 判断标记为  chongdianzhuangmingcheng chongdianzhuangbianhao chongdianshichang chongdiankaishijieshu
+          let chongdianzhuangmingcheng =  false
+          let chongdianzhuangbianhao =  false
+          let chongdianshichang =  false
+          let chongdiankaishijieshu =  false
+          let customerServiceFlag = false;
+          let cancleBtnFlag= false;
+          if(item.reservStatus==2){
+            // 已履约
+            // if(){
+            //   chongdianzhuangmingcheng = true
+            //   chongdianzhuangbianhao = true
+            // }
+          }
+          if(item.reservStatus==3){
+            customerServiceFlag = true;
+          }
+          if(item.reservStatus==0){
+            cancleBtnFlag = true;
+          }
+          item.chongdianzhuangmingcheng = chongdianzhuangmingcheng;
+          item.chongdianzhuangbianhao = chongdianzhuangbianhao;
+          item.chongdianshichang = chongdianshichang;
+          item.chongdiankaishijieshu = chongdiankaishijieshu;
+          item.customerServiceFlag = customerServiceFlag;
+          item.cancleBtnFlag = cancleBtnFlag;
         //console.log(item.chargPile);
       } catch (err) {
         //在这里处理错误
       }
+      try {
+        let chargePile = item.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) {
+        //在这里处理错误
+      }
+
+
     });
 
   },
@@ -119,6 +206,40 @@ Page({
       });
     }
   },
+  customerServiceBtn(){
+    wx.makePhoneCall({
+      phoneNumber: this.data.servicetel
+    })
+  },
+  cancleBtn(e){
+    let reservId = e.currentTarget.dataset.idx;
+    let userInfo = wx.getStorageSync('userInfo');
+    let isLogin = wx.getStorageSync('isLogin');
+    wx.showModal({
+      title: '提示',
+      content: '是否取消预约',
+      complete: (res) => {
+        if (res.cancel) {
+          
+        }
+    
+        if (res.confirm) {
+          wx.request({
+            url: getApp().globalData.postHeadAgreement +'/restapi/wechat/canelReserv?userName=' + userInfo.loginName + '&reservId=' + reservId,
+            data: {
+            },
+            method: 'POST',
+            success(res) {
+              console.info(res)
+              // TODO 重新加载页面
+            }
+          });
+        }
+      }
+    })
+
+
+  },
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

+ 1 - 1
pages/ucenter/yuyt/yuyt.json

@@ -1,4 +1,4 @@
 {
   "usingComponents": {},
-  "navigationBarTitleText": "预约充电"
+  "navigationBarTitleText": "预约记录"
 }

+ 35 - 18
pages/ucenter/yuyt/yuyt.wxml

@@ -1,8 +1,19 @@
 <!--pages/ucenter/charginglog/charginglog.wxml-->
+<view class="topBar">
+<view class="card {{searchIndex==-1?'active':''}}" data-idx="-1" bindtap="switchBar">全部</view>
+<view class="card {{searchIndex==0?'active':''}}" data-idx="0" bindtap="switchBar">待履约</view>
+<view class="card {{searchIndex==2?'active':''}}" data-idx="2" bindtap="switchBar">已履约</view>
+<view class="card {{searchIndex==1?'active':''}}" data-idx="1" bindtap="switchBar">已取消</view>
+<view class="card {{searchIndex==3?'active':''}}" data-idx="3" bindtap="switchBar">已违约</view>
+</view>
+
 <scroll-view class='context' scroll-y='true'  bindscrolltolower="bindScrollTolowerEvent" >
   <view class='context_block'></view>
   
-  <view class="text_context" wx:for="{{charginglogs}}" wx:key="id" wx:for-item="charginglog" hover-class='active'>
+  <view class="text_context" wx:for="{{reservUserOrderList}}" wx:key="id" hover-class='active'>
+  <view class="upFlag" >{{item.reservStatusCN}}</view>
+  <view class="downBtn" wx:if="{{item.cancleBtnFlag}}" bindtap="cancleBtn" data-idx="{{item.id}}">取消预约</view>
+  <view class="downBtn" wx:if="{{item.customerServiceFlag}}" bindtap="customerServiceBtn">联系客服</view>
     <!-- <view class="map-1" bindtap="getRoute">
       <image src="/images/jt.png"></image>
       <view>路线</view>
@@ -12,32 +23,38 @@
         <image src='/images/charging2_1.png'></image>
       </view>
       <view class='charging_text_title1'>
-        <text class='bold'>{{charginglog.chargStation.chargStationName}}</text>
-        <text class="h1">{{charginglog.chargStation.address}}</text>
+        <text class='bold'>{{item.reservStation.chargStationName}}</text>
+        <text class="h1">{{item.reservPile.chargPileId}}</text>
       </view>
     </view>
-    <text>{{charginglog.chargPile.chargPileName}}</text>
+    <text>{{item.reservPile.chargPileName}}</text>
+    <view  class="inline-view">
+      <view class='inlineView' decode='true'><text space="nbsp">预约时段: </text> <text class="gray2"> {{item.reservChargeStartTime}} 至 {{item.reservChargeEndTime}}</text></view>
+    </view>
     <view  class="inline-view">
-      <text class='inline' decode='true'>充电时长:{{charginglog.totalTime}}&nbsp;&nbsp;&nbsp;&nbsp;</text>
-      <text class='inline'>充电电量:{{charginglog.chargpower}}度</text>
+      <view class='inlineView' decode='true'><text space="nbsp">提交预约时间: </text>  <text class="gray2">{{item.createTime}}</text></view>
+    </view>
+    <view  class="inline-view" wx:if="{{chongdianzhuangmingcheng}}">
+      <text class='inlineView' decode='true'>启动充电桩名称: {{item.chargePile.chargPileName}}</text>
     </view>
-    
-    <text class='gray'>{{charginglog.startTime}}-{{charginglog.endTime}}</text>
-    <view style='line-height:0;'>
+    <view  class="inline-view" wx:if="{{chongdianzhuangbianhao}}">
+      <text class='inlineView' decode='true'>启动充电桩编号: {{item.chargePile.chargPileId}}</text>
+    </view>
+    <view  class="inline-view" wx:if="{{chongdianshichang}}">
+      <text class='inline' decode='true'>充电时长:{{item.chargePile.totalTime}}&nbsp;&nbsp;&nbsp;&nbsp;</text>
+      <text class='inline'>充电电量:{{item.chargePile.chargpower}}度</text>
+    </view>
+    <text class='gray'  wx:if="{{chongdiankaishijieshu}}">{{item.chargePile.startTime}}-{{item.chargePile.endTime}}</text>
+    <view style='line-height:0;'  wx:if="{{chongdianfeiyong}}">
       <text class='inline gray1'>总费用:</text>
-      <text class='inline red'>{{charginglog.chargallmoney}}</text>
+      <text class='inline red'>{{item.chargePile.chargallmoney}}</text>
       <text class='inline gray1' decode='true'>元&nbsp;&nbsp;&nbsp;&nbsp;服务费:</text>
-      <text class='inline red'>{{charginglog.chargservice}}</text>
+      <text class='inline red'>{{item.chargePile.chargservice}}</text>
       <text class='inline gray1' decode='true'>元&nbsp;&nbsp;&nbsp;&nbsp;电费:</text>
-      <text class='inline red'>{{charginglog.chargmoney}}</text>
+      <text class='inline red'>{{item.chargePile.chargmoney}}</text>
       <text class='inline gray1'>元</text>
     </view>
-    <text class='gray' wx:if="{{charginglog.paytype==1}}" decode='true'>支付方式:余额</text>
-    <text class='gray' wx:if="{{charginglog.paytype==2}}" decode='true'>支付方式:信用欠款</text>
-    <text class='gray' wx:if="{{charginglog.paytype==3}}" decode='true'>支付方式:支付宝</text>
-    <text class='gray' wx:if="{{charginglog.paytype==4}}" decode='true'>支付方式:微信支付</text>
-    <text class='gray' wx:if="{{charginglog.paytype==5}}" decode='true'>支付方式:银联卡</text>
-    <text class='gray' wx:if="{{charginglog.paytype==6}}" decode='true'>支付方式:虚拟货币</text>
+
   </view>
 
   

+ 44 - 1
pages/ucenter/yuyt/yuyt.wxss

@@ -14,6 +14,24 @@ page {
   width: 100%;
   height: 24rpx;
 }
+.upFlag{
+  position: absolute;
+  color:#E99D42;
+  font-size: 28rpx;
+  right: 20rpx;
+  top: 20rpx;
+}
+
+.downBtn{
+  position: absolute;
+  color:#000000;
+  border: 1px solid #aaaaaa;
+  border-radius: 30rpx;
+  padding: 3rpx 6rpx;
+  font-size: 22rpx;
+  right: 20rpx;
+  bottom: 20rpx;
+}
 
 .text_context {
   position: relative;
@@ -111,10 +129,35 @@ text.gray {
 text.gray1 {
   color: #575757;
 }
+
+text.gray2 {
+  color: #AAAAAA;
+}
+
+.inlineView text{
+  display: inline-block;
+}
 text.inline {
   display: inline-block;
 }
-
+view.inline {
+  display: inline-block;
+}
 text.red {
   color: red;
 }
+
+.topBar{
+  height: 60rpx;
+  font-size: 30rpx;
+  line-height: 80rpx;
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+  padding: 0 40rpx;
+  color:#848484;
+}
+
+.topBar .active{
+  color: #000000;
+}