|
- // pages/passCar/passCar.js
- let config = require('../../config/config.js')
- let Http = require('../../utils/HttpBasics')
- const app = getApp();
- Page({
- data: {
- park: null,
- carList: [],
- addCar: null,
- },
- onLoad: function(options) {
- 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)
- }
- }
- },
- jumpToAdd: function() {
- wx.navigateTo({
- 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) {
- var that = this
- // ETCP
- var etcpData = {
- etcpToken: app.globalData.etcpToken,
- carNumber: carNum,
- }
- // 停简单
- var tjdData = {
- carNumber: carNum,
- }
- var postData = (app.globalData.parkVendor == 1) ? etcpData : tjdData
- Http.post({
- url: config.api.bindCar,
- data: postData,
- })
- .then(res => {
- console.log(res)
- wx.showModal({
- title: '提示',
- showCancel: false,
- content: "绑车牌成功!",
- success: function() {}
- })
- })
- .catch(error => {
- console.log(error)
- wx.showModal({
- title: '提示',
- showCancel: false,
- content: error.data.message,
- success: function() {}
- })
- })
- },
- unbindCar: function(carNum) {
- var that = this
- // carLogin
- app.userCarLogin()
- var postData =
- (parkVendor == 1) ? {
- etcpToken: that.data.etcpToken,
- carNumber: carNum,
- } : {
- carNumber: carNum,
- }
- 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() {}
- })
- })
- },
- init: function() {
- var that = this
- app.parkInitCallback = token => {
- // 车场信息获取
- Http.get({
- url: config.api.getParkInfo,
- data: {}
- })
- .then(res => {
- console.log(res)
- that.setData({
- park: res.data,
- })
- })
- //绑定车获取
- Http.get({
- url: config.api.getUserCarList,
- data: {}
- }).then(res => {
- console.log(res);
- that.setData({
- carList: res.data
- })
- })
- }
- if (app.globalData.token && app.globalData.token != null) {
- app.parkInitCallback(app.globalData.token)
- }
- }
- })
|