|
@@ -5,8 +5,19 @@ let wechat = require("../../utils/wechat");
|
|
|
let amap = require("../../utils/amap");
|
|
|
let Util = require("../../utils/util");
|
|
|
let log = require('../../utils/log.js');
|
|
|
+let wxpro = require('../../utils/wx-promise-pro.js');
|
|
|
let mapregionchange_makertap = false;
|
|
|
|
|
|
+
|
|
|
+wxpro.promisifyAll()
|
|
|
+// wxpro.promisify(wx.getSystemInfo)().then(console.log)
|
|
|
+for (var variable in wx) {
|
|
|
+ if (wx.hasOwnProperty(variable)) {
|
|
|
+ wx.pro[variable] = wxpro.promisify(wx[variable])
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
Page({
|
|
|
data: {
|
|
|
scanFlag:false,
|
|
@@ -172,7 +183,8 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
onLoad(e) {
|
|
|
- this.scanFlag = false;
|
|
|
+
|
|
|
+ this.scanFlag = false;
|
|
|
wx.hideLoading();
|
|
|
if (e.q) {
|
|
|
//console.log(decodeURIComponent(e.q));
|
|
@@ -181,7 +193,18 @@ Page({
|
|
|
//if (charePileId){
|
|
|
|
|
|
//}
|
|
|
- this.wxScan(e.q);
|
|
|
+
|
|
|
+ let userInfo = wx.getStorageSync('userInfo');
|
|
|
+ let isLogin = wx.getStorageSync('isLogin');
|
|
|
+ // userInfo.flag=true;
|
|
|
+ this.setData({
|
|
|
+ userInfo,
|
|
|
+ isLogin
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ this.click_scan_control(e.q,false);
|
|
|
+ // this.wxScan(e.q);
|
|
|
}
|
|
|
log.info('[首页]', '[加载完成]');
|
|
|
|
|
@@ -286,6 +309,7 @@ Page({
|
|
|
address: item.address,
|
|
|
width: "46rpx",
|
|
|
height: "67rpx",
|
|
|
+ chargfeatures: chargfeatures ,
|
|
|
iconPath: iconPath,
|
|
|
id: item.id,
|
|
|
callout: {},
|
|
@@ -342,6 +366,7 @@ Page({
|
|
|
address: item.address,
|
|
|
width: "46rpx",
|
|
|
height: "67rpx",
|
|
|
+ chargfeatures: item.chargfeatures ,
|
|
|
iconPath: iconPath,
|
|
|
id: item.id,
|
|
|
callout: {},
|
|
@@ -623,10 +648,11 @@ Page({
|
|
|
mpCtx.moveToLocation();
|
|
|
},
|
|
|
//打开扫一扫
|
|
|
- click_scan_control(e) {
|
|
|
- if(!this.phoneCheck()){
|
|
|
- return;
|
|
|
- }
|
|
|
+ click_scan_control_outer(){
|
|
|
+ this.click_scan_control("",true)
|
|
|
+ },
|
|
|
+
|
|
|
+ click_scan_control(scanResult,inner) {
|
|
|
if(this.scanFlag){
|
|
|
return;
|
|
|
}
|
|
@@ -649,6 +675,9 @@ Page({
|
|
|
});
|
|
|
return;
|
|
|
} else {
|
|
|
+ if(!this.phoneCheck()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
log.info('[首页]', '[获取用户是否有未支付订单]', '[请求]', { userId: this.data.userInfo.userId });
|
|
|
wx.request({
|
|
|
url: getApp().globalData.postHeadAgreement + '/restapi/pileLog/wechatsettlement',
|
|
@@ -688,85 +717,23 @@ Page({
|
|
|
//console.log('无订单');
|
|
|
log.info('[首页]', '[用户无未支付订单]');
|
|
|
//console.log("打开扫一扫");
|
|
|
- wx.scanCode({
|
|
|
- success: function (d) {
|
|
|
- //console.log("完成扫一扫");
|
|
|
- //console.log(d);
|
|
|
- //兼容标准格式hlht://202001022222220101.330414214二维码
|
|
|
- let scanResult = d.result;
|
|
|
- if((!scanResult) || scanResult == ""){
|
|
|
- scanResult="*"
|
|
|
- }
|
|
|
- console.log(scanResult);
|
|
|
- if (scanResult.startsWith("hlht://") || scanResult.startsWith("HLHT://")){
|
|
|
- scanResult = scanResult.substring(7, scanResult.indexOf("."));
|
|
|
- }
|
|
|
- console.log(scanResult);
|
|
|
- log.info('[首页]', '[用户完成扫一扫]', scanResult);
|
|
|
- log.info('[首页]', '[获取扫一扫充电桩]', '[请求]', scanResult);
|
|
|
- wx.request({
|
|
|
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargPile',
|
|
|
- // data: scanResult,
|
|
|
- data: {
|
|
|
- chargPileId:scanResult,
|
|
|
- userId: that.data.userInfo.userId
|
|
|
- },
|
|
|
- method: 'POST',
|
|
|
- success(res) {
|
|
|
- console.log(scanResult);
|
|
|
- log.info('[首页]', '[获取扫一扫充电桩]', '[响应]', res.data);
|
|
|
- if (!res.data || res.data.code == 500) {
|
|
|
- that.scanFlag = false;
|
|
|
- wx.hideLoading();
|
|
|
- //没有该充电桩信息
|
|
|
- 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`;
|
|
|
- that.scanFlag = false;
|
|
|
- wx.hideLoading();
|
|
|
- wx.navigateTo({
|
|
|
- url
|
|
|
- });
|
|
|
- }
|
|
|
- that.scanFlag = false;
|
|
|
- wx.hideLoading();
|
|
|
- }
|
|
|
- },
|
|
|
- fail(e) {
|
|
|
- getApp().showNetworkError();
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- fail(e){
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(inner){
|
|
|
+ wx.pro.scanCode().then(d=>{
|
|
|
+ that.afterScanCode(d,that,inner)
|
|
|
+ }).catch(e=>{
|
|
|
that.scanFlag = false;
|
|
|
wx.hideLoading();
|
|
|
- }
|
|
|
- });
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ that.afterScanCode(scanResult,that,inner)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
},
|
|
|
fail(e) {
|
|
@@ -778,6 +745,90 @@ Page({
|
|
|
}
|
|
|
|
|
|
},
|
|
|
+ afterScanCode(d,that,inner){
|
|
|
+ let scanResult = ""
|
|
|
+ if(inner){
|
|
|
+ //console.log("完成扫一扫");
|
|
|
+ //console.log(d);
|
|
|
+ //兼容标准格式hlht://202001022222220101.330414214二维码
|
|
|
+ scanResult = d.result;
|
|
|
+ if((!scanResult) || scanResult == ""){
|
|
|
+ scanResult="*"
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ scanResult = decodeURIComponent(d)
|
|
|
+ //console.log(charePileId);
|
|
|
+ log.info('[首页]', '[微信扫一扫]', { 'd': d });
|
|
|
+ if(!scanResult){
|
|
|
+ scanResult = "0"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (scanResult.startsWith("hlht://") || scanResult.startsWith("HLHT://")){
|
|
|
+ scanResult = scanResult. substring(7, scanResult.indexOf("."));
|
|
|
+ }
|
|
|
+ scanResult = scanResult.replace("https://cdgl.pjnes.com/", "");
|
|
|
+ scanResult = scanResult.replace("https://cdglyy.pjnes.com/", "");
|
|
|
+ console.log('扫描到的内容: [' + scanResult + '] , 是否内部按钮:' + inner)
|
|
|
+ log.info('[首页]', '[用户完成扫一扫]', scanResult);
|
|
|
+ log.info('[首页]', '[获取扫一扫充电桩]', '[请求]', scanResult);
|
|
|
+ wx.request({
|
|
|
+ url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargPile',
|
|
|
+ // data: scanResult,
|
|
|
+ data: {
|
|
|
+ chargPileId:scanResult,
|
|
|
+ userId: that.data.userInfo.userId
|
|
|
+ },
|
|
|
+ method: 'POST',
|
|
|
+ success(res) {
|
|
|
+ log.info('[首页]', '[获取扫一扫充电桩]', '[响应]', res.data);
|
|
|
+ if (!res.data || res.data.code == 500) {
|
|
|
+ that.scanFlag = false;
|
|
|
+ wx.hideLoading();
|
|
|
+ //没有该充电桩信息
|
|
|
+ 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`;
|
|
|
+ that.scanFlag = false;
|
|
|
+ wx.hideLoading();
|
|
|
+ wx.navigateTo({
|
|
|
+ url
|
|
|
+ });
|
|
|
+ }
|
|
|
+ that.scanFlag = false;
|
|
|
+ wx.hideLoading();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail(e) {
|
|
|
+ getApp().showNetworkError();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
//地图位移
|
|
|
mapchange(e) {
|
|
|
if (e.type == 'end') {
|
|
@@ -842,6 +893,7 @@ Page({
|
|
|
address: item.address,
|
|
|
width: "46rpx",
|
|
|
height: "67rpx",
|
|
|
+ chargfeatures: item.chargfeatures ,
|
|
|
iconPath: iconPath,
|
|
|
id: item.id,
|
|
|
callout: {},
|
|
@@ -901,6 +953,8 @@ Page({
|
|
|
},
|
|
|
|
|
|
phoneCheck(){
|
|
|
+
|
|
|
+
|
|
|
if (this.data.userInfo.bindingPhone==0) {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|