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.

127 line
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. console.log(e);
  33. var that = this;
  34. var carNum = e.currentTarget.dataset.car;
  35. that.unbindCar(carNum);
  36. },
  37. unbindCar: function(carNum) {
  38. var that = this;
  39. var postData =
  40. app.globalData.parkVendor == 1 ? {
  41. etcpToken: app.globalData.etcpToken,
  42. carNumber: carNum
  43. } : {
  44. carNumber: carNum
  45. };
  46. Http.post({
  47. url: config.api.unbindCar,
  48. data: postData
  49. })
  50. .then(res => {
  51. console.log(res);
  52. that.initUsrCarList();
  53. wx.showModal({
  54. title: "提示",
  55. showCancel: false,
  56. content: "解绑车牌成功!",
  57. success: function() {}
  58. });
  59. })
  60. .catch(error => {
  61. wx.showModal({
  62. title: "提示",
  63. showCancel: false,
  64. content: "解绑车牌失败!",
  65. });
  66. });
  67. },
  68. bindCar: function(carNum) {
  69. var that = this;
  70. // ETCP
  71. var etcpData = {
  72. etcpToken: app.globalData.etcpToken,
  73. carNumber: carNum
  74. };
  75. var tjdData = {
  76. carNumber: carNum
  77. };
  78. var postData = app.globalData.parkVendor == 1 ? etcpData : tjdData;
  79. Http.post({
  80. url: config.api.bindCar,
  81. data: postData
  82. })
  83. .then(res => {
  84. console.log(res);
  85. that.setData({
  86. addCar: null
  87. });
  88. that.initUsrCarList();
  89. wx.showModal({
  90. title: "提示",
  91. showCancel: false,
  92. content: "绑车牌成功!",
  93. success: function() {}
  94. });
  95. })
  96. .catch(err => {
  97. wx.showToast({
  98. title: err.errMsg,
  99. icon: 'none',
  100. duration: 2000,
  101. mask: false
  102. });
  103. })
  104. },
  105. jumpToAdd: function() {
  106. wx.navigateTo({
  107. url: `/pages/addPark/addPark?flags=managepalte`
  108. });
  109. },
  110. onShow: function(options) {
  111. var that = this;
  112. that.initUsrCarList();
  113. if (that.data.addCar) {
  114. // 绑车牌
  115. if (app.globalData.carLogin) {
  116. that.bindCar(that.data.addCar);
  117. } else {
  118. that.bindCar(that.data.addCar);
  119. }
  120. that.setData({
  121. addCar: null
  122. });
  123. }
  124. },
  125. })