index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  1. <template>
  2. <view class="container">
  3. <view class="background-linear" :style="{ 'margin-top': `${statusBarHeight + navabarHeight}px`}">
  4. <NavBar :show="isShowNavaBar" @customBarInfo="getCustomBarInfo" />
  5. <CarDemand v-if="isShowCarDemand" @changeLeaseType="changeLeaseType" @updateInfo="updateInfo"
  6. :top="statusBarHeight + navabarHeight" />
  7. <view class="app-title flex-row">
  8. <image :src="QINIU_URL + 'FkzpKAKGtcnSU1pEXT0jI05VKREo'" style="width: 502rpx;height: 56rpx;" />
  9. <view class="app-name">
  10. {{appConfig.app_name}}
  11. </view>
  12. </view>
  13. <!-- <view class="hire-car flex-row">
  14. <view @tap="navToInputPage" class="position-fa">
  15. <image class="hireCar-way" style="margin-right: 22rpx;"
  16. src="https://qiniu.bms16.com/FheixFAGCKMdFQd3eWpyed6ipyWH" />
  17. <text class="img-text">拍车牌号 绑定车辆</text>
  18. </view>
  19. <view @tap="navToResPage" class="position-fa">
  20. <image class="hireCar-way" src="https://qiniu.bms16.com/FltE4aGRJvZYOEQVNWAy-OghrIWR" />
  21. <text class="img-text">预约便捷 服务周全</text>
  22. </view>
  23. </view> -->
  24. <view class="hire-tab">
  25. <view class="tab-row">
  26. <view :class="[isRentalShort ? 'tab-checked tab-left' : 'tab-base tab-base-left ']"
  27. @tap="changeRentalType('short')">
  28. <image
  29. :src="QINIU_URL + (isRentalShort ? 'FizQr1NpR1PRijdr4V4n8ZlEy1yQ' : 'Fj2eHQYqHghdhaFpw3IKNaKuUX9P')"
  30. :class="[isRentalShort ? 'tab-left-text-big' : 'tab-left-text-small']" />
  31. <image v-if="isRentalShort" src="https://qiniu.bms16.com/Fg3BTdXJEbXB5kGReQKiB1f_YDPr"
  32. class="tab-checked-icon" />
  33. <text v-if="isRentalLong" class="tab-text">时租·日租</text>
  34. </view>
  35. <view :class="[isRentalLong ? 'tab-checked tab-right' : 'tab-base tab-base-right']"
  36. @tap="changeRentalType('long')">
  37. <image
  38. :src="QINIU_URL + (isRentalLong ? 'FgofxO6oxS7-WZGr0W6JAB-GhvcL' : 'Fiq5HVM_G5voYXjAsnxWjHr_yYP_')"
  39. :class="[isRentalLong ? 'tab-right-text-big' : 'tab-right-text-small']" />
  40. <image v-if="isRentalLong" src="https://qiniu.bms16.com/Fg3BTdXJEbXB5kGReQKiB1f_YDPr"
  41. class="tab-checked-icon" />
  42. <text v-if="isRentalShort" class="tab-text">周租·月租·季租</text>
  43. </view>
  44. </view>
  45. <ReservationHireCar ref="reservationHireCar" :rentalType="rentalDurationType" />
  46. </view>
  47. <view v-if="order_status == 3 || order_status == 4" @tap="navToPage" data-url="/pages/battery/battery"
  48. data-index="4" class="my-car">
  49. <view class="my_button" v-if="carList.length>0">
  50. <view class="flex-row" style="padding: 40rpx 0;">
  51. <view class="my_car_button">我的车辆</view>
  52. <image src="https://qiniu.bms16.com/FpIN7AVzFU75slFlX-SIdnSEmn1k"
  53. style="width: 28rpx;height: 28rpx;" />
  54. </view>
  55. <view v-if="carList[0].battery_sn!=''" @tap.stop="navToExchange" :data-car="carList[0]"
  56. class="scan_box">
  57. <view class="scan_button">车辆换电</view>
  58. </view>
  59. </view>
  60. <view v-if="carList.length>0" class="car_info">
  61. <view :class=" carList[0].battery_sn!=''?'info_box':'info_box_1'">
  62. <view class="info_box_title">当前电量</view>
  63. <view class="info_box_data">
  64. <view class="info_box_num">
  65. {{carList[0].quantity}}
  66. </view>
  67. <view class="info_box_unit">%</view>
  68. </view>
  69. </view>
  70. <view :class=" carList[0].battery_sn!=''?'info_box':'info_box_1'">
  71. <view class="info_box_title">预计续航</view>
  72. <view class="info_box_data">
  73. <view class="info_box_num">
  74. {{Math.round((carList[0].last_endurance)/1000)}}
  75. </view>
  76. <view class="info_box_unit">km</view>
  77. </view>
  78. </view>
  79. <view v-if="carList[0].battery_sn!=''" class="info_box">
  80. <view v-if="(carList[0].gift_exchange_num -carList[0].used_exchange_num)>0" class="red_tip">免费
  81. <text
  82. style="margin: 0 4rpx;font-size: 24rpx;">{{carList[0].gift_exchange_num - carList[0].used_exchange_num}}</text>
  83. </view>
  84. <view class="info_box_title">已换电次数</view>
  85. <view class="info_box_data">
  86. <view class="info_box_num">
  87. {{carList[0].total_exchange_num ||0}}
  88. </view>
  89. <view class="info_box_unit">次</view>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. <!-- <view v-if="order_status == 3 || order_status == 4" style="height: 300rpx;color: transparent;">用于撑起被遮挡的部分</view> -->
  95. <view class="hire-tab">
  96. <view class="option-first">
  97. <view @tap="navToPage" data-url="/pages/instruction/instruction" class="flex-column my_function">
  98. <image class="my_icon" src="https://qiniu.bms16.com/FvR8w5KFOBPMbvTPIbQRKIW6IcJj"></image>
  99. <view class="my_title">新手指引</view>
  100. </view>
  101. <view @tap="navToPage" data-url="/pages/platformGuarantee/platformGuarantee"
  102. class="flex-column my_function">
  103. <image class="my_icon" src="https://qiniu.bms16.com/FqYXoI_bPXBuxmUZfQCnx9curZn9"></image>
  104. <view class="my_title">平台保障</view>
  105. </view>
  106. <view @tap="navToPage" data-url="/pages/sesameCredit/sesameCredit" class="flex-column my_function">
  107. <image class="my_icon" src="https://qiniu.bms16.com/FgxiD-W96FGvgyLI_kXUfWVDYLQ9"></image>
  108. <view class="my_title">芝麻免押</view>
  109. </view>
  110. <!-- #ifdef MP-WEIXIN -->
  111. <view v-if="isSmallMany" @tap="navToCooperate" class="flex-column my_function">
  112. <image class="my_icon" src="https://qiniu.bms16.com/Fp0yEXByHk5wDoibxJcahqlhAmkT"></image>
  113. <view class="my_title">加盟合作</view>
  114. </view>
  115. <!-- #endif -->
  116. </view>
  117. </view>
  118. </view>
  119. <CarRentalList :params="getSkipUrlParams()" />
  120. <!-- #ifdef MP-WEIXIN -->
  121. <CustomTabbar />
  122. <!-- #endif -->
  123. </view>
  124. </template>
  125. <script>
  126. var app = getApp();
  127. var config = require('../../common/config.js');
  128. var common = require('../../common/common.js');
  129. var http = require('../../common/http.js');
  130. var storage = require('../../common/storage.js');
  131. import ReservationHireCar from './components/ReservationHireCar/index.vue'
  132. import CarDemand from './components/CarDemand'
  133. import {
  134. QINIU_URL,
  135. LEASE_TYPE_ARR
  136. } from '@/common/constant.js'
  137. import CustomTabbar from '@/component/customTabbar/index';
  138. import CarRentalList from '../carRental/components/carRentalList.vue'
  139. import NavBar from './components/NavBar'
  140. const bus = app.globalData.bus
  141. export default {
  142. data() {
  143. return {
  144. QINIU_URL,
  145. LEASE_TYPE_ARR,
  146. appConfig: {
  147. app_name: ''
  148. },
  149. userInfo: {
  150. is_auth: 0,
  151. status: 0
  152. },
  153. face_token: '',
  154. face_key: '',
  155. carList: [],
  156. plate_number: '',
  157. order_status: 0,
  158. wait_active_predetermine: null,
  159. exchangInfo: {},
  160. rentalDurationType: 'short', // 租赁时长类型
  161. statusBarHeight: 0,
  162. navabarHeight: 0,
  163. isShowNavaBar: false,
  164. isShowCarDemand: false,
  165. isSmallMany: null, //是否是小众出行的appid
  166. };
  167. },
  168. computed: {
  169. isRentalShort() {
  170. return this.rentalDurationType === 'short'
  171. },
  172. isRentalLong() {
  173. return this.rentalDurationType === 'long'
  174. },
  175. isLogin() {
  176. return storage.getUserToken()
  177. }
  178. },
  179. components: {
  180. ReservationHireCar,
  181. CarDemand,
  182. CustomTabbar,
  183. CarRentalList,
  184. NavBar
  185. },
  186. /**
  187. * 生命周期函数--监听页面加载
  188. */
  189. onLoad: function(options) {
  190. const me = this
  191. setTimeout(() => {
  192. const appConfig = storage.getAppConfig()
  193. me.setData({
  194. appConfig: appConfig
  195. })
  196. if(appConfig === null|| appConfig ===''){
  197. http.getAppConfig(function(resp) {
  198. me.setData({
  199. appConfig: resp
  200. })
  201. });
  202. }
  203. }, 200)
  204. // #ifdef MP-ALIPAY
  205. this.isSmallMany = uni.getAccountInfoSync().miniProgram.appId == '2021004109662240'
  206. // #endif
  207. // #ifdef MP-WEIXIN
  208. this.isSmallMany = uni.getAccountInfoSync().miniProgram.appId == 'wx868f4e5130ef2636'
  209. // #endif
  210. // const locationStr = uni.getStorageSync('user_current_location');
  211. // if (locationStr) {
  212. // this.myLocation = locationStr;
  213. // }else{
  214. // }
  215. var userInfo = storage.getUserInfoData()
  216. if (userInfo) this.userInfo = userInfo.userInfo
  217. this.loadLocation()
  218. //微信扫一扫流程
  219. this.loadGeneralQRData(options)
  220. if ('scene' in options) {
  221. var cabinet_dev_id = ''
  222. var charge_dev_id = ''
  223. var socket_dev_id = ''
  224. if (options.scene.split('devid%3D').length > 1 && !(options.scene.indexOf('type%3Dcg') != -1)) {
  225. cabinet_dev_id = options.scene.split('devid%3D')[1].split('%26')[0]
  226. }
  227. if (options.scene.split('devid%3D').length > 1 && (options.scene.indexOf('type%3Dcg') != -1)) {
  228. charge_dev_id = options.scene.split('devid%3D')[1].split('%26')[0]
  229. }
  230. if (options.scene.split('devid%3D').length > 1 && (options.scene.indexOf('type%3Dcg') != -1)) {
  231. socket_dev_id = options.scene.split('devid%3D')[1].split('%26')[0]
  232. }
  233. if (options.scene.split('devid=').length > 1 && (options.scene.indexOf('type=cg') != -1)) {
  234. charge_dev_id = options.scene.split('devid=')[1].split('&')[0]
  235. } else if (options.scene.split('devid=').length > 1 && !(options.scene.indexOf('type=cg') != -1)) {
  236. cabinet_dev_id = options.scene.split('devid=')[1].split('&')[0]
  237. }
  238. if (options.scene.split('devid=').length > 1 && (options.scene.indexOf('type=pl') != -1)) {
  239. socket_dev_id = options.scene.split('devid=')[1].split('&')[0]
  240. }
  241. if (cabinet_dev_id != '') {
  242. const user_token = storage.getUserToken()
  243. if (!user_token) {
  244. this.loadIsLogin()
  245. } else {
  246. wx.navigateTo({
  247. url: '/pages/cabinetDetail/cabinetDetail?dev_id=' + cabinet_dev_id + '&type=' + 2,
  248. })
  249. }
  250. } else if (charge_dev_id != '') {
  251. const user_token = storage.getUserToken()
  252. if (!user_token) {
  253. this.loadIsLogin()
  254. } else {
  255. wx.navigateTo({
  256. url: '/pages/cabinetDetail/cabinetDetail?dev_id=' + charge_dev_id + '&type=' + 2,
  257. })
  258. }
  259. } else if (socket_dev_id != '') {
  260. const user_token = storage.getUserToken()
  261. if (!user_token) {
  262. this.loadIsLogin()
  263. } else {
  264. wx.navigateTo({
  265. url: '/pages/cabinetDetail/cabinetDetail?dev_id=' + socket_dev_id + '&type=' + 2,
  266. })
  267. }
  268. }
  269. }
  270. const throttledHandleScroll = this.throttle(this.onPageScroll, 300)
  271. uni.$on('pageScroll', throttledHandleScroll);
  272. },
  273. /**
  274. * 生命周期函数--监听页面显示
  275. */
  276. onShow: function() {
  277. // #ifdef MP-ALIPAY
  278. if (typeof this.$scope.getTabBar === 'function' && this.$scope.getTabBar()) {
  279. this.$scope.getTabBar().setData({
  280. curtTab: 0
  281. })
  282. }
  283. bus.on('join', () => {
  284. this.navToInputPage()
  285. })
  286. // #endif
  287. const token = storage.getUserToken();
  288. if (!token) return
  289. this.loadUserInfo()
  290. this.loadCarList()
  291. this.loadLocation()
  292. },
  293. // 分享给好友
  294. onShareAppMessage: function(res) { //发送给朋友
  295. return {
  296. title: this.appConfig.app_name,
  297. path: 'pages/index/index',
  298. }
  299. },
  300. onShareTimeline() {
  301. return {
  302. title: this.appConfig.app_name + ',便捷又实惠,安全保障更放心!',
  303. description: this.appConfig.app_name + ',便捷又实惠,安全保障更放心!',
  304. "imageUrl": this.appConfig.app_logo
  305. }
  306. },
  307. methods: {
  308. getCustomBarInfo({
  309. navabarHeight,
  310. statusBarHeight
  311. }) {
  312. this.navabarHeight = navabarHeight
  313. this.statusBarHeight = statusBarHeight
  314. },
  315. getSkipUrlParams() {
  316. const ref = this.$refs.reservationHireCar
  317. return ref && ref.getSkipUrlParams && ref.getSkipUrlParams()
  318. },
  319. changeLeaseType(val) {
  320. const {
  321. type
  322. } = this.LEASE_TYPE_ARR.find(v => v.value === val)
  323. this.rentalDurationType = type
  324. this.$refs.reservationHireCar.duration_unit = val
  325. },
  326. updateInfo(data) {
  327. this.$refs.reservationHireCar.setDataInfo(data)
  328. const {
  329. type
  330. } = this.LEASE_TYPE_ARR.find(v => v.value === data.duration_unit)
  331. this.rentalDurationType = type
  332. },
  333. throttle(fn, delay) {
  334. let lastCall = 0;
  335. return function(...args) {
  336. const now = Date.now();
  337. if (now - lastCall >= delay) {
  338. lastCall = now;
  339. return fn.apply(this, args);
  340. }
  341. }
  342. },
  343. onPageScroll(e) {
  344. this.isShowNavaBar = e.scrollTop >= 62
  345. this.isShowCarDemand = e.scrollTop >= 400
  346. },
  347. changeRentalType(rentalDurationType) {
  348. this.setData({
  349. rentalDurationType
  350. })
  351. },
  352. /**
  353. * 获取用户坐标
  354. */
  355. loadLocation() {
  356. const me = this;
  357. uni.getLocation({
  358. type: 'gcj02',
  359. success: function(res) {
  360. var myLocation = {
  361. longitude: res.longitude,
  362. latitude: res.latitude
  363. }
  364. uni.setStorageSync('user_current_location', myLocation)
  365. },
  366. fail: function(res) {},
  367. complete: function(res) {}
  368. });
  369. },
  370. loadIsLogin() {
  371. uni.showModal({
  372. title: '提示',
  373. content: '您还未登录,请先登录',
  374. showCancel: true,
  375. cancelText: '取消',
  376. confirmText: '确定',
  377. success: function(res) {
  378. if (res.confirm) {
  379. uni.navigateTo({
  380. url: '/pages/login/login',
  381. })
  382. }
  383. },
  384. fail: function(res) {},
  385. complete: function(res) {},
  386. })
  387. },
  388. loadGeneralQRData(options) {
  389. if (('q' in options) || ('result' in options) && (options.result.indexOf("https://zx.uwenya.cc/xcx/s") != -
  390. 1)) {
  391. var url = ''
  392. if ('q' in options) {
  393. url = decodeURIComponent(options.q);
  394. }
  395. if ('result' in options) {
  396. url = options.result
  397. }
  398. var obj = this.getUrlParams(url)
  399. if (('t' in obj) && ('d' in obj)) {
  400. if (obj.t == 1 || obj.t == 4) {
  401. const user_token = storage.getUserToken()
  402. if (!user_token) {
  403. this.loadIsLogin()
  404. } else {
  405. uni.navigateTo({
  406. url: '/pages/cabinetDetail/cabinetDetail?dev_id=' + obj.d + '&type=' + obj.t,
  407. })
  408. return 101
  409. }
  410. }
  411. if (obj.t == 2) {
  412. const user_token = storage.getUserToken()
  413. if (!user_token) {
  414. this.loadIsLogin()
  415. } else {
  416. uni.navigateTo({
  417. url: '/pages/cabinetDetail/cabinetDetail?dev_id=' + obj.d + '&type=' + 2,
  418. })
  419. return 102
  420. }
  421. }
  422. if (obj.t == 5) {
  423. const user_token = storage.getUserToken()
  424. if (!user_token) {
  425. this.loadIsLogin()
  426. } else {
  427. uni.navigateTo({
  428. url: '/pages/cabinetDetail/cabinetDetail?dev_id=' + obj.d + '&type=' + 2,
  429. })
  430. return 105
  431. }
  432. }
  433. }
  434. }
  435. },
  436. getUrlParams(url) {
  437. // 通过 ? 分割获取后面的参数字符串
  438. let urlStr = url.split('?')[1]
  439. // 创建空对象存储参数
  440. let obj = {};
  441. // 再通过 & 将每一个参数单独分割出来
  442. let paramsArr = urlStr.split('&')
  443. for (let i = 0, len = paramsArr.length; i < len; i++) {
  444. // 再通过 = 将每一个参数分割为 key:value 的形式
  445. let arr = paramsArr[i].split('=')
  446. obj[arr[0]] = arr[1];
  447. }
  448. return obj
  449. },
  450. loadExchangeInfo(plate_number) {
  451. const time = new Date().getTime()
  452. // API_CABINET_EXCHANGE_INFO
  453. http.postApi(config.API_CABINET_EXCHANGE_INFO, {
  454. license_plate_number: plate_number,
  455. time
  456. }, (resp) => {
  457. if (resp.data.code === 200) {
  458. this.exchangInfo = resp.data.data
  459. }
  460. })
  461. },
  462. loadUserInfo() {
  463. const me = this
  464. const token = storage.getUserToken();
  465. if (!token) {
  466. return;
  467. }
  468. const accountInfo = uni.getAccountInfoSync() // 上报小程序账号信息
  469. http.postApi(config.API_USER_INFO, {
  470. appid: accountInfo.miniProgram.appId
  471. }, function(resp) {
  472. if (resp.data.code === 200) {
  473. app.globalData.orderSign = resp.data.data.userInfo.order_sign
  474. app.globalData.orderSignUrl = resp.data.data.userInfo.order_sign_url
  475. me.userInfo = resp.data.data.userInfo
  476. storage.setUserInfoData(resp.data.data)
  477. }
  478. })
  479. },
  480. getLocationFromStorage() {
  481. const locationStr = uni.getStorageSync('location');
  482. if (locationStr) {
  483. this.locationInfo = JSON.parse(locationStr);
  484. }
  485. },
  486. navToPage(e) {
  487. var url = e.currentTarget.dataset.url;
  488. const index = e.currentTarget.dataset.index || '';
  489. if (!url) {
  490. return;
  491. }
  492. if (index === '4') {
  493. // 我的车辆
  494. const isReturnIndex = false
  495. url = url + '?plate_number=' + this.plate_number + '&isReturnIndex=' + isReturnIndex
  496. }
  497. uni.navigateTo({
  498. url: url
  499. });
  500. },
  501. navToExchange(e) {
  502. const carInfo = e.currentTarget.dataset.car
  503. const num = (carInfo.gift_exchange_num - carInfo.used_exchange_num) || 0
  504. const free_num = num > 0 ? num : 0
  505. uni.navigateTo({
  506. url: '/pages/exchangeCar/exchangeCar' + '?free_num=' + free_num
  507. });
  508. },
  509. loadCarList() {
  510. const me = this
  511. http.postApi(config.API_DAYHIRE_CAR_CAR_LIST, {}, (resp) => {
  512. if (resp.data.code === 200) {
  513. me.carList = resp.data.data.data
  514. me.wait_active_predetermine = resp.data.data.wait_active_predetermine
  515. const isBuyModel = (me.wait_active_predetermine != null || me.carList.length != 0)
  516. storage.setIsBuyModel(isBuyModel)
  517. var car_list = {}
  518. if (me.carList.length != 0) {
  519. me.order_status = resp.data.data.data[0].order_status
  520. me.plate_number = me.carList.length > 0 ? me.carList[0].license_plate_number : ''
  521. const datetime = Math.floor(new Date().getTime() / 1000);
  522. // 更新车牌存入本地
  523. car_list = {
  524. plate_number: me.plate_number,
  525. order_status: me.order_status,
  526. battery_sn: resp.data.data.data[0].battery_sn || '',
  527. remain: resp.data.data.data[0].hire_expire_time - datetime > 0
  528. }
  529. }
  530. uni.setStorageSync('user_car_list', car_list)
  531. if (car_list.order_status && (car_list.order_status == 3 || car_list.order_status == 4)) {
  532. this.loadExchangeInfo(car_list.plate_number)
  533. }
  534. } else {
  535. common.simpleToast(resp.data.msg)
  536. }
  537. })
  538. },
  539. navToResPage() {
  540. const me = this
  541. if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 == 2) {
  542. if (me.wait_active_predetermine != null) { //预约车辆为待激活状态
  543. if (me.wait_active_predetermine.order_status == 2) {
  544. uni.showModal({
  545. title: '提示',
  546. content: '您有等待激活的车辆,是否跳转至订单详情页?',
  547. cancelText: '取消',
  548. confirmText: '确定',
  549. success: function(res) {
  550. if (res.confirm) {
  551. uni.navigateTo({
  552. url: '/pages/orderStatus/orderStatus?order_sn=' + me
  553. .wait_active_predetermine.order_sn
  554. });
  555. }
  556. },
  557. fail: function(res) {},
  558. complete: function(res) {},
  559. })
  560. }
  561. return
  562. }
  563. if (me.carList.length == 0) {
  564. uni.navigateTo({
  565. url: '/pages/reservationHireCar/reservationHireCar'
  566. });
  567. } else {
  568. // order_status 只有等于 3 、4、5 的时候,才能跳到车辆详情
  569. if (me.order_status == 3 || me.order_status == 4) { // 车辆状态为未激活
  570. uni.showModal({
  571. title: '提示',
  572. content: '已有正在使用的车辆,是否跳转至车辆详情页?',
  573. cancelText: '取消',
  574. confirmText: '确定',
  575. success: function(res) {
  576. if (res.confirm) {
  577. const isReturnIndex = false
  578. uni.navigateTo({
  579. url: '/pages/battery/battery?plate_number=' + me.carList[0]
  580. .license_plate_number + '&isReturnIndex=' +
  581. isReturnIndex
  582. });
  583. }
  584. },
  585. fail: function(res) {},
  586. complete: function(res) {},
  587. })
  588. } else if (me.order_status == 5) {
  589. uni.showModal({
  590. title: '提示',
  591. content: '请等待商家确认还车,是否跳转至订单详情页?',
  592. cancelText: '取消',
  593. confirmText: '确定',
  594. success: function(res) {
  595. if (res.confirm) {
  596. uni.navigateTo({
  597. url: '/pages/orderStatus/orderStatus?order_sn=' + me
  598. .carList[0].order_sn
  599. });
  600. }
  601. },
  602. fail: function(res) {},
  603. complete: function(res) {},
  604. })
  605. } else {
  606. uni.showModal({
  607. title: '提示',
  608. content: '已有正在进行的订单,是否跳转至订单详情页?',
  609. cancelText: '取消',
  610. confirmText: '确定',
  611. success: function(res) {
  612. if (res.confirm) {
  613. uni.navigateTo({
  614. url: '/pages/orderStatus/orderStatus?order_sn=' + me
  615. .carList[0].order_sn
  616. });
  617. }
  618. },
  619. fail: function(res) {},
  620. complete: function(res) {},
  621. })
  622. }
  623. }
  624. } else if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 != 2) {
  625. uni.showModal({
  626. title: '身份认证提示',
  627. content: '尚未完成身份认证,是否进行身份认证?',
  628. cancelText: '取消',
  629. confirmText: '确定',
  630. success: function(res) {
  631. if (res.confirm) {
  632. me.loadFaceToken()
  633. }
  634. },
  635. fail: function(res) {},
  636. complete: function(res) {},
  637. })
  638. } else {
  639. uni.showModal({
  640. title: '提示',
  641. content: '您还未登录,请先登录',
  642. showCancel: false,
  643. confirmText: '确定',
  644. success: function(res) {
  645. if (res.confirm) {
  646. //#ifdef MP-ALIPAY
  647. uni.navigateTo({
  648. url: '/pages/phoneLogin/phoneLogin',
  649. })
  650. //#endif
  651. //#ifdef MP-WEIXIN
  652. uni.navigateTo({
  653. url: '/pages/login/login',
  654. })
  655. //#endif
  656. }
  657. },
  658. fail: function(res) {},
  659. complete: function(res) {},
  660. })
  661. }
  662. },
  663. _getParams() {
  664. return new Promise((reslove, reject) => {
  665. http.postApi(config.API_DAYHIRE_CAR_CAR_LIST, {}, res => {
  666. const {
  667. data = [], wait_active_predetermine = null
  668. } = res.data.data
  669. const obj = {
  670. carList: data,
  671. wait_active_predetermine,
  672. order_status: data.length ? data[0].order_status : 0
  673. }
  674. reslove(obj)
  675. })
  676. })
  677. },
  678. async navToInputPage() {
  679. const me = this
  680. const {
  681. userInfo = ''
  682. } = storage.getUserInfoData()
  683. if (userInfo.is_auth - 0 == 1 && userInfo.status - 0 == 2) {
  684. const params = await this._getParams()
  685. if (params.wait_active_predetermine != null) { //预约车辆为待激活状态
  686. if (params.wait_active_predetermine.order_status == 2) {
  687. uni.showModal({
  688. title: '提示',
  689. content: '您有等待激活的车辆,是否跳转至订单详情页?',
  690. cancelText: '取消',
  691. confirmText: '确定',
  692. success: function(res) {
  693. if (res.confirm) {
  694. uni.navigateTo({
  695. url: '/pages/orderStatus/orderStatus?order_sn=' +
  696. params
  697. .wait_active_predetermine.order_sn
  698. });
  699. }
  700. },
  701. fail: function(res) {},
  702. complete: function(res) {},
  703. })
  704. }
  705. return
  706. }
  707. if (params.carList.length == 0) {
  708. const isReturnIndex = false
  709. uni.navigateTo({
  710. url: '/pages/scanCar/scanCar',
  711. // ?isReturnIndex=' + isReturnIndex
  712. });
  713. // uni.navigateTo({
  714. // url: '/pages/inputLicensePlate/inputLicensePlate?isReturnIndex=' + isReturnIndex
  715. // });
  716. } else {
  717. if (params.order_status == 3 || params.order_status == 4) { // 车辆状态为未激活
  718. uni.showModal({
  719. title: '提示',
  720. content: '已有正在使用的车辆,是否跳转至车辆详情页?',
  721. cancelText: '取消',
  722. confirmText: '确定',
  723. success: function(res) {
  724. if (res.confirm) {
  725. const isReturnIndex = false
  726. uni.navigateTo({
  727. url: '/pages/battery/battery?plate_number=' + params
  728. .carList[0]
  729. .license_plate_number + '&isReturnIndex=' +
  730. isReturnIndex
  731. });
  732. }
  733. },
  734. fail: function(res) {},
  735. complete: function(res) {},
  736. })
  737. } else if (params.order_status == 5) {
  738. uni.showModal({
  739. title: '提示',
  740. content: '请等待商家确认还车,是否跳转至订单详情页?',
  741. cancelText: '取消',
  742. confirmText: '确定',
  743. success: function(res) {
  744. if (res.confirm) {
  745. uni.navigateTo({
  746. url: '/pages/orderStatus/orderStatus?order_sn=' +
  747. params
  748. .carList[0].order_sn
  749. });
  750. }
  751. },
  752. fail: function(res) {},
  753. complete: function(res) {},
  754. })
  755. } else {
  756. uni.showModal({
  757. title: '提示',
  758. content: '已有正在进行的订单,是否跳转至订单详情页?',
  759. cancelText: '取消',
  760. confirmText: '确定',
  761. success: function(res) {
  762. if (res.confirm) {
  763. uni.navigateTo({
  764. url: '/pages/orderStatus/orderStatus?order_sn=' +
  765. params
  766. .carList[0].order_sn
  767. });
  768. }
  769. },
  770. fail: function(res) {},
  771. complete: function(res) {},
  772. })
  773. }
  774. }
  775. } else if (userInfo.is_auth == 1 && userInfo.status != 2) {
  776. uni.showModal({
  777. title: '身份认证提示',
  778. content: '尚未完成身份认证,是否进行身份认证?',
  779. cancelText: '取消',
  780. confirmText: '确定',
  781. success: function(res) {
  782. if (res.confirm) {
  783. me.loadFaceToken()
  784. }
  785. },
  786. fail: function(res) {},
  787. complete: function(res) {},
  788. })
  789. } else {
  790. uni.showModal({
  791. title: '提示',
  792. content: '您还未登录,请先登录',
  793. showCancel: false,
  794. confirmText: '确定',
  795. success: function(res) {
  796. if (res.confirm) {
  797. //#ifdef MP-ALIPAY
  798. uni.navigateTo({
  799. url: '/pages/phoneLogin/phoneLogin',
  800. })
  801. //#endif
  802. //#ifdef MP-WEIXIN
  803. uni.navigateTo({
  804. url: '/pages/login/login',
  805. })
  806. //#endif
  807. }
  808. },
  809. fail: function(res) {},
  810. complete: function(res) {},
  811. })
  812. }
  813. },
  814. navToCooperate() {
  815. const me = this
  816. if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 == 2) {
  817. uni.navigateTo({
  818. url: '/pages/cooperate/cooperate'
  819. });
  820. } else if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 != 2) {
  821. uni.showModal({
  822. title: '身份认证提示',
  823. content: '尚未完成身份认证,是否进行身份认证?',
  824. cancelText: '取消',
  825. confirmText: '确定',
  826. success: function(res) {
  827. if (res.confirm) {
  828. me.loadFaceToken()
  829. }
  830. },
  831. fail: function(res) {},
  832. complete: function(res) {},
  833. })
  834. } else {
  835. uni.showModal({
  836. title: '提示',
  837. content: '您还未登录,请先登录',
  838. showCancel: false,
  839. confirmText: '确定',
  840. success: function(res) {
  841. if (res.confirm) {
  842. //#ifdef MP-ALIPAY
  843. uni.navigateTo({
  844. url: '/pages/phoneLogin/phoneLogin',
  845. })
  846. //#endif
  847. //#ifdef MP-WEIXIN
  848. uni.navigateTo({
  849. url: '/pages/login/login',
  850. })
  851. //#endif
  852. }
  853. },
  854. fail: function(res) {},
  855. complete: function(res) {},
  856. })
  857. }
  858. },
  859. loadFaceToken() {
  860. const me = this
  861. http.postApi(config.API_USER_FACE_TOKEN, {}, (resp) => {
  862. if (resp.data.code === 200) {
  863. me.face_token = resp.data.data.token
  864. me.face_key = resp.data.data.key
  865. uni.navigateTo({
  866. url: '/pages/livenessView/livenessView?face_token=' + me.face_token +
  867. '&face_key=' + this.face_key,
  868. success: function(res) {},
  869. fail: function(res) {},
  870. complete: function(res) {},
  871. })
  872. } else {
  873. common.simpleToast(resp.data.msg)
  874. }
  875. })
  876. },
  877. }
  878. };
  879. </script>
  880. <style>
  881. @import './index.css';
  882. </style>