|
@@ -0,0 +1,859 @@
|
|
|
+// index.js
|
|
|
+// 获取应用实例
|
|
|
+//获取应用实例
|
|
|
+const app = getApp();
|
|
|
+var token = my.getStorageSync({'key':'token'}).data;
|
|
|
+const util = require('../../utils/utils.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: 520, //用到
|
|
|
+ length: '',
|
|
|
+ swiperCurrent: 0,
|
|
|
+ midbolear: '',
|
|
|
+ per_money: '',
|
|
|
+ img: app.globalData.imgUrl,
|
|
|
+ new_user_coupons: [],
|
|
|
+ scanCodeErr: false,//扫码失败弹框
|
|
|
+ },
|
|
|
+
|
|
|
+ onLoad: function (query) {
|
|
|
+ var that = this;
|
|
|
+ console.log(query)
|
|
|
+ my.setNavigationBar({
|
|
|
+ title: app.globalData.title
|
|
|
+ })
|
|
|
+ // if (query.scene) {
|
|
|
+ // app.globalData.id = query.scene
|
|
|
+ // }
|
|
|
+ this.setData({
|
|
|
+ height1: app.globalData.statusBarHeight,
|
|
|
+ screenHeight: app.globalData.screenHeight
|
|
|
+ })
|
|
|
+ my.getSystemInfo({
|
|
|
+ success: (res) => {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ 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: []
|
|
|
+ })
|
|
|
+ that.location();
|
|
|
+ testToken = setInterval(function () {
|
|
|
+ let token=my.getStorageSync({'key':'token'}).data
|
|
|
+ if (token) {
|
|
|
+ console.log('0000')
|
|
|
+ clearInterval(testToken)
|
|
|
+ that.userState();
|
|
|
+ that.getUser();
|
|
|
+ } else {
|
|
|
+ console.log(token,'1')
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ my.hideBackHome();
|
|
|
+ },
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ 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 != '') {
|
|
|
+ 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)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //点击广告页
|
|
|
+ swiper: util.throttle(function (e) {
|
|
|
+ // console.log(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({
|
|
|
+ phoneNumber: 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
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //定位当前位置
|
|
|
+ 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) {
|
|
|
+ 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, '区域')
|
|
|
+ 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)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ clearInterval(mytime)
|
|
|
+ setTimeout(function () {
|
|
|
+ // that.notice();
|
|
|
+ }, 500)
|
|
|
+ if (res.data.status_code == 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':'setting',data:data.setting})
|
|
|
+ my.setStorageSync({'key':'home',data: data})
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //停车区域
|
|
|
+ ban_stop: function (id) {
|
|
|
+ var that = this;
|
|
|
+ var data1 = {
|
|
|
+ 'area_id': id
|
|
|
+ }
|
|
|
+ app.request('/parking/stop-sites', data1, 'GET').then(res => {
|
|
|
+ console.log(res)
|
|
|
+ if (res.status == 200) {
|
|
|
+ var data = res.data
|
|
|
+ console.log(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 == 0) {
|
|
|
+ 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;
|
|
|
+ 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 && that.data.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) {
|
|
|
+ console.log(res, '扫码结果')
|
|
|
+ var index = res.result.lastIndexOf("\=");
|
|
|
+ var code = res.result.substring(index + 1, res.result.length);
|
|
|
+ console.log(code.length)
|
|
|
+ if (code.length == 9) {
|
|
|
+ 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({
|
|
|
+ phoneNumber: my.getStorageSync({'key':'home'}).data.customer_service_phone,
|
|
|
+ })
|
|
|
+ }, 1500),
|
|
|
+ //用户状态
|
|
|
+ userState: function () {
|
|
|
+ var that = this;
|
|
|
+
|
|
|
+ var data = {
|
|
|
+ 'area_id': that.data.id
|
|
|
+ }
|
|
|
+ app.request("/user/status", data, "GET").then(res => {
|
|
|
+ console.log(res)
|
|
|
+ if (res.status == 200) {
|
|
|
+ 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 () {
|
|
|
+ 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) {
|
|
|
+ console.log(e, 'oooooo')
|
|
|
+ let data = e.currentTarget.dataset.id
|
|
|
+ let that = this
|
|
|
+ var userStatus = that.data.userStatus;
|
|
|
+ console.log(that.data.latitude)
|
|
|
+ if (!that.data.latitude && !that.data.longitude) {
|
|
|
+ that.setData({
|
|
|
+ background: true,
|
|
|
+ location: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ if (data.id == 2) {
|
|
|
+ console.log(that.data.userStatus,'')
|
|
|
+ if (!userStatus) {
|
|
|
+ my.navigateTo({
|
|
|
+ url: '/pages/authorization/authorization',
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ that.jiance1();
|
|
|
+ }
|
|
|
+
|
|
|
+ } 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 == 1) {
|
|
|
+ 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({
|
|
|
+ phoneNumber: 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',
|
|
|
+ })
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|