charginfo.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857
  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 = (seeInfoChargPile.chargprice==null || seeInfoChargPile.serviceprice==null || seeInfoChargPile.chargprice=='暂无费用' || seeInfoChargPile.serviceprice=='暂无费用')? null:parseFloat((seeInfoChargPile.chargprice + seeInfoChargPile.serviceprice)).toFixed(8);
  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' || brandName == 'undefined') ? 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. this.selectStationOccupyFee()
  209. .then(result => {
  210. console.log("查询结果:", result);
  211. this.setData({
  212. occupyFee:result[0],
  213. showOccupyFee:true
  214. })
  215. })
  216. .catch(error => {
  217. console.error("查询失败:", error);
  218. });
  219. },
  220. async selectStationOccupyFee() {
  221. try {
  222. const res = await new Promise((resolve, reject) => {
  223. wx.request({
  224. url: `${getApp().globalData.postHeadAgreement}/restapi/wechat/queryStationOccupyFee`,
  225. data: {
  226. chargStation: {
  227. id:this.data.chargid
  228. }
  229. },
  230. method: 'POST',
  231. success: (response) => {
  232. resolve(response.data);
  233. },
  234. fail: (error) => {
  235. reject(error);
  236. }
  237. });
  238. });
  239. if (res.code == 200) {
  240. return res.result;
  241. } else {
  242. throw new Error(`Error: ${res.code}`);
  243. }
  244. } catch (e) {
  245. console.log("查询占位费模版信息异常", e);
  246. log.info('[扫码]', '[查询占位费模版信息]', '[fail]', e);
  247. throw e;
  248. }
  249. },
  250. async selectPileOccupyFee(chargPileId) {
  251. console.log("启动chargPileId",chargPileId);
  252. try {
  253. const res = await new Promise((resolve, reject) => {
  254. wx.request({
  255. url: `${getApp().globalData.postHeadAgreement}/restapi/wechat/queryOccupyFee`,
  256. data: {
  257.  chargPileId: chargPileId
  258. },
  259. method: 'POST',
  260. success: (response) => {
  261. resolve(response.data);
  262. },
  263. fail: (error) => {
  264. reject(error);
  265. }
  266. });
  267. });
  268. if (res.code == 200) {
  269. return res.result;
  270. } else {
  271. throw new Error(`Error: ${res.code}`);
  272. }
  273. } catch (e) {
  274. console.log("查询充电桩占位费模版信息异常", e);
  275. log.info( '[查询充电桩占位费模版信息]', '[fail]', e);
  276. throw e;
  277. }
  278. },
  279. ori_getPage(){
  280. // ivType
  281. // 是否为无人车充电站(0否;1是)
  282. // 0:桩
  283. // 1:电池
  284. if(this.data.chargList.length == this.data.total){
  285. this.setData({
  286. finishedLoadTap:this.data.finishedLoadTap+1
  287. })
  288. if(this.data.finishedLoadTap>0 && this.data.finishedLoadShowTimes==0){
  289. this.setData({
  290. finishedLoadShowTimes:this.data.finishedLoadShowTimes+1
  291. })
  292. wx.showToast({
  293. title: '全部加载完毕',
  294. icon: 'success',
  295. duration: 2000
  296. })
  297. }
  298. return
  299. }
  300. if(this.data.dataLoading){
  301. return
  302. }
  303. this.setData({
  304. dataLoading: true
  305. })
  306. wx.showLoading({
  307. title: '数据加载中....',
  308. })
  309. let that = this;
  310. // 充电桩
  311. wx.request({
  312. url: getApp().globalData.postHeadAgreement +'/restapi/wechat/chargInfo',
  313. data: {
  314. id: that.data.chargid,
  315. pagenum: this.data.pagenum++,
  316. ivType: 0,
  317. pagesize: 10,
  318. },
  319. method: 'POST',
  320. success(res) {
  321. console.log(res);
  322. let chargList = res.data.chargList.rows;
  323. chargList.forEach(key => {
  324. let chargstatusname = '';
  325. let chargstatusclass = '';
  326. if(key.chargstatus == 2){
  327. chargstatusname='空闲中'
  328. chargstatusclass = 'chargstatus_kxz'
  329. }else if(key.chargstatus == 11){
  330. chargstatusname='已插枪'
  331. chargstatusclass = 'chargstatus_ycq'
  332. }else if(key.chargstatus == 3 || key.chargstatus == 10){
  333. chargstatusname='充电中'
  334. chargstatusclass = 'chargstatus_cdz'
  335. }else if(key.chargstatus == 0){
  336. chargstatusname='离线'
  337. chargstatusclass = 'chargstatus_lx'
  338. }else{
  339. chargstatusname='故障'
  340. chargstatusclass = 'chargstatus_gz'
  341. }
  342. key.chargstatusname = chargstatusname;
  343. key.chargstatusclass = chargstatusclass;
  344. })
  345. console.log(chargList);
  346. // that.rechargeTimeOrder(chargemoneylogs);
  347. wx.hideLoading()
  348. that.setData({
  349. chargList: that.data.chargList.concat(chargList),
  350. total: res.data.total,
  351. dataLoading: false,
  352. fastFree : res.data.fastFree,
  353. slowFree : res.data.slowFree,
  354. fastSum : res.data.fastSum,
  355. slowSum : res.data.slowSum
  356. });
  357. console.log("that.data:",that.data);
  358. }
  359. });
  360. },
  361. ele_getPage(){
  362. // ivType
  363. // 是否为无人车充电站(0否;1是)
  364. // 0:桩
  365. // 1:电池
  366. if(this.data.ele_chargList.length == this.data.ele_total){
  367. this.setData({
  368. ele_finishedLoadTap:this.data.ele_finishedLoadTap+1
  369. })
  370. if(this.data.ele_finishedLoadTap>0 && this.data.ele_finishedLoadShowTimes==0){
  371. this.setData({
  372. ele_finishedLoadShowTimes:this.data.ele_finishedLoadShowTimes+1
  373. })
  374. wx.showToast({
  375. title: '全部加载完毕',
  376. icon: 'success',
  377. duration: 2000
  378. })
  379. }
  380. return
  381. }
  382. if(this.data.ele_dataLoading){
  383. return
  384. }
  385. this.setData({
  386. ele_dataLoading: true
  387. })
  388. wx.showLoading({
  389. title: '数据加载中....',
  390. })
  391. let that = this;
  392. // that.setData({
  393. // pagenum:1
  394. // });
  395. // 充电桩
  396. wx.request({
  397. url: getApp().globalData.postHeadAgreement +'/restapi/wechat/chargInfo',
  398. data: {
  399. id: that.data.chargid,
  400. pagenum: this.data.ele_pagenum++,
  401. ivType: 1,
  402. pagesize: 10,
  403. },
  404. method: 'POST',
  405. success(res) {
  406. console.log(res);
  407. let chargList = res.data.chargList.rows;
  408. chargList.forEach(key => {
  409. let chargstatusname = '';
  410. let chargstatusclass = '';
  411. if(key.chargstatus == 2){
  412. chargstatusname='空闲中'
  413. chargstatusclass = 'chargstatus_kxz'
  414. }else if(key.chargstatus == 11){
  415. chargstatusname='已插枪'
  416. chargstatusclass = 'chargstatus_ycq'
  417. }else if(key.chargstatus == 3 || key.chargstatus == 10){
  418. chargstatusname='充电中'
  419. chargstatusclass = 'chargstatus_cdz'
  420. }else if(key.chargstatus == 0){
  421. chargstatusname='离线'
  422. chargstatusclass = 'chargstatus_lx'
  423. }else{
  424. chargstatusname='故障'
  425. chargstatusclass = 'chargstatus_gz'
  426. }
  427. key.chargstatusname = chargstatusname;
  428. key.chargstatusclass = chargstatusclass;
  429. })
  430. console.log(chargList);
  431. // that.rechargeTimeOrder(chargemoneylogs);
  432. wx.hideLoading()
  433. that.setData({
  434. ele_chargList: that.data.ele_chargList.concat(chargList),
  435. ele_total: res.data.chargList.total,
  436. ele_dataLoading: false,
  437. ele_fastFree : res.data.fastFree,
  438. ele_slowFree : res.data.slowFree,
  439. ele_fastSum : res.data.fastSum,
  440. ele_slowSum : res.data.slowSum
  441. });
  442. console.log("that.setData:",that.data);
  443. }
  444. });
  445. },
  446. refreshPage: function(e) {
  447. wx.showLoading({
  448. title: '数据加载中....',
  449. })
  450. let that = this;
  451. that.setData({
  452. pagenum:1,
  453. });
  454. // 清空数据 重新进行刷新
  455. this.data.ele_chargList = []
  456. this.data.ele_total = -1
  457. this.data.chargList=[]
  458. this.data.total = -1
  459. this.ori_getPage();
  460. this.ele_getPage();
  461. that.fastAndSlow()
  462. that.setData({
  463. scrollTop: 0
  464. });
  465. wx.hideLoading()
  466. },
  467. goEleCarMap(e){
  468. console.info("呼叫充电车");
  469. let that = this;
  470. wx.setStorageSync('eleCarMapPage', {
  471. chargid: that.data.chargid
  472. })
  473. let url = '/pages/charginfo/eleCarMap';
  474. wx.navigateTo({
  475. url
  476. });
  477. },
  478. async goScanResult(e){
  479. // scan_result
  480. console.info('xxxxxxxxxxxxxx')
  481. let {
  482. keywords
  483. } = e.currentTarget.dataset;
  484. let userInfo = wx.getStorageSync('userInfo');
  485. let isLogin = wx.getStorageSync('isLogin');
  486. let chargid = keywords.chargPileId;
  487. let that = this;
  488. if(isLogin && userInfo.bindingPhone==0){
  489. console.info('xxxxxxxxxxxxxx1')
  490. wx.showModal({
  491. title: '提示',
  492. content: '当前账户未绑定手机号,请您进行手机号绑定操作',
  493. showCancel:false,
  494. confirmText: '去绑定',
  495. confirmColor:'#00AADD',
  496. success: function (res1) {
  497. let url = `/pages/bindPhone/bindPhone`;
  498. wx.navigateTo({
  499. url
  500. });
  501. }
  502. });
  503. return;
  504. }
  505. wx.showLoading({
  506. title: '努力加载中...',
  507. })
  508. if (!isLogin) {
  509. console.info('xxxxxxxxxxxxxx2')
  510. log.info('[首页]', '[未登陆跳转登录界面]');
  511. let url = `/pages/login/phone_login/phone_login`;
  512. wx.hideLoading();
  513. wx.navigateTo({
  514. url
  515. });
  516. // return;
  517. } else {
  518. let api = getApp().globalData.postHeadAgreement
  519. let path = 'restapi/wechat/queryOccupyFeeOrder'
  520. let params = {
  521. userId: wx.getStorageSync('userInfo').userId,
  522. searchIndex: 2,
  523. pagenum: this.data.pagenum++,
  524. pagesize: 10,
  525. }
  526. let paramsNew = {
  527. userId: wx.getStorageSync('userInfo').userId,
  528. searchIndex: 3,
  529. pagenum: this.data.pagenum++,
  530. pagesize: 10,
  531. }
  532. try{
  533. const resultOrder = await wechat.request(api, path, paramsNew);
  534. if (resultOrder.data.code == 200) {
  535. wx.hideLoading();
  536. if (resultOrder.data.result.total > 0) {
  537. wx.showModal({
  538. showCancel: false,
  539. confirmText: '去支付',
  540. content: '您有未支付的占位费订单,请先支付',
  541. confirmColor:'#00AADD',
  542. success: function (res) {
  543. if (!res.cancel) {
  544. //点击确定
  545. let url = `/pages/ucenter/zhanw/zhanw`;
  546. wx.navigateTo({
  547. url
  548. })
  549. }
  550. }
  551. });
  552. return;
  553. }
  554. }
  555. const result = await wechat.request(api, path, params);
  556. if (result.data.code == 200) {
  557. wx.hideLoading();
  558. if (result.data.result.total > 0) { // 有占位费订单不启动扫码充电
  559. this.setData({
  560. showPopup:true
  561. })
  562. return;
  563. }
  564. }
  565. }catch (error) {
  566. console.error('查询占位费订单失败', error);
  567. wx.showModal({
  568. showCancel: false,
  569. content: '查询占位费订单失败',
  570. confirmColor:'#00AADD',
  571. success: function (res) {
  572. if (!res.cancel) {
  573. //点击确定
  574. }
  575. }
  576. });
  577. }
  578. log.info('[首页]', '[获取用户是否有未支付订单]', '[请求]', { userId: userInfo.userId });
  579. wx.request({
  580. url: getApp().globalData.postHeadAgreement + '/restapi/pileLog/wechatsettlement',
  581. data: {
  582. userId: userInfo.userId
  583. },
  584. method: 'POST',
  585. success(res) {
  586. let {
  587. data
  588. } = res;
  589. let {
  590. result: order
  591. } = data;
  592. log.info('[首页]', '[获取用户是否有未支付订单]', '[响应]', data);
  593. if (data && order && data.code == 200) {
  594. wx.hideLoading();
  595. log.info('[首页]', '[用户有未支付订单跳转订单支付界面]');
  596. wx.showModal({
  597. showCancel: false,
  598. content: '你有未支付的订单,请先支付',
  599. confirmColor:'#00AADD',
  600. success: function (res) {
  601. //console.log(res);
  602. if (!res.cancel) {
  603. //点击确定
  604. let url = `/pages/order/order?orderid=${order.orderid}&userId=${order.userId}&chargPileId=${order.chargPileId}`;
  605. wx.navigateTo({
  606. url
  607. });
  608. }
  609. }
  610. });
  611. //console.log(that.data.result);
  612. } else {
  613. //console.log('无订单');
  614. log.info('[首页]', '[用户无未支付订单]');
  615. wx.request({
  616. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargPile',
  617. // data: scanResult,
  618. data: {
  619. chargPileId: chargid,
  620. userId: userInfo.userId
  621. },
  622. method: 'POST',
  623. success(res) {
  624. console.log(chargid);
  625. log.info('[首页]', '[获取扫一扫充电桩]', '[响应]', res.data);
  626. if (!res.data || res.data.code == 500) {
  627. that.scanFlag = false;
  628. wx.hideLoading();
  629. //没有该充电桩信息
  630. wx.showModal({
  631. showCancel: false,
  632. confirmColor:'#00AADD',
  633. content: res && res.data && res.data.msg ? res.data.msg :'无效的终端编号'
  634. });
  635. } else {
  636. res.data = res.data.result
  637. //充电状态0:离线、1:故障、2:空闲中、3:充电中、4:欠压故障、5:过压故障、6:过电流故障、8:预约、9:在线升级、10:操作中、11:已插枪等
  638. 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) {
  639. //充电桩故障
  640. wx.showModal({
  641. showCancel: false,
  642. content: '终端故障,维修中',
  643. confirmColor:'#00AADD',
  644. });
  645. } else if (res.data.chargstatus == 3 || res.data.chargstatus == 8 || res.data.chargstatus == 10) {
  646. wx.showModal({
  647. showCancel: false,
  648. content: '正在充电中',
  649. confirmColor:'#00AADD',
  650. });
  651. } else if (res.data.chargstatus == 2 || res.data.chargstatus == 11) {
  652. wx.setStorage({
  653. key: "scan_chargpile",
  654. data: res.data
  655. });
  656. log.info('[首页]', '[扫一扫充电桩空闲跳转去充电界面]');
  657. let url = `/pages/scan_result/scan_result?chargPileId=` + chargid;
  658. wx.hideLoading();
  659. wx.navigateTo({
  660. url
  661. });
  662. }
  663. wx.hideLoading();
  664. }
  665. },
  666. fail(e) {
  667. getApp().showNetworkError();
  668. }
  669. });
  670. }
  671. },
  672. fail(e) {
  673. that.scanFlag = false;
  674. wx.hideLoading();
  675. getApp().showNetworkError();
  676. }
  677. });
  678. }
  679. },
  680. seeReservation: function(e){
  681. let userInfo = wx.getStorageSync('userInfo');
  682. let isLogin = wx.getStorageSync('isLogin');
  683. let that = this;
  684. if(isLogin && userInfo.bindingPhone==0){
  685. console.info('xxxxxxxxxxxxxx1')
  686. wx.showModal({
  687. title: '提示',
  688. content: '当前账户未绑定手机号,请您进行手机号绑定操作',
  689. showCancel:false,
  690. confirmText: '去绑定',
  691. confirmColor:'#00AADD',
  692. success: function (res1) {
  693. let url = `/pages/bindPhone/bindPhone`;
  694. wx.navigateTo({
  695. url
  696. });
  697. }
  698. });
  699. return;
  700. }
  701. if (!isLogin) {
  702. console.info('xxxxxxxxxxxxxx2')
  703. log.info('[首页]', '[未登陆跳转登录界面]');
  704. let url = `/pages/login/phone_login/phone_login`;
  705. wx.hideLoading();
  706. wx.navigateTo({
  707. url
  708. });
  709. return;
  710. }
  711. let idx = e.currentTarget.dataset.idx;
  712. console.info(idx)
  713. let {
  714. chargStationId,
  715. chargPileName,
  716. chargPileId,
  717. chargStationName,
  718. id
  719. } = idx;
  720. let brandName = that.data.brandName
  721. let userId = userInfo.userId;
  722. let url = `/pages/reservation/reservation?chargStationId=` + chargStationId + `&chargPileName=` + chargPileName + `&chargPileId=` + chargPileId + `&chargPileIdId=` + id + "&chargStationName=" + chargStationName + "&userId=" + userId+ "&brandName=" + brandName;
  723. wx.navigateTo({
  724. url
  725. });
  726. },
  727. /**
  728. * 生命周期函数--监听页面初次渲染完成
  729. */
  730. onReady: function() {
  731. },
  732. /**
  733. * 生命周期函数--监听页面显示
  734. */
  735. onShow: function(e) {
  736. let userInfo = wx.getStorageSync('userInfo');
  737. let isLogin = wx.getStorageSync('isLogin');
  738. //console.log(userInfo);
  739. // 页面显示
  740. if (userInfo && isLogin) {
  741. //userInfo.flag = true;
  742. this.setData({
  743. userInfo: userInfo,
  744. isLogin: isLogin
  745. });
  746. } else {
  747. //未登录信息
  748. this.setData({
  749. userInfo: {}
  750. });
  751. }
  752. },
  753. chargingLog(e){
  754. let idx = e.currentTarget.dataset.idx;
  755. let chargPileId = idx.chargPileId;
  756. console.info(chargPileId);
  757. let url = '/pages/ucenter/charginglog/opsCharginglog?chargPileId=' + chargPileId
  758. wx.navigateTo({
  759. url
  760. });
  761. return;
  762. },
  763. callphone(){
  764. let that = this
  765. let phonenum = that.data.offlineServicecall;
  766. wx.makePhoneCall({
  767. phoneNumber: that.data.offlineServicecall, //此号码并非真实电话号码,仅用于测试
  768. success:function(){
  769. console.log("拨打电话成功!" + phonenum)
  770. },
  771. fail:function(){
  772. console.log("拨打电话失败!" + phonenum)
  773. }
  774. })
  775. },
  776. toggleTabs(e){
  777. let idx = e.currentTarget.dataset.idx;
  778. this.setData({
  779. activeTab: idx
  780. })
  781. },
  782. /**
  783. * 生命周期函数--监听页面隐藏
  784. */
  785. onHide: function() {
  786. },
  787. /**
  788. * 生命周期函数--监听页面卸载
  789. */
  790. onUnload: function() {
  791. },
  792. bindScrollTolowerEvent: function(){
  793. this.getPage();
  794. console.log("触发滚动");
  795. },
  796. /**
  797. * 页面相关事件处理函数--监听用户下拉动作
  798. */
  799. onPullDownRefresh: function() {
  800. },
  801. /**
  802. * 页面上拉触底事件的处理函数
  803. */
  804. onReachBottom: function() {
  805. },
  806. /**
  807. * 用户点击右上角分享
  808. */
  809. onShareAppMessage: function() {
  810. }
  811. })