// pages/scancode/scancode.js var app = getApp(); const util = require('../../utils/utils.js') Page({ data: { inputLen: 9, isFocus: true, code: '', submitState: 0,//未输入车辆编号 }, onFocus: function (e) { let that=this console.log(e, 'pppp') that.setData({ code: e.detail.value }); if (that.data.code.length == 9) { that.setData({ submitState: 1 }); } }, // setValue: function (e) { // var that = this; // that.setData({ // code: e.detail.value // }); // if (that.data.code.length == 9) { // that.setData({ // submitState: 1 // }); // } // }, sureSubmit: util.throttle(function () { my.showLoading() var that = this; if (that.data.code != '') { that.getBikeMessage() } else { my.showToast({ content: '请输入车牌号', icon: 'none', duration: 2000 }) } }, 1500), //获取车辆信息 getBikeMessage: function () { var that = this; my.hideLoading() app.request('/bike/' + that.data.code, '', 'GET').then(res => { if (res.status == 200) { if (res.data.is_link == 0) { my.alert({ title: '提示', content: '当前车子已下线请换辆车子骑行吧~', success: function (res) { my.reLaunch({ url: '/pages/index/index', }) } }) return; } else if (res.data.put_status == 0) { my.alert({ title: '提示', content: '当前车子还未投放请换辆车子骑行吧~', }) return; } else if (res.data.is_low_battery_power == 0) { my.alert({ title: '提示', content: '当前车子电量过低请换辆车子骑行吧~', }) return; } else if (res.data.is_trouble == 1) { my.alert({ title: '提示', content: '当前车子出现故障请换辆车子骑行吧~', }) return; } else if (res.data.is_riding == 1) { my.alert({ title: '提示', content: '当前车子正在骑行请换辆车子骑行吧~', }) return; } else { console.log(that.data.code, 'that.data.code') my.reLaunch({ url: '/pages/use_bike/use_bike?code=' + that.data.code, }) } } else { my.alert({ title: '提示', content: res.data.message, }) } }).catch(err=>{ console.log(err,'找不到车12121') }) }, onLoad: function (options) { }, onReady: function () { }, onShow: function () { }, onHide: function () { }, onUnload: function () { }, onPullDownRefresh: function () { }, onReachBottom: function () { }, onShareAppMessage: function () { } })