篮球进场最终逻辑,避免冗余请求
This commit is contained in:
@@ -1,20 +1,10 @@
|
||||
// pages/basketballGym/index.js
|
||||
// import QRCode from './qrcode';
|
||||
// import drawQrcode from './weapp.qrcode.js';
|
||||
import { getTimeoutStorage, getDistance } from "../../utils/util";
|
||||
const app = getApp();
|
||||
import {
|
||||
getCurrentPageUrl
|
||||
} from './../../utils/util.js'
|
||||
let id = ''
|
||||
// let qrcode = new QRCode('canvas', {
|
||||
// text: "123456",
|
||||
// width: 120,
|
||||
// height: 120,
|
||||
// colorDark: '#000000',
|
||||
// colorLight: '#ffffff',
|
||||
// correctLevel: QRCode.correctLevel.H
|
||||
// });
|
||||
Page({
|
||||
|
||||
/**
|
||||
@@ -120,9 +110,69 @@ Page({
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
// 原 checkIsPayed 轮询废弃,已由 venueJoin / venueOut 接口主动状态校验代替
|
||||
|
||||
checkIsPayed(orderSn) {
|
||||
this.setData({
|
||||
flg: 777,
|
||||
msg: '正在查询支付结果...'
|
||||
})
|
||||
let that = this;
|
||||
setTimeout(function () {
|
||||
app.$api.memberIsPayed({
|
||||
orderSn: orderSn
|
||||
}).then(res => {
|
||||
if (res.isPayed) {
|
||||
that.setData({
|
||||
flg: 0,
|
||||
msg: ''
|
||||
})
|
||||
that.openDoor(orderSn, that.data.venues.enterFlag != '1')
|
||||
} else {
|
||||
that.setData({
|
||||
flg: 777,
|
||||
msg: '正在确认支付结果,请勿退出...'
|
||||
})
|
||||
//第二次
|
||||
setTimeout(function () {
|
||||
app.$api.memberIsPayed({
|
||||
orderSn: orderSn
|
||||
}).then(res => {
|
||||
if (res.isPayed) {
|
||||
that.setData({
|
||||
flg: 0,
|
||||
msg: ''
|
||||
})
|
||||
that.openDoor(orderSn, that.data.venues.enterFlag != '1')
|
||||
} else {
|
||||
that.setData({
|
||||
flg: 777,
|
||||
msg: '正在确认订单状态...'
|
||||
})
|
||||
// 第三次
|
||||
setTimeout(function () {
|
||||
app.$api.memberIsPayed({
|
||||
orderSn: orderSn
|
||||
}).then(res => {
|
||||
if (res.isPayed) {
|
||||
that.setData({
|
||||
flg: 0,
|
||||
msg: ''
|
||||
})
|
||||
that.openDoor(orderSn, that.data.venues.enterFlag != '1')
|
||||
} else {
|
||||
that.setData({
|
||||
flg: 999,
|
||||
msg: '订单未成功支付,或者网络延迟请重试'
|
||||
})
|
||||
}
|
||||
});
|
||||
}, 5000)
|
||||
}
|
||||
});
|
||||
}, 5000)
|
||||
}
|
||||
});
|
||||
}, 5000)
|
||||
},
|
||||
// 打开导航,
|
||||
opnGPS() {
|
||||
wx.openLocation({
|
||||
@@ -133,20 +183,6 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
// 充值
|
||||
// recharge() {
|
||||
// if (!wx.getStorageSync('accessToken')) {
|
||||
// wx.setStorageSync('history', getCurrentPageUrl());
|
||||
// wx.redirectTo({
|
||||
// url: '/pages/login/index',
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
// wx.navigateTo({
|
||||
// url: '/pages/myAccount/index',
|
||||
// })
|
||||
// },
|
||||
|
||||
// 打电话
|
||||
callPhone() {
|
||||
wx.makePhoneCall({
|
||||
@@ -154,22 +190,6 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
// 购买套餐
|
||||
// nowBuy(e) {
|
||||
// let index = e.currentTarget.dataset.index;
|
||||
// if (!wx.getStorageSync('accessToken')) {
|
||||
// wx.setStorageSync('history', getCurrentPageUrl());
|
||||
// wx.redirectTo({
|
||||
// url: '/pages/login/index',
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
// this.setData({
|
||||
// isShowBuyVip: true,
|
||||
// buyVipObj: this.data.venues.cards[index]
|
||||
// })
|
||||
// },
|
||||
|
||||
// 我要进场
|
||||
enter() {
|
||||
if (this.data.isRequesting) return;
|
||||
@@ -281,66 +301,6 @@ Page({
|
||||
this.initPage()
|
||||
},
|
||||
|
||||
// 关闭购买vip弹框
|
||||
// closeBuyVipPopup() {
|
||||
// this.setData({
|
||||
// isShowBuyVip: false
|
||||
// })
|
||||
// },
|
||||
|
||||
// 购买Vip
|
||||
// buyVip() {
|
||||
// let that = this;
|
||||
// this.setData({
|
||||
// showUnclickMask: true
|
||||
// })
|
||||
// app.$api.memberCardOrderCreate({
|
||||
// cardType: this.data.buyVipObj.cardType,
|
||||
// num: 1,
|
||||
// type: this.data.venues.type,
|
||||
// venueId: this.data.venues.id
|
||||
// }).then(res => {
|
||||
// app.$pay.wxPay(res.pay).then(res => {
|
||||
// that.setData({
|
||||
// isShowBuyVip: false,
|
||||
// showUnclickMask: false
|
||||
// })
|
||||
// }, err => {
|
||||
// that.setData({
|
||||
// isShowBuyVip: false,
|
||||
// showUnclickMask: false
|
||||
// })
|
||||
//
|
||||
// })
|
||||
// }, err => {
|
||||
// // console.log(err);
|
||||
// this.setData({
|
||||
// isShowBuyVip: false,
|
||||
// showUnclickMask: false
|
||||
// })
|
||||
// if (err.data.err_code == 30022) {
|
||||
// this.setData({
|
||||
// isWxLogin: true,
|
||||
// isShowBuyVip: false
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
// },
|
||||
|
||||
// 关闭
|
||||
// cancelCardMask() {
|
||||
// this.setData({
|
||||
// showCardMask: false
|
||||
// })
|
||||
// },
|
||||
|
||||
// 开启会员卡提示
|
||||
// showCardContent() {
|
||||
// this.setData({
|
||||
// showCardMask: true
|
||||
// })
|
||||
// },
|
||||
|
||||
// 关闭提示框
|
||||
cancelDeleteDialog() {
|
||||
if (this.data.isPaying) {
|
||||
@@ -382,19 +342,15 @@ Page({
|
||||
app.$pay.wxPay(res.pay).then(wxRes => {
|
||||
console.log('支付成功了');
|
||||
this.setData({ isPaying: false, isRequesting: false });
|
||||
wx.showLoading({ title: '确认支付结果...', mask: true });
|
||||
if (this.data.venues.enterFlag == '1') {
|
||||
this.out();
|
||||
} else {
|
||||
this.enter();
|
||||
}
|
||||
this.checkIsPayed(orderSn);
|
||||
}, err => {
|
||||
console.log('支付失败');
|
||||
console.log('支付失败', err);
|
||||
this.setData({ isPaying: false, isRequesting: false });
|
||||
if (this.data.venues.enterFlag == '1') {
|
||||
this.out();
|
||||
if (err && err.errMsg && err.errMsg.indexOf('cancel') !== -1) {
|
||||
wx.showToast({ title: '支付已取消', icon: 'none' });
|
||||
this.setData({ flg: 100 });
|
||||
} else {
|
||||
this.enter();
|
||||
this.checkIsPayed(orderSn);
|
||||
}
|
||||
})
|
||||
}, err => {
|
||||
@@ -426,25 +382,17 @@ Page({
|
||||
enterFlag: this.data.venues.enterFlag,
|
||||
orderSn: orderSn
|
||||
}).then(res => {
|
||||
app.$api.checkBarcode({ code: res.barcode }).then(res2 => {
|
||||
wx.hideLoading();
|
||||
this.setData({
|
||||
flg: 0,
|
||||
welcomeMsg: isEnter ? '欢迎光临,请入场' : '再见,请出场'
|
||||
})
|
||||
}).catch(err2 => {
|
||||
wx.hideLoading();
|
||||
this.setData({
|
||||
flg: 999,
|
||||
msg: '开门失败,请联系管理员'
|
||||
})
|
||||
})
|
||||
}, err => {
|
||||
console.log(err)
|
||||
wx.hideLoading();
|
||||
this.setData({
|
||||
flg: 999,
|
||||
msg: '生成门禁信息失败'
|
||||
msg: '开门失败,请联系管理员'
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user