elpackage.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. hid:false
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad: function (options) {
  34. let that = this;
  35. let userInfo = wx.getStorageSync('userInfo');
  36. that.setData({
  37. userInfo
  38. })
  39. wx.getStorage({
  40. key: 'elpackage',
  41. success: function (res) {
  42. console.log(res);
  43. console.log(res.data);
  44. let chargPile = res.data.chargStation;
  45. let eleList = res.data.chargPileList;
  46. let parkObj = res.data
  47. eleList.forEach((key)=>{
  48. if(!key.currentSoc){
  49. key.currentSoc = 0
  50. }
  51. key['active'] = true
  52. })
  53. that.setData({
  54. chargPile,
  55. eleList,
  56. parkObj
  57. })
  58. // 真机诡异的BUG(微信小程序真机)
  59. // 直接设置为false 会 导致界面上的电池量不显示(这是因为真机会在css之前加上两个横线--,但是直接在css中写这两个横线会导致编译报错)
  60. // 这里折中先设置为true,然后在定时器中设置为false 刷新一下
  61. setTimeout(()=>{
  62. eleList.forEach((key)=>{
  63. key['active'] = false
  64. })
  65. that.setData({
  66. eleList
  67. })
  68. }, 250)
  69. setTimeout(()=>{
  70. that.setData({
  71. hid:true
  72. })
  73. }, 300)
  74. // 更新是否减停车费
  75. wx.removeStorage({
  76. key: 'elpackage',
  77. success(res) {
  78. console.log(res);
  79. }
  80. });
  81. }
  82. });
  83. },
  84. selectEle(e){
  85. let idx = e.currentTarget.dataset.idx;
  86. let that = this;
  87. let eleList = that.data.eleList;
  88. let car_active = that.data.car_active;
  89. if(eleList[idx].active){
  90. eleList[idx].active = false;
  91. idx = -1
  92. }else{
  93. eleList[idx].active = true;
  94. if(that.data.selectEleIndex>=0){
  95. eleList[that.data.selectEleIndex].active = false;
  96. }
  97. }
  98. car_active = (idx>=0)
  99. that.setData({
  100. selectEleIndex: idx,
  101. eleList,
  102. car_active
  103. })
  104. },
  105. callCar(){
  106. let that = this
  107. let car_active = that.data.car_active;
  108. if(!car_active){
  109. return;
  110. }
  111. let ivParkPointId = that.data.parkObj.ivParkPointId
  112. let chargePileId = that.data.eleList[that.data.selectEleIndex].id
  113. let userId = that.data.userInfo.userId
  114. wx.request({
  115. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/callCarRequirement?'
  116. + 'ivParkPointId=' + ivParkPointId
  117. + '&chargePileId=' + chargePileId
  118. + '&userId=' + userId
  119. + '&requirementType=0',
  120. data: {
  121. },
  122. method: 'POST',
  123. success: function (res) {
  124. if( res.data.code ==200){
  125. // 走你
  126. let url = `/pages/batteryPack/batteryPackWait`;
  127. wx.navigateTo({
  128. url
  129. });
  130. }else{
  131. // 给出提示
  132. wx.showModal({
  133. showCancel: false,
  134. content: "调度失败" + res.data?.msg,
  135. confirmColor:'#00AADD',
  136. });
  137. }
  138. },
  139. fail(e) {
  140. console.log("呼叫充电车失败");
  141. }
  142. });
  143. },
  144. /**
  145. * 生命周期函数--监听页面初次渲染完成
  146. */
  147. onReady: function () {
  148. },
  149. /**
  150. * 生命周期函数--监听页面显示
  151. */
  152. onShow: function () {
  153. let car = wx.getStorageSync('chooseCar_plateNumber')
  154. let plateNumber = ''
  155. if(car){
  156. plateNumber = car.plateNumber;
  157. wx.removeStorageSync('chooseCar_plateNumber')
  158. }
  159. this.setData({
  160. plateNumber
  161. })
  162. console.info('将会自动跳过弹窗,默认车牌号:' + plateNumber)
  163. if(car){
  164. this.beginChargeInner(this,plateNumber)
  165. }
  166. },
  167. /**
  168. * 生命周期函数--监听页面隐藏
  169. */
  170. onHide: function () {
  171. },
  172. /**
  173. * 生命周期函数--监听页面卸载
  174. */
  175. onUnload: function () {
  176. },
  177. /**
  178. * 页面相关事件处理函数--监听用户下拉动作
  179. */
  180. onPullDownRefresh: function () {
  181. },
  182. /**
  183. * 页面上拉触底事件的处理函数
  184. */
  185. onReachBottom: function () {
  186. },
  187. /**
  188. * 用户点击右上角分享
  189. */
  190. onShareAppMessage: function () {
  191. }
  192. })