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.

124 lines
2.7 KiB

  1. let config = require("../../config/config.js");
  2. let Http = require("../../utils/HttpBasics");
  3. let app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. carList: []
  10. },
  11. initUsrCarList: function() {
  12. var that = this;
  13. // 绑定车获取
  14. Http.get({
  15. url: config.api.getUserCarList,
  16. data: {}
  17. }).then(res => {
  18. that.setData({
  19. carList: res.data
  20. });
  21. })
  22. .catch(err => {
  23. wx.showToast({
  24. title: err.errMsg,
  25. icon: 'none',
  26. duration: 2000,
  27. mask: false
  28. });
  29. })
  30. },
  31. unbindCarBtn: function(e) {
  32. var that = this;
  33. var carNum = e.currentTarget.dataset.car;
  34. that.unbindCar(carNum);
  35. },
  36. unbindCar: function(carNum) {
  37. var that = this;
  38. var postData =
  39. app.globalData.parkVendor == 1 ? {
  40. etcpToken: app.globalData.etcpToken,
  41. carNumber: carNum
  42. } : {
  43. carNumber: carNum
  44. };
  45. Http.post({
  46. url: config.api.unbindCar,
  47. data: postData
  48. })
  49. .then(res => {
  50. that.initUsrCarList();
  51. wx.showModal({
  52. title: "提示",
  53. showCancel: false,
  54. content: "解绑车牌成功!",
  55. success: function() {}
  56. });
  57. })
  58. .catch(error => {
  59. wx.showModal({
  60. title: "提示",
  61. showCancel: false,
  62. content: "解绑车牌失败!",
  63. });
  64. });
  65. },
  66. bindCar: function(carNum) {
  67. var that = this;
  68. // ETCP
  69. var etcpData = {
  70. etcpToken: app.globalData.etcpToken,
  71. carNumber: carNum
  72. };
  73. var tjdData = {
  74. carNumber: carNum
  75. };
  76. var postData = app.globalData.parkVendor == 1 ? etcpData : tjdData;
  77. Http.post({
  78. url: config.api.bindCar,
  79. data: postData
  80. })
  81. .then(res => {
  82. that.setData({
  83. addCar: null
  84. });
  85. that.initUsrCarList();
  86. wx.showModal({
  87. title: "提示",
  88. showCancel: false,
  89. content: "绑车牌成功!",
  90. success: function() {}
  91. });
  92. })
  93. .catch(error => {
  94. wx.showModal({
  95. title: "提示",
  96. showCancel: false,
  97. content: error.data.message,
  98. success: function() {}
  99. });
  100. });
  101. },
  102. jumpToAdd: function() {
  103. wx.navigateTo({
  104. url: `/pages/addPark/addPark?flags=managepalte`
  105. });
  106. },
  107. onShow: function(options) {
  108. var that = this;
  109. that.initUsrCarList();
  110. if (that.data.addCar) {
  111. // 绑车牌
  112. if (app.globalData.carLogin) {
  113. that.bindCar(that.data.addCar);
  114. } else {
  115. that.bindCar(that.data.addCar);
  116. }
  117. that.setData({
  118. addCar: null
  119. });
  120. }
  121. },
  122. })