|
|
@@ -10,18 +10,17 @@ Page({ |
|
|
|
}, |
|
|
|
onLoad: function(options) { |
|
|
|
var that = this |
|
|
|
app.userCarLogin() |
|
|
|
that.init(); |
|
|
|
}, |
|
|
|
onShow: function(options) { |
|
|
|
var that = this |
|
|
|
console.log(options) |
|
|
|
if (options) |
|
|
|
console.log(options) |
|
|
|
if (that.data.addCar) { |
|
|
|
// 绑车牌 |
|
|
|
if (app.globalData.carLogin) { |
|
|
|
that.bindCar(that.data.addCar) |
|
|
|
} else { |
|
|
|
app.userCarLogin() |
|
|
|
that.bindCar(that.data.addCar) |
|
|
|
} |
|
|
|
} |
|
|
@@ -93,8 +92,6 @@ Page({ |
|
|
|
}, |
|
|
|
unbindCar: function(carNum) { |
|
|
|
var that = this |
|
|
|
// carLogin |
|
|
|
app.userCarLogin() |
|
|
|
var postData = |
|
|
|
(app.globalData.parkVendor == 1) ? { |
|
|
|
etcpToken: app.globalData.etcpToken, |
|
|
@@ -131,29 +128,38 @@ Page({ |
|
|
|
var carNum = e.currentTarget.dataset.car |
|
|
|
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() { |
|
|
|
var that = this |
|
|
|
// carLogin |
|
|
|
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() { |
|
|
@@ -181,15 +187,32 @@ Page({ |
|
|
|
that.setData({ |
|
|
|
carList: res.data |
|
|
|
}) |
|
|
|
// 获取 停车费 |
|
|
|
that.getStopFee() |
|
|
|
}) |
|
|
|
}, |
|
|
|
init: function() { |
|
|
|
var that = this |
|
|
|
|
|
|
|
app.parkInitCallback = token => { |
|
|
|
that.initPark() |
|
|
|
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) { |
|
|
|
app.parkInitCallback(app.globalData.token) |
|
|
|