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.

125 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. addUrl: wx.getStorageSync('imgurl').add.url,
  10. carList: []
  11. },
  12. initUsrCarList: function() {
  13. var that = this;
  14. // 绑定车获取
  15. Http.get({
  16. url: config.api.getUserCarList,
  17. data: {}
  18. }).then(res => {
  19. that.setData({
  20. carList: res.data
  21. });
  22. })
  23. .catch(err => {
  24. wx.showToast({
  25. title: err.errMsg,
  26. icon: 'none',
  27. duration: 2000,
  28. mask: false
  29. });
  30. })
  31. },
  32. unbindCarBtn: function(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. that.initUsrCarList();
  52. wx.showModal({
  53. title: "提示",
  54. showCancel: false,
  55. content: "解绑车牌成功!",
  56. success: function() {}
  57. });
  58. })
  59. .catch(error => {
  60. wx.showModal({
  61. title: "提示",
  62. showCancel: false,
  63. content: "解绑车牌失败!",
  64. });
  65. });
  66. },
  67. bindCar: function(carNum) {
  68. var that = this;
  69. // ETCP
  70. var etcpData = {
  71. etcpToken: app.globalData.etcpToken,
  72. carNumber: carNum
  73. };
  74. var tjdData = {
  75. carNumber: carNum
  76. };
  77. var postData = app.globalData.parkVendor == 1 ? etcpData : tjdData;
  78. Http.post({
  79. url: config.api.bindCar,
  80. data: postData
  81. })
  82. .then(res => {
  83. that.setData({
  84. addCar: null
  85. });
  86. that.initUsrCarList();
  87. wx.showModal({
  88. title: "提示",
  89. showCancel: false,
  90. content: "绑车牌成功!",
  91. success: function() {}
  92. });
  93. })
  94. .catch(error => {
  95. wx.showModal({
  96. title: "提示",
  97. showCancel: false,
  98. content: error.data.message,
  99. success: function() {}
  100. });
  101. });
  102. },
  103. jumpToAdd: function() {
  104. wx.navigateTo({
  105. url: `/pages/addPark/addPark?flags=managepalte`
  106. });
  107. },
  108. onShow: function(options) {
  109. var that = this;
  110. that.initUsrCarList();
  111. if (that.data.addCar) {
  112. // 绑车牌
  113. if (app.globalData.carLogin) {
  114. that.bindCar(that.data.addCar);
  115. } else {
  116. that.bindCar(that.data.addCar);
  117. }
  118. that.setData({
  119. addCar: null
  120. });
  121. }
  122. },
  123. })