Browse Source

[C端停车][修改]:停车费修改

tags/2.2.4
Stormeye.Wu 6 years ago
parent
commit
18adfffd55
3 changed files with 54 additions and 30 deletions
  1. +2
    -1
      app.js
  2. +2
    -2
      config/config.js
  3. +50
    -27
      pages/passCar/passCar.js

+ 2
- 1
app.js View File

@@ -115,13 +115,14 @@ App({
Http.post({ Http.post({
url: config.api.carInit, url: config.api.carInit,
data: { data: {
phone: this.globalData.phone
phone: that.globalData.phone
} }
}).then(res => { }).then(res => {
that.globalData.carLogin = true that.globalData.carLogin = true
that.globalData.parkVendor = res.data.vendor that.globalData.parkVendor = res.data.vendor
if (res.data.token != "undefined") { if (res.data.token != "undefined") {
that.globalData.etcpToken = res.data.token that.globalData.etcpToken = res.data.token
console.log("etcpToken", that.globalData.etcpToken)
} }
}) })
} }


+ 2
- 2
config/config.js View File

@@ -1,7 +1,7 @@
var config = { var config = {
name: "富茂", name: "富茂",
//url: "https://ciformall.youlane.cn/C/api",
url: "http://89e4b9c3.ngrok.io/C/api",
url: "https://ciformall.youlane.cn/C/api",
//url: "http://89e4b9c3.ngrok.io/C/api",
api: { api: {
/** /**
* 接口用途:login * 接口用途:login


+ 50
- 27
pages/passCar/passCar.js View File

@@ -10,18 +10,17 @@ Page({
}, },
onLoad: function(options) { onLoad: function(options) {
var that = this var that = this
app.userCarLogin()
that.init(); that.init();
}, },
onShow: function(options) { onShow: function(options) {
var that = this var that = this
console.log(options)
if (options)
console.log(options)
if (that.data.addCar) { if (that.data.addCar) {
// 绑车牌 // 绑车牌
if (app.globalData.carLogin) { if (app.globalData.carLogin) {
that.bindCar(that.data.addCar) that.bindCar(that.data.addCar)
} else { } else {
app.userCarLogin()
that.bindCar(that.data.addCar) that.bindCar(that.data.addCar)
} }
} }
@@ -93,8 +92,6 @@ Page({
}, },
unbindCar: function(carNum) { unbindCar: function(carNum) {
var that = this var that = this
// carLogin
app.userCarLogin()
var postData = var postData =
(app.globalData.parkVendor == 1) ? { (app.globalData.parkVendor == 1) ? {
etcpToken: app.globalData.etcpToken, etcpToken: app.globalData.etcpToken,
@@ -131,29 +128,38 @@ Page({
var carNum = e.currentTarget.dataset.car var carNum = e.currentTarget.dataset.car
that.unbindCar(carNum) that.unbindCar(carNum)
}, },
getStopFeeItem: function(carItem, i) {
var that = this
var postData =
(app.globalData.parkVendor == 1) ? {
etcpToken: app.globalData.etcpToken,
carNumber: carItem.carNumber,
} : {
carNumber: carItem.carNumber,
outCarId: carItem.outCarId,
}
var stopFee = 'carList[' + i + '].stopFee'
console.log(postData)
Http.post({
url: config.api.getCarStopFee,
data: postData
})
.then(res => {
console.log(res)
console.log(stopFee)
that.setData({
[stopFee]: res.data
})
})
.catch(error =>{
console.log(error)
})
},
getStopFee: function() { getStopFee: function() {
var that = this var that = this
// carLogin
for (var i = 0; i < that.data.carList.length; i++) { for (var i = 0; i < that.data.carList.length; i++) {
var carItem = that.data.carList[i]
var postData =
(app.globalData.parkVendor == 1) ? {
etcpToken: app.globalData.etcpToken,
carNumber: carItem.carNumber,
} : {
carNumber: carItem.carNumber,
outCarId: carItem.outCarId,
}
var stopFee = 'carList[' + i + '].stopFee'
Http.post({
url: config.api.getCarStopFee,
data: postData
})
.then(res => {
console.log(res)
that.setData({
[stopFee]: res.data
})
})
that.getStopFeeItem(that.data.carList[i], i)
} }
}, },
initPark: function() { initPark: function() {
@@ -181,15 +187,32 @@ Page({
that.setData({ that.setData({
carList: res.data carList: res.data
}) })
// 获取 停车费
that.getStopFee()
}) })
}, },
init: function() { init: function() {
var that = this var that = this
app.parkInitCallback = token => { app.parkInitCallback = token => {
that.initPark() that.initPark()
that.initUsrCarList() that.initUsrCarList()
if (!app.globalData.carLogin) {
// 共同登录
Http.post({
url: config.api.carInit,
data: {
phone: app.globalData.phone
}
}).then(res => {
app.globalData.carLogin = true
app.globalData.parkVendor = res.data.vendor
if (res.data.token != "undefined") {
app.globalData.etcpToken = res.data.token
console.log("etcpToken", app.globalData.etcpToken)
}
// 获取 停车费
that.getStopFee()
})
}
} }
if (app.globalData.token && app.globalData.token != null) { if (app.globalData.token && app.globalData.token != null) {
app.parkInitCallback(app.globalData.token) app.parkInitCallback(app.globalData.token)


Loading…
Cancel
Save