|
@@ -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();
|
|
|
}
|
|
|
});
|
|
|
-}
|
|
|
+},
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
})
|