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