12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067 |
- // index.js
- // 获取应用实例
- //获取应用实例
- // const log = require('../../utils/log')
- const { getCache, setCache, CacheKeys } = require('../../utils/cache')
- const app = getApp();
- var token = my.getStorageSync({ 'key': 'token' }).data;
- const util = require('../../utils/utils.js');
- //const { content } = require('/utils/dataTransition.js');
- var mytime = null;
- let testToken = ''
- Page({
- data: {
- cardBottom: [
- {
- id: 1,
- name: '故障上报',
- icon: 'icon-banshou',
- url: '/pages/breakdown/breakdown'
- },
- {
- id: 2,
- name: '输码用车',
- icon: 'icon-17-saoma',
- url: '/pages/inputcode/inputcode'
- },
- {
- id: 3,
- name: '计费规则',
- icon: 'icon-wenhao',
- url: '/pages/charge_rule/charge_rule'
- },
- {
- id: 4,
- name: '个人中心',
- icon: 'icon-wode',
- url: '/pages/mine/mine'
- }
- ],
- adFrame: false,//首页中间广告弹框
- markers: [], //显示单车、停车的P
- polygons: [], //区域
- longitude: '', //113.786111
- latitude: '', //34.78304
- height1: '', //兼容自定义导航栏的高度
- id: '', //停车区域的ID
- stopP: false, //判断是否显示停车区域
- polygons1: [], //可骑行区域 先用这个变量代表
- controls: [], //地图上当前定位的箭头
- background: false, //弹窗的背景颜色
- realname: false, //当前是否已经实名
- deposit: false, //当前是否交押金
- userStatus: '', //用户的一些状态 是否交押金等 0
- scanfail: false, //扫码失败弹窗
- is_pay_order: false, //检测当前是否有订单未支付
- is_ride_order: false,//是否有骑行中订单
- is_punishment: false,//有违章订单
- code: '', //点击立即用车 把编号赋值给code
- over: false, //关闭图标
- over1: false, //扫码失败关闭图标
- location: '', //是否有位置权限
- screenHeight: '', //屏幕可视高度
- box_no: '', //中控编号
- abnormal: '', //提示账号异常
- mid: [],//顶部广告
- ads: [],//首页中间广告
- currentSwiper: 0,
- center_currentSwiper: 0,
- bike_no: undefined,
- stopShow: false,
- stop_info: [],
- notice: [], //公告内容
- animationData: {},
- tabbar_index: 0,
- zoom: 18,
- versions: false, //版本过低弹窗
- chooseSize: false,
- animationData1: {},
- arrowDown: '',
- stop_type: '',
- marqueePace: 0.6, //滚动速度
- marqueeDistance: 520, //初始滚动距离 用到
- size: 26, //通知公告用到
- marqueeWidth: 560, //通知公告用到
- length: '',//通知公告
- swiperCurrent: 0,
- midbolear: '',
- per_money: '',
- img: app.globalData.imgUrl,
- new_user_coupons: [],
- scanCodeErr: false,//扫码失败弹框
- isScan: false
- },
- onLoad: function (query) {
- var that = this;
- console.log(my.getStorageSync({ 'key': 'token' }).data, 'yyyyyyyyyyyyyyy')
- my.setNavigationBar({
- title: app.globalData.title
- })
- this.setData({
- height1: app.globalData.statusBarHeight,
- screenHeight: app.globalData.screenHeight
- })
- // this.reloadMap()
- },
- onShow: function () {
- var that = this;
- my.setNavigationBar({
- title: app.globalData.title
- })
- token = my.getStorageSync({ 'key': 'token' }).data
- this.setData({
- show: false,
- midbolear: my.getStorageSync({ 'key': 'midTimes' }).data,
- polygons: []
- })
- if (!this.data.isScan) {
- app.login().then(res => {
- console.log('YYYYYYYYYYYYY')
- that.location()
- that.getUser()
- that.userState()
- })
- }
- that.setData({
- isScan: false
- })
- },
- detail: function () {
- var that = this;
- if (that.data.mid[0].type == 'url') {
- my.navigateTo({
- url: '/' + that.data.mid[0].detail
- })
- }
- },
- //广告列表
- adsList: function (id) {
- var that = this;
- var area_id = ''
- if (id != undefined) {
- area_id = id
- } else {
- area_id = 0
- }
- console.log(id, 'idididid')
- let isCache = getCache('ads:' + id)
- if (isCache) {
- if (isCache == '') return
- if (isCache instanceof Object && isCache.hasOwnProperty('header')) {
-
- that.setData({
- ads: isCache.header
- })
- }
- if (isCache instanceof Object && isCache.hasOwnProperty('mid')) {
- that.setData({
- mid: isCache.mid,
- adFrame: true
- })
- }
- return
- }
- app.request("/ads?area_id=" + area_id + "&position[]=mid&position[]=header&position[]=footer", '', "GET").then(res => {
- console.log(res)
- if (res.status == 200 && res.data != '') {
- setCache('ads:' + id, res.data)
- if (res.data.header) {
- console.log(res.data, 'ppppppppppppppppppppppppp')
- that.setData({
- ads: res.data.header
- })
- }
- if (res.data.mid) {
- that.setData({
- mid: res.data.mid,
- adFrame: true
- })
- }
- }
- }).catch(err => {
- console.log(err)
- })
- },
- reloadMap(classname = 'bottom-bt') {
- // let query = my.createSelectorQuery();
- // let th = this;
- // query.select('.' + classname).boundingClientRect(function (rect) {
- // if (rect != null && rect instanceof Object && rect.hasOwnProperty('height')) {
- // let height = rect.height;
- // th.setData({ mapHeight: 'calc(100vh - ' + height + 'px)' });
- // }
- // }).exec();
- },
- //点击广告页
- swiper: util.throttle(function (e) {
- var type = e.currentTarget.dataset.type;
- var index = e.currentTarget.dataset.index;
- var name = e.currentTarget.dataset.name;
- var detail = e.currentTarget.dataset.detail;
- var id = e.currentTarget.dataset.id;
- if (type != 'clilk_null') {
- if (type == 'wxUrl') {
- my.navigateTo({
- url: '/' + detail,
- })
- } else if (type == 'phone') {
- my.makePhoneCall({
- number: detail,
- })
- } else if (type == 'toMiniProgram') {
- my.navigateToMiniProgram({
- appId: detail,
- extraData: {
- foo: 'bar'
- },
- // envVersion: 'develop',
- success(res) {
- // 打开成功
- }
- })
- } else {
- my.navigateTo({
- url: '../swiper/swiper?type=' + type + '&url=' + id + '&name=' + name + '&detail=' + detail,
- })
- }
- }
- }, 1000),
- //点击轮播图
- swiperChange: function (e) {
- if (this.data.currentSwiper == 0 && this.data.swiperCurrent > 1) { //卡死时,重置current为正确索引
- this.setData({
- currentSwiper: this.data.swiperCurrent
- });
- } else { //正常轮转时,记录正确页码索引
- this.setData({
- swiperCurrent: e.detail.current
- });
- }
- },
- //通知公告
- getNotice(id) {
- let data = {
- 'area_id': id
- }
- let isCache = getCache('Notice:' + id)
- if (isCache) {
- if (isCache instanceof Object && !isCache.hasOwnProperty('id')) return
- this.setData({ notice: isCache })
- var length = isCache.description.length * this.data.size; //计算文字的长度
- this.setData({
- length: length
- })
- if (this.data.length > this.data.marqueeWidth) {
- this.noticeRun();
- } else {
- this.setData({
- marqueeDistance: 0
- })
- }
- return
- }
- app.request("/index/an", data, "GET").then(res => {
- console.log(res)
- if (200 == res.status && res.data.id) {
- setCache('Notice:' + id, res.data)
- this.setData({ notice: res.data })
- var length = res.data.description.length * this.data.size; //计算文字的长度
- this.setData({
- length: length
- })
- if (this.data.length > this.data.marqueeWidth) {
- this.noticeRun();
- } else {
- this.setData({
- marqueeDistance: 0
- })
- }
- }
- }).catch(err => {
- console.log(err)
- })
- },
- noticeRun: function () {
- var that = this;
- mytime = setInterval(function () {
- if (-that.data.marqueeDistance < that.data.length) {
- that.setData({
- marqueeDistance: that.data.marqueeDistance - that.data.marqueePace,
- })
- } else {
- clearInterval(mytime);
- that.setData({
- marqueeDistance: that.data.marqueeWidth
- });
- that.noticeRun();
- }
- }, 10)
- },
- //定位当前位置
- posi: util.throttle(function () {
- //点击定位
- //这是一段注
- var that = this;
- my.showLoading({
- content: '定位中'
- })
- my.getLocation({
- type: 'gcj02',
- success: (res) => {
- console.log('经纬度为:+++++++++++++++++++++' + res.latitude + '++++++++' + res.longitude)
- my.hideLoading()
- that.setData({
- longitude: res.longitude,
- latitude: res.latitude
- })
- },
- fail: function (err) {
- console.log(err, '用户授权失败')
- if (err.error == 11) {
- my.showAuthGuide({
- authType: 'LBS',
- success: (res) => {
- },
- fail: (error) => {
- my.alert({ content: '获取位置授权失败' });
- },
- });
- }
- my.hideLoading()
- my.showToast({
- content: '定位失败',
- icon: 'none'
- })
- }
- // fail: function (err) {
- // my.hideLoading()
- // console.log(err, '定位失败打印')
- // my.showToast({
- // content: '定位失败',
- // icon: 'none'
- // })
- // }
- })
- }, 1000),
- //点击扫描二维码
- sweepCode: util.throttle(function () {
- let that = this
- console.log('点击扫码,‘iooooo')
- if (!that.data.latitude && !that.data.longitude) {
- that.setData({
- background: true,
- location: true
- })
- } else {
- that.sweep_code()
- }
- }, 1500),
- //骑行区禁停区车辆
- home: function () {
- //请求首页接口和一些设置。
- console.log('测试')
- var that = this;
- if (that.data.longitude != '' && that.data.latitude != '') {
- //116.411027
- var data = {
- 'lat': that.data.latitude,
- 'lng': that.data.longitude
- }
- app.request("/pages/home?include=setting", data, "POST").then(res => {
- console.log(res)
- if (res.status == 200) {
- var data = res.data;
- console.log(data, '区域')
- let id = data.id
- this.getNotice(id)
- if (data.points != []) {
- that.setData({
- id: data.id,
- polygons1: that.data.polygons.concat(data),
- setting: data.setting,
- per_money: Number(data.setting.starting_price),
- polygons: []
- })
- if (!data.id) return
- that.adsList(data.id),
- that.ban_stop(data.id), that.setData({
- polygons: that.data.polygons.concat(data)
- })
- }
- if (res.status == 423) {
- my.getLocation({
- success: function (res) {
- my.alert({
- title: '提示',
- content: '您附近暂无运营区域~',
- })
- var setting = {
- is_deposit: 1
- }
- that.setData({
- setting
- })
- },
- fail: function (err) {
- that.setData({
- location: true
- })
- }
- })
- }
- my.setStorageSync({ 'key': 'home', data: data })
- }
- if (data) {
- my.setStorageSync({ 'key': 'setting', data: data.setting })
- } else {
- my.removeStorageSync({ key: 'setting' })
- my.removeStorageSync({ key: 'home' })
- }
- }).catch(err => {
- console.log(err, 'lkkkkk')
- // if (err.data.message == "该附近暂无运营区域") {
- // my.removeStorageSync({ key: 'setting' })
- // my.removeStorageSync({ key: 'home' })
- // }
- my.alert({
- title: '提示',
- content: err.data.message,
- })
- })
- }
- },
- //停车区域
- ban_stop: function (id) {
- var that = this;
- var data1 = {
- 'area_id': id
- }
- let isCache = getCache('BAN_STOP:' + id)
- if (isCache) {
- that.setData({
- markers: that.data.markers.concat(isCache.centres),
- polygons: that.data.polygons1.concat(isCache.polygons),
- })
- return
- }
- app.request('/parking/stop-sites', data1, 'GET').then(res => {
- console.log(res)
- if (res.status == 200) {
- var data = res.data
- setCache('BAN_STOP:' + id, data)
- that.setData({
- polygons2: data.polygons,
- markers: that.data.markers.concat(data.centres),
- polygons: that.data.polygons1.concat(data.polygons)
- })
- }
- })
- },
- //附近车辆坐标
- nearbyCars: function () {
- //附近的车
- var that = this;
- that.setData({
- markers: []
- })
- var data = {
- "lat": that.data.latitude,
- "lng": that.data.longitude
- }
- app.request("/bikes", data, "POST").then(res => {
- // console.log(res)
- if (res.status == 200) {
- var makers = res.data
- if (makers == '') {
- my.showToast({
- content: '附近暂无车辆',
- icon: 'none'
- })
- that.setData({
- markers: []
- })
- } else {
- that.setData({
- markers: makers
- })
- }
- }
- }).catch(err => {
- console.log(err)
- })
- },
- //点击刷新
- refresh: util.throttle(function () {
- var that = this;
- that.setData({
- polygons: []
- })
- if (this.data.stopP == true) {
- that.stopP(), my.showToast({
- content: '刷新成功',
- icon: 'none'
- })
- } else {
- this.location(),
- my.showToast({
- content: '刷新成功',
- icon: 'none'
- })
- }
- }, 1500),
- // //点击去实名认证
- authentication: util.throttle(function () {
- var state = my.getStorageSync({ 'key': 'userState' }).data
- if (state.is_bind_mobile == 1) {
- my.navigateTo({
- url: '/pages/real_name/real_name?state1=1&index=0',
- })
- } else if (state.is_bind_mobile == 1) {
- my.navigateTo({
- url: '/pages/real_name/real_name?state2=2&index=1',
- })
- }
- this.setData({
- background: false,
- realname: false,
- over: false
- })
- }, 1500),
- //点击扫码开锁
- sweep_code: util.throttle(function () {
- var that = this;
- console.log('ooooooo')
- var userStatus = that.data.userStatus;
- var setting = my.getStorageSync({ 'key': 'setting' }).data
- if (!setting) {
- my.alert({
- title: '提示',
- content: '您附近暂无运营区,暂不可用车'
- })
- } else {
- if (!userStatus) {
- my.navigateTo({
- url: '/pages/authorization/authorization',
- })
- }
- else {
- that.jiance('scan');
- }
- }
- }, 1500),
- //扫码用车检测不可用车条件
- jiance: function (source) {
- var that = this;
- var userStatus = that.data.userStatus;
- var setting = my.getStorageSync({ 'key': 'setting' }).data
- //未绑定手机号
- if (userStatus.is_bind_mobile == 0) {
- my.navigateTo({
- url: '/pages/authorization/authorization',
- })
- //未实名认证
- } else if (userStatus.is_card_certified == 0 && setting.is_card == 1) {
- my.navigateTo({
- url: '/pages/real_name/real_name',
- })
- } else {
- //有违章订单
- if (userStatus.is_punishment) {
- my.showToast({
- content: '您当前有违章订单需要处理,请处理后再来用车吧',
- icon: 'none'
- })
- return;
- } else if (userStatus.is_ride_order != false && userStatus.is_ride_order != undefined) {
- my.showToast({
- content: '您有一个正在骑行中的订单',
- icon: 'none'
- })
- return;
- } else {
- //有待支付骑行订单
- if (userStatus.is_pay_order != false && userStatus.is_pay_order != undefined) {
- my.showToast({
- content: '你有未支付订单,请先支付',
- icon: 'none'
- })
- return;
- } else {
- //没有押金没有免押券
- if (userStatus.is_deposit == 0 && setting.is_deposit != 0 && userStatus.is_coupon_deposit_free == false) {
- console.log('没有押金没有免押券')
- my.navigateTo({
- url: '/pages/ride_zige/ride_zige',
- })
- // my.navigateTo({
- // url: '/pages/inputcode/inputcode',
- // })
- } else {
- that.saoMa()
- }
- }
- }
- }
- },
- //扫码事件
- saoMa: function () {
- let that = this
- this.setData({
- scanCodeErr: false
- })
- my.scan({
- onlyFromCamera: true,
- success: function (res) {
- let scanLength = app.globalData.scanLength
- console.log(res, '扫码结果')
- var index = res.code.lastIndexOf("\=");
- console.log(index, '----------')
- var code = res.code.substring(index + 1, res.code.length);
- console.log(code)
- console.log(app.globalData)
- if (code.length == scanLength) {
- that.getBikeMessage(code)
- // my.navigateTo({
- // url: '/pages/use_bike/use_bike?code=' + code,
- // })
- } else {
- console.log(res, '错误码')
- // my.showModal({
- // title:'提示',
- // content:'非法码,请核对车码',
- // showCancel:false
- // })
- that.setData({
- scanCodeErr: true
- })
- }
- },
- fail: function (err) {
- console.log('tuihui')
- // that.setData({
- // scanCodeErr: true
- // })
- }
- })
- },
- //获取车辆信息
- getBikeMessage: function (code) {
- var that = this;
- app.request('/bike/' + code, '', 'GET').then(res => {
- console.log(res, '车辆信息--------------------')
- my.hideLoading()
- 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 {
- my.reLaunch({
- url: '/pages/use_bike/use_bike?code=' + code,
- })
- }
- } else {
- my.alert({
- title: '提示',
- content: res.data.message,
- })
- }
- })
- },
- //去支付未支付订单
- go_pay: util.throttle(function () {
- //点击去支付
- this.setData({
- is_pay_order: false,
- })
- var pay_order = ''
- if (this.data.userStatus.is_pay_order !== false && this.data.userStatus.is_pay_order !== undefined) {
- pay_order = this.data.userStatus.is_pay_order
- }
- my.navigateTo({
- url: '/pages/pay/pay?order=' + pay_order,
- })
- }, 1500),
- //点击查看正在进行中的订单
- goUseBike: function () {
- console.log(this.data.is_ride_order, 'this.data.is_ride_order')
- my.navigateTo({
- url: '/pages/use_bike/use_bike?order=' + this.data.is_ride_order,
- })
- },
- //有违章订单
- havePunishment: function () {
- my.navigateTo({
- url: '/pages/weizhang/weizhang',
- })
- },
- onReady: function () {
- },
- kefu: util.throttle(function () {
- my.makePhoneCall({
- number: my.getStorageSync({ 'key': 'home' }).data.customer_service_phone,
- })
- }, 1500),
- //用户状态
- userState: function (id) {
- var that = this;
- app.request("/user/status", "GET").then(res => {
- console.log(res)
- if (res.status == 200) {
- console.log(res, 'XYYING================')
- that.setData({
- userStatus: res.data,
- is_pay_order: res.data.is_pay_order,
- is_ride_order: res.data.is_ride_order,
- is_punishment: res.data.is_punishment,
- }), my.setStorageSync({ 'key': 'userState', data: res.data })
- }
- }).catch(err => {
- console.log(err)
- })
- },
- getUser() {
- app.request("/me", '', "GET").then(res => {
- console.log(res)
- 200 == res.status && my.setStorageSync({ 'key': 'userInfo', data: res.data })
- }).catch(err => {
- console.log(err)
- })
- },
- go_setting: util.throttle(function () {
- //点击去设置位置权限
- this.setData({
- background: false,
- location: false
- })
- my.openSetting({
- success: function (res) {
- }
- })
- }, 1500),
- //点击已开启位置权限
- open: util.throttle(function () {
- this.setData({
- background: false,
- location: false
- })
- }, 1500),
- location: function () {
- //获取当前经纬度 如果未授权让用户去授权
- console.log('dingwei')
- var that = this;
- my.showLoading({
- content: '定位中...',
- mask: true
- })
- my.getLocation({
- type: 'gcj02',
- success: (res) => {
- console.log('经纬度为:+++++++++++++++++++++' + res.latitude + '++++++++' + res.longitude)
- that.setData({
- longitude: res.longitude,
- latitude: res.latitude,
- show: false
- })
- console.log(res, 'ppp')
- that.home(), that.nearbyCars()
- if (that.data.stopP == false) {
- console.log('false')
- } else {
- that.stop()
- }
- my.hideLoading()
- },
- fail: function (err) {
- console.log(err, '用户授权失败')
- if (err.error == 11) {
- my.showAuthGuide({
- authType: 'LBS',
- success: (res) => {
- },
- fail: (error) => {
- my.alert({ content: '获取位置授权失败' });
- },
- });
- }
- my.hideLoading()
- my.getSetting({
- success: function (res) {
- // console.log(res)
- var statu = res.authSetting;
- if (statu['scope.userLocation'] == false) {
- that.setData({
- background: true,
- location: true
- })
- }
- }
- })
- }
- })
- },
- //底部跳转页面按钮(用户未授权和未实名认证的时候不可以跳转)
- skipPage: function (e) {
- let data = e.target.dataset.id
- let that = this
- console.log(that.data, 'oooooo')
- var userStatus = that.data.userStatus;
- var setting = my.getStorageSync({ 'key': 'setting' }).data
- if (data.id == 2 && !that.data.latitude && !that.data.longitude) {
- that.setData({
- background: true,
- location: true
- })
- return
- }
- if (data.id == 2 && !setting) {
- my.alert({
- title: '提示',
- content: '您附近暂无运营区,暂不可用车'
- })
- return
- }
- if (data.id == 2 && setting) {
- if (!userStatus) {
- my.navigateTo({
- url: '/pages/authorization/authorization',
- })
- }
- else {
- that.jiance1();
- }
- } else {
- my.navigateTo({
- url: data.url,
- })
- }
- // if (!that.data.latitude && !that.data.longitude) {
- // that.setData({
- // background: true,
- // location: true
- // })
- // } else {
- // if (data.id == 2) {
- // console.log(that.data.userStatus, '')
- // if (!setting) {
- // my.alert({
- // title: '提示',
- // content: '您附近暂无运营区,暂不可用车'
- // })
- // }
- // else {
- // if (!userStatus) {
- // my.navigateTo({
- // url: '/pages/authorization/authorization',
- // })
- // }
- // else {
- // that.jiance1();
- // }
- // }
- // } else if (data.id == 4) {
- // if (userStatus.is_bind_mobile == 0) {
- // my.navigateTo({
- // url: '/pages/authorization/authorization',
- // })
- // } else {
- // my.navigateTo({
- // url: data.url,
- // })
- // }
- // }
- // else {
- // if (!userStatus) {
- // my.navigateTo({
- // url: '/pages/authorization/authorization',
- // })
- // } else {
- // my.navigateTo({
- // url: data.url,
- // })
- // }
- // }
- // }
- },
- //输码开锁检测
- jiance1: function (source) {
- var that = this;
- let setting = my.getStorageSync({ 'key': 'setting' }).data
- var userStatus = that.data.userStatus;
- //未绑定手机号
- if (userStatus.is_bind_mobile == 0) {
- my.navigateTo({
- url: '/pages/authorization/authorization',
- })
- //未实名认证
- } else if (userStatus.is_card_certified == 0 && setting.is_card == 1) {
- my.navigateTo({
- url: '/pages/real_name/real_name',
- })
- } else {
- //有违章订单
- if (that.data.userStatus.is_punishment) {
- my.showToast({
- content: '您当前有违章订单需要处理,请处理后再来用车吧',
- icon: 'none'
- })
- return;
- } else if (userStatus.is_ride_order != false && userStatus.is_ride_order != undefined) {
- my.showToast({
- content: '您有一个正在骑行中的订单',
- icon: 'none'
- })
- return;
- }
- else {
- //有待支付骑行订单
- if (userStatus.is_pay_order != false && userStatus.is_pay_order != undefined) {
- my.showToast({
- content: '你有未支付订单,请先支付',
- icon: 'none'
- })
- return;
- } else {
- //没有押金没有免押券
- if (userStatus.is_deposit == 0 && that.data.setting.is_deposit != 0 && userStatus.is_coupon_deposit_free == false) {
- console.log('没有押金没有免押券')
- my.navigateTo({
- url: '/pages/ride_zige/ride_zige',
- })
- } else {
- my.navigateTo({
- url: '/pages/inputcode/inputcode',
- })
- }
- }
- }
- }
- },
- // 客服
- kefu: function () {
- my.makePhoneCall({
- number: my.getStorageSync({ 'key': 'home' }).data.customer_service_phone,
- })
- },
- //附近还车点
- findPark: function () {
- my.navigateTo({
- url: '/pages/parking/parking',
- })
- },
- //关闭中间广告弹框
- closeAdframe: function () {
- this.setData({
- adFrame: false
- })
- },
- onHide: function () {
- console.log('onHide')
- this.setData({
- bike_no: undefined,
- background: false,
- bluetooth: false,
- location: false,
- scanfail: false,
- over1: false
- })
- clearInterval(mytime)
- },
- // 去输码弹框
- cancelErrFrame: function () {
- this.setData({
- scanCodeErr: false
- })
- },
- goInputCode: function () {
- my.navigateTo({
- url: '/pages/inputcode/inputcode',
- })
- },
- })
|