index.js 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445
  1. //index.js
  2. //获取应用实例
  3. let app = getApp();
  4. let wechat = require("../../utils/wechat");
  5. let amap = require("../../utils/amap");
  6. let Util = require("../../utils/util");
  7. let log = require('../../utils/log.js');
  8. let wxpro = require('../../utils/wx-promise-pro.js');
  9. let mapregionchange_makertap = false;
  10. wxpro.promisifyAll()
  11. // wxpro.promisify(wx.getSystemInfo)().then(console.log)
  12. for (var variable in wx) {
  13. if (wx.hasOwnProperty(variable)) {
  14. wx.pro[variable] = wxpro.promisify(wx[variable])
  15. }
  16. }
  17. Page({
  18. data: {
  19. scanFlag:false,
  20. markers: [],
  21. latitude: 39.9088120620532,
  22. longitude: 116.39747668717192,
  23. user_lat: 39.9088120620532,
  24. user_lon: 116.39747668717192,
  25. textData: null,
  26. city: null,
  27. markerId: null,
  28. keywords: "搜索充电桩",
  29. userInfo: {},
  30. isLogin: false,
  31. myChargeStationsIds: '',
  32. distanceinfo: [
  33. // {
  34. // value: 1000,
  35. // text: '1km'
  36. // }, {
  37. // value: 2000,
  38. // text: '2km'
  39. // }, {
  40. // value: 5000,
  41. // text: '5km'
  42. // },
  43. {
  44. value: 10000,
  45. text: '10km'
  46. },
  47. // {
  48. // value: 20000,
  49. // text: '20km'
  50. // },
  51. {
  52. value: 50000,
  53. text: '50km'
  54. }, {
  55. value: 100000,
  56. text: '100km'
  57. }],
  58. distanceinfoindex: 0,
  59. polygon: [{
  60. points: [{
  61. latitude: 31,
  62. longitude: 131
  63. }, {
  64. latitude: 31,
  65. longitude: 131.1
  66. }, {
  67. latitude: 31.1,
  68. longitude: 131.1
  69. }, , {
  70. latitude: 31.1,
  71. longitude: 131
  72. }]
  73. }],
  74. showModal: false,
  75. notice: null,
  76. carParkingRate: false,
  77. showPrivacy:false,
  78. occupyFeeOrderList:[],
  79. load:-1
  80. },
  81. howtouse(){
  82. wx.navigateTo({
  83. url:'/pages/howtouse/howtouse'
  84. });
  85. },
  86. wxScan(q) {
  87. //console.log(decodeURIComponent(e.q));
  88. let charePileId = decodeURIComponent(q).replace("https://cdgl.pjnes.com/", "");
  89. log.info('[首页]', '[微信扫一扫]', { 'q': q });
  90. if(!charePileId){
  91. charePileId = "0"
  92. }
  93. if (charePileId) {
  94. let userInfo = wx.getStorageSync('userInfo');
  95. let isLogin = wx.getStorageSync('isLogin');
  96. if (isLogin && userInfo.flag) {
  97. return;
  98. }
  99. if (!isLogin) {
  100. log.info('[首页]', '[未登陆跳转登录界面]');
  101. let url = `/pages/login/phone_login/phone_login`;
  102. wx.navigateTo({
  103. url
  104. });
  105. return;
  106. } else {
  107. log.info('[首页]', '[获取用户是否有未完成订单]', '[请求]', { userId: userInfo.userId });
  108. wx.request({
  109. url: getApp().globalData.postHeadAgreement + '/restapi/pileLog/wechatchargstatus',
  110. data: {
  111. userId: userInfo.userId
  112. },
  113. method: 'POST',
  114. success(res) {
  115. let {
  116. data
  117. } = res;
  118. log.info('[首页]', '[获取用户是否有未完成订单]', '[响应]', data);
  119. if (data && data.code == 200) {
  120. log.info('[首页]', '[有未完成订单跳充电界面]');
  121. //onShow会跳转
  122. } else {
  123. //console.log('无订单');
  124. log.info('[首页]', '[用户无未完成订单]');
  125. log.info('[首页]', '[获取微信扫一扫充电桩]', '[请求]', charePileId);
  126. wx.request({
  127. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargPile',
  128. // data: charePileId,
  129. data:{
  130. chargPileId:charePileId,
  131. userId: userInfo.userId
  132. },
  133. method: 'POST',
  134. success(res) {
  135. //console.log(res.data);
  136. log.info('[首页]', '[获取微信扫一扫充电桩]', '[响应]', res.data);
  137. if (!res.data || res.data.code == 500) {
  138. //没有该充电桩信息
  139. wx.showModal({
  140. showCancel: false,
  141. content: res && res.data && res.data.msg ? res.data.msg :'无效的终端编号',
  142. confirmColor:'#00AADD',
  143. });
  144. } else {
  145. res.data = res.data.result
  146. //充电状态0:离线、1:故障、2:空闲中、3:充电中、4:欠压故障、5:过压故障、6:过电流故障、8:预约、9:在线升级、10:操作中、11:已插枪等
  147. 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) {
  148. //充电桩故障
  149. wx.showModal({
  150. showCancel: false,
  151. content: '终端故障,维修中',
  152. confirmColor:'#00AADD',
  153. });
  154. } else if (res.data.chargstatus == 3 || res.data.chargstatus == 8 || res.data.chargstatus == 10) {
  155. wx.showModal({
  156. showCancel: false,
  157. content: '正在充电中',
  158. confirmColor:'#00AADD',
  159. });
  160. } else if (res.data.chargstatus == 2 || res.data.chargstatus == 11) {
  161. wx.setStorage({
  162. key: "scan_chargpile",
  163. data: res.data
  164. });
  165. log.info('[首页]', '[微信扫一扫充电桩空闲跳转去充电界面]');
  166. let url = `/pages/scan_result/scan_result`;
  167. wx.navigateTo({
  168. url
  169. });
  170. }
  171. }
  172. },
  173. fail(e) {
  174. getApp().showNetworkError();
  175. }
  176. });
  177. }
  178. },
  179. fail(e) {
  180. getApp().showNetworkError();
  181. }
  182. });
  183. }
  184. }
  185. },
  186. resetchargStations(data){
  187. let that = this
  188. // 刷新 stationTag)
  189. for(let i=0;i<data.length;i++){
  190. let seeInfoChargPile = data[i];
  191. that.resetStationTag(seeInfoChargPile);
  192. let resultTable = seeInfoChargPile.resultList
  193. that.resetResultList(resultTable);
  194. that.resetResultData(resultTable,seeInfoChargPile)
  195. }
  196. },
  197. resetResultData(resultList,data){
  198. if(!resultList){
  199. return;
  200. }
  201. for(let i=0;i<resultList.length;i++){
  202. if(resultList[i].currentTime){
  203. data.chargprice = resultList[i].elecPrice
  204. data.serviceprice = resultList[i].servicePrice
  205. }
  206. }
  207. },
  208. resetStationTag(seeInfoChargPile){
  209. let that = this
  210. if(!seeInfoChargPile){
  211. return;
  212. }
  213. if(!seeInfoChargPile?.stationTag){
  214. return;
  215. }
  216. seeInfoChargPile.stationTagList = seeInfoChargPile.stationTag.split("|");
  217. },
  218. resetResultList(resultList){
  219. let that = this
  220. if(!resultList){
  221. return;
  222. }
  223. resultList.forEach(item=>{
  224. item["sumPrice"] = that.resetResultListSumPrice(item);
  225. if(!item.elecPrice && item.elecPrice!=0){
  226. item["elecPrice"] = '暂无费用'
  227. }
  228. if(!item.servicePrice && item.servicePrice!=0){
  229. item["servicePrice"] = '暂无费用'
  230. }
  231. })
  232. },
  233. resetResultListSumPrice(item){
  234. if(!item.elecPrice && item.elecPrice!=0){
  235. return '暂无费用'
  236. }
  237. if(!item.servicePrice && item.servicePrice!=0){
  238. return '暂无费用'
  239. }
  240. return parseFloat((item.elecPrice + item.servicePrice).toFixed(6))
  241. },
  242. onLoad(e) {
  243. // 隐私开始
  244. wx.getPrivacySetting({
  245. success: res => {
  246. console.log(res) // 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' }
  247. if (res.needAuthorization) {
  248. // 需要弹出隐私协议
  249. this.setData({
  250. showPrivacy: true
  251. })
  252. } else {
  253. // 用户已经同意过隐私协议,所以不需要再弹出隐私协议,也能调用已声明过的隐私接口
  254. // wx.getUserProfile()
  255. // wx.chooseMedia()
  256. // wx.getClipboardData()
  257. // wx.startRecord()
  258. }
  259. },
  260. fail: () => {},
  261. complete: () => {}
  262. })
  263. // 隐私结束
  264. this.data.scanFlag = false;
  265. wx.hideLoading();
  266. if (e.q) {
  267. //console.log(decodeURIComponent(e.q));
  268. //let charePileId = decodeURIComponent(e.q).replace("https://cdgl.pjnes.com/", "");
  269. //console.log(charePileId);
  270. //if (charePileId){
  271. //}
  272. let userInfo = wx.getStorageSync('userInfo');
  273. let isLogin = wx.getStorageSync('isLogin');
  274. // userInfo.flag=true;
  275. this.setData({
  276. userInfo,
  277. isLogin
  278. });
  279. this.click_scan_control(e.q,false);
  280. // this.wxScan(e.q);
  281. }
  282. log.info('[首页]', '[加载完成]');
  283. amap.getRegeo(function () {
  284. var fail = function (obj) {
  285. wx.showModal({
  286. title: '请求失败',
  287. content: obj.errMsg,
  288. confirmColor:'#00AADD',
  289. });
  290. }
  291. })
  292. .then(d => {
  293. //console.log(d);
  294. let {
  295. latitude,
  296. longitude,
  297. latitude: user_lat,
  298. longitude: user_lon
  299. } = d[0];
  300. //console.log(d[0].regeocodeData.addressComponent);
  301. var {
  302. city
  303. } = d[0].regeocodeData.addressComponent;
  304. if (d[0].regeocodeData.addressComponent.city.length == 0) {
  305. var {
  306. province: city
  307. } = d[0].regeocodeData.addressComponent;
  308. }
  309. let that = this;
  310. let userInfo = wx.getStorageSync('userInfo');
  311. let isLogin = wx.getStorageSync('isLogin');
  312. // userInfo.flag=true;
  313. this.setData({
  314. city,
  315. latitude,
  316. longitude,
  317. user_lat,
  318. user_lon,
  319. userInfo,
  320. isLogin
  321. });
  322. //开始请求充电站信息
  323. var chargStationType;
  324. if (!userInfo.flag) {
  325. //用户是普通用户
  326. chargStationType = '2';
  327. }
  328. wx.request({
  329. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargStations',
  330. data: {
  331. lon: longitude,
  332. lat: latitude,
  333. distance: that.data.distanceinfo[that.data.distanceinfoindex].value,
  334. chargStationType
  335. },
  336. method: 'POST',
  337. success(res) {
  338. //userInfo.flag = true;
  339. that.resetchargStations(res.data)
  340. if (isLogin && userInfo.flag) {
  341. wx.request({
  342. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/userChargStations',
  343. data: {
  344. userId: userInfo.userId,
  345. lat: latitude,
  346. lon: longitude
  347. },
  348. method: 'POST',
  349. success(res1) {
  350. var myChargeStationsIds = '';
  351. res1.data.forEach((item, index) => {
  352. myChargeStationsIds += item.id + ",";
  353. });
  354. //console.log(myChargeStationsIds);
  355. let {
  356. data
  357. } = res;
  358. let markers = [];
  359. data.forEach((item, index) => {
  360. //item.callout = {
  361. // content: item.name, //文本 String 1.2.0
  362. // display: 'BYCLICK', //'BYCLICK': 点击显示; 'ALWAYS': 常显 String 1.2.0
  363. // textAlign: 'center' //文本对齐方式。有效值: left, right, center String 1.6.0
  364. // };
  365. var iconPath = "/images/marker.png";
  366. if (myChargeStationsIds.indexOf(item.id + ',') != -1) {
  367. iconPath = "/images/marker1.png";
  368. }
  369. if (item.breaknum && item.breaknum != 0) {
  370. iconPath = "/images/marker_b.png";
  371. }
  372. /**
  373. * 运营状态 初始,待运营,运营中,暂停营业,关闭,未运营
  374. * */
  375. //private Long operationState;
  376. var marker = {
  377. name: item.chargStationName,
  378. address: item.address,
  379. width: "46rpx",
  380. height: "67rpx",
  381. chargfeatures: item.chargfeatures ,
  382. iconPath: iconPath,
  383. id: item.id,
  384. callout: {},
  385. latitude: item.lat,
  386. longitude: item.lon,
  387. //distance: item.distance / 1000,
  388. distance: Util.distance(that.data.user_lat, that.data.user_lon, item.lat, item.lon),
  389. chargPileNum: item.fastCharg + item.slowCharg,
  390. fastCharg: item.fastCharg,
  391. slowCharg: item.slowCharg,
  392. freenum: item.freenum,
  393. fastfreenum: item.fastfreenum,
  394. slowfreenum: item.slowfreenum,
  395. breaknum: item.breaknum,
  396. /** 电费 */
  397. chargprice: item.chargprice,
  398. /** 服务费 */
  399. serviceprice: item.serviceprice,
  400. /** 停车费 */
  401. stopprice: item.stopprice,
  402. operationState: item.operationState,
  403. chargStationId: item.id,
  404. stationTag: item.stationTag,
  405. stationTagList: item.stationTagList,
  406. offlineServicecall: item.offlineServicecall,
  407. };
  408. markers[index] = marker;
  409. });
  410. that.setData({
  411. markers,
  412. myChargeStationsIds
  413. });
  414. },
  415. fail(e) {
  416. getApp().showNetworkError();
  417. }
  418. });
  419. } else {
  420. let {
  421. data
  422. } = res;
  423. let markers = [];
  424. if(data){
  425. data.forEach((item, index) => {
  426. //item.callout = {
  427. // content: item.name, //文本 String 1.2.0
  428. // display: 'BYCLICK', //'BYCLICK': 点击显示; 'ALWAYS': 常显 String 1.2.0
  429. // textAlign: 'center' //文本对齐方式。有效值: left, right, center String 1.6.0
  430. // };
  431. var iconPath = "/images/marker.png";
  432. //撤销普通用户显示异常站
  433. //if (item.breaknum && item.breaknum != 0) {
  434. // iconPath = "/images/marker_b.png";
  435. //}
  436. //撤销结束
  437. var marker = {
  438. name: item.chargStationName,
  439. address: item.address,
  440. width: "46rpx",
  441. height: "67rpx",
  442. chargfeatures: item.chargfeatures ,
  443. iconPath: iconPath,
  444. id: item.id,
  445. callout: {},
  446. latitude: item.lat,
  447. longitude: item.lon,
  448. //distance: item.distance / 1000,
  449. distance: Util.distance(that.data.user_lat, that.data.user_lon, item.lat, item.lon),
  450. chargPileNum: item.fastCharg + item.slowCharg,
  451. fastCharg: item.fastCharg,
  452. slowCharg: item.slowCharg,
  453. freenum: item.freenum,
  454. fastfreenum: item.fastfreenum,
  455. slowfreenum: item.slowfreenum,
  456. breaknum: item.breaknum,
  457. /** 电费 */
  458. chargprice: item.chargprice,
  459. /** 服务费 */
  460. serviceprice: item.serviceprice,
  461. /** 停车费 */
  462. stopprice: item.stopprice,
  463. operationState: item.operationState,
  464. sharpChargPrice : item.sharpChargPrice,
  465. sharpServicePrice : item.sharpServicePrice,
  466. peakChargPrice : item.peakChargPrice,
  467. peakServicePrice : item.peakServicePrice,
  468. flatChargPrice : item.flatChargPrice,
  469. flatServicePrice : item.flatServicePrice,
  470. valleyChargPrice : item.valleyChargPrice,
  471. valleyServicePrice : item.valleyServicePrice,
  472. resultList: item.resultList,
  473. chargStationId: item.id,
  474. stationTag: item.stationTag,
  475. stationTagList: item.stationTagList,
  476. offlineServicecall: item.offlineServicecall,
  477. };
  478. markers[index] = marker;
  479. });
  480. }
  481. that.setData({
  482. markers
  483. });
  484. }
  485. },
  486. fail(e) {
  487. getApp().showNetworkError();
  488. }
  489. });
  490. })
  491. .catch(e => {
  492. console.log(e);
  493. });
  494. let that = this;
  495. let userInfo = wx.getStorageSync('userInfo');
  496. let isLogin = wx.getStorageSync('isLogin');
  497. //console.log(userInfo);
  498. if (isLogin) {
  499. wx.request({
  500. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/lastNotice',
  501. data: { loginName: userInfo.loginName },
  502. method: 'POST',
  503. success(res) {
  504. //console.log(res);
  505. //res.data = { noticeTitle: '派捷充电例行维护通知', noticeContent:'nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好nihao你好'};
  506. if (res.data) {
  507. that.setData({
  508. showModal: true,
  509. notice: res.data
  510. });
  511. } else {
  512. that.setData({
  513. showModal: false,
  514. notice: null
  515. });
  516. }
  517. },
  518. fail(e) {
  519. //console.log(e);
  520. that.setData({
  521. showModal: false,
  522. notice: null
  523. });
  524. getApp().showNetworkError();
  525. }
  526. });
  527. // this.queryParkOrder(3).then(res=>{
  528. // console.log("查询未支付成功",res);
  529. // if (res.total > 0) {
  530. // wx.showModal({
  531. // showCancel: false,
  532. // confirmText: '去支付',
  533. // content: '您有未支付的占位费订单,请先支付',
  534. // confirmColor:'#00AADD',
  535. // success: function (res) {
  536. // if (!res.cancel) {
  537. // console.log("res",res);
  538. // //点击确定
  539. // let url = `/pages/ucenter/zhanw/zhanw`;
  540. // wx.navigateTo({
  541. // url
  542. // })
  543. // return;
  544. // }
  545. // }
  546. // });
  547. // }
  548. // })
  549. // // 查询占位中订单
  550. // this.queryParkOrder(2).then(res=>{
  551. // // console.log("我被调用了");
  552. // if (res.total > 0) { // 有占位费订单不启动扫码充电
  553. // this.setData({
  554. // showPopup:true
  555. // })
  556. // return;
  557. // }
  558. // });
  559. }
  560. },
  561. //跳转个人中心
  562. bindUserAvatarUrl() {
  563. let url = `/pages/ucenter/index/index`;
  564. wx.navigateTo({
  565. url
  566. });
  567. },
  568. //搜索
  569. bindInput() {
  570. var {
  571. user_lat: latitude,
  572. user_lon: longitude,
  573. city
  574. } = this.data;
  575. //console.log(this.data.city);
  576. let url = `/pages/inputtip/inputtip?city=${city}&lonlat=${longitude},${latitude}`;
  577. wx.navigateTo({
  578. url
  579. });
  580. },
  581. //单击地图mark
  582. makertap(e) {
  583. mapregionchange_makertap = true;
  584. //console.log(e);
  585. let {
  586. markerId
  587. } = e.detail;
  588. // console.log({
  589. // e
  590. // });
  591. let {
  592. markers
  593. } = this.data;
  594. //撤销普通用户显示异常站
  595. let userInfo = wx.getStorageSync('userInfo');
  596. let isLogin = wx.getStorageSync('isLogin');
  597. let showBadMark = false;
  598. if (isLogin && userInfo.flag) {
  599. showBadMark = true;
  600. }
  601. //撤销结束
  602. markers.forEach((item, index) => {
  603. item.iconPath = "/images/marker.png";
  604. if (this.data.myChargeStationsIds.indexOf(item.id + ',') != -1) {
  605. item.iconPath = "/images/marker1.png";
  606. }
  607. //撤销普通用户显示异常站
  608. if (showBadMark) {
  609. //撤销结束
  610. if (item.breaknum && item.breaknum != 0) {
  611. item.iconPath = "/images/marker_b.png";
  612. }
  613. //撤销普通用户显示异常站
  614. }
  615. //撤销结束
  616. if (item.id == markerId) {
  617. item.iconPath = "/images/marker_checked.png";
  618. this.showMarkerInfo(item);
  619. }
  620. });
  621. this.setData({
  622. markers,
  623. markerId
  624. });
  625. },
  626. //将mark呈现在地图中心点,并弹出详细信息框
  627. showMarkerInfo(data) {
  628. let that = this
  629. let {
  630. latitude,
  631. longitude
  632. } = data;
  633. this.setData({
  634. textData: data,
  635. latitude: latitude,
  636. longitude: longitude
  637. })
  638. console.info(data)
  639. // 查询是否需要显示
  640. that.execParking(that,data.id)
  641. },
  642. execParking(that,stationId){
  643. wx.request({
  644. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/carParkingRate?stationId=' + stationId,
  645. // data: {
  646. // loginName: userInfo.loginName
  647. // },
  648. method: 'POST',
  649. success: function (res) {
  650. // 是否减免停车费
  651. // carParkingRate: false,
  652. // parkTime: 0,
  653. console.info(res)
  654. let reduceTime = res.data?.reduceTime;
  655. if(!reduceTime){
  656. that.setData({
  657. carParkingRate:false
  658. })
  659. return;
  660. }
  661. that.setData({
  662. carParkingRate:true
  663. })
  664. try{
  665. that.setData({
  666. parkTime: parseFloat((reduceTime/ 3600).toFixed(2))
  667. })
  668. }catch(e){
  669. that.setData({
  670. carParkingRate:false
  671. })
  672. }
  673. },
  674. fail(e) {
  675. console.log("用户数据同步失败");
  676. log.info('[扫码]', '[同步用户数据]', '[fail]', e);
  677. }
  678. });
  679. },
  680. //改变选中mark的颜色
  681. changeMarkerColor(markerId) {
  682. let {
  683. markers
  684. } = this.data;
  685. //撤销普通用户显示异常站
  686. let userInfo = wx.getStorageSync('userInfo');
  687. let isLogin = wx.getStorageSync('isLogin');
  688. let showBadMark = false;
  689. if (isLogin && userInfo.flag) {
  690. showBadMark = true;
  691. }
  692. //撤销结束
  693. markers.forEach((item, index) => {
  694. item.iconPath = "/images/marker.png";
  695. if (this.data.myChargeStationsIds.indexOf(item.id + ',') != -1) {
  696. item.iconPath = "/images/marker1.png";
  697. }
  698. //撤销普通用户显示异常站
  699. if (showBadMark) {
  700. //撤销结束
  701. if (item.breaknum && item.breaknum != 0) {
  702. item.iconPath = "/images/marker_b.png";
  703. }
  704. //撤销普通用户显示异常站
  705. }
  706. //撤销结束
  707. if (item.id == markerId) {
  708. item.iconPath = "/images/marker_checked.png";
  709. }
  710. })
  711. this.setData({
  712. markers,
  713. markerId
  714. });
  715. },
  716. seeInfo(e){
  717. console.log("11111");
  718. // 起点
  719. let {
  720. user_lat: latitude,
  721. user_lon: longitude,
  722. markers,
  723. markerId,
  724. city,
  725. textData
  726. } = this.data;
  727. let {
  728. name,
  729. address,
  730. chargprice,
  731. serviceprice,
  732. brandName
  733. } = textData;
  734. console.log("222222");
  735. console.log(markers);
  736. if (!markers.length) return;
  737. console.log("3333333");
  738. // 终点
  739. markers.forEach((item, index) => {
  740. if (markerId && markerId == item.id) {
  741. let {
  742. name: latitude2,
  743. longitude: longitude2
  744. } = item;
  745. wx.setStorage({
  746. key: "index_seeInfo_chargpile",
  747. data: item
  748. });
  749. let url = `/pages/charginfo/charginfo?name=${name}&address=${address}&chargprice=${chargprice}&serviceprice=${serviceprice}&chargid=${markerId}&brandName=${brandName}`;
  750. wx.navigateTo({
  751. url
  752. });
  753. }
  754. });
  755. },
  756. //导航
  757. getRoute(e) {
  758. //console.log(e);
  759. // 起点
  760. let {
  761. user_lat: latitude,
  762. user_lon: longitude,
  763. markers,
  764. markerId,
  765. city,
  766. textData
  767. } = this.data;
  768. let {
  769. name,
  770. address
  771. } = textData;
  772. if (!markers.length) return;
  773. // 终点
  774. markers.forEach((item, index) => {
  775. if (markerId && markerId == item.id) {
  776. let {
  777. latitude: latitude2,
  778. longitude: longitude2
  779. } = item;
  780. let url = `/pages/routes/routes?longitude=${longitude}&latitude=${latitude}&longitude2=${longitude2}&latitude2=${latitude2}&city=${city}&name=${name}&desc=${address}`;
  781. //console.log(url);
  782. wx.navigateTo({
  783. url
  784. });
  785. }
  786. });
  787. return;
  788. },
  789. //回到当前位置
  790. click_location_control(e) {
  791. //console.log("回到用户当前定位点");
  792. // let {
  793. // controlId
  794. // } = e;
  795. let mpCtx = wx.createMapContext("map");
  796. mpCtx.moveToLocation();
  797. },
  798. //打开扫一扫
  799. click_scan_control_outer(){
  800. this.click_scan_control("",true)
  801. },
  802. async click_scan_control(scanResult,inner) {
  803. if (this.data.isLogin) {
  804. this.queryParkOrder(3).then(res=>{
  805. console.log("查询未支付成功",res);
  806. if (res.total > 0) {
  807. wx.showModal({
  808. showCancel: false,
  809. confirmText: '去支付',
  810. content: '您有未支付的占位费订单,请先支付',
  811. confirmColor:'#00AADD',
  812. success: function (res) {
  813. if (!res.cancel) {
  814. //点击确定
  815. let url = `/pages/ucenter/zhanw/zhanw`;
  816. wx.navigateTo({
  817. url
  818. })
  819. }
  820. }
  821. });
  822. }
  823. })
  824. const result = await this.queryParkOrder(2);
  825. if (result.total > 0) { // 有占位费订单不启动扫码充电
  826. this.setData({
  827. showPopup:true
  828. })
  829. return;
  830. }
  831. }
  832. if(this.data.scanFlag){
  833. return;
  834. }
  835. this.data.scanFlag = true;
  836. wx.showLoading({
  837. title: '努力加载中...',
  838. })
  839. console.log("打开扫一扫");
  840. log.info('[首页]', '[打开扫一扫]');
  841. let that = this;
  842. if (!this.data.isLogin) {
  843. log.info('[首页]', '[未登陆跳转登录界面]');
  844. let url = `/pages/login/phone_login/phone_login`;
  845. that.data.scanFlag = false;
  846. wx.hideLoading();
  847. wx.navigateTo({
  848. url
  849. });
  850. return;
  851. } else {
  852. if (this.data.userInfo.flag) {// 运维人员不作操作,直接返回首页
  853. wx.hideLoading();
  854. return false;
  855. }
  856. if(!this.phoneCheck()){
  857. return;
  858. }
  859. log.info('[首页]', '[获取用户是否有未支付订单]', '[请求]', { userId: this.data.userInfo.userId });
  860. wx.request({
  861. url: getApp().globalData.postHeadAgreement + '/restapi/pileLog/wechatsettlement',
  862. data: {
  863. userId: this.data.userInfo.userId
  864. },
  865. method: 'POST',
  866. success(res) {
  867. let {
  868. data
  869. } = res;
  870. let {
  871. result: order
  872. } = data;
  873. log.info('[首页]', '[获取用户是否有未支付订单]', '[响应]', data);
  874. if (data && order && data.code == 200) {
  875. that.data.scanFlag = false;
  876. wx.hideLoading();
  877. log.info('[首页]', '[用户有未支付订单跳转订单支付界面]');
  878. wx.showModal({
  879. showCancel: false,
  880. content: '你有未支付的订单,请先支付',
  881. confirmColor:'#00AADD',
  882. success: function (res) {
  883. //console.log(res);
  884. if (!res.cancel) {
  885. //点击确定
  886. let url = `/pages/order/order?orderid=${order.orderid}&userId=${order.userId}&chargPileId=${order.chargPileId}`;
  887. wx.navigateTo({
  888. url
  889. });
  890. }
  891. }
  892. });
  893. //console.log(that.data.result);
  894. } else {
  895. //console.log('无订单');
  896. log.info('[首页]', '[用户无未支付订单]');
  897. //console.log("打开扫一扫");
  898. if(inner){
  899. wx.pro.scanCode().then(d=>{
  900. that.afterScanCode(d,that,inner)
  901. }).catch(e=>{
  902. that.data.scanFlag = false;
  903. wx.hideLoading();
  904. });
  905. }else{
  906. that.afterScanCode(scanResult,that,inner)
  907. }
  908. }
  909. },
  910. fail(e) {
  911. that.data.scanFlag = false;
  912. wx.hideLoading();
  913. getApp().showNetworkError();
  914. }
  915. });
  916. }
  917. },
  918. afterScanCode(d,that,inner){
  919. let scanResult = ""
  920. if(inner){
  921. //console.log("完成扫一扫");
  922. //console.log(d);
  923. //兼容标准格式hlht://202001022222220101.330414214二维码
  924. scanResult = d.result;
  925. if((!scanResult) || scanResult == ""){
  926. scanResult="*"
  927. }
  928. }else{
  929. scanResult = decodeURIComponent(d)
  930. //console.log(charePileId);
  931. log.info('[首页]', '[微信扫一扫]', { 'd': d });
  932. if(!scanResult){
  933. scanResult = "0"
  934. }
  935. }
  936. // 是否电池包
  937. let batteryFlag = false;
  938. if (scanResult.startsWith("tkd")){
  939. scanResult = scanResult.substring(3);
  940. batteryFlag = true
  941. }
  942. if (scanResult.startsWith("hlht://") || scanResult.startsWith("HLHT://")){
  943. scanResult = scanResult.substring(7, scanResult.indexOf("."));
  944. }
  945. scanResult = scanResult.replace("https://cdgl.pjnes.com/", "");
  946. scanResult = scanResult.replace("https://cdglyy.pjnes.com/", "");
  947. console.log('扫描到的内容: [' + scanResult + '] , 是否内部按钮:' + inner)
  948. log.info('[首页]', '[用户完成扫一扫]', scanResult);
  949. log.info('[首页]', '[获取扫一扫充电桩]', '[请求]', scanResult);
  950. wx.request({
  951. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/' + (batteryFlag? 'chargBattery' : 'chargPile'),
  952. // data: scanResult,
  953. data: {
  954. chargPileId:scanResult,
  955. userId: that.data.userInfo.userId
  956. },
  957. method: 'POST',
  958. success(res) {
  959. console.log( res.data);
  960. log.info('[首页]', '[获取扫一扫充电桩]', '[响应]', res.data);
  961. if (!res.data || res.data.code == 500) {
  962. that.data.scanFlag = false;
  963. wx.hideLoading();
  964. //没有该充电桩信息
  965. wx.showModal({
  966. showCancel: false,
  967. content: res && res.data && res.data.msg ? res.data.msg :'无效的终端编号',
  968. confirmColor:'#00AADD',
  969. });
  970. } else {
  971. res.data = res.data.result
  972. // 拨乱反正, 将电池包的逻辑强行合并
  973. if(batteryFlag){
  974. // 0空闲
  975. let status = res.data.parkStatus
  976. if(status == 1){
  977. wx.showModal({
  978. showCancel: false,
  979. content: '当前停靠点占用',
  980. confirmColor:'#00AADD',
  981. });
  982. }else if(status == 0){
  983. wx.hideLoading();
  984. that.data.scanFlag = false;
  985. // 判断电池包
  986. if(res?.data?.chargPileList?.length==0 || !res?.data?.chargPileList){
  987. wx.showModal({
  988. showCancel: false,
  989. content: '暂无可用电池包',
  990. confirmColor:'#00AADD',
  991. });
  992. return;
  993. }
  994. wx.setStorage({
  995. key: "elpackage",
  996. data: res.data
  997. });
  998. let url = `/pages/scan_result/elpackage`;
  999. wx.navigateTo({
  1000. url
  1001. });
  1002. }else{
  1003. wx.showModal({
  1004. showCancel: false,
  1005. content: '未知错误,电池包返回状态码异常:' + res.data.parkStatus,
  1006. confirmColor:'#00AADD',
  1007. });
  1008. }
  1009. that.data.scanFlag = false;
  1010. wx.hideLoading();
  1011. return;
  1012. }
  1013. //SZP
  1014. // park_status
  1015. //充电状态0:离线、1:故障、2:空闲中、3:充电中、4:欠压故障、5:过压故障、6:过电流故障、8:预约、9:在线升级、10:操作中、11:已插枪等
  1016. 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) {
  1017. //充电桩故障
  1018. wx.showModal({
  1019. showCancel: false,
  1020. content: '终端故障,维修中',
  1021. confirmColor:'#00AADD',
  1022. });
  1023. } else if (res.data.chargstatus == 3 || res.data.chargstatus == 8 || res.data.chargstatus == 10) {
  1024. wx.showModal({
  1025. showCancel: false,
  1026. content: '正在充电中',
  1027. confirmColor:'#00AADD',
  1028. });
  1029. } else if (res.data.chargstatus == 2 || res.data.chargstatus == 11) {
  1030. wx.setStorage({
  1031. key: "scan_chargpile",
  1032. data: res.data
  1033. });
  1034. log.info('[首页]', '[扫一扫充电桩空闲跳转去充电界面]');
  1035. let url = `/pages/scan_result/scan_result?chargPileId=${scanResult}`;
  1036. that.data.scanFlag = false;
  1037. wx.hideLoading();
  1038. wx.navigateTo({
  1039. url
  1040. });
  1041. }
  1042. that.data.scanFlag = false;
  1043. wx.hideLoading();
  1044. }
  1045. },
  1046. fail(e) {
  1047. getApp().showNetworkError();
  1048. }
  1049. });
  1050. },
  1051. //地图位移
  1052. mapchange(e) {
  1053. if (e.type == 'end') {
  1054. if (!mapregionchange_makertap) {
  1055. //console.log("移动地图");
  1056. let that = this;
  1057. let wMap = wx.createMapContext('map');
  1058. wMap.getCenterLocation({
  1059. type: 'gcj02',
  1060. success: function (res) {
  1061. let {
  1062. latitude,
  1063. longitude
  1064. } = res;
  1065. let userInfo = wx.getStorageSync('userInfo');
  1066. let isLogin = wx.getStorageSync('isLogin');
  1067. var chargStationType;
  1068. if (!userInfo.flag) {
  1069. //用户是普通用户
  1070. chargStationType = '2';
  1071. }
  1072. wx.request({
  1073. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargStations',
  1074. data: {
  1075. lon: longitude,
  1076. lat: latitude,
  1077. distance: that.data.distanceinfo[that.data.distanceinfoindex].value,
  1078. chargStationType
  1079. },
  1080. method: 'POST',
  1081. success(res) {
  1082. that.resetchargStations(res.data)
  1083. let {
  1084. data
  1085. } = res;
  1086. let markers = [];
  1087. var flag = false;
  1088. if(data){
  1089. data.forEach((item, index) => {
  1090. var iconPath;
  1091. if (that.data.markerId && that.data.markerId == item.id) {
  1092. iconPath = "/images/marker_checked.png";
  1093. flag = true;
  1094. } else {
  1095. iconPath = "/images/marker.png";
  1096. if (that.data.myChargeStationsIds.indexOf(item.id + ',') != -1) {
  1097. iconPath = "/images/marker1.png";
  1098. }
  1099. //撤销普通用户显示异常站
  1100. if (isLogin && userInfo.flag) {
  1101. //撤销结束
  1102. if (item.breaknum && item.breaknum != 0) {
  1103. iconPath = "/images/marker_b.png";
  1104. }
  1105. //撤销普通用户显示异常站
  1106. }
  1107. //撤销结束
  1108. }
  1109. //console.log(Util.distance(that.data.user_lat, that.data.user_lon, item.lat, item.lon));
  1110. var marker = {
  1111. brandName:item.brandName,
  1112. name: item.chargStationName,
  1113. address: item.address,
  1114. width: "46rpx",
  1115. height: "67rpx",
  1116. chargfeatures: item.chargfeatures ,
  1117. iconPath: iconPath,
  1118. id: item.id,
  1119. callout: {},
  1120. latitude: item.lat,
  1121. longitude: item.lon,
  1122. //distance: item.distance / 1000,
  1123. distance: Util.distance(that.data.user_lat, that.data.user_lon, item.lat, item.lon),
  1124. chargPileNum: item.fastCharg + item.slowCharg,
  1125. fastCharg: item.fastCharg,
  1126. slowCharg: item.slowCharg,
  1127. freenum: item.freenum,
  1128. fastfreenum: item.fastfreenum,
  1129. slowfreenum: item.slowfreenum,
  1130. breaknum: item.breaknum,
  1131. /** 电费 */
  1132. chargprice: item.chargprice,
  1133. /** 服务费 */
  1134. serviceprice: item.serviceprice,
  1135. /** 停车费 */
  1136. stopprice: item.stopprice,
  1137. operationState: item.operationState,
  1138. sharpChargPrice : item.sharpChargPrice,
  1139. sharpServicePrice : item.sharpServicePrice,
  1140. peakChargPrice : item.peakChargPrice,
  1141. peakServicePrice : item.peakServicePrice,
  1142. flatChargPrice : item.flatChargPrice,
  1143. flatServicePrice : item.flatServicePrice,
  1144. valleyChargPrice : item.valleyChargPrice,
  1145. valleyServicePrice : item.valleyServicePrice,
  1146. resultList: item.resultList,
  1147. chargStationId: item.id,
  1148. stationTag: item.stationTag,
  1149. stationTagList: item.stationTagList,
  1150. offlineServicecall: item.offlineServicecall,
  1151. };
  1152. markers[index] = marker;
  1153. });
  1154. }
  1155. if (!flag) {
  1156. that.setData({
  1157. textData: null,
  1158. markerId: null,
  1159. });
  1160. }
  1161. that.setData({
  1162. markers: markers
  1163. });
  1164. },
  1165. fail(e) {
  1166. getApp().showNetworkError();
  1167. }
  1168. });
  1169. }
  1170. });
  1171. } else {
  1172. //点击marker的情况下
  1173. //console.log("点击marker");
  1174. mapregionchange_makertap = false;
  1175. }
  1176. }
  1177. },
  1178. phoneCheck(){
  1179. if (this.data.userInfo.bindingPhone==0) {
  1180. wx.hideLoading();
  1181. wx.showModal({
  1182. title: '提示',
  1183. content: '当前账户未绑定手机号,请您进行手机号绑定操作',
  1184. showCancel:false,
  1185. confirmText: '去绑定',
  1186. confirmColor:'#00AADD',
  1187. success: function (res1) {
  1188. let url = `/pages/bindPhone/bindPhone`;
  1189. wx.navigateTo({
  1190. url
  1191. });
  1192. }
  1193. })
  1194. return false;
  1195. }else{
  1196. return true;
  1197. }
  1198. },
  1199. // 根据状态查询占位费订单
  1200. queryParkOrder(status) {
  1201. return new Promise((resolve, reject) => {
  1202. let that = this;
  1203. wx.request({
  1204. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/queryOccupyFeeOrder',
  1205. data: {
  1206. userId: wx.getStorageSync('userInfo').userId,
  1207. searchIndex: status,
  1208. pagenum: that.data.pagenum++,
  1209. pagesize: 10,
  1210. },
  1211. method: 'POST',
  1212. success(res) {
  1213. console.log('请求成功,处理数据');
  1214. if(res.data.code==200){
  1215. if (res.data.result.total > 0) {
  1216. resolve(res.data.result);
  1217. }
  1218. }else{
  1219. resolve(res.data);
  1220. }
  1221. },
  1222. fail(err) {
  1223. console.error('请求失败', err);
  1224. reject(err);
  1225. }
  1226. });
  1227. });
  1228. },
  1229. /**
  1230. * 生命周期函数--监听页面显示
  1231. */
  1232. onShow: function () {
  1233. this.data.scanFlag = false;
  1234. let userInfo = wx.getStorageSync('userInfo');
  1235. let isLogin = wx.getStorageSync('isLogin');
  1236. // 页面显示
  1237. if (userInfo && isLogin) {
  1238. //console.log(userInfo);
  1239. //userInfo.flag = true;
  1240. this.setData({
  1241. userInfo: userInfo,
  1242. isLogin: isLogin
  1243. });
  1244. if ((!userInfo.userId && userInfo.userId != 0)){
  1245. log.info('[首页]', '[已登陆未有用户ID跳转登录界面]');
  1246. let url = `/pages/login/phone_login/phone_login`;
  1247. wx.navigateTo({
  1248. url
  1249. });
  1250. return;
  1251. }
  1252. // 查询订单
  1253. log.info('[首页]', '[获取用户是否有未完成订单]', '[请求]', { userId: userInfo.userId });
  1254. wx.request({
  1255. url: getApp().globalData.postHeadAgreement + '/restapi/pileLog/wechatchargstatus',
  1256. data: {
  1257. userId: userInfo.userId
  1258. },
  1259. method: 'POST',
  1260. success(res) {
  1261. let {
  1262. data
  1263. } = res;
  1264. log.info('[首页]', '[获取用户是否有未完成订单]', '[响应]', data);
  1265. if (data && data.code == 200) {
  1266. log.info('[首页]', '[有未完成订单跳充电界面]');
  1267. //获取用户正在充电的订单,并跳转到该页面
  1268. let url = `/pages/charging/charging?orderid=${data.result.orderid}&userId=${userInfo.userId}&chargPileId=${data.result.chargPileId}`;
  1269. //let url = `/pages/charging/charging?userId=${userInfo.userId}`;
  1270. wx.navigateTo({
  1271. url
  1272. });
  1273. } else {
  1274. //console.log(res);
  1275. }
  1276. },
  1277. fail(e) {
  1278. getApp().showNetworkError();
  1279. }
  1280. });
  1281. // 查询呼叫电车
  1282. console.log("查询呼叫电车")
  1283. wx.request({
  1284. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/ivCarRequirement' +
  1285. '?userId='+userInfo.userId,
  1286. data: {
  1287. },
  1288. method: 'POST',
  1289. success(res) {
  1290. console.log(res?.data?.result?.requirementStep)
  1291. // 0-7 进等待 8进终端详情
  1292. if(res?.data?.result?.requirementStep>=0 && res?.data?.result?.requirementStep<=7){
  1293. // 等待
  1294. let url = `/pages/batteryPack/batteryPackWait`;
  1295. wx.reLaunch({
  1296. url
  1297. });
  1298. }else if(res?.data?.result?.requirementStep==8){
  1299. // 8进终端详情
  1300. let url = `/pages/batteryPack/batteryPackWait`;
  1301. wx.reLaunch({
  1302. url
  1303. });
  1304. }
  1305. },
  1306. fail(e) {
  1307. getApp().showNetworkError();
  1308. }
  1309. });
  1310. this.queryParkOrder(3).then(res=>{
  1311. console.log("查询未支付成功",res);
  1312. if (res.total > 0) {
  1313. wx.showModal({
  1314. showCancel: false,
  1315. confirmText: '去支付',
  1316. content: '您有未支付的占位费订单,请先支付',
  1317. confirmColor:'#00AADD',
  1318. success: function (res) {
  1319. if (!res.cancel) {
  1320. console.log("res",res);
  1321. //点击确定
  1322. let url = `/pages/ucenter/zhanw/zhanw`;
  1323. wx.navigateTo({
  1324. url
  1325. })
  1326. return;
  1327. }
  1328. }
  1329. });
  1330. }
  1331. })
  1332. // 查询占位中订单
  1333. this.queryParkOrder(2).then(res=>{
  1334. // 30s查询一次,动态返回数据
  1335. // console.log("我被调用了");
  1336. if (res.total > 0) { // 有占位费订单不启动扫码充电
  1337. this.setData({
  1338. showPopup:true
  1339. })
  1340. return;
  1341. }
  1342. });
  1343. } else {
  1344. //未登录信息
  1345. this.setData({
  1346. userInfo: {}
  1347. });
  1348. }
  1349. },
  1350. bindDistanceinfoChange: function (e) {
  1351. let distance = this.data.distanceinfo[e.detail.value].value;
  1352. this.setData({
  1353. distanceinfoindex: e.detail.value
  1354. });
  1355. },
  1356. Sure: function () {
  1357. this.setData({
  1358. showModal: false
  1359. });
  1360. },
  1361. handleAgreePrivacyAuthorization() {
  1362. console.info('3333333333333');
  1363. this.setData({
  1364. showPrivacy: false
  1365. })
  1366. // 用户同意隐私协议事件回调
  1367. // 用户点击了同意,之后所有已声明过的隐私接口和组件都可以调用了
  1368. // wx.getUserProfile()
  1369. // wx.chooseMedia()
  1370. // wx.getClipboardData()
  1371. // wx.startRecord()
  1372. },
  1373. handleOpenPrivacyContract() {
  1374. // 打开隐私协议页面
  1375. wx.openPrivacyContract({
  1376. success: () => {}, // 打开成功
  1377. fail: () => {}, // 打开失败
  1378. complete: () => {}
  1379. })
  1380. }
  1381. })