elpackage.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. // pages/scan_result/elpackage.js
  2. let log = require('../../utils/log.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. progressPercentage: 100, // 初始进度值为50%
  9. // chargPile: null,
  10. chargPile: {
  11. },
  12. parkObj:{},
  13. eleList:{},
  14. orderid: null,
  15. userInfo:{},
  16. userId: null,
  17. repaidbalance: 0,
  18. resultTable: [],
  19. selectEleIndex : -1,
  20. // 是否减免停车费
  21. carParkingRate: false,
  22. // 停车时间
  23. parkTime: 0,
  24. url:'/images/scan_result.png',
  25. authStatus: 1,
  26. defPlateNumber:'',
  27. car_active: false
  28. },
  29. /**
  30. * 生命周期函数--监听页面加载
  31. */
  32. onLoad: function (options) {
  33. let that = this;
  34. let userInfo = wx.getStorageSync('userInfo');
  35. that.setData({
  36. userInfo
  37. })
  38. wx.getStorage({
  39. key: 'elpackage',
  40. success: function (res) {
  41. console.log(res);
  42. console.log(res.data);
  43. let chargPile = res.data.chargStation;
  44. let eleList = res.data.chargPileList;
  45. let parkObj = res.data
  46. eleList.forEach((key)=>{
  47. if(!key.currentSoc){
  48. key.currentSoc = 0
  49. }
  50. key['active'] = false
  51. })
  52. that.setData({
  53. chargPile,
  54. eleList,
  55. parkObj
  56. })
  57. // 更新是否减停车费
  58. wx.removeStorage({
  59. key: 'elpackage',
  60. success(res) {
  61. console.log(res);
  62. }
  63. });
  64. }
  65. });
  66. },
  67. selectEle(e){
  68. let idx = e.currentTarget.dataset.idx;
  69. let that = this;
  70. let eleList = that.data.eleList;
  71. let car_active = that.data.car_active;
  72. if(eleList[idx].active){
  73. eleList[idx].active = false;
  74. idx = -1
  75. }else{
  76. eleList[idx].active = true;
  77. if(that.data.selectEleIndex>=0){
  78. eleList[that.data.selectEleIndex].active = false;
  79. }
  80. }
  81. car_active = (idx>=0)
  82. that.setData({
  83. selectEleIndex: idx,
  84. eleList,
  85. car_active
  86. })
  87. },
  88. callCar(){
  89. let that = this
  90. let car_active = that.data.car_active;
  91. if(!car_active){
  92. return;
  93. }
  94. let ivParkPointId = that.data.parkObj.ivParkPointId
  95. let chargePileId = that.data.eleList[that.data.selectEleIndex].id
  96. let userId = that.data.userInfo.userId
  97. wx.request({
  98. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/callCarRequirement?'
  99. + 'ivParkPointId=' + ivParkPointId
  100. + '&chargePileId=' + chargePileId
  101. + '&userId=' + userId
  102. + '&requirementType=0',
  103. data: {
  104. },
  105. method: 'POST',
  106. success: function (res) {
  107. if( res.data.code ==200){
  108. // 走你
  109. let url = `/pages/batteryPack/batteryPackWait`;
  110. wx.navigateTo({
  111. url
  112. });
  113. }else{
  114. // 给出提示
  115. wx.showModal({
  116. showCancel: false,
  117. content: "调度失败" + res.data?.msg,
  118. confirmColor:'#00AADD',
  119. });
  120. }
  121. },
  122. fail(e) {
  123. console.log("呼叫充电车失败");
  124. }
  125. });
  126. },
  127. /**
  128. * 生命周期函数--监听页面初次渲染完成
  129. */
  130. onReady: function () {
  131. },
  132. /**
  133. * 生命周期函数--监听页面显示
  134. */
  135. onShow: function () {
  136. let car = wx.getStorageSync('chooseCar_plateNumber')
  137. let plateNumber = ''
  138. if(car){
  139. plateNumber = car.plateNumber;
  140. wx.removeStorageSync('chooseCar_plateNumber')
  141. }
  142. this.setData({
  143. plateNumber
  144. })
  145. console.info('将会自动跳过弹窗,默认车牌号:' + plateNumber)
  146. if(car){
  147. this.beginChargeInner(this,plateNumber)
  148. }
  149. },
  150. /**
  151. * 生命周期函数--监听页面隐藏
  152. */
  153. onHide: function () {
  154. },
  155. /**
  156. * 生命周期函数--监听页面卸载
  157. */
  158. onUnload: function () {
  159. },
  160. /**
  161. * 页面相关事件处理函数--监听用户下拉动作
  162. */
  163. onPullDownRefresh: function () {
  164. },
  165. /**
  166. * 页面上拉触底事件的处理函数
  167. */
  168. onReachBottom: function () {
  169. },
  170. /**
  171. * 用户点击右上角分享
  172. */
  173. onShareAppMessage: function () {
  174. }
  175. })