Browse Source

修改电池包

XWookey 2 months ago
parent
commit
9deb938978

+ 3 - 3
pages/index/index.js

@@ -1265,9 +1265,9 @@ Page({
             }else if(res?.data?.result?.requirementStep==8){
                 // 8进终端详情
                 let url = `/pages/batteryPack/batteryPackWait`;
-                // wx.reLaunch({
-                //   url
-                // });
+                wx.reLaunch({
+                  url
+                });
             }
         },
         fail(e) {

+ 131 - 30
pages/ucenter/control/batteryControl.js

@@ -1,11 +1,23 @@
 // pages/ucenter/control/batteryControl.js
-Page({
 
+
+var selectPopup1;
+var selectPopup2;
+
+Page({
   /**
    * 页面的初始数据
    */
   data: {
     code: '202007221111110201',
+    s1_index: -1,
+    select1_text: '点击选择',
+    select2_text: '点击选择',
+    select1_arr:[],
+    select2_arr:[],
+    select1_index:-1,
+    select2_index:-1,
+    batteryByStation: {},
     chargPile:{
         // chargPileName:'测试电池包',
         // chargPileId:'202007221111110201',
@@ -61,7 +73,6 @@ Page({
         },
         method: 'POST',
         success(res) {
-            console.info(res);
             let cars = res?.data?.result?res?.data?.result:[]
             that.setData({
                 cars
@@ -82,35 +93,41 @@ Page({
             })
         }
     })
-    let userInfo = wx.getStorageSync('userInfo');
-    wx.request({
-        url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargPile',
-        data: {
-          chargPileId:that.data.code,
-          userId: userInfo.userId
-        },
-        method: 'POST',
-        success(res) {
-        //   log.info('[首页]', '[获取扫一扫充电桩]', '[响应]', res.data);
-        console.info(res)
-        if (!res.data || res.data.code == 500) {
-            wx.showModal({
-              showCancel: false,
-              content: res && res.data && res.data.msg ? res.data.msg :'无效的终端编号',
-              confirmColor:'#00AADD',
-            });
-        }else{
-            let chargPile = res.data.result;
+
+        let userInfo = wx.getStorageSync('userInfo');
+      // 加载下拉框
+      wx.request({
+          url: getApp().globalData.postHeadAgreement + '/restapi/wechat/batteryByStation',
+          // data: charePileId,
+          data:{
+            chargPileId: '1771052602050748417',
+            userId: userInfo.userId
+          },
+          method: 'POST',
+          success(res) {
+            res = res.data
+            let batteryByStation = res.result
+            let select1_arr = Object.keys(batteryByStation).sort().map(it=>{
+                let regex = /chargStationName=(.*?)(,|")/;
+                let match = it.match(regex);
+                return match && match[1]?match[1]:it
+            })
+            let ee = {
+                "detail":{
+                    "value":0
+                }
+            }
             that.setData({
-                chargPile
+                batteryByStation,
+                select1_arr,
             })
-        }
 
-        },
-        fail(e) {
-          getApp().showNetworkError();
-        }
-      });
+          },
+          fail(e) {
+            getApp().showNetworkError();
+          }
+        });
+       
 
 
     // wx.showToast({
@@ -119,12 +136,93 @@ Page({
     //     duration: 2000
     //   })
   },
+  loadSelect2(){
+    let that = this;
+    let index1 = that.data.select1_index
+    let batteryByStation = that.data.batteryByStation;
+    let key = Object.keys(batteryByStation).sort()[index1]
+    let select2_arr = batteryByStation[key].map(it=>it.chargPileName)
+    that.setData({
+        select2_arr,
+    })
+
+  },
+  bindPickerChange1(e){
+    let index = e.detail.value
+    let text = this.data.select1_arr[index]
+    this.setData({
+        select1_index: index,
+        select1_text: text,
+        select2_index: -1,
+        select2_text: '点击选择',
+        chargPile:{}
+    })
+    this.loadSelect2()
+  },
+  bindPickerChange2(e){
+    let that = this;
+    let index = e.detail.value
+    let text = this.data.select2_arr[index]
+
+    let index1 = that.data.select1_index
+    let batteryByStation = that.data.batteryByStation;
+    let key = Object.keys(batteryByStation).sort()[index1]
+    console.info(index1)
+    console.info(index)
+    console.info(key)
+    console.info(batteryByStation[key])
+    let code = batteryByStation[key].map(it=>it.chargPileId)[index]
+    this.setData({
+        select2_index: index,
+        select2_text: text,
+        code
+    })
+    that.loadCode()
+  },
+  loadCode(){
+    let that = this
+
+
+    let index1 = that.data.select1_index
+    let batteryByStation = that.data.batteryByStation;
+    let key = Object.keys(batteryByStation).sort()[index1]
+    let chargPile = batteryByStation[key][that.data.select2_index]
+    // let userInfo = wx.getStorageSync('userInfo');
+    // wx.request({
+    //     url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargPile',
+    //     data: {
+    //       chargPileId:that.data.code,
+    //       userId: userInfo.userId
+    //     },
+    //     method: 'POST',
+    //     success(res) {
+    //     //   log.info('[首页]', '[获取扫一扫充电桩]', '[响应]', res.data);
+    //     console.info(res)
+    //     if (!res.data || res.data.code == 500) {
+    //         wx.showModal({
+    //           showCancel: false,
+    //           content: res && res.data && res.data.msg ? res.data.msg :'无效的终端编号',
+    //           confirmColor:'#00AADD',
+    //         });
+    //     }else{
+    //         let chargPile = res.data.result;
+            that.setData({
+                chargPile
+            })
+    //     }
 
+    //     },
+    //     fail(e) {
+    //       getApp().showNetworkError();
+    //     }
+    //   });
+  },
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady() {
-
+    selectPopup1 = this.selectComponent("#selectpopup1");
+    selectPopup2 = this.selectComponent("#selectpopup2");
   },
 
   /**
@@ -476,5 +574,8 @@ Page({
           getApp().showNetworkError();
         }
       });
-}
+},
+
+
+
 })

+ 4 - 2
pages/ucenter/control/batteryControl.json

@@ -1,4 +1,6 @@
 {
-  "usingComponents": {},
-  "navigationBarTitleText": "电池包控制"
+  "navigationBarTitleText": "电池包控制",
+  "usingComponents": {
+    "selectpopup": "/components/selectpopup/selectpopup"
+  }
 }

+ 17 - 0
pages/ucenter/control/batteryControl.wxml

@@ -1,5 +1,22 @@
 
 <view class="pg">
+
+    <view class="selectBox">
+    <view class="selectCard">
+        <text>请选择充电站</text>
+        <picker bindchange="bindPickerChange1" value="{{index}}" range="{{select1_arr}}">
+            <view class="picker">{{select1_text}}</view>
+        </picker>
+    </view>
+    <view class="selectCard">
+        <text>请选择充电桩</text>
+        <picker bindchange="bindPickerChange2" value="{{index}}" range="{{select2_arr}}">
+            <view class="picker">{{select2_text}}</view>
+        </picker>
+    </view>
+    </view>
+
+
     <view class='charging_text_title'>
       <view class='charging'>
         <image src='/images/charging2_1.png' bindtap="wxTestDebugClick"></image>

+ 38 - 1
pages/ucenter/control/batteryControl.wxss

@@ -141,4 +141,41 @@
   }
   .char4{
     font-size: 24rpx;
-  }
+  }
+
+  .selectBox{
+    margin-top: 10rpx;
+    font-size: 28rpx;
+    line-height: 28rpx;
+    height: 110rpx;
+    width: 100%;
+    display: flex;
+    flex-direction: column;
+    justify-content:space-between;
+  }
+  .selectCard{
+    width: 100%;
+    height:50rpx;
+    display: flex;
+    flex-direction: row;
+    justify-content:space-between;
+}
+
+ .selectCard text{
+    font-size: 28rpx;
+    line-height: 50rpx;
+    height:50rpx;
+    width: 180rpx;
+}
+.selectCard picker{
+    width: calc(100% - 200rpx);
+    height: 50rpx;
+    padding-left: 20rpx;
+    background: #EFEFEF;
+    color:#575757;
+    border-radius: 10rpx;
+    font-size: 28rpx;
+    line-height: 50rpx;
+}
+
+