123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614 |
- var app = getApp()
- import {
- BluetoothManager,
- CMD
- } from '../../service/BluWkm'
- const bluM = new BluetoothManager;
- const util = require('../../utils/utils.js');
- var interval;
- Page({
- data: {
- useBikeTip: true,
- code: '',
- arr: [],
- screenHeight: '',
- show: false,
- popShow: false,
- time: 5,
- tapShow: false,
- setting: wx.getStorageSync('setting'),
- footer: [],
- chooseSize: false,
- mid: [],
- animationData: {},
- chooseSize: false,
- animationData1: {},
- arrowDown: '',
- midbolear: '',
- img:app.globalData.imgUrl,
- deposit:false,
- realname:false,
- background:false,
- over:false,
- userStatus:''
- },
- authentication: util.throttle(function () {
-
- var state = wx.getStorageSync('userState')
- if (state.is_bind_mobile == 0) {
- wx.navigateTo({
- url: '/pages/real_name/real_name?state1=1&index=0',
- })
- } else if (state.is_bind_mobile == 1) {
- wx.navigateTo({
- url: '/pages/real_name/real_name?state2=2&index=1',
- })
- }
-
- this.setData({
- background: false,
- realname: false,
- over: false
- })
- }, 1500),
- deposit: util.throttle(function () {
-
- this.setData({
- background: false,
- deposit: false,
- over: false
- })
- wx.navigateTo({
- url: '/pages/personal/deposit/deposit?home=index',
- })
- }, 1500),
- chooseSezi: function (e) {
-
- var that = this;
-
- var animation = wx.createAnimation({
-
- duration: 600,
-
- timingFunction: 'linear'
- })
-
- that.animation = animation
-
- animation.translateY(300).step()
-
- that.setData({
-
- animationData1: animation.export(),
-
- chooseSize: true
- })
-
- setTimeout(function () {
- animation.translateY(0).step()
- that.setData({
- animationData1: animation.export()
- })
- }, 100)
- var query = wx.createSelectorQuery();
- query.select('.choose').boundingClientRect();
- query.exec(function (res) {
- console.log(res)
- that.setData({
- arrowDown: res[0].height + 15
- })
- })
- },
- hideModal: function (e) {
- var that = this;
- var animation = wx.createAnimation({
- duration: 800,
- timingFunction: 'linear'
- })
- that.animation = animation
- animation.translateY(300).step()
- that.setData({
- animationData1: animation.export()
- })
- setTimeout(function () {
- animation.translateY(0).step()
- that.setData({
- animationData1: animation.export(),
- chooseSize: false
- })
- }, 700)
- },
- ads: function () {
- var that = this;
- var area_id = ''
- if (wx.getStorageSync('home').id != undefined) {
- area_id = wx.getStorageSync('home').id
- } else {
- area_id = 0
- }
-
-
-
-
- app.request("/ads?area_id=" + area_id + "&position[]=mid&position[]=header&position[]=footer", '', "GET").then(res => {
-
- if (res.statusCode == 200) {
- that.setData({
- ads: res.data.header
- })
- if (res.data.mid == undefined || res.data.mid == 'undefined') {
- } else {
- that.setData({
- mid: res.data.mid
- })
- }
- if (res.data.footer == undefined || res.data.footer == 'undefined') {
- } else {
- that.setData({
- footer: res.data.footer
- })
- }
- }
- }).catch(err => {
- console.log(err)
- })
- },
- onLoad: function (options) {
-
- console.log(options)
- var that = this;
- var state = wx.getStorageSync('userState')
- if(state.is_new_user==1){
-
- that.setData({
- useBikeTip:false
- })
- console.log(that.data.useBikeTip)
- }else{
- that.setData({
- useBikeTip:true
- })
- }
- wx.showLoading({
- title: '加载中...',
- mask: true
- })
- if (wx.getStorageSync('popShow') != true) {
- that.setData({
- popShow: true
- })
- } else {
- that.setData({
- popShow: false
- })
- }
- interval = setInterval(function () {
- var time = that.data.time - 1;
- that.setData({
- time
- })
- if (time <= 0) {
- clearInterval(interval)
- that.setData({
- tapShow: true
- })
- }
- }, 1000)
- this.setData({
- screenHeight: app.globalData.screenHeight
- })
- app.request('/bike/' + options.code, '', 'GET').then(res => {
- console.log(res)
- 200 == res.statusCode && that.setData({
- arr: res.data
- }), wx.hideLoading()
- if (res.statusCode == 200) {
- if (res.data.is_link == 0) {
- wx.showModal({
- title: '提示',
- content: '当前车子已下线请换辆车子骑行吧~',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- wx.navigateBack()
- }
- }
- })
- return;
- } else if (res.data.put_status == 0) {
- wx.showModal({
- title: '提示',
- content: '当前车子还未投放请换辆车子骑行吧~',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- wx.navigateBack()
- }
- }
- })
- return;
- } else if (res.data.is_low_battery_power == 0) {
- wx.showModal({
- title: '提示',
- content: '当前车子电量过低请换辆车子骑行吧~',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- wx.navigateBack()
- }
- }
- })
- return;
- } else if (res.data.is_trouble == 1) {
- wx.showModal({
- title: '提示',
- content: '当前车子出现故障请换辆车子骑行吧~',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- wx.navigateBack()
- }
- }
- })
- return;
- } else if (res.data.is_riding == 1) {
- wx.showModal({
- title: '提示',
- content: '当前车子正在骑行请换辆车子骑行吧~',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- wx.navigateBack()
- }
- }
- })
- return;
- } else {
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }
- })
- that.setData({
- code: options.code
- })
- setTimeout(() => {
- that.ads();
- }, 500);
- },
- rules: function () {
- wx.navigateTo({
- url: "/pages/accounting_rules/accounting_rules",
- })
- },
- view_area: function () {
- wx.navigateTo({
- url: '/pages/navigation/navigation',
- })
- },
- closePop() {
- this.setData({
- popShow: false,
- })
- wx.setStorageSync('popShow', true)
- },
- repair: util.throttle(function () {
- wx.navigateTo({
- url: '../repair/repair?bike_id=' + this.data.code
- })
- }, 1000),
- openBike() {
- var that = this;
- wx.showLoading({
- title: '开锁中...',
- mask: true
- })
- wx.getLocation({
- type: 'gcj02',
- success: function (res) {
- console.log(res)
- var data = {
- bike_no: that.data.code,
- lat: res.latitude,
- lng: res.longitude,
- area_id: wx.getStorageSync('home').id,
- }
- bluM.connectDeivece(that.data.arr.box_no, CMD.unlock)
- app.request('/bike/open-lock', data, 'POST', app.globalData.req).then(res => {
- console.log(res)
- if (res.statusCode == 200) {
- wx.reLaunch({
- url: '../riding/riding?order=' + res.data.no + '&code=' + that.data.code + '&box_no=' + that.data.arr.box_no + '&time=true',
- })
- wx.hideLoading()
- }
- })
- },
- })
- },
- think:function () {
-
- this.setData({
- background: false,
- deposit: false,
- over: false
- })
- },
- start: util.throttle(function () {
- var that = this;
- that.jiance()
- if(that.data.deposit==true) return;
- wx.getLocation({
- success: function (res) {
- wx.requestSubscribeMessage({
- tmplIds: ['CBp8jWZHVOQBIB7_n4EHuDv3ik12gOvlaXsOG2U0dPc', 'rV85SkGp7Q508xXz45ycQw8nTN_2VEB7m_GhR-WrCDY'],
- success(res) {
- console.log(res)
- },
- fail: function (err) {
- console.log(err)
- },
- complete: function () {
-
- }
- })
- },
- fail: function (err) {
- wx.showModal({
- title: '提示',
- content: '请打开位置权限~',
- cancelText: "去设置",
- confirmText: "已打开",
- success: function (resp) {
- if (resp.cancel) {
- wx.openSetting({
- success: function (res) {
-
-
- }
- })
- }
- }
- })
- }
- })
- }, 1000),
- rent_start: function () {
- this.setData({
- show: true
- })
- },
- over: function () {
-
- this.setData({
- realname: false,
- background: false,
- scanfail: false,
- over: false,
- })
- },
- jiance:function(){
- var userStatus = this.data.userStatus;
- var setting = wx.getStorageSync('setting');
- console.log(userStatus)
- console.log(setting)
- var that = this;
- if (setting.is_card == 1) {
- if (userStatus.is_card_certified == 0) {
- that.setData({
- realname: true,
- background: true,
- over: true
- })
- return;
- }
- }
- if (userStatus.is_bind_mobile == 0) {
- wx.showModal({
- title: '提示',
- content: '您还未绑定手机号,去绑定?',
- success: function (res) {
- if (res.confirm) {
- wx.navigateTo({
- url: '/pages/real_name/real_name?state1=1&index=0',
- })
- }
- }
- })
- return;
- }
- if (userStatus.is_deposit == 0 && setting.is_deposit != 0 && userStatus.is_coupon_deposit_free == false) {
- console.log('else===>else===>else if')
- that.setData({
- deposit: true,
- background: true
- })
- return;
- }else{
- this.openBike()
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- rent_startBike() {
- var that = this;
- if(that.data.deposit==true) return;
- wx.getLocation({
- success: function (res) {
- console.log(res)
- if (app.globalData.req) {
- var data = {
- 'type': 'D',
- 'bike_no': that.data.code,
- 'area_id': wx.getStorageSync('home').id,
- 'lat': res.latitude,
- 'lng': res.longitude
- }
- app.request('/rent/store-order', data, 'POST', app.globalData.req).then(res => {
- console.log(res)
- if (res.statusCode == 200) {
- console.log(res.data.nonceStr == undefined)
- if (res.data.nonceStr == undefined) {
- wx.reLaunch({
- url: '/pages/daily_riding/daily_riding?order=' + res.data.no,
- })
- } else {
- wx.reLaunch({
- url: '/pages/daily_riding/daily_riding?order=' + res.data.no,
- })
- }
- }
- })
- } else {
- wx.showToast({
- title: '您的操作过于频繁,请稍后再试~',
- icon: 'none'
- })
- }
- },
- })
- },
- btn: util.throttle(function () {
- var that = this;
-
- wx.getLocation({
- success: function (res) {
- wx.requestSubscribeMessage({
- tmplIds: ['ahWdpxZJ48d3K9ZxnrNvXLvx7NEI2j-Ckp5LODNlYNU', 'N7etCOUMjvsyGxx0JroDfMwEmi8daKC20czG6aqkpPc'],
- success(res) {
- console.log(res)
- },
- fail: function (err) {
- console.log(err)
- },
- complete: function () {
- that.rent_startBike()
- }
- })
- },
- fail: function (err) {
- wx.showModal({
- title: '提示',
- content: '请打开位置权限~',
- cancelText: "去设置",
- confirmText: "已打开",
- success: function (resp) {
- if (resp.cancel) {
- wx.openSetting({
- success: function (res) {
-
-
- }
- })
- }
- }
- })
- }
- })
- }, 1000),
- over: function () {
- this.setData({
- show: false
- })
- },
- iKnow: function (e) {
- console.log(e)
- this.setData({
- useBikeTip: true
- })
- console.log(this.data.useBikeTip)
- },
- onReady: function () {
- },
- onShow: function () {
- this.setData({
- setting: wx.getStorageSync('setting')
- })
- var data = {
- 'area_id': wx.getStorageSync('mead_area_id')
- }
- app.request("/user/status", data, "GET").then(res=>{
- console.log(res)
- this.setData({userStatus:res.data})
- wx.setStorageSync('userState', res.data)
- })
- },
- onHide: function () {
- clearInterval(interval)
- this.setData({
- time: 5
- })
- },
- onUnload: function () {
- clearInterval(interval)
- this.setData({
- time: 5
- })
- },
-
-
- agree(e) {
- wx.getLocation({
- type: 'gcj02',
- success: (res) => {
- console.log('经纬度为:+++++++++++++++++++++' + res.latitude + '++++++++' + res.longitude)
- var latitude = res.latitude
- var longitude = res.longitude
- that.setData({
- longitude: longitude,
- latitude: latitude
- })
- },
- fail: function (err) {
- console.log(err)
- }
- })
- },
-
- disagree(e) {
- console.log("用户拒绝隐私授权, 未同意过的隐私协议中的接口将不能调用")
-
- },
- onPullDownRefresh: function () {
- },
- onReachBottom: function () {
- },
- onShareAppMessage: function () {
- }
- })
|