From d20ed2a691ff91eb4e0789dbce1f39ea119f932b Mon Sep 17 00:00:00 2001 From: limqsh <540344226@qq.com> Date: Wed, 3 Jun 2026 18:43:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=94=AF=E4=BB=98=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E3=80=81=E9=98=B2=E6=AD=A2=E7=94=A8=E6=88=B7=E8=BF=9E?= =?UTF-8?q?=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/basketballGym/index.js | 133 +++++++++++++++-------------------- project.config.json | 11 ++- 2 files changed, 64 insertions(+), 80 deletions(-) diff --git a/pages/basketballGym/index.js b/pages/basketballGym/index.js index 5fa05b0..af6115b 100644 --- a/pages/basketballGym/index.js +++ b/pages/basketballGym/index.js @@ -31,6 +31,7 @@ Page({ isGoHome: false, welcomeMsg: '', isRequesting: false, + isPaying: false, }, /** @@ -120,69 +121,7 @@ Page({ }); }, - 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) - }, + // 原 checkIsPayed 轮询废弃,已由 venueJoin / venueOut 接口主动状态校验代替 // 打开导航, opnGPS() { @@ -256,7 +195,7 @@ Page({ type: 'wgs84', success: (locRes) => { let distance = getDistance(locRes.latitude, locRes.longitude, Number(this.data.venues.latitude), Number(this.data.venues.longitude)); - if (distance > 90000) { + if (distance > 40000) { this.setData({ isRequesting: false }); wx.showModal({ title: '提示', @@ -275,7 +214,15 @@ Page({ isRequesting: false }) if (res.join.flg == 0) { - this.openDoor('000', true) + if (res.join.order_sn) { + this.openDoor(res.join.order_sn, true) + } else { + console.log('已在场内,无操作') + this.setData({ + flg: 100 + }) + wx.showToast({ title: '您已在场内', icon: 'none' }); + } } }, err => { this.setData({ isRequesting: false }); @@ -311,7 +258,7 @@ Page({ isRequesting: false }) if (res.out.flg == 0) { - this.openDoor('000', false) + this.openDoor(res.out.order_sn || '000', false) } }, err => { console.log(err); @@ -396,6 +343,10 @@ Page({ // 关闭提示框 cancelDeleteDialog() { + if (this.data.isPaying) { + wx.showToast({ title: '订单处理中,请稍后', icon: 'none' }); + return; + } this.setData({ flg: 100 }) @@ -403,32 +354,58 @@ Page({ // 点击提示框确认 confirmDeleteDialog() { + if (this.data.isPaying) return; // 防重复点击 + this.setData({ isPaying: true }); + wx.showLoading({ title: '正在处理订单...', mask: true }); // 物理锁死屏幕 + // 去支付 app.$api.basketOrder({ venueId: this.data.venues.id, enterFlag: this.data.venues.enterFlag, payMoney: this.data.payMoney }).then(res => { + // 如果后端判定这笔订单已经支付,直接开门 + if (res.paid_flag) { + wx.hideLoading(); + this.setData({ isPaying: false, flg: 0, msg: '' }); + this.openDoor(res.order_sn, this.data.venues.enterFlag != '1'); + return; + } + + // 未支付,拿到单号拉起微信支付 + let orderSn = res.order_sn || (res.pay && res.pay.orderSn); this.setData({ - orderSn: res.pay.orderSn, - flg: 777, - msg: '正在支付...' + orderSn: orderSn }) - app.$pay.wxPay(res.pay).then(res => { - console.log('支付成功了') - this.checkIsPayed(this.data.orderSn) + wx.hideLoading(); // 隐藏下单的 Loading + + 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(); + } }, err => { - console.log('支付失败') - this.setData({ - flg: 999, - msg: '支付失败,用户取消支付' - }) + console.log('支付失败'); + this.setData({ isPaying: false, isRequesting: false }); + if (this.data.venues.enterFlag == '1') { + this.out(); + } else { + this.enter(); + } }) }, err => { - if (err.data.err_code == 30022) { + this.setData({ isPaying: false }); + wx.hideLoading(); + if (err.data && err.data.err_code == 30022) { this.setData({ isWxLogin: true, }) + } else { + wx.showToast({ title: '网络异常,请重试', icon: 'none' }); } }) }, diff --git a/project.config.json b/project.config.json index 074f699..c1f5e66 100644 --- a/project.config.json +++ b/project.config.json @@ -38,10 +38,17 @@ "packNpmManually": false, "packNpmRelationList": [], "minifyWXSS": true, - "condition": false + "condition": false, + "compileWorklet": false, + "minifyWXML": true, + "localPlugins": false, + "disableUseStrict": false, + "useCompilerPlugins": false, + "swc": false, + "disableSWC": true }, "compileType": "miniprogram", - "libVersion": "2.17.0", + "libVersion": "2.27.3", "appid": "wx73eb8a9ed10a029d", "projectname": "%E6%99%BA%E6%85%A7%E4%BA%91%E9%A6%86", "simulatorType": "wechat",