123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- var initNum = 7;
- var spaceNum = 1000;
- var space = 1000;
- var begin = -(1 / 2 * Math.PI);
- var pai2 = 2 * Math.PI;
- var app = getApp();
- import {
- BluetoothManager,
- BtErrorCode,
- CMD
- } from '../../service/BluWkm'
- const bluM = new BluetoothManager;
- const util = require('../../utils/utils.js')
- Page({
- data: {
- progress_txt: 60,
- count:0,
- countTimer: null,
- money:[],
- request_data:[],
- notice:false,
- order:'',
- screenHeight:''
- },
- closeLock: function (data) {
- var that = this;
- bluM.connectDeivece(that.data.box_no,CMD.lock)
- app.request('/bike/close-lock', data, 'POST').then(res => {
- console.log(res)
- if (res.statusCode == 200) {
- wx.reLaunch({
- url: '../payment/payment?order=' + res.data.no
- })
- } else if (res.statusCode == 450) {
-
- }
- }).catch(err => {
- console.log(err)
- })
- },
- rent_closeLock: function(data) {
- var that = this;
- bluM.connectDeivece(that.data.box_no,CMD.lock)
- app.request('/rent/close-order', data, 'POST').then(res => {
- console.log(res)
- if (res.statusCode == 200) {
- wx.reLaunch({
- url: '../payment/payment?order=' + res.data.no + '&rent=rent'
- })
- } else if (res.statusCode == 450) {
- that.coundDown()
- }
- }).catch(err => {
- console.log(err)
- })
- },
- onLoad: function (options) {
- console.log(options)
- wx.setNavigationBarTitle({
- title: app.globalData.title
- })
- this.setData({
- screenHeight: app.globalData.screenHeight
- })
- wx.showLoading({
- title: '加载中...'
- })
- var data = {
- bike_no: options.bike_no,
- order_no: options.order_no,
- lat: options.lat,
- lng: options.lng
- }
- this.setData({request_data:data,order:options.order})
- if(options.order=='order'){
- app.request('/order/expect-order-money', data, 'POST').then(res => {
- console.log(res)
- if (res.statusCode == 200) {
- wx.hideLoading()
- this.setData({money:res.data})
- }
- })
- }else{
- app.request('/rent/expect-rent-order-money', data, 'POST').then(res => {
- console.log(res)
- if (res.statusCode == 200) {
- wx.hideLoading()
- this.setData({money:res.data})
- }
- })
- }
- },
- notice:function(){
- this.setData({notice:true})
- },
- notice_false:function(){
- this.setData({notice:false})
- },
- kefu:function(){
- wx.makePhoneCall({
- phoneNumber: wx.getStorageSync('home').customer_service_phone,
- })
- },
- close_bike:function(){
- if(this.data.order=='rent'){
- console.log('rent')
- this.rent_closeLock(this.data.request_data)
- }else{
- this.closeLock(this.data.request_data)
- }
- },
- onReady: function () {
- this.drawCircle(60 / (60/2))
- this.drawProgressbg();
- this.countInterval()
- },
- drawProgressbg: function(){
-
- var ctx = wx.createCanvasContext('canvasProgressbg')
- ctx.setLineWidth(6);
- ctx.setStrokeStyle('#cccccc');
- ctx.setLineCap('round')
- ctx.beginPath();
- ctx.arc(55, 55, 50, -Math.PI / 2, 60, false);
-
- ctx.stroke();
- ctx.draw();
- },
- drawCircle: function (step){
- var context = wx.createCanvasContext('canvasProgress');
-
- var gradient = context.createLinearGradient(100, 50, 50, 100);
- context.setStrokeStyle("#F95A29");
-
- context.setLineWidth(6);
-
- context.setLineCap('round')
- context.beginPath();
-
- context.arc(55, 55, 50, -Math.PI / 2, step * Math.PI - Math.PI / 2, false);
- context.stroke();
- context.draw()
-
- },
- countInterval: function () {
-
- this.countTimer = setInterval(() => {
- if (this.data.count <= 60) {
-
- var time = this.data.progress_txt-1
- this.drawCircle(time / (60/2))
- this.data.count++;
- if(time<=0){
- clearInterval(this.countTimer);
- time = 0;
- wx.navigateBack()
- }
- this.setData({
- progress_txt: time
- });
- } else {
- clearInterval(this.countTimer);
- }
- }, 1000)
- },
- parkTip: function () {
- wx.navigateTo({
- url: '/pages/navigation/navigation',
- })
- },
- continue:function(){
- clearInterval(this.countTimer);
- wx.navigateBack()
- },
- onShow: function () {
- },
- onHide: function () {
-
- },
- onUnload: function () {
- clearInterval(this.countTimer);
- },
- onPullDownRefresh: function () {
- },
- onReachBottom: function () {
- },
- onShareAppMessage: function () {
- }
- })
|