From 9e92707d684fe0838bd2c6ceaa36953ae4eef303 Mon Sep 17 00:00:00 2001 From: "Stormeye.Wu" Date: Fri, 24 Aug 2018 14:38:45 +0800 Subject: [PATCH] =?UTF-8?q?[=E8=BD=A6=E6=B5=81][=E6=96=B0=E5=A2=9E]:?= =?UTF-8?q?=E5=81=9C=E8=BD=A6=E5=9C=BA=E4=BF=A1=E6=81=AF=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/passCar/passCar.js | 176 ++++++++++++++++++++++--------------- pages/passCar/passCar.wxml | 6 +- 2 files changed, 109 insertions(+), 73 deletions(-) diff --git a/pages/passCar/passCar.js b/pages/passCar/passCar.js index 86c49db..ce70f2b 100644 --- a/pages/passCar/passCar.js +++ b/pages/passCar/passCar.js @@ -1,9 +1,8 @@ // pages/passCar/passCar.js +let config = require('../../config/config.js') +let Http = require('../../utils/HttpBasics') const app = getApp(); -Component({ - properties: { - - }, +Page({ data: { parkVendor: 1, park: null, @@ -11,81 +10,120 @@ Component({ etcpToken: null, }, - methods: { - jumpToAdd: function() { - wx.redirectTo({ - url: '/pages/addPark/addPark' - }); - }, - jumpToPay: function() { - wx.redirectTo({ - url: '/pages/pay/pay', - }) - }, - passb: function() { - wx.showToast({ - title: '货物在路上~', + onLoad: function(options) { + if (options.addcar != 'undefined') { + // 绑车牌 + } + this.init(); + + }, + jumpToAdd: function() { + wx.redirectTo({ + url: '/pages/addPark/addPark' + }); + }, + jumpToPay: function() { + wx.redirectTo({ + url: '/pages/pay/pay', + }) + }, + passb: function() { + wx.showToast({ + title: '货物在路上~', + }) + }, + passc: function() { + wx.showToast({ + title: '宝宝最可爱~', + }) + }, + orderPay: function() { + wx.redirectTo({ + url: '/pages/pay/pay' + }); + }, + bindCar: function(carNum) { + // ETCP + var etcpData = { + etcpToken: that.data.etcpToken, + carNumber: carNum, + } + // 停简单 + var tjdData = { + carNumber: carNum, + } + var postData = (parkVendor == 1) ? etcpData : tjdData + Http.post({ + url: config.api.bindCar, + data: postData, }) - }, - passc: function() { - wx.showToast({ - title: '宝宝最可爱~', + .then(res => { + console.log(res) + wx.showModal({ + title: '提示', + showCancel: false, + content: "绑车牌成功!", + success: function() {} + }) }) - }, - orderPay: function() { - wx.redirectTo({ - url: '/pages/pay/pay' - }); - }, - unbindCar: function() { - 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 - Http.post({ - url: config.api.unbindCar, - data: postData, + .catch(error => { + console.log(error) + wx.showModal({ + title: '提示', + showCancel: false, + content: "绑车牌失败!", + success: function() {} }) - .then(res => { - console.log(res) - wx.showModal({ - title: '提示', - showCancel: false, - content: "解绑车牌成功!", - success: function() {} - }) + }) + }, + unbindCar: function() { + 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 + Http.post({ + url: config.api.unbindCar, + data: postData, + }) + .then(res => { + console.log(res) + wx.showModal({ + title: '提示', + showCancel: false, + content: "解绑车牌成功!", + success: function() {} }) - .catch(error => { - wx.showModal({ - title: '提示', - showCancel: false, - content: "解绑车牌失败!", - success: function () { } - }) + }) + .catch(error => { + wx.showModal({ + title: '提示', + showCancel: false, + content: "解绑车牌失败!", + success: function() {} }) - }, + }) }, - ready() { + init: function () { var that = this - initCallback = token => { + app.parkInitCallback = token => { // 车场信息获取 Http.get({ - url: config.api.getParkInfo, - data: {} - }) + url: config.api.getParkInfo, + data: {} + }) .then(res => { console.log(res) that.setData({ - tabs: res.data + park: res.data }) }) //绑定车获取 @@ -100,9 +138,7 @@ Component({ }) } if (app.globalData.token && app.globalData.token != null) { - initCallback(app.globalData.token) - } else { - initCallback(app.globalData.token) + app.parkInitCallback(app.globalData.token) } } }) \ No newline at end of file diff --git a/pages/passCar/passCar.wxml b/pages/passCar/passCar.wxml index 219bcea..e7b6044 100644 --- a/pages/passCar/passCar.wxml +++ b/pages/passCar/passCar.wxml @@ -2,12 +2,12 @@ - 万达停车场 + {{park.addr}} 总车位: - + 停车费: - +