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.

126 line
2.7 KiB

  1. let config = require("../../config/config.js");
  2. let Http = require("../../utils/HttpBasics");
  3. let app = getApp();
  4. const imgurl = require("../../utils/imgurl");
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. addUrl: imgurl.add.url,
  11. carList: []
  12. },
  13. initUsrCarList: function() {
  14. var that = this;
  15. // 绑定车获取
  16. Http.get({
  17. url: config.api.getUserCarList,
  18. data: {}
  19. }).then(res => {
  20. that.setData({
  21. carList: res.data
  22. });
  23. })
  24. .catch(err => {
  25. wx.showToast({
  26. title: err.errMsg,
  27. icon: 'none',
  28. duration: 2000,
  29. mask: false
  30. });
  31. })
  32. },
  33. unbindCarBtn: function(e) {
  34. var that = this;
  35. var carNum = e.currentTarget.dataset.car;
  36. that.unbindCar(carNum);
  37. },
  38. unbindCar: function(carNum) {
  39. var that = this;
  40. var postData =
  41. app.globalData.parkVendor == 1 ? {
  42. etcpToken: app.globalData.etcpToken,
  43. carNumber: carNum
  44. } : {
  45. carNumber: carNum
  46. };
  47. Http.post({
  48. url: config.api.unbindCar,
  49. data: postData
  50. })
  51. .then(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. that.setData({
  85. addCar: null
  86. });
  87. that.initUsrCarList();
  88. wx.showModal({
  89. title: "提示",
  90. showCancel: false,
  91. content: "绑车牌成功!",
  92. success: function() {}
  93. });
  94. })
  95. .catch(error => {
  96. wx.showModal({
  97. title: "提示",
  98. showCancel: false,
  99. content: error.data.message,
  100. success: function() {}
  101. });
  102. });
  103. },
  104. jumpToAdd: function() {
  105. wx.navigateTo({
  106. url: `/pages/addPark/addPark?flags=managepalte`
  107. });
  108. },
  109. onShow: function(options) {
  110. var that = this;
  111. that.initUsrCarList();
  112. if (that.data.addCar) {
  113. // 绑车牌
  114. if (app.globalData.carLogin) {
  115. that.bindCar(that.data.addCar);
  116. } else {
  117. that.bindCar(that.data.addCar);
  118. }
  119. that.setData({
  120. addCar: null
  121. });
  122. }
  123. },
  124. })