index.js 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439
  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. this.queryParkOrder(3).then(res=>{
  804. console.log("查询未支付成功",res);
  805. if (res.total > 0) {
  806. wx.showModal({
  807. showCancel: false,
  808. confirmText: '去支付',
  809. content: '您有未支付的占位费订单,请先支付',
  810. confirmColor:'#00AADD',
  811. success: function (res) {
  812. if (!res.cancel) {
  813. //点击确定
  814. let url = `/pages/ucenter/zhanw/zhanw`;
  815. wx.navigateTo({
  816. url
  817. })
  818. return;
  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. if(this.data.scanFlag){
  832. return;
  833. }
  834. this.data.scanFlag = true;
  835. wx.showLoading({
  836. title: '努力加载中...',
  837. })
  838. console.log("打开扫一扫");
  839. log.info('[首页]', '[打开扫一扫]');
  840. let that = this;
  841. if (!this.data.isLogin) {
  842. log.info('[首页]', '[未登陆跳转登录界面]');
  843. let url = `/pages/login/phone_login/phone_login`;
  844. that.data.scanFlag = false;
  845. wx.hideLoading();
  846. wx.navigateTo({
  847. url
  848. });
  849. return;
  850. } else {
  851. if(!this.phoneCheck()){
  852. return;
  853. }
  854. log.info('[首页]', '[获取用户是否有未支付订单]', '[请求]', { userId: this.data.userInfo.userId });
  855. wx.request({
  856. url: getApp().globalData.postHeadAgreement + '/restapi/pileLog/wechatsettlement',
  857. data: {
  858. userId: this.data.userInfo.userId
  859. },
  860. method: 'POST',
  861. success(res) {
  862. let {
  863. data
  864. } = res;
  865. let {
  866. result: order
  867. } = data;
  868. log.info('[首页]', '[获取用户是否有未支付订单]', '[响应]', data);
  869. if (data && order && data.code == 200) {
  870. that.data.scanFlag = false;
  871. wx.hideLoading();
  872. log.info('[首页]', '[用户有未支付订单跳转订单支付界面]');
  873. wx.showModal({
  874. showCancel: false,
  875. content: '你有未支付的订单,请先支付',
  876. confirmColor:'#00AADD',
  877. success: function (res) {
  878. //console.log(res);
  879. if (!res.cancel) {
  880. //点击确定
  881. let url = `/pages/order/order?orderid=${order.orderid}&userId=${order.userId}&chargPileId=${order.chargPileId}`;
  882. wx.navigateTo({
  883. url
  884. });
  885. }
  886. }
  887. });
  888. //console.log(that.data.result);
  889. } else {
  890. //console.log('无订单');
  891. log.info('[首页]', '[用户无未支付订单]');
  892. //console.log("打开扫一扫");
  893. if(inner){
  894. wx.pro.scanCode().then(d=>{
  895. that.afterScanCode(d,that,inner)
  896. }).catch(e=>{
  897. that.data.scanFlag = false;
  898. wx.hideLoading();
  899. });
  900. }else{
  901. that.afterScanCode(scanResult,that,inner)
  902. }
  903. }
  904. },
  905. fail(e) {
  906. that.data.scanFlag = false;
  907. wx.hideLoading();
  908. getApp().showNetworkError();
  909. }
  910. });
  911. }
  912. },
  913. afterScanCode(d,that,inner){
  914. let scanResult = ""
  915. if(inner){
  916. //console.log("完成扫一扫");
  917. //console.log(d);
  918. //兼容标准格式hlht://202001022222220101.330414214二维码
  919. scanResult = d.result;
  920. if((!scanResult) || scanResult == ""){
  921. scanResult="*"
  922. }
  923. }else{
  924. scanResult = decodeURIComponent(d)
  925. //console.log(charePileId);
  926. log.info('[首页]', '[微信扫一扫]', { 'd': d });
  927. if(!scanResult){
  928. scanResult = "0"
  929. }
  930. }
  931. // 是否电池包
  932. let batteryFlag = false;
  933. if (scanResult.startsWith("tkd")){
  934. scanResult = scanResult.substring(3);
  935. batteryFlag = true
  936. }
  937. if (scanResult.startsWith("hlht://") || scanResult.startsWith("HLHT://")){
  938. scanResult = scanResult.substring(7, scanResult.indexOf("."));
  939. }
  940. scanResult = scanResult.replace("https://cdgl.pjnes.com/", "");
  941. scanResult = scanResult.replace("https://cdglyy.pjnes.com/", "");
  942. console.log('扫描到的内容: [' + scanResult + '] , 是否内部按钮:' + inner)
  943. log.info('[首页]', '[用户完成扫一扫]', scanResult);
  944. log.info('[首页]', '[获取扫一扫充电桩]', '[请求]', scanResult);
  945. wx.request({
  946. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/' + (batteryFlag? 'chargBattery' : 'chargPile'),
  947. // data: scanResult,
  948. data: {
  949. chargPileId:scanResult,
  950. userId: that.data.userInfo.userId
  951. },
  952. method: 'POST',
  953. success(res) {
  954. console.log( res.data);
  955. log.info('[首页]', '[获取扫一扫充电桩]', '[响应]', res.data);
  956. if (!res.data || res.data.code == 500) {
  957. that.data.scanFlag = false;
  958. wx.hideLoading();
  959. //没有该充电桩信息
  960. wx.showModal({
  961. showCancel: false,
  962. content: res && res.data && res.data.msg ? res.data.msg :'无效的终端编号',
  963. confirmColor:'#00AADD',
  964. });
  965. } else {
  966. res.data = res.data.result
  967. // 拨乱反正, 将电池包的逻辑强行合并
  968. if(batteryFlag){
  969. // 0空闲
  970. let status = res.data.parkStatus
  971. if(status == 1){
  972. wx.showModal({
  973. showCancel: false,
  974. content: '当前停靠点占用',
  975. confirmColor:'#00AADD',
  976. });
  977. }else if(status == 0){
  978. wx.hideLoading();
  979. that.data.scanFlag = false;
  980. // 判断电池包
  981. if(res?.data?.chargPileList?.length==0 || !res?.data?.chargPileList){
  982. wx.showModal({
  983. showCancel: false,
  984. content: '暂无可用电池包',
  985. confirmColor:'#00AADD',
  986. });
  987. return;
  988. }
  989. wx.setStorage({
  990. key: "elpackage",
  991. data: res.data
  992. });
  993. let url = `/pages/scan_result/elpackage`;
  994. wx.navigateTo({
  995. url
  996. });
  997. }else{
  998. wx.showModal({
  999. showCancel: false,
  1000. content: '未知错误,电池包返回状态码异常:' + res.data.parkStatus,
  1001. confirmColor:'#00AADD',
  1002. });
  1003. }
  1004. that.data.scanFlag = false;
  1005. wx.hideLoading();
  1006. return;
  1007. }
  1008. //SZP
  1009. // park_status
  1010. //充电状态0:离线、1:故障、2:空闲中、3:充电中、4:欠压故障、5:过压故障、6:过电流故障、8:预约、9:在线升级、10:操作中、11:已插枪等
  1011. 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) {
  1012. //充电桩故障
  1013. wx.showModal({
  1014. showCancel: false,
  1015. content: '终端故障,维修中',
  1016. confirmColor:'#00AADD',
  1017. });
  1018. } else if (res.data.chargstatus == 3 || res.data.chargstatus == 8 || res.data.chargstatus == 10) {
  1019. wx.showModal({
  1020. showCancel: false,
  1021. content: '正在充电中',
  1022. confirmColor:'#00AADD',
  1023. });
  1024. } else if (res.data.chargstatus == 2 || res.data.chargstatus == 11) {
  1025. wx.setStorage({
  1026. key: "scan_chargpile",
  1027. data: res.data
  1028. });
  1029. log.info('[首页]', '[扫一扫充电桩空闲跳转去充电界面]');
  1030. let url = `/pages/scan_result/scan_result`;
  1031. that.data.scanFlag = false;
  1032. wx.hideLoading();
  1033. wx.navigateTo({
  1034. url
  1035. });
  1036. }
  1037. that.data.scanFlag = false;
  1038. wx.hideLoading();
  1039. }
  1040. },
  1041. fail(e) {
  1042. getApp().showNetworkError();
  1043. }
  1044. });
  1045. },
  1046. //地图位移
  1047. mapchange(e) {
  1048. if (e.type == 'end') {
  1049. if (!mapregionchange_makertap) {
  1050. //console.log("移动地图");
  1051. let that = this;
  1052. let wMap = wx.createMapContext('map');
  1053. wMap.getCenterLocation({
  1054. type: 'gcj02',
  1055. success: function (res) {
  1056. let {
  1057. latitude,
  1058. longitude
  1059. } = res;
  1060. let userInfo = wx.getStorageSync('userInfo');
  1061. let isLogin = wx.getStorageSync('isLogin');
  1062. var chargStationType;
  1063. if (!userInfo.flag) {
  1064. //用户是普通用户
  1065. chargStationType = '2';
  1066. }
  1067. wx.request({
  1068. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargStations',
  1069. data: {
  1070. lon: longitude,
  1071. lat: latitude,
  1072. distance: that.data.distanceinfo[that.data.distanceinfoindex].value,
  1073. chargStationType
  1074. },
  1075. method: 'POST',
  1076. success(res) {
  1077. that.resetchargStations(res.data)
  1078. let {
  1079. data
  1080. } = res;
  1081. let markers = [];
  1082. var flag = false;
  1083. if(data){
  1084. data.forEach((item, index) => {
  1085. var iconPath;
  1086. if (that.data.markerId && that.data.markerId == item.id) {
  1087. iconPath = "/images/marker_checked.png";
  1088. flag = true;
  1089. } else {
  1090. iconPath = "/images/marker.png";
  1091. if (that.data.myChargeStationsIds.indexOf(item.id + ',') != -1) {
  1092. iconPath = "/images/marker1.png";
  1093. }
  1094. //撤销普通用户显示异常站
  1095. if (isLogin && userInfo.flag) {
  1096. //撤销结束
  1097. if (item.breaknum && item.breaknum != 0) {
  1098. iconPath = "/images/marker_b.png";
  1099. }
  1100. //撤销普通用户显示异常站
  1101. }
  1102. //撤销结束
  1103. }
  1104. //console.log(Util.distance(that.data.user_lat, that.data.user_lon, item.lat, item.lon));
  1105. var marker = {
  1106. brandName:item.brandName,
  1107. name: item.chargStationName,
  1108. address: item.address,
  1109. width: "46rpx",
  1110. height: "67rpx",
  1111. chargfeatures: item.chargfeatures ,
  1112. iconPath: iconPath,
  1113. id: item.id,
  1114. callout: {},
  1115. latitude: item.lat,
  1116. longitude: item.lon,
  1117. //distance: item.distance / 1000,
  1118. distance: Util.distance(that.data.user_lat, that.data.user_lon, item.lat, item.lon),
  1119. chargPileNum: item.fastCharg + item.slowCharg,
  1120. fastCharg: item.fastCharg,
  1121. slowCharg: item.slowCharg,
  1122. freenum: item.freenum,
  1123. fastfreenum: item.fastfreenum,
  1124. slowfreenum: item.slowfreenum,
  1125. breaknum: item.breaknum,
  1126. /** 电费 */
  1127. chargprice: item.chargprice,
  1128. /** 服务费 */
  1129. serviceprice: item.serviceprice,
  1130. /** 停车费 */
  1131. stopprice: item.stopprice,
  1132. operationState: item.operationState,
  1133. sharpChargPrice : item.sharpChargPrice,
  1134. sharpServicePrice : item.sharpServicePrice,
  1135. peakChargPrice : item.peakChargPrice,
  1136. peakServicePrice : item.peakServicePrice,
  1137. flatChargPrice : item.flatChargPrice,
  1138. flatServicePrice : item.flatServicePrice,
  1139. valleyChargPrice : item.valleyChargPrice,
  1140. valleyServicePrice : item.valleyServicePrice,
  1141. resultList: item.resultList,
  1142. chargStationId: item.id,
  1143. stationTag: item.stationTag,
  1144. stationTagList: item.stationTagList,
  1145. offlineServicecall: item.offlineServicecall,
  1146. };
  1147. markers[index] = marker;
  1148. });
  1149. }
  1150. if (!flag) {
  1151. that.setData({
  1152. textData: null,
  1153. markerId: null,
  1154. });
  1155. }
  1156. that.setData({
  1157. markers: markers
  1158. });
  1159. },
  1160. fail(e) {
  1161. getApp().showNetworkError();
  1162. }
  1163. });
  1164. }
  1165. });
  1166. } else {
  1167. //点击marker的情况下
  1168. //console.log("点击marker");
  1169. mapregionchange_makertap = false;
  1170. }
  1171. }
  1172. },
  1173. phoneCheck(){
  1174. if (this.data.userInfo.bindingPhone==0) {
  1175. wx.hideLoading();
  1176. wx.showModal({
  1177. title: '提示',
  1178. content: '当前账户未绑定手机号,请您进行手机号绑定操作',
  1179. showCancel:false,
  1180. confirmText: '去绑定',
  1181. confirmColor:'#00AADD',
  1182. success: function (res1) {
  1183. let url = `/pages/bindPhone/bindPhone`;
  1184. wx.navigateTo({
  1185. url
  1186. });
  1187. }
  1188. })
  1189. return false;
  1190. }else{
  1191. return true;
  1192. }
  1193. },
  1194. // 根据状态查询占位费订单
  1195. queryParkOrder(status) {
  1196. return new Promise((resolve, reject) => {
  1197. let that = this;
  1198. wx.request({
  1199. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/queryOccupyFeeOrder',
  1200. data: {
  1201. userId: wx.getStorageSync('userInfo').userId,
  1202. searchIndex: status,
  1203. pagenum: that.data.pagenum++,
  1204. pagesize: 10,
  1205. },
  1206. method: 'POST',
  1207. success(res) {
  1208. console.log('请求成功,处理数据');
  1209. if(res.data.code==200){
  1210. if (res.data.result.total > 0) {
  1211. resolve(res.data.result);
  1212. }
  1213. }else{
  1214. resolve(res.data);
  1215. }
  1216. },
  1217. fail(err) {
  1218. console.error('请求失败', err);
  1219. reject(err);
  1220. }
  1221. });
  1222. });
  1223. },
  1224. /**
  1225. * 生命周期函数--监听页面显示
  1226. */
  1227. onShow: function () {
  1228. this.data.scanFlag = false;
  1229. let userInfo = wx.getStorageSync('userInfo');
  1230. let isLogin = wx.getStorageSync('isLogin');
  1231. // 页面显示
  1232. if (userInfo && isLogin) {
  1233. //console.log(userInfo);
  1234. //userInfo.flag = true;
  1235. this.setData({
  1236. userInfo: userInfo,
  1237. isLogin: isLogin
  1238. });
  1239. if ((!userInfo.userId && userInfo.userId != 0)){
  1240. log.info('[首页]', '[已登陆未有用户ID跳转登录界面]');
  1241. let url = `/pages/login/phone_login/phone_login`;
  1242. wx.navigateTo({
  1243. url
  1244. });
  1245. return;
  1246. }
  1247. // 查询订单
  1248. log.info('[首页]', '[获取用户是否有未完成订单]', '[请求]', { userId: userInfo.userId });
  1249. wx.request({
  1250. url: getApp().globalData.postHeadAgreement + '/restapi/pileLog/wechatchargstatus',
  1251. data: {
  1252. userId: userInfo.userId
  1253. },
  1254. method: 'POST',
  1255. success(res) {
  1256. let {
  1257. data
  1258. } = res;
  1259. log.info('[首页]', '[获取用户是否有未完成订单]', '[响应]', data);
  1260. if (data && data.code == 200) {
  1261. log.info('[首页]', '[有未完成订单跳充电界面]');
  1262. //获取用户正在充电的订单,并跳转到该页面
  1263. let url = `/pages/charging/charging?orderid=${data.result.orderid}&userId=${userInfo.userId}&chargPileId=${data.result.chargPileId}`;
  1264. //let url = `/pages/charging/charging?userId=${userInfo.userId}`;
  1265. wx.navigateTo({
  1266. url
  1267. });
  1268. } else {
  1269. //console.log(res);
  1270. }
  1271. },
  1272. fail(e) {
  1273. getApp().showNetworkError();
  1274. }
  1275. });
  1276. // 查询呼叫电车
  1277. console.log("查询呼叫电车")
  1278. wx.request({
  1279. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/ivCarRequirement' +
  1280. '?userId='+userInfo.userId,
  1281. data: {
  1282. },
  1283. method: 'POST',
  1284. success(res) {
  1285. console.log(res?.data?.result?.requirementStep)
  1286. // 0-7 进等待 8进终端详情
  1287. if(res?.data?.result?.requirementStep>=0 && res?.data?.result?.requirementStep<=7){
  1288. // 等待
  1289. let url = `/pages/batteryPack/batteryPackWait`;
  1290. wx.reLaunch({
  1291. url
  1292. });
  1293. }else if(res?.data?.result?.requirementStep==8){
  1294. // 8进终端详情
  1295. let url = `/pages/batteryPack/batteryPackWait`;
  1296. wx.reLaunch({
  1297. url
  1298. });
  1299. }
  1300. },
  1301. fail(e) {
  1302. getApp().showNetworkError();
  1303. }
  1304. });
  1305. this.queryParkOrder(3).then(res=>{
  1306. console.log("查询未支付成功",res);
  1307. if (res.total > 0) {
  1308. wx.showModal({
  1309. showCancel: false,
  1310. confirmText: '去支付',
  1311. content: '您有未支付的占位费订单,请先支付',
  1312. confirmColor:'#00AADD',
  1313. success: function (res) {
  1314. if (!res.cancel) {
  1315. console.log("res",res);
  1316. //点击确定
  1317. let url = `/pages/ucenter/zhanw/zhanw`;
  1318. wx.navigateTo({
  1319. url
  1320. })
  1321. return;
  1322. }
  1323. }
  1324. });
  1325. }
  1326. })
  1327. // 查询占位中订单
  1328. this.queryParkOrder(2).then(res=>{
  1329. // console.log("我被调用了");
  1330. if (res.total > 0) { // 有占位费订单不启动扫码充电
  1331. this.setData({
  1332. showPopup:true
  1333. })
  1334. return;
  1335. }
  1336. });
  1337. } else {
  1338. //未登录信息
  1339. this.setData({
  1340. userInfo: {}
  1341. });
  1342. }
  1343. },
  1344. bindDistanceinfoChange: function (e) {
  1345. let distance = this.data.distanceinfo[e.detail.value].value;
  1346. this.setData({
  1347. distanceinfoindex: e.detail.value
  1348. });
  1349. },
  1350. Sure: function () {
  1351. this.setData({
  1352. showModal: false
  1353. });
  1354. },
  1355. handleAgreePrivacyAuthorization() {
  1356. console.info('3333333333333');
  1357. this.setData({
  1358. showPrivacy: false
  1359. })
  1360. // 用户同意隐私协议事件回调
  1361. // 用户点击了同意,之后所有已声明过的隐私接口和组件都可以调用了
  1362. // wx.getUserProfile()
  1363. // wx.chooseMedia()
  1364. // wx.getClipboardData()
  1365. // wx.startRecord()
  1366. },
  1367. handleOpenPrivacyContract() {
  1368. // 打开隐私协议页面
  1369. wx.openPrivacyContract({
  1370. success: () => {}, // 打开成功
  1371. fail: () => {}, // 打开失败
  1372. complete: () => {}
  1373. })
  1374. }
  1375. })