XWookey hai 4 meses
pai
achega
35dc6f3a81

+ 120 - 1
pages/batteryPack/batteryPackWait.js

@@ -5,15 +5,134 @@ Page({
    * 页面的初始数据
    */
   data: {
-
+    chargePileId: -9,
+    timer:{},
+    userInfo:{},
+    // count: 0 , // 用于测试
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
+    let that = this
+    let userInfo = wx.getStorageSync('userInfo');
+    let timer  = setInterval(()=>{
+        that.wait(that)
+    }, 2000);
+    that.setData({
+        timer,
+        userInfo
+    })
 
   },
+  wait(that){
+    let userInfo = that.data.userInfo;
+    if(!userInfo){
+       return; 
+    }
+    wx.request({
+        url: getApp().globalData.postHeadAgreement + '/restapi/wechat/ivCarRequirement' + 
+        '?userId='+userInfo.userId,
+        data: {
+        },
+        method: 'POST',
+        success(res) {
+            // 0-7 进等待 8进终端详情
+            if(res?.data?.result?.requirementStep>=0 && res?.data?.result?.requirementStep<=7 
+                // || that.data.count < 3
+            ){
+                that.setData({
+                    chargePileId: res?.data?.result?.terminalId,
+                    // chargePileId: res?.data?.result?.terminalId,
+                    // count: that.data.count + 1
+                })
+                // 等待
+                console.log(new Date() + " - requirementStep:" + res?.data?.result?.requirementStep)
+            }else if(res?.data?.result?.requirementStep==8 
+                // || that.data.count>3
+                ){
+                that.setData({
+                    chargePileId: res?.data?.result?.terminalId,
+                    // chargePileId: res?.data?.result?.terminalId,
+                    // count: that.data.count + 1
+                })
+                // 8进终端详情
+                clearInterval(that.data.timer)
+                that.gotoScan_result(that)
+            }else{
+                that.gotoIndex()
+            }
+            
+        },
+        fail(e) {
+            getApp().showNetworkError();
+        }
+    });
+  },
+gotoIndex(){
+    let url = `/pages/index/index`;
+    wx.reLaunch({
+        url
+      });
+},
+gotoScan_result(that){
+    let chargPileId = that.data.chargePileId
+    let userInfo = that.data.userInfo
+    wx.request({
+        url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargPile',
+        // data: charePileId,
+        data:{
+          chargPileId,
+          userId: userInfo.userId
+        },
+        method: 'POST',
+        success(res) {
+          //console.log(res.data);
+          // log.info('[首页]', '[获取微信扫一扫充电桩]', '[响应]', res.data);
+          if (!res.data || res.data.code == 500) {
+            //没有该充电桩信息
+            wx.showModal({
+              showCancel: false,
+              content: res && res.data && res.data.msg ? res.data.msg :'无效的终端编号',
+              confirmColor:'#00AADD',
+            });
+          } else {
+            res.data = res.data.result
+            //充电状态0:离线、1:故障、2:空闲中、3:充电中、4:欠压故障、5:过压故障、6:过电流故障、8:预约、9:在线升级、10:操作中、11:已插枪等
+            if (!res.data.chargstatus || res.data.chargstatus == 0 || res.data.chargstatus == 1 || res.data.chargstatus == 4 || res.data.chargstatus == 5 || res.data.chargstatus == 6 || res.data.chargstatus == 9) {
+              //充电桩故障
+
+              wx.showModal({
+                showCancel: false,
+                content: '终端故障,维修中',
+                confirmColor:'#00AADD',
+              });
+            } else if (res.data.chargstatus == 3 || res.data.chargstatus == 8 || res.data.chargstatus == 10) {
+              wx.showModal({
+                showCancel: false,
+                content: '正在充电中',
+                confirmColor:'#00AADD',
+              });
+            } else if (res.data.chargstatus == 2 || res.data.chargstatus == 11) {
+              wx.setStorage({
+                key: "scan_chargpile",
+                data: res.data
+              });
+            //  log.info('[首页]', '[微信扫一扫充电桩空闲跳转去充电界面]');
+              let url = `/pages/scan_result/scan_result`;
+              wx.reLaunch({
+                url
+              });
+            }
+          }
+        },
+        fail(e) {
+          getApp().showNetworkError();
+        }
+      });
+},
+
 
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 1 - 1
pages/batteryPack/batteryPackWait.wxml

@@ -1,6 +1,6 @@
 <!--pages/batteryPack/batteryPackWait.wxml-->
 <image class="car" src='/images/chargingCarIcon.png'></image>
-<view class="txt">智能充电车调度中, 请等待!!</view>
+<view class="txt">智能充电车调度中, 请等待!</view>
 <view class="loading">
     <view class="loader-circle"></view>
     <view class="loader-circle"></view>

+ 10 - 4
pages/charginfo/eleCarMap.js

@@ -242,6 +242,11 @@ Page({
             mark['title'] = key?.currentSoc? key?.currentSoc + '%' : '-'
             mark['type'] = mark['ele_lock'] ? '锁定' : '未锁定'
             mark['objType'] = 'ele'
+            // mark['chargPileId'] = that.data.chargid
+            // mark['chargPileId'] = key?.chargPileId
+            mark['chargPileId'] = key?.id
+
+
             // mark.callout.content = key?.currentParkPoint?.pointShowName
             ele_chargList.push(mark)
             that.setData({
@@ -320,6 +325,7 @@ Page({
             mark['title'] = key?.pointShowName? key?.pointShowName : '-'
             mark['type'] = mark['ele_lock'] ? '占用' : '空闲'
             mark['objType'] = 'park'
+            mark['ivParkPointId'] = key?.ivParkPointId;
             // mark.callout.content = key?.currentParkPoint?.pointShowName
             ele_chargList.push(mark)
             that.setData({
@@ -360,8 +366,8 @@ Page({
         return;
     }
 
-    let ivParkPointId = that.data.ele_chargList[that.data.parkActiveIndex].id
-    let chargePileId = that.data.ele_chargList[that.data.eleActiveIndex].id
+    let ivParkPointId = that.data.ele_chargList[that.data.parkActiveIndex].ivParkPointId
+    let chargePileId = that.data.ele_chargList[that.data.eleActiveIndex].chargPileId
     let userId = that.data.userInfo.userId
 
     wx.request({
@@ -376,8 +382,8 @@ Page({
         success: function (res) {
             if( res.data.code ==200){
                 // 走你
-                let url = `/pages/batteryPackWait/batteryPackWait`;
-                wx.navigateTo({
+                let url = `/pages/batteryPack/batteryPackWait`;
+                wx.redirectTo({
                   url
                 });
             }else{

+ 0 - 4
pages/charging/charging.js

@@ -200,10 +200,6 @@ Page({
       userId,
       orderid
     });
-
-    // 查询是否充电包
-
-    // 查询是否正在充电
     wx.request({
       url: getApp().globalData.postHeadAgreement + '/restapi/pileLog/wechatchargstatus',
       data: {

+ 48 - 2
pages/index/index.js

@@ -108,6 +108,7 @@ Page({
         });
         return;
       } else {
+
         log.info('[首页]', '[获取用户是否有未完成订单]', '[请求]', { userId: userInfo.userId });
         wx.request({
           url: getApp().globalData.postHeadAgreement + '/restapi/pileLog/wechatchargstatus',
@@ -959,6 +960,17 @@ Page({
                     confirmColor:'#00AADD',
                 });
             }else if(status == 0){
+                wx.hideLoading();
+                that.data.scanFlag = false;
+                // 判断电池包
+                if(res?.data?.chargPileList?.length==0 || !res?.data?.chargPileList){
+                    wx.showModal({
+                        showCancel: false,
+                        content: '暂无可用电池包',
+                        confirmColor:'#00AADD',
+                    });
+                    return;
+                }
 
                 wx.setStorage({
                     key: "elpackage",
@@ -966,8 +978,8 @@ Page({
                   });
 
                 let url = `/pages/scan_result/elpackage`;
-                that.data.scanFlag = false;
-                wx.hideLoading();
+
+
                 wx.navigateTo({
                   url
                 });
@@ -1201,6 +1213,9 @@ Page({
         });
         return;
       }
+
+    // 查询订单
+
       log.info('[首页]', '[获取用户是否有未完成订单]', '[请求]', { userId: userInfo.userId });
       wx.request({
         url: getApp().globalData.postHeadAgreement + '/restapi/pileLog/wechatchargstatus',
@@ -1229,6 +1244,37 @@ Page({
           getApp().showNetworkError();
         }
       });
+
+    // 查询呼叫电车
+    console.log("查询呼叫电车")
+    wx.request({
+        url: getApp().globalData.postHeadAgreement + '/restapi/wechat/ivCarRequirement' + 
+        '?userId='+userInfo.userId,
+        data: {
+        },
+        method: 'POST',
+        success(res) {
+            console.log(res?.data?.result?.requirementStep)
+            // 0-7 进等待 8进终端详情
+            if(res?.data?.result?.requirementStep>=0 && res?.data?.result?.requirementStep<=7){
+                // 等待
+                let url = `/pages/batteryPack/batteryPackWait`;
+                wx.reLaunch({
+                  url
+                });
+            }else if(res?.data?.result?.requirementStep==8){
+                // 8进终端详情
+                let url = `/pages/batteryPack/batteryPackWait`;
+                // wx.reLaunch({
+                //   url
+                // });
+            }
+        },
+        fail(e) {
+            getApp().showNetworkError();
+        }
+    });
+
     } else {
       //未登录信息
       this.setData({

+ 3 - 3
pages/scan_result/elpackage.js

@@ -111,8 +111,8 @@ Page({
         return;
     }
 
-    let ivParkPointId = that.data.parkObj.id 
-    let chargePileId = that.data.eleList[that.data.selectEleIndex].chargPileId
+    let ivParkPointId = that.data.parkObj.ivParkPointId 
+    let chargePileId = that.data.eleList[that.data.selectEleIndex].id
     let userId = that.data.userInfo.userId
 
     wx.request({
@@ -127,7 +127,7 @@ Page({
         success: function (res) {
             if( res.data.code ==200){
                 // 走你
-                let url = `/pages/batteryPackWait/batteryPackWait`;
+                let url = `/pages/batteryPack/batteryPackWait`;
                 wx.navigateTo({
                   url
                 });