| @@ -101,6 +101,7 @@ App({ | |||||
| that.globalData.phone = res.data.phone | that.globalData.phone = res.data.phone | ||||
| that.globalData.supportCar = true | that.globalData.supportCar = true | ||||
| // 共同登录 | // 共同登录 | ||||
| that.userCarLogin() | |||||
| } | } | ||||
| }) | }) | ||||
| }, | }, | ||||
| @@ -109,18 +110,21 @@ App({ | |||||
| */ | */ | ||||
| userCarLogin: function() { | userCarLogin: function() { | ||||
| var that = this | var that = this | ||||
| // 共同登录 | |||||
| Http.post({ | |||||
| url: config.api.carInit, | |||||
| data: { | |||||
| phone: this.globalData.phone | |||||
| } | |||||
| }).then(res => { | |||||
| that.globalData.parkVendor = res.data.parkVendor | |||||
| if (res.data.token != "undefined") { | |||||
| that.globalData.etcpToken = res.data.token | |||||
| } | |||||
| }) | |||||
| if (!that.globalData.carLogin) { | |||||
| // 共同登录 | |||||
| Http.post({ | |||||
| url: config.api.carInit, | |||||
| data: { | |||||
| phone: this.globalData.phone | |||||
| } | |||||
| }).then(res => { | |||||
| that.globalData.carLogin = true | |||||
| that.globalData.parkVendor = res.data.vendor | |||||
| if (res.data.token != "undefined") { | |||||
| that.globalData.etcpToken = res.data.token | |||||
| } | |||||
| }) | |||||
| } | |||||
| }, | }, | ||||
| globalData: { | globalData: { | ||||
| // token | // token | ||||
| @@ -135,6 +139,7 @@ App({ | |||||
| parkVendor: 1, // 1: ETCP, 2: TJD | parkVendor: 1, // 1: ETCP, 2: TJD | ||||
| // ETCP token | // ETCP token | ||||
| etcpToken: null, | etcpToken: null, | ||||
| carLogin: false, | |||||
| // 当前商场信息 | // 当前商场信息 | ||||
| market: { | market: { | ||||
| name: "陕西大悦城" | name: "陕西大悦城" | ||||
| @@ -90,7 +90,7 @@ var config = { | |||||
| /** | /** | ||||
| * 绑车牌 | * 绑车牌 | ||||
| */ | */ | ||||
| bindCarNum: '/car/bindCar', | |||||
| bindCar: '/car/bindCar', | |||||
| /** | /** | ||||
| * 解绑车牌 | * 解绑车牌 | ||||
| */ | */ | ||||
| @@ -60,9 +60,9 @@ Page({ | |||||
| }, | }, | ||||
| jumpTo: function () { | jumpTo: function () { | ||||
| // 返回 | // 返回 | ||||
| wx.redirectTo({ | |||||
| wx.navigateBack({ | |||||
| url: '/pages/passCar/passCar' | url: '/pages/passCar/passCar' | ||||
| }); | |||||
| }) | |||||
| }, | }, | ||||
| handleTap: function (e) { | handleTap: function (e) { | ||||
| this.buttonStatus(); | this.buttonStatus(); | ||||
| @@ -335,9 +335,20 @@ Page({ | |||||
| submit: function () { | submit: function () { | ||||
| wx.navigateTo({ | |||||
| url: '/pages/passCar/passCar', | |||||
| if (this.data.title != "" && this.data.numFir != "" && this.data.numSco != "" && this.data.numThr != "" && this.data.numFor != "" && this.data.numFive != "" && this.data.numSix != "") { | |||||
| var carNumber = '' | |||||
| carNumber += this.data.title + this.data.numFir + this.data.numSco + this.data.numThr + this.data.numFor + this.data.numFive + this.data.numSix | |||||
| if (this.data.numSource != "") | |||||
| carNumber += this.data.numSource | |||||
| var pages = getCurrentPages(); | |||||
| var prevPage = pages[pages.length - 2]; | |||||
| prevPage.setData({ | |||||
| addCar: carNumber | |||||
| }) | }) | ||||
| wx.navigateBack({ | |||||
| url: '../passCar/passCar?addcar=' + carNumber, | |||||
| }) | |||||
| } | |||||
| }, | }, | ||||
| buttonStatus: function () { | buttonStatus: function () { | ||||
| if (this.data.title != "" && this.data.numFir != "" && this.data.numSco != "" && this.data.numThr != "" && this.data.numFor != "" && this.data.numFive != "" && this.data.numSix != "") { | if (this.data.title != "" && this.data.numFir != "" && this.data.numSco != "" && this.data.numThr != "" && this.data.numFor != "" && this.data.numFive != "" && this.data.numSix != "") { | ||||
| @@ -4,22 +4,31 @@ let Http = require('../../utils/HttpBasics') | |||||
| const app = getApp(); | const app = getApp(); | ||||
| Page({ | Page({ | ||||
| data: { | data: { | ||||
| parkVendor: 1, | |||||
| park: null, | park: null, | ||||
| carList: [], | carList: [], | ||||
| etcpToken: null, | |||||
| addCar: null, | |||||
| }, | }, | ||||
| onLoad: function(options) { | onLoad: function(options) { | ||||
| if (options.addcar != 'undefined') { | |||||
| var that = this | |||||
| app.userCarLogin() | |||||
| that.init(); | |||||
| }, | |||||
| onShow: function(options) { | |||||
| var that = this | |||||
| console.log(options) | |||||
| if (that.data.addCar) { | |||||
| // 绑车牌 | // 绑车牌 | ||||
| if (app.globalData.carLogin) { | |||||
| that.bindCar(that.data.addCar) | |||||
| } else { | |||||
| app.userCarLogin() | |||||
| that.bindCar(that.data.addCar) | |||||
| } | |||||
| } | } | ||||
| this.init(); | |||||
| }, | }, | ||||
| jumpToAdd: function() { | jumpToAdd: function() { | ||||
| wx.redirectTo({ | |||||
| url: '/pages/addPark/addPark' | |||||
| wx.navigateTo({ | |||||
| url: '/pages/addPark/addPark', | |||||
| }); | }); | ||||
| }, | }, | ||||
| jumpToPay: function() { | jumpToPay: function() { | ||||
| @@ -43,16 +52,17 @@ Page({ | |||||
| }); | }); | ||||
| }, | }, | ||||
| bindCar: function(carNum) { | bindCar: function(carNum) { | ||||
| var that = this | |||||
| // ETCP | // ETCP | ||||
| var etcpData = { | var etcpData = { | ||||
| etcpToken: that.data.etcpToken, | |||||
| etcpToken: app.globalData.etcpToken, | |||||
| carNumber: carNum, | carNumber: carNum, | ||||
| } | } | ||||
| // 停简单 | // 停简单 | ||||
| var tjdData = { | var tjdData = { | ||||
| carNumber: carNum, | carNumber: carNum, | ||||
| } | } | ||||
| var postData = (parkVendor == 1) ? etcpData : tjdData | |||||
| var postData = (app.globalData.parkVendor == 1) ? etcpData : tjdData | |||||
| Http.post({ | Http.post({ | ||||
| url: config.api.bindCar, | url: config.api.bindCar, | ||||
| data: postData, | data: postData, | ||||
| @@ -71,25 +81,22 @@ Page({ | |||||
| wx.showModal({ | wx.showModal({ | ||||
| title: '提示', | title: '提示', | ||||
| showCancel: false, | showCancel: false, | ||||
| content: "绑车牌失败!", | |||||
| content: error.data.message, | |||||
| success: function() {} | success: function() {} | ||||
| }) | }) | ||||
| }) | }) | ||||
| }, | }, | ||||
| unbindCar: function() { | |||||
| unbindCar: function(carNum) { | |||||
| var that = this | var that = this | ||||
| // ETCP | |||||
| var etcpData = { | |||||
| etcpToken: that.data.etcpToken, | |||||
| carNumber: null, | |||||
| } | |||||
| // 停简单 | |||||
| var tjdData = { | |||||
| carNumber: null, | |||||
| carNumColor: null, | |||||
| outCarId: null, | |||||
| } | |||||
| var postData = (parkVendor == 1) ? etcpData : tjdData | |||||
| // carLogin | |||||
| app.userCarLogin() | |||||
| var postData = | |||||
| (parkVendor == 1) ? { | |||||
| etcpToken: that.data.etcpToken, | |||||
| carNumber: carNum, | |||||
| } : { | |||||
| carNumber: carNum, | |||||
| } | |||||
| Http.post({ | Http.post({ | ||||
| url: config.api.unbindCar, | url: config.api.unbindCar, | ||||
| data: postData, | data: postData, | ||||
| @@ -112,7 +119,7 @@ Page({ | |||||
| }) | }) | ||||
| }) | }) | ||||
| }, | }, | ||||
| init: function () { | |||||
| init: function() { | |||||
| var that = this | var that = this | ||||
| app.parkInitCallback = token => { | app.parkInitCallback = token => { | ||||
| // 车场信息获取 | // 车场信息获取 | ||||
| @@ -123,7 +130,7 @@ Page({ | |||||
| .then(res => { | .then(res => { | ||||
| console.log(res) | console.log(res) | ||||
| that.setData({ | that.setData({ | ||||
| park: res.data | |||||
| park: res.data, | |||||
| }) | }) | ||||
| }) | }) | ||||
| //绑定车获取 | //绑定车获取 | ||||