From bab0602663a0f728338d4fd090e9e395a57dcfe1 Mon Sep 17 00:00:00 2001 From: limqsh <540344226@qq.com> Date: Sun, 14 Jun 2026 09:40:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AF=AE=E7=90=83=E8=BF=9B=E5=9C=BA=E6=9C=80?= =?UTF-8?q?=E7=BB=88=E9=80=BB=E8=BE=91=EF=BC=8C=E9=81=BF=E5=85=8D=E5=86=97?= =?UTF-8?q?=E4=BD=99=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/basketballGym/index.js | 200 +++++++++++++---------------------- 1 file changed, 74 insertions(+), 126 deletions(-) diff --git a/pages/basketballGym/index.js b/pages/basketballGym/index.js index b3e871d..2e76845 100644 --- a/pages/basketballGym/index.js +++ b/pages/basketballGym/index.js @@ -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: '开门失败,请联系管理员' - }) + wx.hideLoading(); + this.setData({ + flg: 0, + welcomeMsg: isEnter ? '欢迎光临,请入场' : '再见,请出场' }) }, err => { console.log(err) wx.hideLoading(); this.setData({ flg: 999, - msg: '生成门禁信息失败' + msg: '开门失败,请联系管理员' }) }); },