modified: pages/basketballGym/index.js

modified:   pages/basketballGym/index.wxml
modified:   pages/currentEnter/index.wxml
modified:   pages/loginIndex/index.js
modified:   pages/loginIndex/index.wxml
modified:   pages/loginIndex/index.wxss
modified:   pages/myEnters/index.wxml
modified:   utils/api.js
modified:   utils/util.js
This commit is contained in:
2026-04-08 16:40:48 +08:00
parent db13ba7c1c
commit 1559181b2e
9 changed files with 156 additions and 166 deletions

View File

@@ -1,7 +1,7 @@
// pages/basketballGym/index.js
// import QRCode from './qrcode';
import drawQrcode from './weapp.qrcode.js';
import {getTimeoutStorage} from "../../utils/util";
// import drawQrcode from './weapp.qrcode.js';
import { getTimeoutStorage, getDistance } from "../../utils/util";
const app = getApp();
import {
getCurrentPageUrl
@@ -21,27 +21,22 @@ Page({
* 页面的初始数据
*/
data: {
barcodeClock: null,
clockTime: 0,
venues: {},
// isShowBuyVip: false,
// buyVipObj: {},
showUnclickMask: false,
barcodeTimeOut: false,
// showCardMask: false,
orderSn: '000',
payMoney: 0,
flg: 100,
isPayed: false,
msg: '',
isWxLogin: false,
isGoHome: false,
welcomeMsg: '',
isRequesting: false,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
onLoad: function (options) {
if (options.id) {
id = options.id;
}
@@ -55,7 +50,7 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
onReady: function () {
let pages = getCurrentPages();
this.setData({
isGoHome: pages.length == 1
@@ -65,7 +60,7 @@ Page({
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
onShow: function () {
this.setData({
showUnclickMask: false
// flg: 100
@@ -76,75 +71,32 @@ Page({
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
this.endInter()
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
this.endInter()
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
onPullDownRefresh: function () {
this.initPage()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
onReachBottom: function () {
},
/**
* 启动定时器
*/
startInter : function(barcode){
var that = this;
that.data.barcodeClock= setInterval(
function () {
console.log('setInterval 每过500毫秒执行一次任务' + that.data.clockTime)
app.$api.memberBarcodeIsUsed({
barcode: barcode
}).then(res => {
if (res) {
// 二维码被使用过了
if (res.barcodeDTO.used){
that.closeInStep()
wx.navigateTo({
url: `/pages/currentEnter/index?id=${res.barcodeDTO.enterId}`,
})
}
}
})
that.setData({
clockTime: that.data.clockTime+1
})
if (that.data.clockTime > 10){
that.showTimeOutBarcode();
}
}, 2000);
},
/**
* 结束定时器
*/
endInter: function(){
if (this.data.barcodeClock) {
clearInterval(this.data.barcodeClock)
this.setData({
clockTime: 0
})
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
onShareAppMessage: function () {
return {
title: this.data.venues.name,
imageUrl: this.data.venues.images[0].url
@@ -168,24 +120,13 @@ Page({
});
},
showTimeOutBarcode() {
this.endInter()
this.setData({
barcodeTimeOut: true
})
},
reloadBarcode() {
this.showBarcode('000')
},
checkIsPayed(orderSn) {
this.setData({
flg: 777,
msg: '正在查询支付结果...'
})
let that = this;
setTimeout(function(){
setTimeout(function () {
app.$api.memberIsPayed({
orderSn: orderSn
}).then(res => {
@@ -194,14 +135,14 @@ Page({
flg: 0,
msg: ''
})
that.showBarcode(orderSn)
that.openDoor(orderSn, that.data.venues.enterFlag != '1')
} else {
that.setData({
flg: 777,
msg: '正在确认支付结果,请勿退出...'
})
//第二次
setTimeout(function(){
setTimeout(function () {
app.$api.memberIsPayed({
orderSn: orderSn
}).then(res => {
@@ -210,14 +151,14 @@ Page({
flg: 0,
msg: ''
})
that.showBarcode(orderSn)
that.openDoor(orderSn, that.data.venues.enterFlag != '1')
} else {
that.setData({
flg: 777,
msg: '最后一次确认订单状态...'
})
// 第三次
setTimeout(function(){
setTimeout(function () {
app.$api.memberIsPayed({
orderSn: orderSn
}).then(res => {
@@ -226,21 +167,21 @@ Page({
flg: 0,
msg: ''
})
that.showBarcode(orderSn)
}else {
that.openDoor(orderSn, that.data.venues.enterFlag != '1')
} else {
that.setData({
flg: 999,
msg: '订单未成功支付'
})
}
});
},5000)
}, 5000)
}
});
},5000)
}, 5000)
}
});
},5000)
}, 5000)
},
// 打开导航,
@@ -292,24 +233,50 @@ Page({
// 我要进场
enter() {
if (this.data.isRequesting) return;
let isRead = getTimeoutStorage('isReaded');
console.log('isRead======' + isRead)
if (isRead == 'ojbk') {
app.$api.venueJoin({
venueId: id
}).then(res => {
this.setData({
flg: res.join.flg,
msg: res.join.msg,
payMoney: res.join.money
})
if (res.join.flg == 0) {
this.showBarcode('000')
this.setData({ isRequesting: true });
wx.getFuzzyLocation({
type: 'wgs84',
success: (locRes) => {
let distance = getDistance(locRes.latitude, locRes.longitude, Number(this.data.venues.latitude), Number(this.data.venues.longitude));
if (distance > 9000) {
this.setData({ isRequesting: false });
wx.showModal({
title: '提示',
content: `距离场馆过远,请靠近后再试!`,
showCancel: false
});
return;
}
app.$api.venueJoin({
venueId: id
}).then(res => {
this.setData({
flg: res.join.flg,
msg: res.join.msg,
payMoney: res.join.money,
isRequesting: false
})
if (res.join.flg == 0) {
this.openDoor('000', true)
}
}, err => {
this.setData({ isRequesting: false });
})
},
fail: (err) => {
this.setData({ isRequesting: false });
wx.showModal({
title: '提示',
content: '无法获取您的位置信息,可能会影响进场识别,请确保开启微信和定位权限。',
showCancel: false
});
}
}, err => {
console.log(err);
})
}else {
});
} else {
wx.navigateTo({
url: '/pages/disclaimers/index'
})
@@ -318,19 +285,23 @@ Page({
// 我要出场
out() {
if (this.data.isRequesting) return;
this.setData({ isRequesting: true });
app.$api.venueOut({
venueId: id
}).then(res => {
this.setData({
flg: res.out.flg,
msg: res.out.msg,
payMoney: res.out.money
payMoney: res.out.money,
isRequesting: false
})
if (res.out.flg == 0) {
this.showBarcode('000')
this.openDoor('000', false)
}
}, err => {
console.log(err);
this.setData({ isRequesting: false });
})
},
@@ -343,9 +314,9 @@ Page({
// 关闭进场步骤弹框
closeInStep() {
this.setData({
flg: 100
flg: 100,
welcomeMsg: ''
})
this.endInter()
this.initPage()
},
@@ -416,12 +387,6 @@ Page({
})
},
// 点击提示框确认
confirmOutDialog() {
// 出场
this.showBarcode('000')
},
// 点击提示框确认
confirmDeleteDialog() {
// 去支付
@@ -454,12 +419,15 @@ Page({
})
},
showBarcode(orderSn) {
this.setData({
barcodeTimeOut: false
})
// 点击提示框确认
confirmOutDialog() {
// 出场
this.openDoor('000', false)
},
openDoor(orderSn, isEnter) {
wx.showLoading({
title: '加载中...',
title: '正在开门...',
mask: true,
})
app.$api.generateBarcode({
@@ -467,25 +435,25 @@ Page({
enterFlag: this.data.venues.enterFlag,
orderSn: orderSn
}).then(res => {
this.setData({
flg: 0
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: '开门失败,请联系管理员'
})
})
drawQrcode({
width: 180,
height: 180,
x: 10,
y: 10,
canvasId: 'myQrcode',
// ctx: wx.createCanvasContext('myQrcode'),
typeNumber: 10,
text: res.barcode
})
this.startInter(res.barcode)
}, err => {
console.log(err)
wx.hideLoading();
this.setData({
flg: 999,
msg: '生成二维码失败'
msg: '生成门禁信息失败'
})
});
},