index.js 47 KB

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