123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906 |
- <template>
- <view class="container">
- <view class="background-linear" :style="{ 'margin-top': `${statusBarHeight + navabarHeight}px`}">
- <NavBar :show="isShowNavaBar" @customBarInfo="getCustomBarInfo" />
- <CarDemand v-if="isShowCarDemand" @changeLeaseType="changeLeaseType" @updateInfo="updateInfo"
- :top="statusBarHeight + navabarHeight" />
- <view class="app-title flex-row">
- <image :src="QINIU_URL + 'FkzpKAKGtcnSU1pEXT0jI05VKREo'" style="width: 502rpx;height: 56rpx;" />
- <view class="app-name">
- {{appConfig.app_name}}
- </view>
- </view>
- <!-- <view class="hire-car flex-row">
- <view @tap="navToInputPage" class="position-fa">
- <image class="hireCar-way" style="margin-right: 22rpx;"
- src="https://qiniu.bms16.com/FheixFAGCKMdFQd3eWpyed6ipyWH" />
- <text class="img-text">拍车牌号 绑定车辆</text>
- </view>
- <view @tap="navToResPage" class="position-fa">
- <image class="hireCar-way" src="https://qiniu.bms16.com/FltE4aGRJvZYOEQVNWAy-OghrIWR" />
- <text class="img-text">预约便捷 服务周全</text>
- </view>
- </view> -->
- <view class="hire-tab">
- <view class="tab-row">
- <view :class="[isRentalShort ? 'tab-checked tab-left' : 'tab-base tab-base-left ']"
- @tap="changeRentalType('short')">
- <image
- :src="QINIU_URL + (isRentalShort ? 'FizQr1NpR1PRijdr4V4n8ZlEy1yQ' : 'Fj2eHQYqHghdhaFpw3IKNaKuUX9P')"
- :class="[isRentalShort ? 'tab-left-text-big' : 'tab-left-text-small']" />
- <image v-if="isRentalShort" src="https://qiniu.bms16.com/Fg3BTdXJEbXB5kGReQKiB1f_YDPr"
- class="tab-checked-icon" />
- <text v-if="isRentalLong" class="tab-text">时租·日租</text>
- </view>
- <view :class="[isRentalLong ? 'tab-checked tab-right' : 'tab-base tab-base-right']"
- @tap="changeRentalType('long')">
- <image
- :src="QINIU_URL + (isRentalLong ? 'FgofxO6oxS7-WZGr0W6JAB-GhvcL' : 'Fiq5HVM_G5voYXjAsnxWjHr_yYP_')"
- :class="[isRentalLong ? 'tab-right-text-big' : 'tab-right-text-small']" />
- <image v-if="isRentalLong" src="https://qiniu.bms16.com/Fg3BTdXJEbXB5kGReQKiB1f_YDPr"
- class="tab-checked-icon" />
- <text v-if="isRentalShort" class="tab-text">周租·月租·季租</text>
- </view>
- </view>
- <ReservationHireCar ref="reservationHireCar" :rentalType="rentalDurationType" />
- </view>
- <view v-if="order_status == 3 || order_status == 4" @tap="navToPage" data-url="/pages/battery/battery"
- data-index="4" class="my-car">
- <view class="my_button" v-if="carList.length>0">
- <view class="flex-row" style="padding: 40rpx 0;">
- <view class="my_car_button">我的车辆</view>
- <image src="https://qiniu.bms16.com/FpIN7AVzFU75slFlX-SIdnSEmn1k"
- style="width: 28rpx;height: 28rpx;" />
- </view>
- <view v-if="carList[0].battery_sn!=''" @tap.stop="navToExchange" :data-car="carList[0]"
- class="scan_box">
- <view class="scan_button">车辆换电</view>
- </view>
- </view>
- <view v-if="carList.length>0" class="car_info">
- <view :class=" carList[0].battery_sn!=''?'info_box':'info_box_1'">
- <view class="info_box_title">当前电量</view>
- <view class="info_box_data">
- <view class="info_box_num">
- {{carList[0].quantity}}
- </view>
- <view class="info_box_unit">%</view>
- </view>
- </view>
- <view :class=" carList[0].battery_sn!=''?'info_box':'info_box_1'">
- <view class="info_box_title">预计续航</view>
- <view class="info_box_data">
- <view class="info_box_num">
- {{Math.round((carList[0].last_endurance)/1000)}}
- </view>
- <view class="info_box_unit">km</view>
- </view>
- </view>
- <view v-if="carList[0].battery_sn!=''" class="info_box">
- <view v-if="(carList[0].gift_exchange_num -carList[0].used_exchange_num)>0" class="red_tip">免费
- <text
- style="margin: 0 4rpx;font-size: 24rpx;">{{carList[0].gift_exchange_num - carList[0].used_exchange_num}}</text>
- 次
- </view>
- <view class="info_box_title">已换电次数</view>
- <view class="info_box_data">
- <view class="info_box_num">
- {{carList[0].total_exchange_num ||0}}
- </view>
- <view class="info_box_unit">次</view>
- </view>
- </view>
- </view>
- </view>
- <!-- <view v-if="order_status == 3 || order_status == 4" style="height: 300rpx;color: transparent;">用于撑起被遮挡的部分</view> -->
- <view class="hire-tab">
- <view class="option-first">
- <view @tap="navToPage" data-url="/pages/instruction/instruction" class="flex-column my_function">
- <image class="my_icon" src="https://qiniu.bms16.com/FvR8w5KFOBPMbvTPIbQRKIW6IcJj"></image>
- <view class="my_title">新手指引</view>
- </view>
- <view @tap="navToPage" data-url="/pages/platformGuarantee/platformGuarantee"
- class="flex-column my_function">
- <image class="my_icon" src="https://qiniu.bms16.com/FqYXoI_bPXBuxmUZfQCnx9curZn9"></image>
- <view class="my_title">平台保障</view>
- </view>
- <view @tap="navToPage" data-url="/pages/sesameCredit/sesameCredit" class="flex-column my_function">
- <image class="my_icon" src="https://qiniu.bms16.com/FgxiD-W96FGvgyLI_kXUfWVDYLQ9"></image>
- <view class="my_title">芝麻免押</view>
- </view>
- <!-- #ifdef MP-WEIXIN -->
- <view v-if="isSmallMany" @tap="navToCooperate" class="flex-column my_function">
- <image class="my_icon" src="https://qiniu.bms16.com/Fp0yEXByHk5wDoibxJcahqlhAmkT"></image>
- <view class="my_title">加盟合作</view>
- </view>
- <!-- #endif -->
- </view>
- </view>
- </view>
- <CarRentalList :params="getSkipUrlParams()" />
- <!-- #ifdef MP-WEIXIN -->
- <CustomTabbar />
- <!-- #endif -->
- </view>
- </template>
- <script>
- var app = getApp();
- var config = require('../../common/config.js');
- var common = require('../../common/common.js');
- var http = require('../../common/http.js');
- var storage = require('../../common/storage.js');
- import ReservationHireCar from './components/ReservationHireCar/index.vue'
- import CarDemand from './components/CarDemand'
- import {
- QINIU_URL,
- LEASE_TYPE_ARR
- } from '@/common/constant.js'
- import CustomTabbar from '@/component/customTabbar/index';
- import CarRentalList from '../carRental/components/carRentalList.vue'
- import NavBar from './components/NavBar'
- const bus = app.globalData.bus
- export default {
- data() {
- return {
- QINIU_URL,
- LEASE_TYPE_ARR,
- appConfig: {
- app_name: ''
- },
- userInfo: {
- is_auth: 0,
- status: 0
- },
- face_token: '',
- face_key: '',
- carList: [],
- plate_number: '',
- order_status: 0,
- wait_active_predetermine: null,
- exchangInfo: {},
- rentalDurationType: 'short', // 租赁时长类型
- statusBarHeight: 0,
- navabarHeight: 0,
- isShowNavaBar: false,
- isShowCarDemand: false,
- isSmallMany: null, //是否是小众出行的appid
- };
- },
- computed: {
- isRentalShort() {
- return this.rentalDurationType === 'short'
- },
- isRentalLong() {
- return this.rentalDurationType === 'long'
- },
- isLogin() {
- return storage.getUserToken()
- }
- },
- components: {
- ReservationHireCar,
- CarDemand,
- CustomTabbar,
- CarRentalList,
- NavBar
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- const me = this
- setTimeout(() => {
- const appConfig = storage.getAppConfig()
- me.setData({
- appConfig: appConfig
- })
- if(appConfig === null|| appConfig ===''){
- http.getAppConfig(function(resp) {
- me.setData({
- appConfig: resp
- })
- });
- }
- }, 200)
- // #ifdef MP-ALIPAY
- this.isSmallMany = uni.getAccountInfoSync().miniProgram.appId == '2021004109662240'
- // #endif
- // #ifdef MP-WEIXIN
- this.isSmallMany = uni.getAccountInfoSync().miniProgram.appId == 'wx868f4e5130ef2636'
- // #endif
- // const locationStr = uni.getStorageSync('user_current_location');
- // if (locationStr) {
- // this.myLocation = locationStr;
- // }else{
- // }
- var userInfo = storage.getUserInfoData()
- if (userInfo) this.userInfo = userInfo.userInfo
- this.loadLocation()
- //微信扫一扫流程
- this.loadGeneralQRData(options)
- if ('scene' in options) {
- var cabinet_dev_id = ''
- var charge_dev_id = ''
- var socket_dev_id = ''
- if (options.scene.split('devid%3D').length > 1 && !(options.scene.indexOf('type%3Dcg') != -1)) {
- cabinet_dev_id = options.scene.split('devid%3D')[1].split('%26')[0]
- }
- if (options.scene.split('devid%3D').length > 1 && (options.scene.indexOf('type%3Dcg') != -1)) {
- charge_dev_id = options.scene.split('devid%3D')[1].split('%26')[0]
- }
- if (options.scene.split('devid%3D').length > 1 && (options.scene.indexOf('type%3Dcg') != -1)) {
- socket_dev_id = options.scene.split('devid%3D')[1].split('%26')[0]
- }
- if (options.scene.split('devid=').length > 1 && (options.scene.indexOf('type=cg') != -1)) {
- charge_dev_id = options.scene.split('devid=')[1].split('&')[0]
- } else if (options.scene.split('devid=').length > 1 && !(options.scene.indexOf('type=cg') != -1)) {
- cabinet_dev_id = options.scene.split('devid=')[1].split('&')[0]
- }
- if (options.scene.split('devid=').length > 1 && (options.scene.indexOf('type=pl') != -1)) {
- socket_dev_id = options.scene.split('devid=')[1].split('&')[0]
- }
- if (cabinet_dev_id != '') {
- const user_token = storage.getUserToken()
- if (!user_token) {
- this.loadIsLogin()
- } else {
- wx.navigateTo({
- url: '/pages/cabinetDetail/cabinetDetail?dev_id=' + cabinet_dev_id + '&type=' + 2,
- })
- }
- } else if (charge_dev_id != '') {
- const user_token = storage.getUserToken()
- if (!user_token) {
- this.loadIsLogin()
- } else {
- wx.navigateTo({
- url: '/pages/cabinetDetail/cabinetDetail?dev_id=' + charge_dev_id + '&type=' + 2,
- })
- }
- } else if (socket_dev_id != '') {
- const user_token = storage.getUserToken()
- if (!user_token) {
- this.loadIsLogin()
- } else {
- wx.navigateTo({
- url: '/pages/cabinetDetail/cabinetDetail?dev_id=' + socket_dev_id + '&type=' + 2,
- })
- }
- }
- }
- const throttledHandleScroll = this.throttle(this.onPageScroll, 300)
- uni.$on('pageScroll', throttledHandleScroll);
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- // #ifdef MP-ALIPAY
- if (typeof this.$scope.getTabBar === 'function' && this.$scope.getTabBar()) {
- this.$scope.getTabBar().setData({
- curtTab: 0
- })
- }
- bus.on('join', () => {
- this.navToInputPage()
- })
- // #endif
- const token = storage.getUserToken();
- if (!token) return
- this.loadUserInfo()
- this.loadCarList()
- this.loadLocation()
- },
- // 分享给好友
- onShareAppMessage: function(res) { //发送给朋友
- return {
- title: this.appConfig.app_name,
- path: 'pages/index/index',
- }
- },
- onShareTimeline() {
- return {
- title: this.appConfig.app_name + ',便捷又实惠,安全保障更放心!',
- description: this.appConfig.app_name + ',便捷又实惠,安全保障更放心!',
- "imageUrl": this.appConfig.app_logo
- }
- },
- methods: {
- getCustomBarInfo({
- navabarHeight,
- statusBarHeight
- }) {
- this.navabarHeight = navabarHeight
- this.statusBarHeight = statusBarHeight
- },
- getSkipUrlParams() {
- const ref = this.$refs.reservationHireCar
- return ref && ref.getSkipUrlParams && ref.getSkipUrlParams()
- },
- changeLeaseType(val) {
- const {
- type
- } = this.LEASE_TYPE_ARR.find(v => v.value === val)
- this.rentalDurationType = type
- this.$refs.reservationHireCar.duration_unit = val
- },
- updateInfo(data) {
- this.$refs.reservationHireCar.setDataInfo(data)
- const {
- type
- } = this.LEASE_TYPE_ARR.find(v => v.value === data.duration_unit)
- this.rentalDurationType = type
- },
- throttle(fn, delay) {
- let lastCall = 0;
- return function(...args) {
- const now = Date.now();
- if (now - lastCall >= delay) {
- lastCall = now;
- return fn.apply(this, args);
- }
- }
- },
- onPageScroll(e) {
- this.isShowNavaBar = e.scrollTop >= 62
- this.isShowCarDemand = e.scrollTop >= 400
- },
- changeRentalType(rentalDurationType) {
- this.setData({
- rentalDurationType
- })
- },
- /**
- * 获取用户坐标
- */
- loadLocation() {
- const me = this;
- uni.getLocation({
- type: 'gcj02',
- success: function(res) {
- var myLocation = {
- longitude: res.longitude,
- latitude: res.latitude
- }
- uni.setStorageSync('user_current_location', myLocation)
- },
- fail: function(res) {},
- complete: function(res) {}
- });
- },
- loadIsLogin() {
- uni.showModal({
- title: '提示',
- content: '您还未登录,请先登录',
- showCancel: true,
- cancelText: '取消',
- confirmText: '确定',
- success: function(res) {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/login/login',
- })
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- },
- loadGeneralQRData(options) {
- if (('q' in options) || ('result' in options) && (options.result.indexOf("https://zx.uwenya.cc/xcx/s") != -
- 1)) {
- var url = ''
- if ('q' in options) {
- url = decodeURIComponent(options.q);
- }
- if ('result' in options) {
- url = options.result
- }
- var obj = this.getUrlParams(url)
- if (('t' in obj) && ('d' in obj)) {
- if (obj.t == 1 || obj.t == 4) {
- const user_token = storage.getUserToken()
- if (!user_token) {
- this.loadIsLogin()
- } else {
- uni.navigateTo({
- url: '/pages/cabinetDetail/cabinetDetail?dev_id=' + obj.d + '&type=' + obj.t,
- })
- return 101
- }
- }
- if (obj.t == 2) {
- const user_token = storage.getUserToken()
- if (!user_token) {
- this.loadIsLogin()
- } else {
- uni.navigateTo({
- url: '/pages/cabinetDetail/cabinetDetail?dev_id=' + obj.d + '&type=' + 2,
- })
- return 102
- }
- }
- if (obj.t == 5) {
- const user_token = storage.getUserToken()
- if (!user_token) {
- this.loadIsLogin()
- } else {
- uni.navigateTo({
- url: '/pages/cabinetDetail/cabinetDetail?dev_id=' + obj.d + '&type=' + 2,
- })
- return 105
- }
- }
- }
- }
- },
- getUrlParams(url) {
- // 通过 ? 分割获取后面的参数字符串
- let urlStr = url.split('?')[1]
- // 创建空对象存储参数
- let obj = {};
- // 再通过 & 将每一个参数单独分割出来
- let paramsArr = urlStr.split('&')
- for (let i = 0, len = paramsArr.length; i < len; i++) {
- // 再通过 = 将每一个参数分割为 key:value 的形式
- let arr = paramsArr[i].split('=')
- obj[arr[0]] = arr[1];
- }
- return obj
- },
- loadExchangeInfo(plate_number) {
- const time = new Date().getTime()
- // API_CABINET_EXCHANGE_INFO
- http.postApi(config.API_CABINET_EXCHANGE_INFO, {
- license_plate_number: plate_number,
- time
- }, (resp) => {
- if (resp.data.code === 200) {
- this.exchangInfo = resp.data.data
- }
- })
- },
- loadUserInfo() {
- const me = this
- const token = storage.getUserToken();
- if (!token) {
- return;
- }
- const accountInfo = uni.getAccountInfoSync() // 上报小程序账号信息
- http.postApi(config.API_USER_INFO, {
- appid: accountInfo.miniProgram.appId
- }, function(resp) {
- if (resp.data.code === 200) {
- app.globalData.orderSign = resp.data.data.userInfo.order_sign
- app.globalData.orderSignUrl = resp.data.data.userInfo.order_sign_url
- me.userInfo = resp.data.data.userInfo
- storage.setUserInfoData(resp.data.data)
- }
- })
- },
- getLocationFromStorage() {
- const locationStr = uni.getStorageSync('location');
- if (locationStr) {
- this.locationInfo = JSON.parse(locationStr);
- }
- },
- navToPage(e) {
- var url = e.currentTarget.dataset.url;
- const index = e.currentTarget.dataset.index || '';
- if (!url) {
- return;
- }
- if (index === '4') {
- // 我的车辆
- const isReturnIndex = false
- url = url + '?plate_number=' + this.plate_number + '&isReturnIndex=' + isReturnIndex
- }
- uni.navigateTo({
- url: url
- });
- },
- navToExchange(e) {
- const carInfo = e.currentTarget.dataset.car
- const num = (carInfo.gift_exchange_num - carInfo.used_exchange_num) || 0
- const free_num = num > 0 ? num : 0
- uni.navigateTo({
- url: '/pages/exchangeCar/exchangeCar' + '?free_num=' + free_num
- });
- },
- loadCarList() {
- const me = this
- http.postApi(config.API_DAYHIRE_CAR_CAR_LIST, {}, (resp) => {
- if (resp.data.code === 200) {
- me.carList = resp.data.data.data
- me.wait_active_predetermine = resp.data.data.wait_active_predetermine
- const isBuyModel = (me.wait_active_predetermine != null || me.carList.length != 0)
- storage.setIsBuyModel(isBuyModel)
- var car_list = {}
- if (me.carList.length != 0) {
- me.order_status = resp.data.data.data[0].order_status
- me.plate_number = me.carList.length > 0 ? me.carList[0].license_plate_number : ''
- const datetime = Math.floor(new Date().getTime() / 1000);
- // 更新车牌存入本地
- car_list = {
- plate_number: me.plate_number,
- order_status: me.order_status,
- battery_sn: resp.data.data.data[0].battery_sn || '',
- remain: resp.data.data.data[0].hire_expire_time - datetime > 0
- }
- }
- uni.setStorageSync('user_car_list', car_list)
- if (car_list.order_status && (car_list.order_status == 3 || car_list.order_status == 4)) {
- this.loadExchangeInfo(car_list.plate_number)
- }
- } else {
- common.simpleToast(resp.data.msg)
- }
- })
- },
- navToResPage() {
- const me = this
- if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 == 2) {
- if (me.wait_active_predetermine != null) { //预约车辆为待激活状态
- if (me.wait_active_predetermine.order_status == 2) {
- uni.showModal({
- title: '提示',
- content: '您有等待激活的车辆,是否跳转至订单详情页?',
- cancelText: '取消',
- confirmText: '确定',
- success: function(res) {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/orderStatus/orderStatus?order_sn=' + me
- .wait_active_predetermine.order_sn
- });
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- }
- return
- }
- if (me.carList.length == 0) {
- uni.navigateTo({
- url: '/pages/reservationHireCar/reservationHireCar'
- });
- } else {
- // order_status 只有等于 3 、4、5 的时候,才能跳到车辆详情
- if (me.order_status == 3 || me.order_status == 4) { // 车辆状态为未激活
- uni.showModal({
- title: '提示',
- content: '已有正在使用的车辆,是否跳转至车辆详情页?',
- cancelText: '取消',
- confirmText: '确定',
- success: function(res) {
- if (res.confirm) {
- const isReturnIndex = false
- uni.navigateTo({
- url: '/pages/battery/battery?plate_number=' + me.carList[0]
- .license_plate_number + '&isReturnIndex=' +
- isReturnIndex
- });
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- } else if (me.order_status == 5) {
- uni.showModal({
- title: '提示',
- content: '请等待商家确认还车,是否跳转至订单详情页?',
- cancelText: '取消',
- confirmText: '确定',
- success: function(res) {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/orderStatus/orderStatus?order_sn=' + me
- .carList[0].order_sn
- });
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- } else {
- uni.showModal({
- title: '提示',
- content: '已有正在进行的订单,是否跳转至订单详情页?',
- cancelText: '取消',
- confirmText: '确定',
- success: function(res) {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/orderStatus/orderStatus?order_sn=' + me
- .carList[0].order_sn
- });
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- }
- }
- } else if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 != 2) {
- uni.showModal({
- title: '身份认证提示',
- content: '尚未完成身份认证,是否进行身份认证?',
- cancelText: '取消',
- confirmText: '确定',
- success: function(res) {
- if (res.confirm) {
- me.loadFaceToken()
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- } else {
- uni.showModal({
- title: '提示',
- content: '您还未登录,请先登录',
- showCancel: false,
- confirmText: '确定',
- success: function(res) {
- if (res.confirm) {
- //#ifdef MP-ALIPAY
- uni.navigateTo({
- url: '/pages/phoneLogin/phoneLogin',
- })
- //#endif
- //#ifdef MP-WEIXIN
- uni.navigateTo({
- url: '/pages/login/login',
- })
- //#endif
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- }
- },
- _getParams() {
- return new Promise((reslove, reject) => {
- http.postApi(config.API_DAYHIRE_CAR_CAR_LIST, {}, res => {
- const {
- data = [], wait_active_predetermine = null
- } = res.data.data
- const obj = {
- carList: data,
- wait_active_predetermine,
- order_status: data.length ? data[0].order_status : 0
- }
- reslove(obj)
- })
- })
- },
- async navToInputPage() {
- const me = this
- const {
- userInfo = ''
- } = storage.getUserInfoData()
- if (userInfo.is_auth - 0 == 1 && userInfo.status - 0 == 2) {
- const params = await this._getParams()
- if (params.wait_active_predetermine != null) { //预约车辆为待激活状态
- if (params.wait_active_predetermine.order_status == 2) {
- uni.showModal({
- title: '提示',
- content: '您有等待激活的车辆,是否跳转至订单详情页?',
- cancelText: '取消',
- confirmText: '确定',
- success: function(res) {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/orderStatus/orderStatus?order_sn=' +
- params
- .wait_active_predetermine.order_sn
- });
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- }
- return
- }
- if (params.carList.length == 0) {
- const isReturnIndex = false
- uni.navigateTo({
- url: '/pages/scanCar/scanCar',
- // ?isReturnIndex=' + isReturnIndex
- });
- // uni.navigateTo({
- // url: '/pages/inputLicensePlate/inputLicensePlate?isReturnIndex=' + isReturnIndex
- // });
- } else {
- if (params.order_status == 3 || params.order_status == 4) { // 车辆状态为未激活
- uni.showModal({
- title: '提示',
- content: '已有正在使用的车辆,是否跳转至车辆详情页?',
- cancelText: '取消',
- confirmText: '确定',
- success: function(res) {
- if (res.confirm) {
- const isReturnIndex = false
- uni.navigateTo({
- url: '/pages/battery/battery?plate_number=' + params
- .carList[0]
- .license_plate_number + '&isReturnIndex=' +
- isReturnIndex
- });
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- } else if (params.order_status == 5) {
- uni.showModal({
- title: '提示',
- content: '请等待商家确认还车,是否跳转至订单详情页?',
- cancelText: '取消',
- confirmText: '确定',
- success: function(res) {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/orderStatus/orderStatus?order_sn=' +
- params
- .carList[0].order_sn
- });
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- } else {
- uni.showModal({
- title: '提示',
- content: '已有正在进行的订单,是否跳转至订单详情页?',
- cancelText: '取消',
- confirmText: '确定',
- success: function(res) {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/orderStatus/orderStatus?order_sn=' +
- params
- .carList[0].order_sn
- });
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- }
- }
- } else if (userInfo.is_auth == 1 && userInfo.status != 2) {
- uni.showModal({
- title: '身份认证提示',
- content: '尚未完成身份认证,是否进行身份认证?',
- cancelText: '取消',
- confirmText: '确定',
- success: function(res) {
- if (res.confirm) {
- me.loadFaceToken()
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- } else {
- uni.showModal({
- title: '提示',
- content: '您还未登录,请先登录',
- showCancel: false,
- confirmText: '确定',
- success: function(res) {
- if (res.confirm) {
- //#ifdef MP-ALIPAY
- uni.navigateTo({
- url: '/pages/phoneLogin/phoneLogin',
- })
- //#endif
- //#ifdef MP-WEIXIN
- uni.navigateTo({
- url: '/pages/login/login',
- })
- //#endif
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- }
- },
- navToCooperate() {
- const me = this
- if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 == 2) {
- uni.navigateTo({
- url: '/pages/cooperate/cooperate'
- });
- } else if (me.userInfo.is_auth - 0 == 1 && me.userInfo.status - 0 != 2) {
- uni.showModal({
- title: '身份认证提示',
- content: '尚未完成身份认证,是否进行身份认证?',
- cancelText: '取消',
- confirmText: '确定',
- success: function(res) {
- if (res.confirm) {
- me.loadFaceToken()
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- } else {
- uni.showModal({
- title: '提示',
- content: '您还未登录,请先登录',
- showCancel: false,
- confirmText: '确定',
- success: function(res) {
- if (res.confirm) {
- //#ifdef MP-ALIPAY
- uni.navigateTo({
- url: '/pages/phoneLogin/phoneLogin',
- })
- //#endif
- //#ifdef MP-WEIXIN
- uni.navigateTo({
- url: '/pages/login/login',
- })
- //#endif
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- }
- },
- loadFaceToken() {
- const me = this
- http.postApi(config.API_USER_FACE_TOKEN, {}, (resp) => {
- if (resp.data.code === 200) {
- me.face_token = resp.data.data.token
- me.face_key = resp.data.data.key
- uni.navigateTo({
- url: '/pages/livenessView/livenessView?face_token=' + me.face_token +
- '&face_key=' + this.face_key,
- success: function(res) {},
- fail: function(res) {},
- complete: function(res) {},
- })
- } else {
- common.simpleToast(resp.data.msg)
- }
- })
- },
- }
- };
- </script>
- <style>
- @import './index.css';
- </style>
|