var app = getApp() var url = '' import { BluetoothManager, BtErrorCode } from '../../service/BlueMgr' var intervar; const bluM = new BluetoothManager Page({ data: { order: '', date: [], balance: '', //当前余额 bolear: '', //判断当前余额够不够本次消费 够为true 不够为false check1: '', check2: '', index: '', //记录当前选择的是余额还是微信支付 disable: false, timing: '', rent: '', screenHeight: '', code: '', chooseSize: false, animationData1: {}, couponIndex: 0, coupon_user_bags_id: 0, coupon: [], payment_type: false, notice:false, setting: wx.getStorageSync('setting') }, catchtouchmove:function(){ return; }, tap_coupon: function (e) { this.setData({ couponIndex: e.currentTarget.dataset.index }) }, payment_type: function () { this.setData({ payment_type: true }) }, cancel: function () { console.log(this.data.index) this.setData({ index: this.data.index, payment_type: false }) if(this.data.index==2){ this.setData({check1:true,check2:false}) } if(this.data.index==1){ this.setData({check2:true,check1:false}) } }, queding: function () { console.log(this.data.check2) console.log(this.data.check1) console.log(this.data.index) if(this.data.check1){ //判断当前是不是余额支付 this.setData({ check1: true, check2: false, index: 2, }) }else{ this.setData({ check1: false, check2: true, index: 1, }) } this.setData({ payment_type: false }) }, to_recharge:function(){ // console.log('去充值') wx.navigateTo({ url: '/pages/personal/recharge/recharge', }) }, notice:function(){ this.setData({notice:true}) }, notice_false:function(){ this.setData({notice:false}) }, onLoad: function (options) { console.log(options) var that = this; this.setData({ screenHeight: app.globalData.screenHeight }) if (options.rent == 'rent') { //说明是日租订单 url = '/rent' this.setData({ rent: false }) } else { url = '/order' this.setData({ rent: true }) } this.setData({ order: options.order }) console.log(options.order) }, home: function () { //点击返回首页 if(app.globalData.compatible){ wx.reLaunch({ url: '/pages/compatible/index/index', }) }else{ wx.reLaunch({ url: '/pages/index/index', }) } }, retryClose: function () { //点击关锁失败 var that = this; wx.showLoading({ title: '关锁中...', mask: true }) clearInterval(intervar) wx.getLocation({ type: 'gcj02', success: function (res) { console.log(res) app.request('/order/retry-close-lock?order_no=' + that.data.date.orders.no + '&bike_no=' + that.data.date.orders.bike_no, '', 'GET').then(res => { console.log(res) if (res.statusCode == 200) { wx.hideLoading() bluM.connectDeivece(that.data.box_no).then(res => { //关锁成功 调用蓝牙关锁 console.log('lockbike') return bluM.lockBike() }, reject => {}) if (res.data.status == 1) { wx.showToast({ title: '关锁成功', icon: 'none' }) } } }) }, }) }, check1: function () { //选择余额支付 this.setData({ check1: true, check2: false }) }, check2: function () { //选择微信支付 this.setData({ check1: false, check2: true }) }, check4: function () { //点击去购买骑行卡 wx.navigateTo({ url: '/pages/recharge/recharge', }) }, check3: function () { var that = this; // 创建一个动画实例 console.log(that.data.coupon) app.request('/coupon/getCouponsByOrder?order_no=' + that.data.order, '', 'GET').then(res => { console.log(res) if (res.statusCode == 200) { that.setData({coupon:res.data}) var coupon = res.data.dataYes; for(var i=0;i { console.log(res) if (res.statusCode == 200) { wx.hideLoading() that.setData({ date: res.data, balance: res.data.wallet_money, bolear: res.data.wallet_pay_status, chooseSize:false }) if (res.data.wallet_pay_status == false) { that.setData({ check1: false, check2: true, index: 1 }) } else { that.setData({ check1: true, check2: false, index: 2 }) } console.log(that.data.index) if (res.data.user_coupon.is_coupon) { that.setData({ coupon_user_bags_id: res.data.user_coupon.coupon_user_bags_id }) } } }) }, payment: function () { //点击立即支付 var that = this; console.log(that.data.index) if (that.data.index != '') { var data = { pay_type: that.data.index, order_no: that.data.order, coupon_user_bags_id: that.data.coupon_user_bags_id } if (that.data.disable == true) { return; } that.setData({ disable: true }) app.request(url + '/pay', data, 'POST').then(res => { console.log(res) //获取支付参数 if (res.statusCode == 200) { if (that.data.index == 1) { wx.requestPayment({ //调用微信支付 timeStamp: res.data.timeStamp.toString(), nonceStr: res.data.nonceStr, package: res.data.package, signType: res.data.signType, paySign: res.data.paySign, success(resp) { console.log(resp) wx.reLaunch({ url: '/pages/personal/rechSuce/rechSuce?order=' + that.data.date.orders.no + '&rent=' + that.data.rent, }) }, fail(err) { console.log(err) wx.showToast({ title: '支付失败', icon: 'none' }) if (res.data.order_no != that.data.order) { that.setData({ order: res.data.order_no }) } } }) that.setData({ disable: false }) } else { wx.reLaunch({ url: '/pages/personal/rechSuce/rechSuce?order=' + that.data.order + '&rent=' + that.data.rent, }) } } else { that.setData({ disable: false }) } }).catch(err => { console.log(err) }) } else { wx.showToast({ title: '请选择支付方式', icon: 'none' }) } }, repair: function () { wx.navigateTo({ url: '/pages/repair/repair?bike_id=' + this.data.code, }) }, phone: function (e) { wx.makePhoneCall({ phoneNumber: wx.getStorageSync('home').customer_service_phone, }) }, onReady: function () { // console.log(this.data.coupon.dataYes) }, onShow: function () { this.refresh() this.setData({ setting: wx.getStorageSync('setting') }) }, refresh: function () { wx.showNavigationBarLoading(); var that = this; wx.showLoading({ title: '加载中...', mask:true }) app.request(url + '/pay-show?order_no=' + that.data.order + '&is_first=true', '', 'GET').then(res => { console.log(res) if (res.statusCode == 200) { wx.hideLoading({ complete: (res) => {}, }) that.setData({ date: res.data, balance: res.data.wallet_money, bolear: res.data.wallet_pay_status, code: res.data.orders.bike_no }) if (res.data.wallet_pay_status == false) { that.setData({ check1: false, check2: true, index: 1 }) } else { that.setData({ check1: true, check2: false, index: 2 }) } if (res.data.user_coupon.is_coupon) { that.setData({ coupon_user_bags_id: res.data.user_coupon.coupon_user_bags_id }) } wx.hideNavigationBarLoading() wx.stopPullDownRefresh() } }) }, onHide: function () { }, onUnload: function () { }, onPullDownRefresh: function () { this.refresh() }, onReachBottom: function () { }, onShareAppMessage: function () { } })