riding.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  1. var app = getApp()
  2. var interval;
  3. var interval1;
  4. var locationTerval;
  5. var bikelocationTerval;
  6. var settime;
  7. var timeing;
  8. var inter1;
  9. var huancheTime;
  10. import {
  11. BluetoothManager,
  12. BtErrorCode,
  13. CMD
  14. } from '../../service/BluWkm'
  15. const bluM = new BluetoothManager;
  16. const util = require('../../utils/utils.js');
  17. Page({
  18. data: {
  19. windowHeight: '',
  20. bolear: 1,
  21. code: '',
  22. longitude: '',
  23. latitude: '',
  24. order: '',
  25. markers: [], //显示单车、停车的P图标
  26. polygons: [], //区域
  27. id: '', //区域的ID
  28. polygons1: [], //可骑行区域 先用这个变量代表
  29. controls: [], //地图上当前定位的箭头
  30. height: '',
  31. times: '00:00', //当前骑行时间
  32. detail: '', //车辆信息详情
  33. estimate_money: '0.00', //预计金额
  34. minute: '', //骑行总时间秒
  35. data: [],
  36. box_no: '',
  37. screenHeight: '',
  38. change: false,
  39. timing: 5,
  40. isShow: false,
  41. minute1: '',
  42. parke: true,
  43. timeout: 15,
  44. retry: '',
  45. bikePosition: false,
  46. battery_power: '',
  47. huanche_timeout: 0,
  48. img: app.globalData.imgUrl,
  49. title:app.globalData.title
  50. },
  51. onLoad: function (options) {
  52. var that = this;
  53. wx.showLoading({
  54. title: '加载中...',
  55. mask: true
  56. })
  57. wx.getSystemInfo({
  58. success: function (res) {
  59. // 获取可使用窗口宽度
  60. let clientHeight = res.windowHeight;
  61. // 获取可使用窗口高度
  62. let clientWidth = res.windowWidth;
  63. // 算出比例
  64. let ratio = 750 / clientWidth;
  65. // 算出高度(单位rpx)
  66. let height = clientHeight * ratio;
  67. // 设置高度
  68. console.log(height)
  69. that.setData({
  70. windowHeight: height
  71. });
  72. }
  73. })
  74. console.log(app.globalData.screenHeight)
  75. that.setData({
  76. screenHeight: app.globalData.screenHeight
  77. })
  78. console.log(options)
  79. if (options.order != undefined) {
  80. that.setData({
  81. order: options.order
  82. })
  83. }
  84. if (options.box_no != undefined) {
  85. that.setData({
  86. box_no: options.box_no
  87. })
  88. }
  89. wx.hideLoading()
  90. that.posiLoca()
  91. that.bikePosition()
  92. if (options.time == 'true') {
  93. that.setData({
  94. retry: true
  95. })
  96. that.inter1()
  97. }
  98. },
  99. terval: function () {
  100. var that = this;
  101. clearInterval(interval)
  102. clearInterval(huancheTime)
  103. var times = ''; //秒数
  104. var minute = 0; //分钟
  105. var minute1 = '0'; //分钟
  106. var hour = 0; //小时
  107. var hour1 = '0'; //小时
  108. var time = that.data.minute //获取当前已骑行的秒数
  109. console.log(time)
  110. var setting = wx.getStorageSync('setting');
  111. var no_money_time = time;
  112. var close_bike_time = setting.close_bike_time;
  113. if (no_money_time < close_bike_time) {
  114. that.setData({
  115. huanche_timeout: close_bike_time - no_money_time
  116. })
  117. huancheTime = setInterval(() => {
  118. var no_money_time1 = that.data.huanche_timeout - 1
  119. that.setData({
  120. huanche_timeout: no_money_time1
  121. })
  122. if (no_money_time1 == 0) {
  123. that.setData({
  124. huanche_timeout: -1
  125. })
  126. clearInterval(huancheTime)
  127. }
  128. }, 1000);
  129. } else {
  130. that.setData({
  131. huanche_timeout: -1
  132. })
  133. }
  134. if (time > 60) { //秒数大于60 分钟= 秒数/60 秒数= -1*60 40
  135. minute = parseInt(time / 60);
  136. times = time - minute * 60;
  137. //minute代表分钟 times 代表秒数
  138. } else {
  139. minute = parseInt(time / 60);
  140. times = time;
  141. }
  142. interval = setInterval(function () {
  143. //定时器 秒数一秒加1
  144. times++
  145. if (times > 59) { //如果秒数大于59 让分钟加1 秒数归0
  146. minute = minute + 1
  147. times = 0
  148. }
  149. if (times < 10) { //如果秒数小于10 加一个0
  150. times = '0' + times
  151. }
  152. if (minute < 10) { //如果分钟小于10 加一个0
  153. minute1 = '0' + minute
  154. } else {
  155. minute1 = minute
  156. }
  157. if (minute > 59) {
  158. //分钟大于59 让小时+1
  159. hour = parseInt(minute / 60)
  160. minute1 = minute - hour * 60;
  161. if (hour < 10) {
  162. hour1 = '0' + hour;
  163. } else {
  164. hour1 = hour
  165. }
  166. }
  167. if (minute1 < 10 && hour > 0) { //如果分钟小于10 加一个0
  168. minute1 = '0' + minute1
  169. } else {
  170. minute1 = minute1
  171. }
  172. if (hour > 0) {
  173. //如果小时大于0 显示 时分
  174. that.setData({
  175. times: hour1 + ':' + minute1 + ':' + times
  176. })
  177. } else {
  178. //else 显示 分秒
  179. that.setData({
  180. times: minute1 + ':' + times
  181. })
  182. }
  183. // that.setData({ times: minute1 + ':' + times})
  184. //计算钱 分钟除以5*5 判断秒数>30 minute = minute+1
  185. //不满12分钟按12分钟算 并且大于30秒
  186. var per_money = setting.per_money;
  187. var per_minute = setting.per_minute;
  188. // console.log(minute)
  189. // console.log(minute1)
  190. if (setting.starting_price_time > minute) {
  191. that.setData({
  192. estimate_money: setting.starting_price
  193. })
  194. } else {
  195. //起步价+(分钟数-起步时长)/ 一块钱可骑多少分钟 * 钱数
  196. var time = minute - setting.starting_price_time;
  197. let money = Math.ceil(time / per_minute * Number(per_money)) + Number(setting.starting_price) + '.00';
  198. if (money == NaN) {
  199. money = Math.ceil(time / per_minute * Number(per_money)) + Number(setting.starting_price) + '.00';
  200. }
  201. if (minute > 0) {
  202. that.setData({
  203. estimate_money: money
  204. })
  205. } else {
  206. if (times >= 30) {
  207. that.setData({
  208. estimate_money: Math.ceil(1 / per_minute * Number(per_money)) + '.00'
  209. })
  210. }
  211. }
  212. }
  213. }, 1000)
  214. },
  215. onReady: function () {
  216. var that = this;
  217. // wx.getSystemInfo({
  218. // success({
  219. // windowHeight
  220. // }) {
  221. // console.log(windowHeight)
  222. // that.setData({
  223. // windowHeight
  224. // });
  225. // }
  226. // });
  227. this.dialog = this.selectComponent("#dialog");
  228. },
  229. help: util.throttle(function () {
  230. //点击帮助
  231. wx.navigateTo({
  232. url: '../personal/help/help',
  233. })
  234. }, 1000),
  235. posiLoca: function () {
  236. //每5秒刷新当前位置
  237. var that = this;
  238. locationTerval = setInterval(function () {
  239. wx.getLocation({
  240. type: 'gcj02',
  241. success: (res) => {
  242. console.log('经纬度为:+++++++++++++++++++++' + res.latitude + '++++++++' + res.longitude)
  243. var latitude = res.latitude
  244. var longitude = res.longitude
  245. that.setData({
  246. longitude: longitude,
  247. latitude: latitude
  248. })
  249. },
  250. fail: function (err) {
  251. console.log(err)
  252. }
  253. })
  254. }, 5000)
  255. },
  256. bikePosition: function () {
  257. //每5秒刷新当前位置
  258. var that = this;
  259. bikelocationTerval = setInterval(function () {
  260. that.bikeLocation()
  261. }, 30000)
  262. },
  263. posi: util.throttle(function () {
  264. //点击定位
  265. var that = this;
  266. wx.getLocation({
  267. type: 'gcj02',
  268. success: (res) => {
  269. console.log('经纬度为:+++++++++++++++++++++' + res.latitude + '++++++++' + res.longitude)
  270. var latitude = res.latitude
  271. var longitude = res.longitude
  272. that.setData({
  273. longitude: longitude,
  274. latitude: latitude
  275. })
  276. }
  277. })
  278. }, 1000),
  279. search: util.throttle(function () {
  280. wx.navigateTo({
  281. url: '../navigation/navigation',
  282. })
  283. }, 1000),
  284. seek: util.throttle(function () {
  285. //点击响铃
  286. var that = this;
  287. wx.showLoading({
  288. title: '找车中...',
  289. mask: true
  290. })
  291. bluM.connectDeivece(that.data.code, CMD.bell)
  292. app.request('/order/retry-bell-lock?order_no=' + that.data.order + '&bike_no=' + that.data.code, '', 'GET').then(res => {
  293. console.log(res)
  294. if (res.statusCode == 200) {
  295. res.data.is_ok == true && wx.showToast({
  296. title: '找车成功',
  297. icon: 'none',
  298. duration: 2000
  299. })
  300. res.data.is_ok == false && wx.showToast({
  301. title: '找车失败请重试',
  302. icon: 'none',
  303. duration: 2000
  304. })
  305. }
  306. })
  307. }, 1000),
  308. refresh: util.throttle(function () {
  309. //点击刷新
  310. var that = this;
  311. var data = Date.parse(new Date()) / 1000;
  312. that.chushi()
  313. that.terval()
  314. }, 1000),
  315. bikeLocation: function () {
  316. var that = this;
  317. var data = {
  318. bike_no: that.data.code
  319. }
  320. app.request('/order/orderBikePosition', data, 'GET').then(res => {
  321. if (res.statusCode == 200) {
  322. var mark = that.data.markers;
  323. if (that.data.bikePosition) {
  324. mark.pop()
  325. }
  326. that.setData({
  327. markers: mark,
  328. battery_power: res.data.battery_power
  329. })
  330. var array = {}
  331. array.iconPath = 'http://resource.bike.hanyiyun.com/weapp/dianche.png';
  332. array.width = 28;
  333. array.height = 28;
  334. array.zIndex = 1111;
  335. array.id = 12345;
  336. array.latitude = res.data.latitude;
  337. array.longitude = res.data.longitude;
  338. that.setData({
  339. markers: that.data.markers.concat(array)
  340. })
  341. that.setData({
  342. bikePosition: true
  343. })
  344. }
  345. }).catch(err => {
  346. console.log(err)
  347. })
  348. },
  349. chushi: function () {
  350. var that = this;
  351. var date = Date.parse(new Date()) / 1000;
  352. app.request('/pages/ride-order?no=' + that.data.order, '', 'GET').then(res => {
  353. console.log(res)
  354. if (res.statusCode == 200) {
  355. // var start_time = 1578446930
  356. if (date - res.data.start_use_bike_time <= 0) {
  357. that.setData({
  358. minute: 0
  359. })
  360. } else {
  361. that.setData({
  362. minute: date - res.data.start_use_bike_time
  363. })
  364. }
  365. // if (date - start_time <= 0) {
  366. // that.setData({ minute: 0 })
  367. // } else {
  368. // that.setData({ minute: date - start_time })
  369. // }
  370. that.terval()
  371. wx.showToast({
  372. title: '刷新成功',
  373. icon: 'none'
  374. })
  375. that.setData({
  376. data: res.data,
  377. code: res.data.bike_no,
  378. })
  379. app.request('/bike/' + that.data.code, '', 'GET').then(res => {
  380. console.log(res)
  381. 200 == res.statusCode && that.setData({
  382. battery_power: res.data.battery_power,
  383. box_no: res.data.box_no
  384. })
  385. })
  386. if (res.data.status == 0) {
  387. that.setData({
  388. bolear: 0
  389. })
  390. } else if (res.data.status == 1) {
  391. that.setData({
  392. bolear: 1
  393. })
  394. } else if (res.data.status == 2) {
  395. clearInterval(interval),
  396. clearInterval(interval1);
  397. clearInterval(locationTerval);
  398. clearInterval(bikelocationTerval);
  399. wx.reLaunch({
  400. url: '../payment/payment?order=' + res.data.no
  401. })
  402. } else if (res.data.status == 3) {
  403. wx.reLaunch({
  404. url: '../index/index',
  405. })
  406. } else if (res.data.status == 4) {
  407. wx.reLaunch({
  408. url: '../index/index',
  409. })
  410. }
  411. that.bikeLocation();
  412. }
  413. }).catch(err => {
  414. console.log(err)
  415. })
  416. },
  417. location: function () {
  418. //获取当前经纬度 给地图赋值
  419. wx.showNavigationBarLoading()
  420. var that = this
  421. that.setData({
  422. polygons: []
  423. })
  424. wx.getLocation({
  425. type: 'gcj02',
  426. success: (res) => {
  427. console.log('经纬度为:+++++++++++++++++++++' + res.latitude + '++++++++' + res.longitude)
  428. var latitude = res.latitude
  429. var longitude = res.longitude
  430. that.setData({
  431. longitude: longitude,
  432. latitude: latitude
  433. })
  434. var data = {
  435. 'lat': latitude,
  436. 'lng': longitude
  437. }
  438. app.request('/pages/home?include=setting', data, 'POST').then(res => {
  439. if (res.statusCode == 200) {
  440. var data = res.data;
  441. var points = data.area_fence;
  442. data.points = points;
  443. data.area_fence = []
  444. data.strokeWidth = 4;
  445. data.strokeColor = '#0000FF';
  446. data.zIndex = 1111;
  447. console.log(data)
  448. that.setData({
  449. polygons: that.data.polygons.concat(data),
  450. id: data.id,
  451. polygons1: that.data.polygons.concat(data)
  452. })
  453. var data1 = {
  454. 'area_id': data.id
  455. }
  456. app.request('/parking/stop-sites', data1, 'GET').then(res => {
  457. // console.log(res)
  458. if (res.statusCode == 200) {
  459. var data = res.data
  460. that.setData({
  461. polygons: that.data.polygons1.concat(data.polygons),
  462. markers: data.centres
  463. })
  464. }
  465. })
  466. }
  467. }).catch(err => {
  468. console.log(err)
  469. })
  470. }
  471. })
  472. },
  473. coundDown: function () {
  474. var that = this;
  475. that.setData({
  476. isShow: true
  477. })
  478. timeing = setInterval(function () {
  479. var timeing1 = that.data.timing;
  480. timeing1--
  481. that.setData({
  482. timing: timeing1
  483. })
  484. if (timeing1 <= 0) {
  485. that.setData({
  486. timing: 5,
  487. isShow: false
  488. })
  489. clearInterval(timeing)
  490. }
  491. }, 1000)
  492. },
  493. bindregionchange: function (e) {
  494. //实现大头针移动选点
  495. var that = this;
  496. if (e.type == 'begin') {
  497. clearTimeout(settime)
  498. clearInterval(locationTerval);
  499. }
  500. if (e.type == 'end') {
  501. settime = setTimeout(function () {
  502. that.posiLoca()
  503. }, 3000)
  504. }
  505. },
  506. onShow: function () {
  507. this.location();
  508. this.chushi();
  509. this.posi()
  510. },
  511. closeLock: function (data) {
  512. var that = this;
  513. bluM.connectDeivece(that.data.box_no, CMD.lock)
  514. app.request('/bike/close-lock', data, 'POST').then(res => {
  515. console.log(res)
  516. if (res.statusCode == 200) {
  517. clearInterval(locationTerval);
  518. clearInterval(interval);
  519. clearInterval(bikelocationTerval);
  520. clearInterval(interval1);
  521. wx.reLaunch({
  522. url: '../payment/payment?order=' + res.data.no
  523. })
  524. } else if (res.statusCode == 450) {
  525. that.coundDown()
  526. }
  527. }).catch(err => {
  528. console.log(err)
  529. })
  530. },
  531. end: util.throttle(function () {
  532. //点击结束骑行 先调接口看看是不是在停车区域 如果是清除定时器 如果不是询问用户用户点继续停车 清除定时器 如果点取消 无反应
  533. // wx.showNavigationBarLoading()
  534. wx.showLoading({
  535. title: '结算中...',
  536. mask: true
  537. })
  538. var that = this;
  539. wx.getLocation({
  540. type: 'gcj02',
  541. success: (res) => {
  542. console.log('经纬度为:+++++++++++++++++++++' + res.latitude + '++++++++' + res.longitude)
  543. var latitude = res.latitude
  544. var longitude = res.longitude
  545. var data = {
  546. bike_no: that.data.code,
  547. order_no: that.data.order,
  548. lat: latitude,
  549. lng: longitude
  550. }
  551. app.request('/bike/check-is-riding-area', data, 'POST').then(res => {
  552. console.log(res)
  553. if (res.statusCode == 200) {
  554. // clearInterval(interval);
  555. // clearInterval(interval1);
  556. clearInterval(locationTerval);
  557. clearInterval(bikelocationTerval);
  558. wx.hideNavigationBarLoading(), wx.hideLoading()
  559. if (res.data.is_close_order == false) {
  560. // that.closeLock(data)
  561. wx.navigateTo({
  562. url: '/pages/confirm_order/confirm_order?bike_no=' + that.data.code + '&order_no=' + that.data.order + '&lat=' + latitude + '&lng=' + longitude + '&order=order',
  563. })
  564. } else {
  565. bluM.connectDeivece(that.data.box_no, CMD.lock)
  566. app.request('/bike/close-lock', data, 'POST').then(res => {
  567. console.log(res)
  568. if (res.statusCode == 200) {
  569. clearInterval(interval);
  570. clearInterval(interval1);
  571. clearInterval(locationTerval);
  572. clearInterval(bikelocationTerval);
  573. wx.hideLoading()
  574. wx.reLaunch({
  575. url: '../payment/payment?order=' + res.data.no
  576. })
  577. } else if (res.statusCode == 450) {
  578. that.coundDown()
  579. }
  580. // wx.hideNavigationBarLoading()
  581. }).catch(err => {
  582. console.log(err)
  583. })
  584. }
  585. } else if (res.statusCode == 450) {
  586. that.coundDown()
  587. wx.hideLoading()
  588. }
  589. }).catch(err => {
  590. console.log(err)
  591. })
  592. }
  593. })
  594. }, 1000),
  595. openBike: function () {
  596. //点击开锁失败重试
  597. var that = this;
  598. clearInterval(inter1)
  599. that.setData({
  600. timeout: 15
  601. })
  602. wx.getBluetoothAdapterState({
  603. success(res) {
  604. console.log(res)
  605. if (res.available == false) {
  606. wx.showModal({
  607. title: '提示',
  608. content: '手动开启蓝牙使用蓝牙开锁',
  609. showCancel: false
  610. })
  611. that.inter1()
  612. } else {
  613. wx.showLoading({
  614. title: '开锁中...',
  615. mask: true
  616. })
  617. wx.getLocation({
  618. type: 'gcj02',
  619. success: function (res) {
  620. console.log(res)
  621. bluM.connectDeivece(that.data.box_no, CMD.unlock)
  622. app.request('/order/retry-open-lock?order_no=' + that.data.order + '&bike_no=' + that.data.code, '', 'GET').then(res => {
  623. console.log(res)
  624. that.inter1()
  625. if (res.statusCode == 200) {
  626. wx.hideLoading()
  627. if (res.data.status == 1) {
  628. wx.showToast({
  629. title: '开锁成功',
  630. icon: 'none'
  631. })
  632. }
  633. }
  634. })
  635. },
  636. })
  637. }
  638. }
  639. })
  640. },
  641. inter1: function () {
  642. //点击临时开车 临时停车后按钮的定时器
  643. var that = this;
  644. var timeout1 = that.data.timeout;
  645. inter1 = setInterval(function () {
  646. timeout1--
  647. that.setData({
  648. timeout: timeout1
  649. })
  650. if (timeout1 <= 0) {
  651. clearInterval(inter1)
  652. that.setData({
  653. parke: true,
  654. timeout: 15,
  655. retry: false
  656. })
  657. } else {
  658. retry: true
  659. }
  660. }, 1000)
  661. },
  662. retry1: function () {
  663. var that = this;
  664. that.setData({
  665. timeout: 15
  666. })
  667. clearInterval(inter1)
  668. wx.getLocation({
  669. type: 'gcj02',
  670. success: (res) => {
  671. console.log('经纬度为:+++++++++++++++++++++' + res.latitude + '++++++++' + res.longitude)
  672. var latitude = res.latitude
  673. var longitude = res.longitude
  674. var data = {
  675. bike_no: that.data.code,
  676. order_no: that.data.order,
  677. lat: latitude,
  678. lng: longitude
  679. }
  680. bluM.connectDeivece(that.data.bike_no, CMD.unlock)
  681. app.request('/bike/temporary-open-lock', data, 'POST').then(res => {
  682. that.inter1()
  683. if (res.statusCode == 200) {
  684. wx.showToast({
  685. title: '开车成功',
  686. icon: 'none'
  687. })
  688. that.setData({
  689. bolear: 1
  690. })
  691. }
  692. })
  693. }
  694. })
  695. },
  696. retry2: function () {
  697. var that = this;
  698. that.setData({
  699. timeout: 15
  700. })
  701. clearInterval(inter1)
  702. wx.getLocation({
  703. type: 'gcj02',
  704. success: (res) => {
  705. console.log('经纬度为:+++++++++++++++++++++' + res.latitude + '++++++++' + res.longitude)
  706. var latitude = res.latitude
  707. var longitude = res.longitude
  708. var data = {
  709. bike_no: that.data.code,
  710. order_no: that.data.order,
  711. lat: latitude,
  712. lng: longitude
  713. }
  714. bluM.connectDeivece(that.data.box_no, CMD.lock)
  715. app.request('/bike/temporary-close-lock', data, 'POST').then(res => {
  716. console.log(res)
  717. that.inter1()
  718. if (res.statusCode == 200) {
  719. wx.showToast({
  720. title: '停车成功',
  721. icon: 'none'
  722. })
  723. that.setData({
  724. bolear: 0
  725. })
  726. } else if (res.statusCode == 450) {
  727. that.coundDown()
  728. }
  729. })
  730. }
  731. })
  732. },
  733. parking: function () {
  734. //点击临时停车
  735. var that = this;
  736. wx.getLocation({
  737. type: 'gcj02',
  738. success: (res) => {
  739. console.log('经纬度为:+++++++++++++++++++++' + res.latitude + '++++++++' + res.longitude)
  740. var latitude = res.latitude
  741. var longitude = res.longitude
  742. var data = {
  743. bike_no: that.data.code,
  744. order_no: that.data.order,
  745. lat: latitude,
  746. lng: longitude
  747. }
  748. clearInterval(inter1)
  749. that.setData({
  750. timeout: 15
  751. })
  752. if (that.data.bolear == 1) {
  753. //代表要临时停车
  754. app.request('/bike/temporary-close-lock', data, 'POST').then(res => {
  755. console.log(res)
  756. that.inter1()
  757. if (res.statusCode == 200) {
  758. wx.showToast({
  759. title: '停车成功',
  760. icon: 'none'
  761. })
  762. bluM.connectDeivece(that.data.box_no, CMD.lock)
  763. that.setData({
  764. bolear: 0,
  765. parke: false
  766. })
  767. } else if (res.statusCode == 450) {
  768. that.coundDown()
  769. }
  770. })
  771. }
  772. if (that.data.bolear == 0) {
  773. //代表要临时开车
  774. app.request('/bike/temporary-open-lock', data, 'POST').then(res => {
  775. that.inter1()
  776. if (res.statusCode == 200) {
  777. wx.showToast({
  778. title: '开车成功',
  779. icon: 'none'
  780. })
  781. bluM.connectDeivece(that.data.box_no, CMD.unlock)
  782. that.setData({
  783. bolear: 1,
  784. parke: false
  785. })
  786. }
  787. })
  788. }
  789. }
  790. })
  791. },
  792. onHide: function () {
  793. clearInterval(locationTerval);
  794. },
  795. onUnload: function () {
  796. clearInterval(locationTerval)
  797. clearInterval(bikelocationTerval)
  798. clearTimeout(settime)
  799. // clearInterval(huancheTime)
  800. },
  801. onPullDownRefresh: function () {
  802. },
  803. onReachBottom: function () {
  804. },
  805. onShareAppMessage: function () {
  806. }
  807. })