Browse Source

充电站详情

XWookey 6 months ago
parent
commit
bfe9297d11

+ 2 - 0
app.js

@@ -1,6 +1,8 @@
 //app.js
 let wechat = require('./utils/wechat.js');
 let log = require('./utils/log.js');
+import EventBus from './utils/EventBus.js'
+wx.$bus = new EventBus()
 App({
   globalData: {
     // postHeadAgreement: 'http://127.0.0.1:10301',

+ 3 - 1
app.json

@@ -1,6 +1,7 @@
 {
   "lazyCodeLoading": "requiredComponents",
   "pages": [
+
     "pages/index/index",
     "pages/routes/routes",
     "pages/charginfo/charginfo",
@@ -56,7 +57,8 @@
     "pages/ucenter/control/carControl",
     "pages/ucenter/control/batteryControl",
     "pages/scan_result/elpackage",
-    "pages/batteryPack/batteryPackWait"
+    "pages/batteryPack/batteryPackWait",
+    "pages/charginfo/eleCarMap"
   ],
   "window": {
     "backgroundTextStyle": "light",

+ 133 - 17
pages/charginfo/charginfo.js

@@ -1,6 +1,3 @@
-import * as echarts from '../../ec-canvas/echarts';
-import * as lf from '../../ec-canvas/echarts-liquidfill';
-
 
 let log = require('../../utils/log.js');
 
@@ -24,12 +21,18 @@ Page({
     slowSum:0,
     pagesize:30,
     pagenum:1,
+    ele_pagenum:1,
     total:-1,
+    ele_total:-1,
     loadTotal: 0,
     dataLoading: false,
+    ele_dataLoading: false,
     finishedLoadTap: 0,
+    ele_finishedLoadTap: 0,
     finishedLoadShowTimes: 0,
+    ele_finishedLoadShowTimes: 0,
     chargList: [],
+    ele_chargList: [],
     seeInfoChargPile:{},
     userInfo:{},
     chargfeatureList:[],
@@ -161,7 +164,8 @@ Page({
       sumprice
     });
  
-    this.getPage();
+    this.ori_getPage();
+    this.ele_getPage();
   },
   previewImage(e){
     var that = this,
@@ -177,14 +181,113 @@ Page({
     })
   },
   getPage(){
+    let that = this;
+    if(that.activeTab=='1'){
+        that.ori_getPage();
+    }else{
+        that.ele_getPage();
+    }
+
+  },
 
+  ori_getPage(){
+    // ivType
+    // 是否为无人车充电站(0否;1是)
+    // 0:桩
+    // 1:电池
     if(this.data.chargList.length == this.data.total){
+        this.setData({
+          finishedLoadTap:this.data.finishedLoadTap+1
+        })
+        if(this.data.finishedLoadTap>0 && this.data.finishedLoadShowTimes==0){
+          this.setData({
+            finishedLoadShowTimes:this.data.finishedLoadShowTimes+1
+          })
+          wx.showToast({
+            title: '全部加载完毕',
+            icon: 'success',
+            duration: 2000
+          })
+        }
+        return
+      }
+  
+      if(this.data.dataLoading){
+        return
+      }
       this.setData({
-        finishedLoadTap:this.data.finishedLoadTap+1
+        dataLoading: true
+      })
+      wx.showLoading({
+        title: '数据加载中....',
       })
-      if(this.data.finishedLoadTap>0 && this.data.finishedLoadShowTimes==0){
+  
+    let that = this;
+      // 充电桩
+      wx.request({
+        url: getApp().globalData.postHeadAgreement +'/restapi/wechat/chargInfo',
+        data: {
+          id: that.data.chargid,
+          pagenum: this.data.pagenum++,
+          ivType: 0,
+          pagesize: 30,
+        },
+        method: 'POST',
+        success(res) {
+          console.log(res);
+          let chargList = res.data.chargList.rows;
+  
+          chargList.forEach(key => {
+            let chargstatusname = '';
+            let chargstatusclass = '';
+            if(key.chargstatus == 2){
+              chargstatusname='空闲中'
+              chargstatusclass = 'chargstatus_kxz'
+            }else if(key.chargstatus == 11){
+              chargstatusname='已插枪'
+              chargstatusclass = 'chargstatus_ycq'
+            }else if(key.chargstatus == 3 || key.chargstatus == 10){
+              chargstatusname='充电中'
+              chargstatusclass = 'chargstatus_cdz'
+            }else if(key.chargstatus == 0){
+              chargstatusname='离线'
+              chargstatusclass = 'chargstatus_lx'
+            }else{
+              chargstatusname='故障'
+              chargstatusclass = 'chargstatus_gz'
+            }
+            key.chargstatusname = chargstatusname;
+            key.chargstatusclass = chargstatusclass;
+        })
+  
+          console.log(chargList);
+          // that.rechargeTimeOrder(chargemoneylogs);
+          wx.hideLoading()
+          that.setData({
+            chargList: that.data.chargList.concat(chargList),
+            total: res.data.chargList.total,
+            dataLoading: false,
+            fastFree : res.data.fastFree,
+            slowFree : res.data.slowFree,
+            fastSum : res.data.fastSum,
+            slowSum : res.data.slowSum
+          });
+        }
+      });
+  },
+
+  ele_getPage(){
+    // ivType
+    // 是否为无人车充电站(0否;1是)
+    // 0:桩
+    // 1:电池
+    if(this.data.ele_chargList.length == this.data.ele_total){
+      this.setData({
+        ele_finishedLoadTap:this.data.ele_finishedLoadTap+1
+      })
+      if(this.data.ele_finishedLoadTap>0 && this.data.ele_finishedLoadShowTimes==0){
         this.setData({
-          finishedLoadShowTimes:this.data.finishedLoadShowTimes+1
+          ele_finishedLoadShowTimes:this.data.ele_finishedLoadShowTimes+1
         })
         wx.showToast({
           title: '全部加载完毕',
@@ -195,22 +298,24 @@ Page({
       return
     }
 
-    if(this.data.dataLoading){
+    if(this.data.ele_dataLoading){
       return
     }
     this.setData({
-      dataLoading: true
+      ele_dataLoading: true
     })
     wx.showLoading({
       title: '数据加载中....',
     })
 
   let that = this;
+    // 充电桩
     wx.request({
       url: getApp().globalData.postHeadAgreement +'/restapi/wechat/chargInfo',
       data: {
         id: that.data.chargid,
-        pagenum: this.data.pagenum++,
+        pagenum: this.data.ele_pagenum++,
+        ivType: 1,
         pagesize: 30,
       },
       method: 'POST',
@@ -245,18 +350,29 @@ Page({
         // that.rechargeTimeOrder(chargemoneylogs);
         wx.hideLoading()
         that.setData({
-          chargList: that.data.chargList.concat(chargList),
-          total: res.data.chargList.total,
-          dataLoading: false,
-          fastFree : res.data.fastFree,
-          slowFree : res.data.slowFree,
-          fastSum : res.data.fastSum,
-          slowSum : res.data.slowSum
+          ele_chargList: that.data.ele_chargList.concat(chargList),
+          ele_total: res.data.chargList.total,
+          ele_dataLoading: false,
+          ele_fastFree : res.data.fastFree,
+          ele_slowFree : res.data.slowFree,
+          ele_fastSum : res.data.fastSum,
+          ele_slowSum : res.data.slowSum
         });
       }
     });
 
   },
+  goEleCarMap(e){
+    console.info("呼叫充电车");
+    let that = this;
+   wx.$bus.emit('eleCarMapPage', {
+    chargid: that.data.chargid
+   })
+    let url = '/pages/charginfo/eleCarMap';
+    wx.navigateTo({
+        url
+    });
+  },
   goScanResult(e){
     // scan_result
 

+ 7 - 4
pages/charginfo/charginfo.wxml

@@ -118,17 +118,20 @@
     <!-- 充电桩 end  -->
 
     <!-- 机器人充电车 start -->
-    <view wx:if="{{activeTab=='1'}}" class="charg"  hover-class='active' wx:key='{{key}}' wx:for="{{chargList}}" data-idx="{{item}}" bindtap="{{userInfo.flag ?'chargingLog':''}}">
+    <!--
+    <view wx:if="{{activeTab=='1'}}" class="charg"  hover-class='active' wx:key='{{key}}' wx:for="{{ele_chargList}}" data-idx="{{item}}" bindtap="{{userInfo.flag ?'chargingLog':''}}">
+    -->
+    <view wx:if="{{activeTab=='1'}}" class="charg"  hover-class='active' wx:key='{{key}}' wx:for="{{ele_chargList}}" data-idx="{{item}}" bindtap="goEleCarMap">
       <view class="runstatus {{item.chargstatusclass}}">
       <view class="runstatus_inner ">{{item.chargstatusname}}</view>
       </view>
       <view class="chargInfo_v">
       <view class="chargInfo_v_name">{{item.chargPileName}}</view>
-      <view class="chargInfo_v_id"><text style="width:300rpx">{{item.chargPileId}}</text><text wx:if="{{!item.openStatus}}" decode="{{true}}" space="nbsp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</text><text wx:if="{{!userInfo.flag && item.openStatus}}" class="seeReservation" bindtap="seeReservation" bindtap="seeReservation"  data-idx="{{item}}">查看预约</text><text class="startpower" wx:if="{{!userInfo.flag && item.chargstatusname=='已插枪'}}"  data-keywords="{{item}}"  bindtap="{{(!userInfo.flag && item.chargstatusname=='已插枪')?'goScanResult':''}}">呼叫充电车 ></text></view>
+      <view class="chargInfo_v_id"><text style="width:300rpx">{{item.chargPileId}}</text><text wx:if="{{!item.openStatus}}" decode="{{true}}" space="nbsp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</text><text wx:if="{{!userInfo.flag && item.openStatus}}" class="seeReservation" bindtap="seeReservation" bindtap="seeReservation"  data-idx="{{item}}">查看预约</text><text class="startpower" wx:if="{{!userInfo.flag && item.chargstatusname=='已插枪'}}"  data-keywords="{{item}}"  bindtap="{{(!userInfo.flag && item.chargstatusname=='已插枪')?'goEleCarMap':''}}">呼叫充电车 ></text></view>
       </view>
-      <view class="iconCard" >
+      <!-- <view class="iconCard" >
         <view class="icon {{item.pileType=='慢充'?'slowBar':'fastBar'}}">{{item.pileType=='慢充'?'慢':'快'}}</view>
-      </view>
+      </view> -->
     </view>
     <!-- 机器人充电车 end  -->
 

+ 136 - 0
pages/charginfo/eleCarMap.js

@@ -0,0 +1,136 @@
+// pages/charginfo/eleCarMap.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    longitude:116.4965075,
+    latitude: 40.006103,
+    speed:0,
+    accuracy:0,
+    chargid:chargid
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    wx.$bus.on('eleCarMapPage', this.addHandler)
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  },
+
+  addHandler(json){
+    let {
+        chargid
+    } = json
+    this.setData({
+        chargid
+    })
+
+  },
+  getEleData(){
+
+    let that = this;
+    // 充电桩
+    wx.request({
+      url: getApp().globalData.postHeadAgreement +'/restapi/wechat/chargInfo',
+      data: {
+        id: that.data.chargid,
+        ele_pagenum: this.data.ele_pagenum++,
+        ivType: 1,
+        pagesize: 30,
+      },
+      method: 'POST',
+      success(res) {
+        console.log(res);
+        let chargList = res.data.chargList.rows;
+
+        chargList.forEach(key => {
+          let chargstatusname = '';
+          let chargstatusclass = '';
+          if(key.chargstatus == 2){
+            chargstatusname='空闲中'
+            chargstatusclass = 'chargstatus_kxz'
+          }else if(key.chargstatus == 11){
+            chargstatusname='已插枪'
+            chargstatusclass = 'chargstatus_ycq'
+          }else if(key.chargstatus == 3 || key.chargstatus == 10){
+            chargstatusname='充电中'
+            chargstatusclass = 'chargstatus_cdz'
+          }else if(key.chargstatus == 0){
+            chargstatusname='离线'
+            chargstatusclass = 'chargstatus_lx'
+          }else{
+            chargstatusname='故障'
+            chargstatusclass = 'chargstatus_gz'
+          }
+          key.chargstatusname = chargstatusname;
+          key.chargstatusclass = chargstatusclass;
+      })
+
+        console.log(chargList);
+        // that.rechargeTimeOrder(chargemoneylogs);
+        wx.hideLoading()
+        that.setData({
+          ele_chargList: that.data.ele_chargList.concat(chargList),
+          ele_total: res.data.chargList.total,
+          ele_dataLoading: false,
+          ele_fastFree : res.data.fastFree,
+          ele_slowFree : res.data.slowFree,
+          ele_fastSum : res.data.fastSum,
+          ele_slowSum : res.data.slowSum
+        });
+      }
+    });
+    
+  }
+})

+ 3 - 0
pages/charginfo/eleCarMap.json

@@ -0,0 +1,3 @@
+{
+    "navigationBarTitleText": "详情"
+}

+ 20 - 0
pages/charginfo/eleCarMap.wxml

@@ -0,0 +1,20 @@
+
+<view class='view'>
+  <map longitude="{{longitude}}" latitude="{{latitude}}" markers="{{markers}}" covers="{{covers}}" show-location>
+
+    <cover-view slot="callout">
+        <block wx:for="{{customCalloutMarkerIds}}" wx:key="*this">
+          <cover-view  class="customCallout" marker-id="{{item}}" >
+            <cover-image class="icon" src="/image/voice.png"></cover-image>
+            <cover-view class="content"> 
+              {{num}}-{{item}}-{{index}}
+            </cover-view>
+          </cover-view>
+        </block>
+      </cover-view>
+ 
+  </map>
+  <text class="txt">请选择可用车位和电池包</text>
+  <button class='login_button' bindtap="bindCar">呼叫充电车</button>
+</view>
+

+ 65 - 0
pages/charginfo/eleCarMap.wxss

@@ -0,0 +1,65 @@
+/**index.wxss**/
+/* 不加page无法全屏 */
+page {
+    height: 100%;
+}
+   
+.view {
+width: 100%;
+height: 100%;
+}
+   
+  map {
+    margin: 0 20rpx;
+    width: calc(100% - 40rpx);
+    height: 70%;
+    background-color: red;
+  }
+
+
+  
+  .login_button {
+    width: calc(100% - 270rpx);
+    font-size: 32rpx;
+    /* margin: 0rpx 32rpx; */
+    font-family: 'Lucida Sans',
+                   'Lucida Sans Regular',
+                   'Lucida Grande',
+                   'Lucida Sans Unicode',
+                   Geneva,
+                   Verdana,
+                   sans-serif;
+    color: #fff;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    background-color: #00a8dc;
+    border-radius: 40rpx;
+    height: 80rpx;
+    border: none;
+    margin: 50rpx auto;
+  }
+  
+  .login_button_disable {
+    width: calc(100% - 270rpx);
+    font-size: 32rpx;
+    /* margin: 0rpx 32rpx; */
+    font-family: 'Lucida Sans',
+                   'Lucida Sans Regular',
+                   'Lucida Grande',
+                   'Lucida Sans Unicode',
+                   Geneva,
+                   Verdana,
+                   sans-serif;
+    color: #fff;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    background-color: #c9c9c9;
+    border-radius: 40rpx;
+    height: 80rpx;
+    border: none;
+    margin: 125rpx 135rpx 0 135rpx;
+  }
+  
+  .login_button.button-hover {
+    background-color: #36a9a6;
+  }

+ 7 - 0
pages/ucenter/control/batteryControl.js

@@ -182,6 +182,13 @@ Page({
     // }
     that.bettyControl(2);
   },
+  pauseBtn(){
+    let that = this;
+    // if(that.wxTestDebug(that,'d') > 4){
+    //     return ;
+    // }
+    that.bettyControl(3);
+  },
   bettyControl(bettyControl){
     let that = this;
     wx.showLoading({

+ 4 - 3
pages/ucenter/control/batteryControl.wxml

@@ -11,9 +11,10 @@
     </view>
     <rich-text space='nbsp' nodes="地址:{{chargPile.address}}" style='line-height:30rpx;font-size:24rpx;margin-bottom:10rpx;word-wrap: break-word;' ></rich-text>
     <text class="stitle" >电池包举升控制</text>
-    <view class="vbtn v2">
-        <button class='btn b2 active' bindtap="upBtn" >上升</button>
-        <button class='btn b2 active' bindtap="downBtn" >下降</button>
+    <view class="vbtn v3">
+        <button class='btn b3 active' bindtap="upBtn" >上升</button>
+        <button class='btn b3 active' bindtap="downBtn" >下降</button>
+        <button class='btn b3 active' bindtap="pauseBtn" >暂停</button>
     </view>
     <text class="stitle" >选择车辆</text>
     <view class="vbtn v3">

+ 39 - 0
utils/EventBus.js

@@ -0,0 +1,39 @@
+class EventBus{
+    constructor(){
+      this.task = {}
+    }
+   
+    on(name, cb){
+      if(!this.task[name]){
+        this.task[name] = []
+      }
+      typeof cb === 'function' && this.task[name].push(cb)
+    }
+   
+    emit(name, ...arg){
+      let taskQueen = this.task[name]
+      if(taskQueen && taskQueen.length > 0){
+        taskQueen.forEach(cb=>{
+          cb(...arg)
+        })
+      }
+    }
+   
+    off(name, cb){
+      let taskQueen = this.task[name]
+      if(taskQueen && taskQueen.length > 0){
+        let index = taskQueen.indexOf(cb)
+        index != -1 && taskQueen.splice(index, 1)
+      }
+    }
+   
+    once(name, cb){
+      function callback(...arg){
+        this.off(name, cb)
+        cb(...arg)
+      }
+      typeof cb === 'function' && this.on(name, callback)
+    }
+  }
+   
+  export default EventBus