index.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  1. // index.js
  2. // 获取应用实例
  3. //获取应用实例
  4. const app = getApp();
  5. var token = my.getStorageSync({ 'key': 'token' }).data;
  6. const util = require('../../utils/utils.js');
  7. const { content } = require('/utils/dataTransition.js');
  8. var mytime = null;
  9. let testToken = ''
  10. Page({
  11. data: {
  12. cardBottom: [
  13. {
  14. id: 1,
  15. name: '故障上报',
  16. icon: 'icon-banshou',
  17. url: '/pages/breakdown/breakdown'
  18. },
  19. {
  20. id: 2,
  21. name: '输码用车',
  22. icon: 'icon-17-saoma',
  23. url: '/pages/inputcode/inputcode'
  24. },
  25. {
  26. id: 3,
  27. name: '计费规则',
  28. icon: 'icon-wenhao',
  29. url: '/pages/charge_rule/charge_rule'
  30. },
  31. {
  32. id: 4,
  33. name: '个人中心',
  34. icon: 'icon-wode',
  35. url: '/pages/mine/mine'
  36. }
  37. ],
  38. adFrame: false,//首页中间广告弹框
  39. markers: [], //显示单车、停车的P
  40. polygons: [], //区域
  41. longitude: '', //113.786111
  42. latitude: '', //34.78304
  43. height1: '', //兼容自定义导航栏的高度
  44. id: '', //停车区域的ID
  45. stopP: false, //判断是否显示停车区域
  46. polygons1: [], //可骑行区域 先用这个变量代表
  47. controls: [], //地图上当前定位的箭头
  48. background: false, //弹窗的背景颜色
  49. realname: false, //当前是否已经实名
  50. deposit: false, //当前是否交押金
  51. userStatus: '', //用户的一些状态 是否交押金等 0
  52. scanfail: false, //扫码失败弹窗
  53. is_pay_order: false, //检测当前是否有订单未支付
  54. is_ride_order: false,//是否有骑行中订单
  55. is_punishment: false,//有违章订单
  56. code: '', //点击立即用车 把编号赋值给code
  57. over: false, //关闭图标
  58. over1: false, //扫码失败关闭图标
  59. location: '', //是否有位置权限
  60. screenHeight: '', //屏幕可视高度
  61. box_no: '', //中控编号
  62. abnormal: '', //提示账号异常
  63. mid: [],//顶部广告
  64. ads: [],//首页中间广告
  65. currentSwiper: 0,
  66. center_currentSwiper: 0,
  67. bike_no: undefined,
  68. stopShow: false,
  69. stop_info: [],
  70. notice: [], //公告内容
  71. animationData: {},
  72. tabbar_index: 0,
  73. zoom: 18,
  74. versions: false, //版本过低弹窗
  75. chooseSize: false,
  76. animationData1: {},
  77. arrowDown: '',
  78. stop_type: '',
  79. marqueePace: 0.6, //滚动速度
  80. marqueeDistance: 520, //初始滚动距离 用到
  81. size: 26, //用到
  82. marqueeWidth: 520, //用到
  83. length: '',
  84. swiperCurrent: 0,
  85. midbolear: '',
  86. per_money: '',
  87. img: app.globalData.imgUrl,
  88. new_user_coupons: [],
  89. scanCodeErr: false,//扫码失败弹框
  90. },
  91. onLoad: function (query) {
  92. var that = this;
  93. console.log(my.getStorageSync({ 'key': 'token' }).data, 'yyyyyyyyyyyyyyy')
  94. my.setNavigationBar({
  95. title: app.globalData.title
  96. })
  97. this.setData({
  98. height1: app.globalData.statusBarHeight,
  99. screenHeight: app.globalData.screenHeight
  100. })
  101. },
  102. onShow: function () {
  103. var that = this;
  104. my.setNavigationBar({
  105. title: app.globalData.title
  106. })
  107. token = my.getStorageSync({ 'key': 'token' }).data
  108. this.setData({
  109. show: false,
  110. midbolear: my.getStorageSync({ 'key': 'midTimes' }).data,
  111. polygons: []
  112. })
  113. app.login().then(res => {
  114. console.log('YYYYYYYYYYYYY')
  115. that.location()
  116. that.getUser()
  117. })
  118. // that.location();
  119. // testToken = setInterval(function () {
  120. // let token=my.getStorageSync({'key':'token'}).data
  121. // if (token) {
  122. // console.log('0000')
  123. // clearInterval(testToken)
  124. // } else {
  125. // console.log(token,'1')
  126. // }
  127. // }, 1000)
  128. my.hideBackHome();
  129. },
  130. detail: function () {
  131. var that = this;
  132. if (that.data.mid[0].type == 'url') {
  133. my.navigateTo({
  134. url: '/' + that.data.mid[0].detail
  135. })
  136. }
  137. },
  138. //广告列表
  139. adsList: function (id) {
  140. var that = this;
  141. var area_id = ''
  142. if (id != undefined) {
  143. area_id = id
  144. } else {
  145. area_id = 0
  146. }
  147. app.request("/ads?area_id=" + area_id + "&position[]=mid&position[]=header&position[]=footer", '', "GET").then(res => {
  148. console.log(res)
  149. if (res.status == 200 && res.data != '') {
  150. if (res.data.header) {
  151. console.log(res.data, 'ppppppppppppppppppppppppp')
  152. that.setData({
  153. ads: res.data.header
  154. })
  155. }
  156. if (res.data.mid) {
  157. that.setData({
  158. mid: res.data.mid,
  159. adFrame: true
  160. })
  161. }
  162. }
  163. }).catch(err => {
  164. console.log(err)
  165. })
  166. },
  167. //点击广告页
  168. swiper: util.throttle(function (e) {
  169. // console.log(e)
  170. var type = e.currentTarget.dataset.type;
  171. var index = e.currentTarget.dataset.index;
  172. var name = e.currentTarget.dataset.name;
  173. var detail = e.currentTarget.dataset.detail;
  174. var id = e.currentTarget.dataset.id;
  175. if (type != 'clilk_null') {
  176. if (type == 'wxUrl') {
  177. my.navigateTo({
  178. url: '/' + detail,
  179. })
  180. } else if (type == 'phone') {
  181. my.makePhoneCall({
  182. number: detail,
  183. })
  184. } else if (type == 'toMiniProgram') {
  185. my.navigateToMiniProgram({
  186. appId: detail,
  187. extraData: {
  188. foo: 'bar'
  189. },
  190. // envVersion: 'develop',
  191. success(res) {
  192. // 打开成功
  193. }
  194. })
  195. } else {
  196. my.navigateTo({
  197. url: '../swiper/swiper?type=' + type + '&url=' + id + '&name=' + name + '&detail=' + detail,
  198. })
  199. }
  200. }
  201. }, 1000),
  202. //点击轮播图
  203. swiperChange: function (e) {
  204. if (this.data.currentSwiper == 0 && this.data.swiperCurrent > 1) { //卡死时,重置current为正确索引
  205. this.setData({
  206. currentSwiper: this.data.swiperCurrent
  207. });
  208. } else { //正常轮转时,记录正确页码索引
  209. this.setData({
  210. swiperCurrent: e.detail.current
  211. });
  212. }
  213. },
  214. //定位当前位置
  215. posi: util.throttle(function () {
  216. //点击定位
  217. //这是一段注
  218. var that = this;
  219. my.showLoading({
  220. content: '定位中'
  221. })
  222. my.getLocation({
  223. type: 'gcj02',
  224. success: (res) => {
  225. console.log('经纬度为:+++++++++++++++++++++' + res.latitude + '++++++++' + res.longitude)
  226. my.hideLoading()
  227. that.setData({
  228. longitude: res.longitude,
  229. latitude: res.latitude
  230. })
  231. },
  232. fail: function (err) {
  233. my.hideLoading()
  234. console.log(err, '定位失败打印')
  235. my.showToast({
  236. content: '定位失败',
  237. icon: 'none'
  238. })
  239. }
  240. })
  241. }, 1000),
  242. //点击扫描二维码
  243. sweepCode: util.throttle(function () {
  244. let that = this
  245. console.log('点击扫码,‘iooooo')
  246. if (!that.data.latitude && !that.data.longitude) {
  247. that.setData({
  248. background: true,
  249. location: true
  250. })
  251. } else {
  252. that.sweep_code()
  253. }
  254. }, 1500),
  255. //骑行区禁停区车辆
  256. home: function () {
  257. //请求首页接口和一些设置。
  258. console.log('测试')
  259. var that = this;
  260. if (that.data.longitude != '' && that.data.latitude != '') {
  261. //116.411027
  262. var data = {
  263. 'lat': that.data.latitude,
  264. 'lng': that.data.longitude
  265. }
  266. app.request("/pages/home?include=setting", data, "POST").then(res => {
  267. console.log(res)
  268. if (res.status == 200) {
  269. var data = res.data;
  270. console.log(data, '区域')
  271. let id = data.id
  272. that.userState()
  273. if (data.points != []) {
  274. that.setData({
  275. id: data.id,
  276. polygons1: that.data.polygons.concat(data),
  277. setting: data.setting,
  278. per_money: Number(data.setting.starting_price),
  279. polygons: []
  280. })
  281. if (!data.id) return
  282. that.adsList(data.id),
  283. that.ban_stop(data.id), that.setData({
  284. polygons: that.data.polygons.concat(data)
  285. })
  286. }
  287. clearInterval(mytime)
  288. my.setStorageSync({ 'key': 'home', data: data })
  289. }
  290. if (data) {
  291. my.setStorageSync({ 'key': 'setting', data: data.setting })
  292. } else {
  293. my.removeStorageSync({ key: 'setting' })
  294. my.removeStorageSync({ key: 'home' })
  295. }
  296. }).catch(err => {
  297. console.log(err)
  298. if (err.data.message == "该附近暂无运营区域") {
  299. my.removeStorageSync({ key: 'setting' })
  300. my.removeStorageSync({ key: 'home' })
  301. }
  302. my.alert({
  303. title: '提示',
  304. content: err.data.message,
  305. })
  306. })
  307. }
  308. },
  309. //停车区域
  310. ban_stop: function (id) {
  311. var that = this;
  312. var data1 = {
  313. 'area_id': id
  314. }
  315. app.request('/parking/stop-sites', data1, 'GET').then(res => {
  316. console.log(res)
  317. if (res.status == 200) {
  318. var data = res.data
  319. console.log(data)
  320. that.setData({
  321. polygons2: data.polygons,
  322. markers: that.data.markers.concat(data.centres),
  323. polygons: that.data.polygons1.concat(data.polygons)
  324. })
  325. }
  326. })
  327. },
  328. //附近车辆坐标
  329. nearbyCars: function () {
  330. //附近的车
  331. var that = this;
  332. that.setData({
  333. markers: []
  334. })
  335. var data = {
  336. "lat": that.data.latitude,
  337. "lng": that.data.longitude
  338. }
  339. app.request("/bikes", data, "POST").then(res => {
  340. // console.log(res)
  341. if (res.status == 200) {
  342. var makers = res.data
  343. if (makers == '') {
  344. my.showToast({
  345. content: '附近暂无车辆',
  346. icon: 'none'
  347. })
  348. that.setData({
  349. markers: []
  350. })
  351. } else {
  352. that.setData({
  353. markers: makers
  354. })
  355. }
  356. }
  357. }).catch(err => {
  358. console.log(err)
  359. })
  360. },
  361. //点击刷新
  362. refresh: util.throttle(function () {
  363. var that = this;
  364. that.setData({
  365. polygons: []
  366. })
  367. if (this.data.stopP == true) {
  368. that.stopP(), my.showToast({
  369. content: '刷新成功',
  370. icon: 'none'
  371. })
  372. } else {
  373. this.location(),
  374. my.showToast({
  375. content: '刷新成功',
  376. icon: 'none'
  377. })
  378. }
  379. }, 1500),
  380. // //点击去实名认证
  381. authentication: util.throttle(function () {
  382. var state = my.getStorageSync({ 'key': 'userState' }).data
  383. if (state.is_bind_mobile == 1) {
  384. my.navigateTo({
  385. url: '/pages/real_name/real_name?state1=1&index=0',
  386. })
  387. } else if (state.is_bind_mobile == 1) {
  388. my.navigateTo({
  389. url: '/pages/real_name/real_name?state2=2&index=1',
  390. })
  391. }
  392. this.setData({
  393. background: false,
  394. realname: false,
  395. over: false
  396. })
  397. }, 1500),
  398. //点击扫码开锁
  399. sweep_code: util.throttle(function () {
  400. var that = this;
  401. console.log('ooooooo')
  402. var userStatus = that.data.userStatus;
  403. var setting = my.getStorageSync({ 'key': 'setting' }).data
  404. if (!setting) {
  405. my.alert({
  406. title: '提示',
  407. content: '您附近暂无运营区,暂不可用车'
  408. })
  409. } else {
  410. if (!userStatus) {
  411. my.navigateTo({
  412. url: '/pages/authorization/authorization',
  413. })
  414. }
  415. else {
  416. that.jiance('scan');
  417. }
  418. }
  419. }, 1500),
  420. //扫码用车检测不可用车条件
  421. jiance: function (source) {
  422. var that = this;
  423. var userStatus = that.data.userStatus;
  424. var setting = my.getStorageSync({ 'key': 'setting' }).data
  425. //未绑定手机号
  426. if (userStatus.is_bind_mobile == 0) {
  427. my.navigateTo({
  428. url: '/pages/authorization/authorization',
  429. })
  430. //未实名认证
  431. } else if (userStatus.is_card_certified == 0 && setting.is_card == 1) {
  432. my.navigateTo({
  433. url: '/pages/real_name/real_name',
  434. })
  435. } else {
  436. //有违章订单
  437. if (userStatus.is_punishment) {
  438. my.showToast({
  439. content: '您当前有违章订单需要处理,请处理后再来用车吧',
  440. icon: 'none'
  441. })
  442. return;
  443. } else if (userStatus.is_ride_order != false && userStatus.is_ride_order != undefined) {
  444. my.showToast({
  445. content: '您有一个正在骑行中的订单',
  446. icon: 'none'
  447. })
  448. return;
  449. } else {
  450. //有待支付骑行订单
  451. if (userStatus.is_pay_order != false && userStatus.is_pay_order != undefined) {
  452. my.showToast({
  453. content: '你有未支付订单,请先支付',
  454. icon: 'none'
  455. })
  456. return;
  457. } else {
  458. //没有押金没有免押券
  459. if (userStatus.is_deposit == 0 && that.data.setting.is_deposit != 0 && userStatus.is_coupon_deposit_free == false) {
  460. console.log('没有押金没有免押券')
  461. my.navigateTo({
  462. url: '/pages/ride_zige/ride_zige',
  463. })
  464. // my.navigateTo({
  465. // url: '/pages/inputcode/inputcode',
  466. // })
  467. } else {
  468. that.saoMa()
  469. }
  470. }
  471. }
  472. }
  473. },
  474. //扫码事件
  475. saoMa: function () {
  476. let that = this
  477. this.setData({
  478. scanCodeErr: false
  479. })
  480. my.scan({
  481. onlyFromCamera: true,
  482. success: function (res) {
  483. let scanLength = app.globalData.scanLength
  484. console.log(res, '扫码结果')
  485. var index = res.code.lastIndexOf("\=");
  486. console.log(index, '----------')
  487. var code = res.code.substring(index + 1, res.code.length);
  488. console.log(code)
  489. console.log(app.globalData)
  490. if (code.length == scanLength) {
  491. that.getBikeMessage(code)
  492. // my.navigateTo({
  493. // url: '/pages/use_bike/use_bike?code=' + code,
  494. // })
  495. } else {
  496. console.log(res, '错误码')
  497. // my.showModal({
  498. // title:'提示',
  499. // content:'非法码,请核对车码',
  500. // showCancel:false
  501. // })
  502. that.setData({
  503. scanCodeErr: true
  504. })
  505. }
  506. },
  507. fail: function (err) {
  508. console.log('tuihui')
  509. // that.setData({
  510. // scanCodeErr: true
  511. // })
  512. }
  513. })
  514. },
  515. //获取车辆信息
  516. getBikeMessage: function (code) {
  517. var that = this;
  518. app.request('/bike/' + code, '', 'GET').then(res => {
  519. console.log(res, '车辆信息--------------------')
  520. my.hideLoading()
  521. if (res.status == 200) {
  522. if (res.data.is_link == 0) {
  523. my.alert({
  524. title: '提示',
  525. content: '当前车子已下线请换辆车子骑行吧~',
  526. success: function (res) {
  527. my.reLaunch({
  528. url: '/pages/index/index',
  529. })
  530. }
  531. })
  532. return;
  533. } else if (res.data.put_status == 0) {
  534. my.alert({
  535. title: '提示',
  536. content: '当前车子还未投放请换辆车子骑行吧~',
  537. })
  538. return;
  539. } else if (res.data.is_low_battery_power == 0) {
  540. my.alert({
  541. title: '提示',
  542. content: '当前车子电量过低请换辆车子骑行吧~',
  543. })
  544. return;
  545. } else if (res.data.is_trouble == 1) {
  546. my.alert({
  547. title: '提示',
  548. content: '当前车子出现故障请换辆车子骑行吧~',
  549. })
  550. return;
  551. } else if (res.data.is_riding == 1) {
  552. my.alert({
  553. title: '提示',
  554. content: '当前车子正在骑行请换辆车子骑行吧~',
  555. })
  556. return;
  557. } else {
  558. my.reLaunch({
  559. url: '/pages/use_bike/use_bike?code=' + code,
  560. })
  561. }
  562. } else {
  563. my.alert({
  564. title: '提示',
  565. content: res.data.message,
  566. })
  567. }
  568. })
  569. },
  570. //去支付未支付订单
  571. go_pay: util.throttle(function () {
  572. //点击去支付
  573. this.setData({
  574. is_pay_order: false,
  575. })
  576. var pay_order = ''
  577. if (this.data.userStatus.is_pay_order !== false && this.data.userStatus.is_pay_order !== undefined) {
  578. pay_order = this.data.userStatus.is_pay_order
  579. }
  580. my.navigateTo({
  581. url: '/pages/pay/pay?order=' + pay_order,
  582. })
  583. }, 1500),
  584. //点击查看正在进行中的订单
  585. goUseBike: function () {
  586. console.log(this.data.is_ride_order, 'this.data.is_ride_order')
  587. my.navigateTo({
  588. url: '/pages/use_bike/use_bike?order=' + this.data.is_ride_order,
  589. })
  590. },
  591. //有违章订单
  592. havePunishment: function () {
  593. my.navigateTo({
  594. url: '/pages/weizhang/weizhang',
  595. })
  596. },
  597. onReady: function () {
  598. },
  599. kefu: util.throttle(function () {
  600. my.makePhoneCall({
  601. number: my.getStorageSync({ 'key': 'home' }).data.customer_service_phone,
  602. })
  603. }, 1500),
  604. //用户状态
  605. userState: function (id) {
  606. var that = this;
  607. var data = {
  608. 'area_id': id
  609. }
  610. app.request("/user/status", data, "GET").then(res => {
  611. console.log(res)
  612. if (res.status == 200) {
  613. console.log(res, 'XYYING================')
  614. that.setData({
  615. userStatus: res.data,
  616. is_pay_order: res.data.is_pay_order,
  617. is_ride_order: res.data.is_ride_order,
  618. is_punishment: res.data.is_punishment,
  619. }), my.setStorageSync({ 'key': 'userState', data: res.data })
  620. }
  621. }).catch(err => {
  622. console.log(err)
  623. })
  624. },
  625. getUser() {
  626. app.request("/me", '', "GET").then(res => {
  627. console.log(res)
  628. 200 == res.status && my.setStorageSync({ 'key': 'userInfo', data: res.data })
  629. }).catch(err => {
  630. console.log(err)
  631. })
  632. },
  633. go_setting: util.throttle(function () {
  634. //点击去设置位置权限
  635. this.setData({
  636. background: false,
  637. location: false
  638. })
  639. my.openSetting({
  640. success: function (res) {
  641. }
  642. })
  643. }, 1500),
  644. //点击已开启位置权限
  645. open: util.throttle(function () {
  646. this.setData({
  647. background: false,
  648. location: false
  649. })
  650. }, 1500),
  651. location: function () {
  652. //获取当前经纬度 如果未授权让用户去授权
  653. console.log('dingwei')
  654. var that = this;
  655. my.showLoading({
  656. content: '定位中...',
  657. mask: true
  658. })
  659. my.getLocation({
  660. type: 'gcj02',
  661. success: (res) => {
  662. console.log('经纬度为:+++++++++++++++++++++' + res.latitude + '++++++++' + res.longitude)
  663. that.setData({
  664. longitude: res.longitude,
  665. latitude: res.latitude,
  666. show: false
  667. })
  668. console.log(res, 'ppp')
  669. that.home(), that.nearbyCars()
  670. if (that.data.stopP == false) {
  671. console.log('false')
  672. } else {
  673. that.stop()
  674. }
  675. my.hideLoading()
  676. },
  677. fail: function () {
  678. my.hideLoading()
  679. my.getSetting({
  680. success: function (res) {
  681. // console.log(res)
  682. var statu = res.authSetting;
  683. if (statu['scope.userLocation'] == false) {
  684. that.setData({
  685. background: true,
  686. location: true
  687. })
  688. }
  689. }
  690. })
  691. }
  692. })
  693. },
  694. //底部跳转页面按钮(用户未授权和未实名认证的时候不可以跳转)
  695. skipPage: function (e) {
  696. let data = e.target.dataset.id
  697. let that = this
  698. console.log(that.data, 'oooooo')
  699. var userStatus = that.data.userStatus;
  700. var setting = my.getStorageSync({ 'key': 'setting' }).data
  701. console.log(!setting, '运营区检测')
  702. if (!that.data.latitude && !that.data.longitude) {
  703. that.setData({
  704. background: true,
  705. location: true
  706. })
  707. } else {
  708. if (data.id == 2) {
  709. console.log(that.data.userStatus, '')
  710. if (!setting) {
  711. my.alert({
  712. title: '提示',
  713. content: '您附近暂无运营区,暂不可用车'
  714. })
  715. }
  716. else {
  717. if (!userStatus) {
  718. my.navigateTo({
  719. url: '/pages/authorization/authorization',
  720. })
  721. }
  722. else {
  723. that.jiance1();
  724. }
  725. }
  726. } else if (data.id == 3 && !setting) {
  727. wx.showModal({
  728. title: '提示',
  729. content: '您附近暂无运营区,暂不可用车',
  730. showCancel: false
  731. })
  732. } else if (data.id == 4) {
  733. if (userStatus.is_bind_mobile == 0) {
  734. my.navigateTo({
  735. url: '/pages/authorization/authorization',
  736. })
  737. } else {
  738. my.navigateTo({
  739. url: data.url,
  740. })
  741. }
  742. }
  743. else {
  744. if (!userStatus) {
  745. my.navigateTo({
  746. url: '/pages/authorization/authorization',
  747. })
  748. } else {
  749. my.navigateTo({
  750. url: data.url,
  751. })
  752. }
  753. }
  754. }
  755. },
  756. //输码开锁检测
  757. jiance1: function (source) {
  758. var that = this;
  759. let setting = my.getStorageSync({ 'key': 'setting' }).data
  760. var userStatus = that.data.userStatus;
  761. //未绑定手机号
  762. if (userStatus.is_bind_mobile == 0) {
  763. my.navigateTo({
  764. url: '/pages/authorization/authorization',
  765. })
  766. //未实名认证
  767. } else if (userStatus.is_card_certified == 0 && setting.is_card == 1) {
  768. my.navigateTo({
  769. url: '/pages/real_name/real_name',
  770. })
  771. } else {
  772. //有违章订单
  773. if (that.data.userStatus.is_punishment) {
  774. my.showToast({
  775. content: '您当前有违章订单需要处理,请处理后再来用车吧',
  776. icon: 'none'
  777. })
  778. return;
  779. } else if (userStatus.is_ride_order != false && userStatus.is_ride_order != undefined) {
  780. my.showToast({
  781. content: '您有一个正在骑行中的订单',
  782. icon: 'none'
  783. })
  784. return;
  785. }
  786. else {
  787. //有待支付骑行订单
  788. if (userStatus.is_pay_order != false && userStatus.is_pay_order != undefined) {
  789. my.showToast({
  790. content: '你有未支付订单,请先支付',
  791. icon: 'none'
  792. })
  793. return;
  794. } else {
  795. //没有押金没有免押券
  796. if (userStatus.is_deposit == 0 && that.data.setting.is_deposit != 0 && userStatus.is_coupon_deposit_free == false) {
  797. console.log('没有押金没有免押券')
  798. my.navigateTo({
  799. url: '/pages/ride_zige/ride_zige',
  800. })
  801. } else {
  802. my.navigateTo({
  803. url: '/pages/inputcode/inputcode',
  804. })
  805. }
  806. }
  807. }
  808. }
  809. },
  810. // 客服
  811. kefu: function () {
  812. my.makePhoneCall({
  813. number: my.getStorageSync({ 'key': 'home' }).data.customer_service_phone,
  814. })
  815. },
  816. //附近还车点
  817. findPark: function () {
  818. my.navigateTo({
  819. url: '/pages/parking/parking',
  820. })
  821. },
  822. //关闭中间广告弹框
  823. closeAdframe: function () {
  824. this.setData({
  825. adFrame: false
  826. })
  827. },
  828. onHide: function () {
  829. console.log('onHide')
  830. this.setData({
  831. bike_no: undefined,
  832. background: false,
  833. bluetooth: false,
  834. location: false,
  835. scanfail: false,
  836. over1: false
  837. })
  838. // clearInterval(mytime)
  839. },
  840. // 去输码弹框
  841. cancelErrFrame: function () {
  842. this.setData({
  843. scanCodeErr: false
  844. })
  845. },
  846. goInputCode: function () {
  847. my.navigateTo({
  848. url: '/pages/inputcode/inputcode',
  849. })
  850. }
  851. })