charginfo.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. import * as echarts from '../../ec-canvas/echarts';
  2. import * as lf from '../../ec-canvas/echarts-liquidfill';
  3. let log = require('../../utils/log.js');
  4. let wechat = require("../../utils/wechat");
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. brandName:'',
  11. name:'',
  12. address:'',
  13. offlineServicecall:'',
  14. stationTagList:[],
  15. chargprice: '',
  16. serviceprice: '',
  17. chargid: '',
  18. sumprice: '',
  19. fastFree:0,
  20. slowFree:0,
  21. fastSum:0,
  22. slowSum:0,
  23. pagesize:10,
  24. pagenum:1,
  25. ele_pagenum:1,
  26. total:-1,
  27. ele_total:-1,
  28. loadTotal: 0,
  29. dataLoading: false,
  30. ele_dataLoading: false,
  31. finishedLoadTap: 0,
  32. ele_finishedLoadTap: 0,
  33. finishedLoadShowTimes: 0,
  34. ele_finishedLoadShowTimes: 0,
  35. chargList: [],
  36. ele_chargList: [],
  37. seeInfoChargPile:{},
  38. userInfo:{},
  39. chargfeatureList:[],
  40. isLogin: false,
  41. resultTable: [],
  42. // 是否减免停车费
  43. carParkingRate: false,
  44. // 停车时间
  45. parkTime: 0,
  46. activeTab: '0',
  47. scrollTop:0,
  48. occupyFee:{},
  49. showOccupyFee:false,
  50. },
  51. execParking(that,stationId){
  52. wx.request({
  53. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/carParkingRate?stationId=' + stationId,
  54. // data: {
  55. // loginName: userInfo.loginName
  56. // },
  57. method: 'POST',
  58. success: function (res) {
  59. // 是否减免停车费
  60. // carParkingRate: false,
  61. // parkTime: 0,
  62. console.info(res)
  63. let reduceTime = res.data?.reduceTime;
  64. if(!reduceTime){
  65. that.setData({
  66. carParkingRate:false
  67. })
  68. return;
  69. }
  70. that.setData({
  71. carParkingRate:true
  72. })
  73. try{
  74. that.setData({
  75. parkTime: parseFloat((reduceTime/ 3600).toFixed(2))
  76. })
  77. }catch(e){
  78. that.setData({
  79. carParkingRate:false
  80. })
  81. }
  82. },
  83. fail(e) {
  84. console.log("用户数据同步失败");
  85. log.info('[扫码]', '[同步用户数据]', '[fail]', e);
  86. }
  87. });
  88. },
  89. /**
  90. * 生命周期函数--监听页面加载
  91. */
  92. onLoad: function(e) {
  93. let that = this;
  94. let stationTagList = [];
  95. let offlineServicecall ="";
  96. wx.getStorage({
  97. key: 'index_seeInfo_chargpile',
  98. success: function (res) {
  99. console.info(res)
  100. var seeInfoChargPile = res.data;
  101. stationTagList = seeInfoChargPile.stationTagList
  102. offlineServicecall = seeInfoChargPile.offlineServicecall
  103. that.setData({
  104. stationTagList,
  105. offlineServicecall,
  106. })
  107. console.info(stationTagList)
  108. // 异步更新
  109. console.info(seeInfoChargPile.chargStationId)
  110. that.execParking(that,seeInfoChargPile.chargStationId)
  111. let resultTable = seeInfoChargPile.resultList
  112. that.setData({
  113. resultTable
  114. })
  115. that.setData({
  116. resultTable
  117. })
  118. let chargfeatureList;
  119. if(seeInfoChargPile.chargfeatures){
  120. chargfeatureList = seeInfoChargPile.chargfeatures.split(',')
  121. }else{
  122. chargfeatureList = [];
  123. }
  124. seeInfoChargPile.sharpTotalPrice = parseFloat((seeInfoChargPile.sharpChargPrice==null || seeInfoChargPile.sharpServicePrice==null || seeInfoChargPile.sharpChargPrice=='暂无费用' || seeInfoChargPile.sharpServicePrice=='暂无费用')? null:(seeInfoChargPile.sharpChargPrice + seeInfoChargPile.sharpServicePrice).toFixed(6));
  125. seeInfoChargPile.peakTotalPrice = parseFloat((seeInfoChargPile.peakChargPrice==null || seeInfoChargPile.peakServicePrice==null || seeInfoChargPile.peakChargPrice=='暂无费用' || seeInfoChargPile.peakServicePrice=='暂无费用' )? null:(seeInfoChargPile.peakChargPrice + seeInfoChargPile.peakServicePrice).toFixed(6));
  126. seeInfoChargPile.flatTotalPrice = parseFloat((seeInfoChargPile.flatChargPrice==null || seeInfoChargPile.flatServicePrice==null || seeInfoChargPile.flatChargPrice=='暂无费用' || seeInfoChargPile.flatServicePrice=='暂无费用' )? null:(seeInfoChargPile.flatChargPrice + seeInfoChargPile.flatServicePrice).toFixed(6));
  127. seeInfoChargPile.valleyTotalPrice = parseFloat((seeInfoChargPile.valleyChargPrice==null || seeInfoChargPile.valleyServicePrice==null || seeInfoChargPile.valleyChargPrice=='暂无费用' || seeInfoChargPile.valleyServicePrice=='暂无费用' )? null:(seeInfoChargPile.valleyChargPrice + seeInfoChargPile.valleyServicePrice).toFixed(6));
  128. seeInfoChargPile.totalprice = parseFloat((seeInfoChargPile.chargprice==null || seeInfoChargPile.serviceprice==null || seeInfoChargPile.chargprice=='暂无费用' || seeInfoChargPile.serviceprice=='暂无费用')? null:(seeInfoChargPile.chargprice + seeInfoChargPile.serviceprice).toFixed(6));
  129. that.setData({
  130. seeInfoChargPile,
  131. chargfeatureList
  132. });
  133. console.info(seeInfoChargPile)
  134. console.info(chargfeatureList)
  135. wx.removeStorage({
  136. key: 'index_seeInfo_chargpile',
  137. success(res) {
  138. }
  139. });
  140. }
  141. });
  142. let { name, address, chargprice, serviceprice, chargid,brandName } = e;
  143. name = name=='null'?null:name;
  144. brandName = brandName=='null'?null:brandName;
  145. address = address=='null'?null:address;
  146. // stationTagList = !stationTagList?null:stationTagList;
  147. chargprice = chargprice=='null'?null:chargprice;
  148. serviceprice = serviceprice=='null'?null:serviceprice;
  149. chargid = chargid=='null'?null:chargid;
  150. // let sumprice = (chargprice==null || serviceprice==null)? null:chargprice+serviceprice;
  151. let sumprice = (chargprice==null || serviceprice==null)? null:chargprice+serviceprice;
  152. this.setData({
  153. brandName,
  154. name,
  155. address,
  156. // stationTagList,
  157. chargprice,
  158. serviceprice,
  159. chargid,
  160. sumprice
  161. });
  162. this.fastAndSlow()
  163. this.ori_getPage();
  164. this.ele_getPage();
  165. this.getOccupyFee();
  166. },
  167. fastAndSlow(e){
  168. let that = this;
  169. wx.request({
  170. url: getApp().globalData.postHeadAgreement +'/restapi/wechat/fastAndSlow',
  171. data: {
  172. id: that.data.chargid,
  173. ivType: 3,//统计桩和电池
  174. },
  175. method: 'POST',
  176. success(res) {
  177. that.setData({
  178. fastFree : res.data.fastFree,
  179. slowFree : res.data.slowFree,
  180. fastSum : res.data.fastSum,
  181. slowSum : res.data.slowSum
  182. });
  183. }
  184. });
  185. },
  186. previewImage(e){
  187. var that = this,
  188. //获取当前图片的下表
  189. index = e.currentTarget.dataset.index,
  190. //数据源
  191. pictures = this.data.chargfeatureList;
  192. wx.previewImage({
  193. //当前显示下表
  194. current: pictures[index],
  195. //数据源
  196. urls: pictures
  197. })
  198. },
  199. getPage(){
  200. let that = this;
  201. if(that.__data__.activeTab=='0'){
  202. that.ori_getPage();
  203. }else{
  204. that.ele_getPage();
  205. }
  206. },
  207. getOccupyFee(){
  208. // test对象对接后端服务传递过来的数据
  209. var test = {
  210. cost_cycle:2,
  211. max_fee_time:120,
  212. cost_time_period:'00:00-08:00,12:00-14:00,18:00-21:00,22:00-23:00,22:00-23:00',
  213. free_time:10
  214. }
  215. if (Object.keys(test).length > 0) { // 判断对象数据是否为空
  216. this.setData({
  217. occupyFee:test,
  218. showOccupyFee:true
  219. })
  220. }
  221. console.log("occupyFee",Object.keys(this.data.occupyFee).length > 0);
  222. },
  223. ori_getPage(){
  224. // ivType
  225. // 是否为无人车充电站(0否;1是)
  226. // 0:桩
  227. // 1:电池
  228. if(this.data.chargList.length == this.data.total){
  229. this.setData({
  230. finishedLoadTap:this.data.finishedLoadTap+1
  231. })
  232. if(this.data.finishedLoadTap>0 && this.data.finishedLoadShowTimes==0){
  233. this.setData({
  234. finishedLoadShowTimes:this.data.finishedLoadShowTimes+1
  235. })
  236. wx.showToast({
  237. title: '全部加载完毕',
  238. icon: 'success',
  239. duration: 2000
  240. })
  241. }
  242. return
  243. }
  244. if(this.data.dataLoading){
  245. return
  246. }
  247. this.setData({
  248. dataLoading: true
  249. })
  250. wx.showLoading({
  251. title: '数据加载中....',
  252. })
  253. let that = this;
  254. // 充电桩
  255. wx.request({
  256. url: getApp().globalData.postHeadAgreement +'/restapi/wechat/chargInfo',
  257. data: {
  258. id: that.data.chargid,
  259. pagenum: this.data.pagenum++,
  260. ivType: 0,
  261. pagesize: 10,
  262. },
  263. method: 'POST',
  264. success(res) {
  265. console.log(res);
  266. let chargList = res.data.chargList.rows;
  267. chargList.forEach(key => {
  268. let chargstatusname = '';
  269. let chargstatusclass = '';
  270. if(key.chargstatus == 2){
  271. chargstatusname='空闲中'
  272. chargstatusclass = 'chargstatus_kxz'
  273. }else if(key.chargstatus == 11){
  274. chargstatusname='已插枪'
  275. chargstatusclass = 'chargstatus_ycq'
  276. }else if(key.chargstatus == 3 || key.chargstatus == 10){
  277. chargstatusname='充电中'
  278. chargstatusclass = 'chargstatus_cdz'
  279. }else if(key.chargstatus == 0){
  280. chargstatusname='离线'
  281. chargstatusclass = 'chargstatus_lx'
  282. }else{
  283. chargstatusname='故障'
  284. chargstatusclass = 'chargstatus_gz'
  285. }
  286. key.chargstatusname = chargstatusname;
  287. key.chargstatusclass = chargstatusclass;
  288. })
  289. console.log(chargList);
  290. // that.rechargeTimeOrder(chargemoneylogs);
  291. wx.hideLoading()
  292. that.setData({
  293. chargList: that.data.chargList.concat(chargList),
  294. total: res.data.total,
  295. dataLoading: false,
  296. fastFree : res.data.fastFree,
  297. slowFree : res.data.slowFree,
  298. fastSum : res.data.fastSum,
  299. slowSum : res.data.slowSum
  300. });
  301. console.log("that.data:",that.data);
  302. }
  303. });
  304. },
  305. ele_getPage(){
  306. // ivType
  307. // 是否为无人车充电站(0否;1是)
  308. // 0:桩
  309. // 1:电池
  310. if(this.data.ele_chargList.length == this.data.ele_total){
  311. this.setData({
  312. ele_finishedLoadTap:this.data.ele_finishedLoadTap+1
  313. })
  314. if(this.data.ele_finishedLoadTap>0 && this.data.ele_finishedLoadShowTimes==0){
  315. this.setData({
  316. ele_finishedLoadShowTimes:this.data.ele_finishedLoadShowTimes+1
  317. })
  318. wx.showToast({
  319. title: '全部加载完毕',
  320. icon: 'success',
  321. duration: 2000
  322. })
  323. }
  324. return
  325. }
  326. if(this.data.ele_dataLoading){
  327. return
  328. }
  329. this.setData({
  330. ele_dataLoading: true
  331. })
  332. wx.showLoading({
  333. title: '数据加载中....',
  334. })
  335. let that = this;
  336. // that.setData({
  337. // pagenum:1
  338. // });
  339. // 充电桩
  340. wx.request({
  341. url: getApp().globalData.postHeadAgreement +'/restapi/wechat/chargInfo',
  342. data: {
  343. id: that.data.chargid,
  344. pagenum: this.data.ele_pagenum++,
  345. ivType: 1,
  346. pagesize: 10,
  347. },
  348. method: 'POST',
  349. success(res) {
  350. console.log(res);
  351. let chargList = res.data.chargList.rows;
  352. chargList.forEach(key => {
  353. let chargstatusname = '';
  354. let chargstatusclass = '';
  355. if(key.chargstatus == 2){
  356. chargstatusname='空闲中'
  357. chargstatusclass = 'chargstatus_kxz'
  358. }else if(key.chargstatus == 11){
  359. chargstatusname='已插枪'
  360. chargstatusclass = 'chargstatus_ycq'
  361. }else if(key.chargstatus == 3 || key.chargstatus == 10){
  362. chargstatusname='充电中'
  363. chargstatusclass = 'chargstatus_cdz'
  364. }else if(key.chargstatus == 0){
  365. chargstatusname='离线'
  366. chargstatusclass = 'chargstatus_lx'
  367. }else{
  368. chargstatusname='故障'
  369. chargstatusclass = 'chargstatus_gz'
  370. }
  371. key.chargstatusname = chargstatusname;
  372. key.chargstatusclass = chargstatusclass;
  373. })
  374. console.log(chargList);
  375. // that.rechargeTimeOrder(chargemoneylogs);
  376. wx.hideLoading()
  377. that.setData({
  378. ele_chargList: that.data.ele_chargList.concat(chargList),
  379. ele_total: res.data.chargList.total,
  380. ele_dataLoading: false,
  381. ele_fastFree : res.data.fastFree,
  382. ele_slowFree : res.data.slowFree,
  383. ele_fastSum : res.data.fastSum,
  384. ele_slowSum : res.data.slowSum
  385. });
  386. console.log("that.setData:",that.data);
  387. }
  388. });
  389. },
  390. refreshPage: function(e) {
  391. wx.showLoading({
  392. title: '数据加载中....',
  393. })
  394. let that = this;
  395. that.setData({
  396. pagenum:1,
  397. });
  398. // 清空数据 重新进行刷新
  399. this.data.ele_chargList = []
  400. this.data.ele_total = -1
  401. this.data.chargList=[]
  402. this.data.total = -1
  403. this.ori_getPage();
  404. this.ele_getPage();
  405. that.fastAndSlow()
  406. that.setData({
  407. scrollTop: 0
  408. });
  409. wx.hideLoading()
  410. },
  411. goEleCarMap(e){
  412. console.info("呼叫充电车");
  413. let that = this;
  414. wx.setStorageSync('eleCarMapPage', {
  415. chargid: that.data.chargid
  416. })
  417. let url = '/pages/charginfo/eleCarMap';
  418. wx.navigateTo({
  419. url
  420. });
  421. },
  422. async goScanResult(e){
  423. // scan_result
  424. let api = getApp().globalData.postHeadAgreement
  425. let path = 'restapi/wechat/queryOccupyFeeOrder'
  426. let params = {
  427. userId: wx.getStorageSync('userInfo').userId,
  428. searchIndex: 2,
  429. pagenum: this.data.pagenum++,
  430. pagesize: 10,
  431. }
  432. let paramsNew = {
  433. userId: wx.getStorageSync('userInfo').userId,
  434. searchIndex: 3,
  435. pagenum: this.data.pagenum++,
  436. pagesize: 10,
  437. }
  438. try{
  439. const resultOrder = await wechat.request(api, path, paramsNew);
  440. if (resultOrder.data.code == 200) {
  441. if (resultOrder.data.result.total > 0) {
  442. wx.showModal({
  443. showCancel: false,
  444. confirmText: '去支付',
  445. content: '您有未支付的占位费订单,请先支付',
  446. confirmColor:'#00AADD',
  447. success: function (res) {
  448. if (!res.cancel) {
  449. //点击确定
  450. let url = `/pages/ucenter/zhanw/zhanw`;
  451. wx.navigateTo({
  452. url
  453. })
  454. return;
  455. }
  456. }
  457. });
  458. }
  459. }
  460. const result = await wechat.request(api, path, params);
  461. if (result.data.code == 200) {
  462. if (result.data.result.total > 0) { // 有占位费订单不启动扫码充电
  463. this.setData({
  464. showPopup:true
  465. })
  466. return;
  467. }
  468. }
  469. }catch (error) {
  470. console.error('查询占位费订单失败', error);
  471. wx.showModal({
  472. showCancel: false,
  473. content: '查询占位费订单失败',
  474. confirmColor:'#00AADD',
  475. success: function (res) {
  476. if (!res.cancel) {
  477. //点击确定
  478. }
  479. }
  480. });
  481. }
  482. console.info('xxxxxxxxxxxxxx')
  483. let {
  484. keywords
  485. } = e.currentTarget.dataset;
  486. let userInfo = wx.getStorageSync('userInfo');
  487. let isLogin = wx.getStorageSync('isLogin');
  488. let chargid = keywords.chargPileId;
  489. let that = this;
  490. if(isLogin && userInfo.bindingPhone==0){
  491. console.info('xxxxxxxxxxxxxx1')
  492. wx.showModal({
  493. title: '提示',
  494. content: '当前账户未绑定手机号,请您进行手机号绑定操作',
  495. showCancel:false,
  496. confirmText: '去绑定',
  497. confirmColor:'#00AADD',
  498. success: function (res1) {
  499. let url = `/pages/bindPhone/bindPhone`;
  500. wx.navigateTo({
  501. url
  502. });
  503. }
  504. });
  505. return;
  506. }
  507. wx.showLoading({
  508. title: '努力加载中...',
  509. })
  510. if (!isLogin) {
  511. console.info('xxxxxxxxxxxxxx2')
  512. log.info('[首页]', '[未登陆跳转登录界面]');
  513. let url = `/pages/login/phone_login/phone_login`;
  514. wx.hideLoading();
  515. wx.navigateTo({
  516. url
  517. });
  518. // return;
  519. } else {
  520. log.info('[首页]', '[获取用户是否有未支付订单]', '[请求]', { userId: userInfo.userId });
  521. wx.request({
  522. url: getApp().globalData.postHeadAgreement + '/restapi/pileLog/wechatsettlement',
  523. data: {
  524. userId: userInfo.userId
  525. },
  526. method: 'POST',
  527. success(res) {
  528. let {
  529. data
  530. } = res;
  531. let {
  532. result: order
  533. } = data;
  534. log.info('[首页]', '[获取用户是否有未支付订单]', '[响应]', data);
  535. if (data && order && data.code == 200) {
  536. wx.hideLoading();
  537. log.info('[首页]', '[用户有未支付订单跳转订单支付界面]');
  538. wx.showModal({
  539. showCancel: false,
  540. content: '你有未支付的订单,请先支付',
  541. confirmColor:'#00AADD',
  542. success: function (res) {
  543. //console.log(res);
  544. if (!res.cancel) {
  545. //点击确定
  546. let url = `/pages/order/order?orderid=${order.orderid}&userId=${order.userId}&chargPileId=${order.chargPileId}`;
  547. wx.navigateTo({
  548. url
  549. });
  550. }
  551. }
  552. });
  553. //console.log(that.data.result);
  554. } else {
  555. //console.log('无订单');
  556. log.info('[首页]', '[用户无未支付订单]');
  557. wx.request({
  558. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargPile',
  559. // data: scanResult,
  560. data: {
  561. chargPileId: chargid,
  562. userId: userInfo.userId
  563. },
  564. method: 'POST',
  565. success(res) {
  566. console.log(chargid);
  567. log.info('[首页]', '[获取扫一扫充电桩]', '[响应]', res.data);
  568. if (!res.data || res.data.code == 500) {
  569. that.scanFlag = false;
  570. wx.hideLoading();
  571. //没有该充电桩信息
  572. wx.showModal({
  573. showCancel: false,
  574. confirmColor:'#00AADD',
  575. content: res && res.data && res.data.msg ? res.data.msg :'无效的终端编号'
  576. });
  577. } else {
  578. res.data = res.data.result
  579. //充电状态0:离线、1:故障、2:空闲中、3:充电中、4:欠压故障、5:过压故障、6:过电流故障、8:预约、9:在线升级、10:操作中、11:已插枪等
  580. if (!res.data.chargstatus || res.data.chargstatus == 0 || res.data.chargstatus == 1 || res.data.chargstatus == 4 || res.data.chargstatus == 5 || res.data.chargstatus == 6 || res.data.chargstatus == 9) {
  581. //充电桩故障
  582. wx.showModal({
  583. showCancel: false,
  584. content: '终端故障,维修中',
  585. confirmColor:'#00AADD',
  586. });
  587. } else if (res.data.chargstatus == 3 || res.data.chargstatus == 8 || res.data.chargstatus == 10) {
  588. wx.showModal({
  589. showCancel: false,
  590. content: '正在充电中',
  591. confirmColor:'#00AADD',
  592. });
  593. } else if (res.data.chargstatus == 2 || res.data.chargstatus == 11) {
  594. wx.setStorage({
  595. key: "scan_chargpile",
  596. data: res.data
  597. });
  598. log.info('[首页]', '[扫一扫充电桩空闲跳转去充电界面]');
  599. let url = `/pages/scan_result/scan_result`;
  600. wx.hideLoading();
  601. wx.navigateTo({
  602. url
  603. });
  604. }
  605. wx.hideLoading();
  606. }
  607. },
  608. fail(e) {
  609. getApp().showNetworkError();
  610. }
  611. });
  612. }
  613. },
  614. fail(e) {
  615. that.scanFlag = false;
  616. wx.hideLoading();
  617. getApp().showNetworkError();
  618. }
  619. });
  620. }
  621. },
  622. seeReservation: function(e){
  623. let userInfo = wx.getStorageSync('userInfo');
  624. let isLogin = wx.getStorageSync('isLogin');
  625. let that = this;
  626. if(isLogin && userInfo.bindingPhone==0){
  627. console.info('xxxxxxxxxxxxxx1')
  628. wx.showModal({
  629. title: '提示',
  630. content: '当前账户未绑定手机号,请您进行手机号绑定操作',
  631. showCancel:false,
  632. confirmText: '去绑定',
  633. confirmColor:'#00AADD',
  634. success: function (res1) {
  635. let url = `/pages/bindPhone/bindPhone`;
  636. wx.navigateTo({
  637. url
  638. });
  639. }
  640. });
  641. return;
  642. }
  643. if (!isLogin) {
  644. console.info('xxxxxxxxxxxxxx2')
  645. log.info('[首页]', '[未登陆跳转登录界面]');
  646. let url = `/pages/login/phone_login/phone_login`;
  647. wx.hideLoading();
  648. wx.navigateTo({
  649. url
  650. });
  651. return;
  652. }
  653. let idx = e.currentTarget.dataset.idx;
  654. console.info(idx)
  655. let {
  656. chargStationId,
  657. chargPileName,
  658. chargPileId,
  659. chargStationName,
  660. id
  661. } = idx;
  662. let brandName = that.data.brandName
  663. let userId = userInfo.userId;
  664. let url = `/pages/reservation/reservation?chargStationId=` + chargStationId + `&chargPileName=` + chargPileName + `&chargPileId=` + chargPileId + `&chargPileIdId=` + id + "&chargStationName=" + chargStationName + "&userId=" + userId+ "&brandName=" + brandName;
  665. wx.navigateTo({
  666. url
  667. });
  668. },
  669. /**
  670. * 生命周期函数--监听页面初次渲染完成
  671. */
  672. onReady: function() {
  673. },
  674. /**
  675. * 生命周期函数--监听页面显示
  676. */
  677. onShow: function(e) {
  678. let userInfo = wx.getStorageSync('userInfo');
  679. let isLogin = wx.getStorageSync('isLogin');
  680. //console.log(userInfo);
  681. // 页面显示
  682. if (userInfo && isLogin) {
  683. //userInfo.flag = true;
  684. this.setData({
  685. userInfo: userInfo,
  686. isLogin: isLogin
  687. });
  688. } else {
  689. //未登录信息
  690. this.setData({
  691. userInfo: {}
  692. });
  693. }
  694. },
  695. chargingLog(e){
  696. let idx = e.currentTarget.dataset.idx;
  697. let chargPileId = idx.chargPileId;
  698. console.info(chargPileId);
  699. let url = '/pages/ucenter/charginglog/opsCharginglog?chargPileId=' + chargPileId
  700. wx.navigateTo({
  701. url
  702. });
  703. return;
  704. },
  705. callphone(){
  706. let that = this
  707. let phonenum = that.data.offlineServicecall;
  708. wx.makePhoneCall({
  709. phoneNumber: that.data.offlineServicecall, //此号码并非真实电话号码,仅用于测试
  710. success:function(){
  711. console.log("拨打电话成功!" + phonenum)
  712. },
  713. fail:function(){
  714. console.log("拨打电话失败!" + phonenum)
  715. }
  716. })
  717. },
  718. toggleTabs(e){
  719. let idx = e.currentTarget.dataset.idx;
  720. this.setData({
  721. activeTab: idx
  722. })
  723. },
  724. /**
  725. * 生命周期函数--监听页面隐藏
  726. */
  727. onHide: function() {
  728. },
  729. /**
  730. * 生命周期函数--监听页面卸载
  731. */
  732. onUnload: function() {
  733. },
  734. bindScrollTolowerEvent: function(){
  735. this.getPage();
  736. console.log("触发滚动");
  737. },
  738. /**
  739. * 页面相关事件处理函数--监听用户下拉动作
  740. */
  741. onPullDownRefresh: function() {
  742. },
  743. /**
  744. * 页面上拉触底事件的处理函数
  745. */
  746. onReachBottom: function() {
  747. },
  748. /**
  749. * 用户点击右上角分享
  750. */
  751. onShareAppMessage: function() {
  752. }
  753. })