|
@@ -8,18 +8,25 @@ Page({
|
|
|
data: {
|
|
|
progressPercentage: 100, // 初始进度值为50%
|
|
|
// chargPile: null,
|
|
|
- chargPile: true,
|
|
|
+ chargPile: {
|
|
|
+
|
|
|
+ },
|
|
|
+ parkObj:{},
|
|
|
+ eleList:{},
|
|
|
orderid: null,
|
|
|
+ userInfo:{},
|
|
|
userId: null,
|
|
|
repaidbalance: 0,
|
|
|
resultTable: [],
|
|
|
+ selectEleIndex : -1,
|
|
|
// 是否减免停车费
|
|
|
carParkingRate: false,
|
|
|
// 停车时间
|
|
|
parkTime: 0,
|
|
|
url:'/images/scan_result.png',
|
|
|
authStatus: 1,
|
|
|
- defPlateNumber:''
|
|
|
+ defPlateNumber:'',
|
|
|
+ car_active: false
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -27,450 +34,121 @@ Page({
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
let that = this;
|
|
|
+
|
|
|
+ let userInfo = wx.getStorageSync('userInfo');
|
|
|
+ that.setData({
|
|
|
+ userInfo
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
wx.getStorage({
|
|
|
- key: 'scan_chargpile',
|
|
|
+ key: 'elpackage',
|
|
|
success: function (res) {
|
|
|
console.log(res);
|
|
|
- //console.log(res.data);
|
|
|
- var chargPile = res.data;
|
|
|
- let authStatus = chargPile.authStatus
|
|
|
- let resultTable = chargPile.resultList
|
|
|
- that.resetResultList(resultTable)
|
|
|
- that.setData({
|
|
|
- resultTable,
|
|
|
- authStatus
|
|
|
+ console.log(res.data);
|
|
|
+ let chargPile = res.data.chargStation;
|
|
|
+ let eleList = res.data.chargPileList;
|
|
|
+ let parkObj = res.data
|
|
|
+
|
|
|
+ eleList.forEach((key)=>{
|
|
|
+ if(!key.currentSoc){
|
|
|
+ key.currentSoc = 0
|
|
|
+ }
|
|
|
+ key['active'] = false
|
|
|
})
|
|
|
- chargPile.sharpTotalPrice = parseFloat((chargPile.sharpChargPrice + chargPile.sharpServicePrice).toFixed(6));
|
|
|
- chargPile.peakTotalPrice = parseFloat((chargPile.peakChargPrice + chargPile.peakServicePrice).toFixed(6));
|
|
|
- chargPile.flatTotalPrice = parseFloat((chargPile.flatChargPrice + chargPile.flatServicePrice).toFixed(6));
|
|
|
- chargPile.valleyTotalPrice = parseFloat((chargPile.valleyChargPrice + chargPile.valleyServicePrice).toFixed(6));
|
|
|
- chargPile.totalprice = parseFloat((chargPile.chargprice + chargPile.serviceprice).toFixed(6));
|
|
|
+
|
|
|
+
|
|
|
that.setData({
|
|
|
- chargPile
|
|
|
- });
|
|
|
- //console.log(chargPile);
|
|
|
+ chargPile,
|
|
|
+ eleList,
|
|
|
+ parkObj
|
|
|
+ })
|
|
|
|
|
|
// 更新是否减停车费
|
|
|
- that.execParking(that,chargPile)
|
|
|
+
|
|
|
|
|
|
|
|
|
wx.removeStorage({
|
|
|
- key: 'scan_chargpile',
|
|
|
+ key: 'elpackage',
|
|
|
success(res) {
|
|
|
console.log(res);
|
|
|
}
|
|
|
});
|
|
|
- log.info('[扫码]', '[加载完成]', '[参数]', res.data);
|
|
|
- let userInfo = wx.getStorageSync('userInfo');
|
|
|
- wx.request({
|
|
|
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/syncUser',
|
|
|
- data: {
|
|
|
- loginName: userInfo.loginName
|
|
|
- },
|
|
|
- method: 'POST',
|
|
|
- success: function (res) {
|
|
|
- let {
|
|
|
- data
|
|
|
- } = res;
|
|
|
- log.info('[扫码]', '[同步用户数据]', '[响应]', data);
|
|
|
- console.info('[扫码]', '[同步用户数据]', '[响应]', data);
|
|
|
- if (data.code && data.code != 200) {
|
|
|
- log.info('[扫码]', '[同步用户数据]', '[失败data null||data.code<>200跳转登陆界面]', data);
|
|
|
- } else {
|
|
|
- that.setData({
|
|
|
- repaidbalance:data.repaidbalance
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- fail(e) {
|
|
|
- console.log("用户数据同步失败");
|
|
|
- log.info('[扫码]', '[同步用户数据]', '[fail]', e);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- execParking(that,chargPile){
|
|
|
- let stationId = chargPile.chargStationId;
|
|
|
- wx.request({
|
|
|
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/carParkingRate?stationId=' + stationId,
|
|
|
- // data: {
|
|
|
- // loginName: userInfo.loginName
|
|
|
- // },
|
|
|
- method: 'POST',
|
|
|
- success: function (res) {
|
|
|
- // 是否减免停车费
|
|
|
- // carParkingRate: false,
|
|
|
- // parkTime: 0,
|
|
|
- console.info(res)
|
|
|
- let reduceTime = res.data?.reduceTime;
|
|
|
- if(!reduceTime){
|
|
|
- that.setData({
|
|
|
- carParkingRate:false
|
|
|
- })
|
|
|
- return;
|
|
|
- }
|
|
|
- that.setData({
|
|
|
- carParkingRate:true
|
|
|
- })
|
|
|
- try{
|
|
|
- that.setData({
|
|
|
- parkTime: parseFloat((reduceTime/ 3600).toFixed(2))
|
|
|
- })
|
|
|
- }catch(e){
|
|
|
- that.setData({
|
|
|
- carParkingRate:false
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- },
|
|
|
- fail(e) {
|
|
|
- console.log("用户数据同步失败");
|
|
|
- log.info('[扫码]', '[同步用户数据]', '[fail]', e);
|
|
|
- }
|
|
|
- });
|
|
|
|
|
|
- },
|
|
|
+ selectEle(e){
|
|
|
+ let idx = e.currentTarget.dataset.idx;
|
|
|
|
|
|
- beginChargeInner(that,plateNumber){
|
|
|
- let userInfo = wx.getStorageSync('userInfo');
|
|
|
- let isLogin = wx.getStorageSync('isLogin');
|
|
|
- // 扫码启动
|
|
|
- wx.showLoading({
|
|
|
- title: '开启充电中...',
|
|
|
- mask: true
|
|
|
- });
|
|
|
- log.info('[扫码]', '[开始充电流程]');
|
|
|
- //同步用户数据
|
|
|
- log.info('[扫码]', '[同步用户数据]', '[请求]', {
|
|
|
- loginName: userInfo.loginName
|
|
|
- });
|
|
|
- wx.request({
|
|
|
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/syncUser',
|
|
|
- data: {
|
|
|
- loginName: userInfo.loginName,
|
|
|
- },
|
|
|
- method: 'POST',
|
|
|
- success: function (res) {
|
|
|
- wx.hideLoading();
|
|
|
- let {
|
|
|
- data
|
|
|
- } = res;
|
|
|
-
|
|
|
-
|
|
|
- log.info('[扫码]', '[同步用户数据]', '[响应]', data);
|
|
|
- console.info('[扫码]', '[同步用户数据]', '[响应]', data);
|
|
|
- if (data.code && data.code != 200) {
|
|
|
- wx.removeStorageSync('userInfo');
|
|
|
- wx.removeStorageSync('isLogin');
|
|
|
- let url = '/pages/login/phone_login/phone_login';
|
|
|
- wx.redirectTo({
|
|
|
- url,
|
|
|
- });
|
|
|
- log.info('[扫码]', '[同步用户数据]', '[失败data null||data.code<>200跳转登陆界面]', data);
|
|
|
- } else {
|
|
|
- wx.setStorageSync('userInfo', data);
|
|
|
- wx.setStorageSync('isLogin', true);
|
|
|
- let repaidbalance = data.repaidbalance;
|
|
|
- that.setData({
|
|
|
- repaidbalance
|
|
|
- });
|
|
|
- //开始充电
|
|
|
- if(data.bindingPhone==0){
|
|
|
- wx.showModal({
|
|
|
- title: '提示',
|
|
|
- content: '您未绑定手机号,请重新登录后自动刷新绑定信息',
|
|
|
- confirmText: '去登录',
|
|
|
- showCancel:false,
|
|
|
- confirmColor:'#00AADD',
|
|
|
- success: function (res1) {
|
|
|
- if (res1.confirm) {
|
|
|
- wx.removeStorageSync('userInfo');
|
|
|
- wx.removeStorageSync('isLogin');
|
|
|
- let url = '/pages/login/phone_login/phone_login';
|
|
|
- wx.redirectTo({
|
|
|
- url
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- log.info('[扫码]', '[同步用户数据]', '[未绑定手机号]', data);
|
|
|
- }else if (!data.repaidbalance || data.repaidbalance <= 0) {
|
|
|
- wx.showModal({
|
|
|
- showCancel: false,
|
|
|
- content: '余额不足,请充值!',
|
|
|
- confirmColor:'#00AADD',
|
|
|
- success: function (res) {
|
|
|
- if (res.confirm) {
|
|
|
- let url = "/pages/chargemoney/chargemoney";
|
|
|
- wx.navigateTo({
|
|
|
- url
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- log.info('[扫码]', '[同步用户数据]', '[data.repaidbalance null||data.repaidbalance<=0余额不足跳转充值界面]', data);
|
|
|
- } else if (data.repaidbalance > 0 && data.repaidbalance <= 15) {
|
|
|
- wx.showModal({
|
|
|
- title: '余额:' + data.repaidbalance + '元',
|
|
|
- showCancel: false,
|
|
|
- confirmText: "去充值",
|
|
|
- confirmColor:'#00AADD',
|
|
|
- content: '余额过低,请尽快充值!',
|
|
|
- success: function (res) {
|
|
|
- if (res.confirm) {
|
|
|
- let url = "/pages/chargemoney/chargemoney";
|
|
|
- wx.navigateTo({
|
|
|
- url
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- log.info('[扫码]', '[同步用户数据]', '[0<data.repaidbalance<=15余额过低]', data);
|
|
|
-
|
|
|
- // wx.showModal({
|
|
|
- // title:'请选择',
|
|
|
- // showCancel: true,
|
|
|
- // confirmText:"继续充电",
|
|
|
- // cancelText:"去充值",
|
|
|
- // content: '余额过低,请尽快充值!',
|
|
|
- // success: function (res) {
|
|
|
- // if (res.confirm) {
|
|
|
-
|
|
|
- // that.beginCharge_satrt();
|
|
|
- // } else if (res.cancel) {
|
|
|
- // let url = "/pages/chargemoney/chargemoney";
|
|
|
- // wx.navigateTo({
|
|
|
- // url
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }
|
|
|
- // });
|
|
|
- } else if (data.repaidbalance > 15) {
|
|
|
- log.info('[扫码]', '[同步用户数据]', '[余额充足开始充电]', data);
|
|
|
- that.beginCharge_satrt(plateNumber,1);
|
|
|
- }
|
|
|
+ let that = this;
|
|
|
+ let eleList = that.data.eleList;
|
|
|
+ let car_active = that.data.car_active;
|
|
|
+ if(eleList[idx].active){
|
|
|
+ eleList[idx].active = false;
|
|
|
+ idx = -1
|
|
|
+ }else{
|
|
|
+ eleList[idx].active = true;
|
|
|
+ if(that.data.selectEleIndex>=0){
|
|
|
+ eleList[that.data.selectEleIndex].active = false;
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
- // 扫描结束
|
|
|
- },
|
|
|
- beginChargeMsg(e){
|
|
|
- let that = this
|
|
|
- wx.requestSubscribeMessage({
|
|
|
- tmplIds: ['3FR5XRyycT81ZWMdVi_ZQYKJcVatZr2Tm7DgcLwCD1I','KWHBIONCrdumgTkE1dpIpAZRgrN5TuhpHuZ0uU-Eud4','XWj70eHMLAjLlufPuhE_NQmdSQzhrOwEXIblWveH0bk'],
|
|
|
- success (res33333) {
|
|
|
- that.beginCharge(e)
|
|
|
- },fail(reee){
|
|
|
- console.info("ffffffffffffff")
|
|
|
- console.info(reee)
|
|
|
- }
|
|
|
+
|
|
|
+ }
|
|
|
+ car_active = (idx>=0)
|
|
|
+ that.setData({
|
|
|
+ selectEleIndex: idx,
|
|
|
+ eleList,
|
|
|
+ car_active
|
|
|
})
|
|
|
+
|
|
|
},
|
|
|
- beginCharge(e) {
|
|
|
+ callCar(){
|
|
|
let that = this
|
|
|
- let userInfo = wx.getStorageSync('userInfo');
|
|
|
- let isLogin = wx.getStorageSync('isLogin');
|
|
|
+ let car_active = that.data.car_active;
|
|
|
|
|
|
- if(!that.data.carParkingRate){
|
|
|
- that.beginChargeInner(that,'');
|
|
|
- return;
|
|
|
+ if(!car_active){
|
|
|
+ return;
|
|
|
}
|
|
|
- // 读取默认车牌
|
|
|
+
|
|
|
+ let ivParkPointId = that.data.parkObj.id
|
|
|
+ let chargePileId = that.data.eleList[that.data.selectEleIndex].chargPileId
|
|
|
+ let userId = that.data.userInfo.userId
|
|
|
+
|
|
|
wx.request({
|
|
|
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/carList?loginName=' + userInfo.loginName,
|
|
|
- // data: {
|
|
|
- // loginName: userInfo.loginName
|
|
|
- // },
|
|
|
- method: 'POST',
|
|
|
- success: function (res) {
|
|
|
- let userCarList = res.data;
|
|
|
- userCarList = userCarList.filter(it=>it.defaultType==1);
|
|
|
- console.info(userCarList)
|
|
|
- if(userCarList.length==0 ){
|
|
|
- wx.showModal({
|
|
|
- title: '提示',
|
|
|
- content: '当前充电站可减免停车费,是否绑定车牌信息?',
|
|
|
- confirmText: '绑定车牌',
|
|
|
- cancelText: '直接启动',
|
|
|
- showCancel:true,
|
|
|
- confirmColor:'#00AADD',
|
|
|
- cancelColor:'#00AADD',
|
|
|
- success: function (ress1) {
|
|
|
- if(ress1.confirm){
|
|
|
- let url = '/pages/ucenter/car/chooseCar'
|
|
|
+ url: getApp().globalData.postHeadAgreement + '/restapi/wechat/callCarRequirement?'
|
|
|
+ + 'ivParkPointId=' + ivParkPointId
|
|
|
+ + '&chargePileId=' + chargePileId
|
|
|
+ + '&userId=' + userId
|
|
|
+ + '&requirementType=0',
|
|
|
+ data: {
|
|
|
+ },
|
|
|
+ method: 'POST',
|
|
|
+ success: function (res) {
|
|
|
+ if( res.data.code ==200){
|
|
|
+ // 走你
|
|
|
+ let url = `/pages/batteryPackWait/batteryPackWait`;
|
|
|
wx.navigateTo({
|
|
|
url
|
|
|
});
|
|
|
- }else{
|
|
|
- that.beginChargeInner(that,'')
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }else{
|
|
|
- let userCar = userCarList[0]
|
|
|
- wx.showModal({
|
|
|
- title: '提示',
|
|
|
- content: '确定使用' + userCar.plateNumber + '车牌信息减免停车费?',
|
|
|
- confirmText: '确定',
|
|
|
- cancelText: '其他车牌',
|
|
|
- showCancel:true,
|
|
|
- confirmColor:'#00AADD',
|
|
|
- cancelColor:'#00AADD',
|
|
|
- success: function (ress1) {
|
|
|
- if(ress1.confirm){
|
|
|
- that.beginChargeInner(that,userCar.plateNumber)
|
|
|
- }else{
|
|
|
- let url = '/pages/ucenter/car/chooseCar'
|
|
|
- wx.navigateTo({
|
|
|
- url
|
|
|
+ }else{
|
|
|
+ // 给出提示
|
|
|
+ wx.showModal({
|
|
|
+ showCancel: false,
|
|
|
+ content: "调度失败" + res.data?.msg,
|
|
|
+ confirmColor:'#00AADD',
|
|
|
});
|
|
|
- }
|
|
|
- return;
|
|
|
-
|
|
|
- },
|
|
|
- fail: function(res1){
|
|
|
- console.info(res1)
|
|
|
}
|
|
|
- });
|
|
|
+ },
|
|
|
+ fail(e) {
|
|
|
+ console.log("呼叫充电车失败");
|
|
|
}
|
|
|
+ });
|
|
|
|
|
|
- },
|
|
|
- fail(e) {
|
|
|
- console.log("查询车辆失败");
|
|
|
- log.info('[查询车辆]','[fail]', e);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- },
|
|
|
- beginCharge_satrt(plateNumber,runTimes) {
|
|
|
- wx.showLoading({
|
|
|
- title: '开启充电中...',
|
|
|
- mask: true
|
|
|
- });
|
|
|
|
|
|
- let that = this;
|
|
|
- let terminalNum = this.data.chargPile.chargPileId;
|
|
|
|
|
|
- let userInfo = wx.getStorageSync('userInfo');
|
|
|
- let isLogin = wx.getStorageSync('isLogin');
|
|
|
-
|
|
|
- console.log(terminalNum);
|
|
|
- let userId = userInfo.userId;
|
|
|
- let chargstarttime = new Date().getTime();
|
|
|
- console.log(chargstarttime);
|
|
|
- log.info('[扫码]', '[开始充电]', '[请求]', {
|
|
|
- //chargPileId: '201811010000004202',
|
|
|
- chargPileId: terminalNum,
|
|
|
- userId: userId,
|
|
|
- chargstarttime: chargstarttime
|
|
|
- });
|
|
|
- wx.request({
|
|
|
- url: getApp().globalData.postHeadAgreement + '/restapi/pileLog/miniprogramadd',
|
|
|
- data: {
|
|
|
- //chargPileId: '201811010000004202',
|
|
|
- chargPileId: terminalNum,
|
|
|
- userId: userId,
|
|
|
- chargstarttime: chargstarttime,
|
|
|
- userPlateNumber: plateNumber,
|
|
|
- runTimes:runTimes
|
|
|
- },
|
|
|
- method: 'POST',
|
|
|
- fail(e) {
|
|
|
-
|
|
|
- wx.hideLoading();
|
|
|
- //开启充电失败,提示用户
|
|
|
- wx.showModal({
|
|
|
- showCancel: false,
|
|
|
- content: '开启充电失败',
|
|
|
- confirmColor:'#00AADD',
|
|
|
- });
|
|
|
- log.info('[扫码]', '[开始充电]', '[fail]', e);
|
|
|
- },
|
|
|
- success(res) {
|
|
|
- wx.hideLoading();
|
|
|
- let {
|
|
|
- data
|
|
|
- } = res;
|
|
|
- log.info('[扫码]', '[开始充电]', '[响应]', data);
|
|
|
- if (data && data.code == 200) {
|
|
|
- //if (data && data.code == 200 && data.orderid) {
|
|
|
- //开启充电成功,跳转到正在充电界面
|
|
|
- let {
|
|
|
- orderid
|
|
|
- } = data;
|
|
|
- log.info('[扫码]', '[开始充电]', '[成功,跳转充电中页面]', data);
|
|
|
- //console.log(this.data.city);
|
|
|
- let url = `/pages/charging/charging?orderid=${orderid}&userId=${userId}&chargPileId=${terminalNum}`;
|
|
|
- wx.redirectTo({
|
|
|
- url
|
|
|
- });
|
|
|
- } else if (data && data.code == 501) {
|
|
|
- //开启充电失败,提示用户
|
|
|
- wx.showModal({
|
|
|
- showCancel: false,
|
|
|
- content: '余额不足,请充值!',
|
|
|
- confirmColor:'#00AADD',
|
|
|
- });
|
|
|
- log.info('[扫码]', '[开始充电]', '[失败data.code=501余额不足]', data);
|
|
|
- } else if (data && data.code == 502) {
|
|
|
- //开启充电失败,提示用户
|
|
|
- wx.showModal({
|
|
|
- showCancel: false,
|
|
|
- content: data.message,
|
|
|
- confirmColor:'#00AADD',
|
|
|
- });
|
|
|
- log.info('[扫码]', '[开始充电]', '[失败data.code=502' + data.message + ']', data);
|
|
|
- } else if (data && data.code == 503) {
|
|
|
- //开启充电失败,提示用户
|
|
|
- let msg = res?.data?.message
|
|
|
- wx.showModal({
|
|
|
- title: '提示',
|
|
|
- showCancel: true,
|
|
|
- content: msg,
|
|
|
- cancelText:'其他车辆',
|
|
|
- confirmText:'继续启动',
|
|
|
- confirmColor:'#00AADD',
|
|
|
- cancelColor:'#00AADD',
|
|
|
- success: function (res) {
|
|
|
- if (res.cancel) {
|
|
|
- //点击取消,其他车辆
|
|
|
- } else {
|
|
|
- //点击确定,继续启动
|
|
|
- that.beginCharge_satrt(plateNumber,runTimes + 1)
|
|
|
- }
|
|
|
- },
|
|
|
- fail: function (res) { },//接口调用失败的回调函数
|
|
|
- complete: function (res) { },//接口调用结束的回调函数(调用成功、失败都会执行)
|
|
|
- });
|
|
|
- log.info('[扫码]', '[开始充电]', '[失败data.code=502' + data.message + ']', data);
|
|
|
- } else {
|
|
|
- //开启充电失败,提示用户
|
|
|
- let msg = res?.data?.message
|
|
|
- msg = msg?msg:'开启充电失败'
|
|
|
- wx.showModal({
|
|
|
- showCancel: false,
|
|
|
- content: msg,
|
|
|
- confirmColor:'#00AADD',
|
|
|
- });
|
|
|
- log.info('[扫码]', '[开始充电]', '[失败]', data);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
},
|
|
|
- previewImage(e){
|
|
|
- let cur = e.target.dataset.src;//获取本地一张图片链接
|
|
|
- console.info(cur)
|
|
|
- wx.previewImage({
|
|
|
- current: cur, //字符串,默认显示urls的第一张
|
|
|
- urls: [cur] // 数组,需要预览的图片链接列表
|
|
|
- })
|
|
|
-},
|
|
|
+
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|