charginfo.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  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. let api = getApp().globalData.postHeadAgreement
  481. let path = 'restapi/wechat/queryOccupyFeeOrder'
  482. let params = {
  483. userId: wx.getStorageSync('userInfo').userId,
  484. searchIndex: 2,
  485. pagenum: this.data.pagenum++,
  486. pagesize: 10,
  487. }
  488. let paramsNew = {
  489. userId: wx.getStorageSync('userInfo').userId,
  490. searchIndex: 3,
  491. pagenum: this.data.pagenum++,
  492. pagesize: 10,
  493. }
  494. try{
  495. const resultOrder = await wechat.request(api, path, paramsNew);
  496. if (resultOrder.data.code == 200) {
  497. if (resultOrder.data.result.total > 0) {
  498. wx.showModal({
  499. showCancel: false,
  500. confirmText: '去支付',
  501. content: '您有未支付的占位费订单,请先支付',
  502. confirmColor:'#00AADD',
  503. success: function (res) {
  504. if (!res.cancel) {
  505. //点击确定
  506. let url = `/pages/ucenter/zhanw/zhanw`;
  507. wx.navigateTo({
  508. url
  509. })
  510. }
  511. }
  512. });
  513. return;
  514. }
  515. }
  516. const result = await wechat.request(api, path, params);
  517. if (result.data.code == 200) {
  518. if (result.data.result.total > 0) { // 有占位费订单不启动扫码充电
  519. this.setData({
  520. showPopup:true
  521. })
  522. return;
  523. }
  524. }
  525. }catch (error) {
  526. console.error('查询占位费订单失败', error);
  527. wx.showModal({
  528. showCancel: false,
  529. content: '查询占位费订单失败',
  530. confirmColor:'#00AADD',
  531. success: function (res) {
  532. if (!res.cancel) {
  533. //点击确定
  534. }
  535. }
  536. });
  537. }
  538. console.info('xxxxxxxxxxxxxx')
  539. let {
  540. keywords
  541. } = e.currentTarget.dataset;
  542. let userInfo = wx.getStorageSync('userInfo');
  543. let isLogin = wx.getStorageSync('isLogin');
  544. let chargid = keywords.chargPileId;
  545. let that = this;
  546. if(isLogin && userInfo.bindingPhone==0){
  547. console.info('xxxxxxxxxxxxxx1')
  548. wx.showModal({
  549. title: '提示',
  550. content: '当前账户未绑定手机号,请您进行手机号绑定操作',
  551. showCancel:false,
  552. confirmText: '去绑定',
  553. confirmColor:'#00AADD',
  554. success: function (res1) {
  555. let url = `/pages/bindPhone/bindPhone`;
  556. wx.navigateTo({
  557. url
  558. });
  559. }
  560. });
  561. return;
  562. }
  563. wx.showLoading({
  564. title: '努力加载中...',
  565. })
  566. if (!isLogin) {
  567. console.info('xxxxxxxxxxxxxx2')
  568. log.info('[首页]', '[未登陆跳转登录界面]');
  569. let url = `/pages/login/phone_login/phone_login`;
  570. wx.hideLoading();
  571. wx.navigateTo({
  572. url
  573. });
  574. // return;
  575. } else {
  576. log.info('[首页]', '[获取用户是否有未支付订单]', '[请求]', { userId: userInfo.userId });
  577. wx.request({
  578. url: getApp().globalData.postHeadAgreement + '/restapi/pileLog/wechatsettlement',
  579. data: {
  580. userId: userInfo.userId
  581. },
  582. method: 'POST',
  583. success(res) {
  584. let {
  585. data
  586. } = res;
  587. let {
  588. result: order
  589. } = data;
  590. log.info('[首页]', '[获取用户是否有未支付订单]', '[响应]', data);
  591. if (data && order && data.code == 200) {
  592. wx.hideLoading();
  593. log.info('[首页]', '[用户有未支付订单跳转订单支付界面]');
  594. wx.showModal({
  595. showCancel: false,
  596. content: '你有未支付的订单,请先支付',
  597. confirmColor:'#00AADD',
  598. success: function (res) {
  599. //console.log(res);
  600. if (!res.cancel) {
  601. //点击确定
  602. let url = `/pages/order/order?orderid=${order.orderid}&userId=${order.userId}&chargPileId=${order.chargPileId}`;
  603. wx.navigateTo({
  604. url
  605. });
  606. }
  607. }
  608. });
  609. //console.log(that.data.result);
  610. } else {
  611. //console.log('无订单');
  612. log.info('[首页]', '[用户无未支付订单]');
  613. wx.request({
  614. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargPile',
  615. // data: scanResult,
  616. data: {
  617. chargPileId: chargid,
  618. userId: userInfo.userId
  619. },
  620. method: 'POST',
  621. success(res) {
  622. console.log(chargid);
  623. log.info('[首页]', '[获取扫一扫充电桩]', '[响应]', res.data);
  624. if (!res.data || res.data.code == 500) {
  625. that.scanFlag = false;
  626. wx.hideLoading();
  627. //没有该充电桩信息
  628. wx.showModal({
  629. showCancel: false,
  630. confirmColor:'#00AADD',
  631. content: res && res.data && res.data.msg ? res.data.msg :'无效的终端编号'
  632. });
  633. } else {
  634. res.data = res.data.result
  635. //充电状态0:离线、1:故障、2:空闲中、3:充电中、4:欠压故障、5:过压故障、6:过电流故障、8:预约、9:在线升级、10:操作中、11:已插枪等
  636. 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) {
  637. //充电桩故障
  638. wx.showModal({
  639. showCancel: false,
  640. content: '终端故障,维修中',
  641. confirmColor:'#00AADD',
  642. });
  643. } else if (res.data.chargstatus == 3 || res.data.chargstatus == 8 || res.data.chargstatus == 10) {
  644. wx.showModal({
  645. showCancel: false,
  646. content: '正在充电中',
  647. confirmColor:'#00AADD',
  648. });
  649. } else if (res.data.chargstatus == 2 || res.data.chargstatus == 11) {
  650. wx.setStorage({
  651. key: "scan_chargpile",
  652. data: res.data
  653. });
  654. log.info('[首页]', '[扫一扫充电桩空闲跳转去充电界面]');
  655. let url = `/pages/scan_result/scan_result?chargPileId=` + chargid;
  656. wx.hideLoading();
  657. wx.navigateTo({
  658. url
  659. });
  660. }
  661. wx.hideLoading();
  662. }
  663. },
  664. fail(e) {
  665. getApp().showNetworkError();
  666. }
  667. });
  668. }
  669. },
  670. fail(e) {
  671. that.scanFlag = false;
  672. wx.hideLoading();
  673. getApp().showNetworkError();
  674. }
  675. });
  676. }
  677. },
  678. seeReservation: function(e){
  679. let userInfo = wx.getStorageSync('userInfo');
  680. let isLogin = wx.getStorageSync('isLogin');
  681. let that = this;
  682. if(isLogin && userInfo.bindingPhone==0){
  683. console.info('xxxxxxxxxxxxxx1')
  684. wx.showModal({
  685. title: '提示',
  686. content: '当前账户未绑定手机号,请您进行手机号绑定操作',
  687. showCancel:false,
  688. confirmText: '去绑定',
  689. confirmColor:'#00AADD',
  690. success: function (res1) {
  691. let url = `/pages/bindPhone/bindPhone`;
  692. wx.navigateTo({
  693. url
  694. });
  695. }
  696. });
  697. return;
  698. }
  699. if (!isLogin) {
  700. console.info('xxxxxxxxxxxxxx2')
  701. log.info('[首页]', '[未登陆跳转登录界面]');
  702. let url = `/pages/login/phone_login/phone_login`;
  703. wx.hideLoading();
  704. wx.navigateTo({
  705. url
  706. });
  707. return;
  708. }
  709. let idx = e.currentTarget.dataset.idx;
  710. console.info(idx)
  711. let {
  712. chargStationId,
  713. chargPileName,
  714. chargPileId,
  715. chargStationName,
  716. id
  717. } = idx;
  718. let brandName = that.data.brandName
  719. let userId = userInfo.userId;
  720. let url = `/pages/reservation/reservation?chargStationId=` + chargStationId + `&chargPileName=` + chargPileName + `&chargPileId=` + chargPileId + `&chargPileIdId=` + id + "&chargStationName=" + chargStationName + "&userId=" + userId+ "&brandName=" + brandName;
  721. wx.navigateTo({
  722. url
  723. });
  724. },
  725. /**
  726. * 生命周期函数--监听页面初次渲染完成
  727. */
  728. onReady: function() {
  729. },
  730. /**
  731. * 生命周期函数--监听页面显示
  732. */
  733. onShow: function(e) {
  734. let userInfo = wx.getStorageSync('userInfo');
  735. let isLogin = wx.getStorageSync('isLogin');
  736. //console.log(userInfo);
  737. // 页面显示
  738. if (userInfo && isLogin) {
  739. //userInfo.flag = true;
  740. this.setData({
  741. userInfo: userInfo,
  742. isLogin: isLogin
  743. });
  744. } else {
  745. //未登录信息
  746. this.setData({
  747. userInfo: {}
  748. });
  749. }
  750. },
  751. chargingLog(e){
  752. let idx = e.currentTarget.dataset.idx;
  753. let chargPileId = idx.chargPileId;
  754. console.info(chargPileId);
  755. let url = '/pages/ucenter/charginglog/opsCharginglog?chargPileId=' + chargPileId
  756. wx.navigateTo({
  757. url
  758. });
  759. return;
  760. },
  761. callphone(){
  762. let that = this
  763. let phonenum = that.data.offlineServicecall;
  764. wx.makePhoneCall({
  765. phoneNumber: that.data.offlineServicecall, //此号码并非真实电话号码,仅用于测试
  766. success:function(){
  767. console.log("拨打电话成功!" + phonenum)
  768. },
  769. fail:function(){
  770. console.log("拨打电话失败!" + phonenum)
  771. }
  772. })
  773. },
  774. toggleTabs(e){
  775. let idx = e.currentTarget.dataset.idx;
  776. this.setData({
  777. activeTab: idx
  778. })
  779. },
  780. /**
  781. * 生命周期函数--监听页面隐藏
  782. */
  783. onHide: function() {
  784. },
  785. /**
  786. * 生命周期函数--监听页面卸载
  787. */
  788. onUnload: function() {
  789. },
  790. bindScrollTolowerEvent: function(){
  791. this.getPage();
  792. console.log("触发滚动");
  793. },
  794. /**
  795. * 页面相关事件处理函数--监听用户下拉动作
  796. */
  797. onPullDownRefresh: function() {
  798. },
  799. /**
  800. * 页面上拉触底事件的处理函数
  801. */
  802. onReachBottom: function() {
  803. },
  804. /**
  805. * 用户点击右上角分享
  806. */
  807. onShareAppMessage: function() {
  808. }
  809. })