C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
3.0 KiB

  1. // pages/passCar/passCar.js
  2. let config = require('../../config/config.js')
  3. let Http = require('../../utils/HttpBasics')
  4. const app = getApp();
  5. Page({
  6. data: {
  7. parkVendor: 1,
  8. park: null,
  9. carList: [],
  10. etcpToken: null,
  11. },
  12. onLoad: function(options) {
  13. if (options.addcar != 'undefined') {
  14. // 绑车牌
  15. }
  16. this.init();
  17. },
  18. jumpToAdd: function() {
  19. wx.redirectTo({
  20. url: '/pages/addPark/addPark'
  21. });
  22. },
  23. jumpToPay: function() {
  24. wx.redirectTo({
  25. url: '/pages/pay/pay',
  26. })
  27. },
  28. passb: function() {
  29. wx.showToast({
  30. title: '货物在路上~',
  31. })
  32. },
  33. passc: function() {
  34. wx.showToast({
  35. title: '宝宝最可爱~',
  36. })
  37. },
  38. orderPay: function() {
  39. wx.redirectTo({
  40. url: '/pages/pay/pay'
  41. });
  42. },
  43. bindCar: function(carNum) {
  44. // ETCP
  45. var etcpData = {
  46. etcpToken: that.data.etcpToken,
  47. carNumber: carNum,
  48. }
  49. // 停简单
  50. var tjdData = {
  51. carNumber: carNum,
  52. }
  53. var postData = (parkVendor == 1) ? etcpData : tjdData
  54. Http.post({
  55. url: config.api.bindCar,
  56. data: postData,
  57. })
  58. .then(res => {
  59. console.log(res)
  60. wx.showModal({
  61. title: '提示',
  62. showCancel: false,
  63. content: "绑车牌成功!",
  64. success: function() {}
  65. })
  66. })
  67. .catch(error => {
  68. console.log(error)
  69. wx.showModal({
  70. title: '提示',
  71. showCancel: false,
  72. content: "绑车牌失败!",
  73. success: function() {}
  74. })
  75. })
  76. },
  77. unbindCar: function() {
  78. var that = this
  79. // ETCP
  80. var etcpData = {
  81. etcpToken: that.data.etcpToken,
  82. carNumber: null,
  83. }
  84. // 停简单
  85. var tjdData = {
  86. carNumber: null,
  87. carNumColor: null,
  88. outCarId: null,
  89. }
  90. var postData = (parkVendor == 1) ? etcpData : tjdData
  91. Http.post({
  92. url: config.api.unbindCar,
  93. data: postData,
  94. })
  95. .then(res => {
  96. console.log(res)
  97. wx.showModal({
  98. title: '提示',
  99. showCancel: false,
  100. content: "解绑车牌成功!",
  101. success: function() {}
  102. })
  103. })
  104. .catch(error => {
  105. wx.showModal({
  106. title: '提示',
  107. showCancel: false,
  108. content: "解绑车牌失败!",
  109. success: function() {}
  110. })
  111. })
  112. },
  113. init: function () {
  114. var that = this
  115. app.parkInitCallback = token => {
  116. // 车场信息获取
  117. Http.get({
  118. url: config.api.getParkInfo,
  119. data: {}
  120. })
  121. .then(res => {
  122. console.log(res)
  123. that.setData({
  124. park: res.data
  125. })
  126. })
  127. //绑定车获取
  128. Http.get({
  129. url: config.api.getUserCarList,
  130. data: {}
  131. }).then(res => {
  132. console.log(res);
  133. that.setData({
  134. carList: res.data
  135. })
  136. })
  137. }
  138. if (app.globalData.token && app.globalData.token != null) {
  139. app.parkInitCallback(app.globalData.token)
  140. }
  141. }
  142. })