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: '生成门禁信息失败'
})
});
},

View File

@@ -79,30 +79,17 @@
</view>
<view class='in-step-popup' catchtouchmove='unMove' wx:if="{{flg == 0}}">
<view class='body'>
<view class='medium-body body'>
<view class='top'>
<view class='title'>
<image src='../../images/24@3x.png'></image>
<text>请向门禁读头出示本二维码</text>
<text>开门成功</text>
</view>
<image src='../../images/23@3x.png' bindtap='closeInStep'></image>
</view>
<view class='center'>
<view class='item'>
<view wx:if="{{barcodeTimeOut}}" class='step'>二维码超时</view>
<view wx:else class='step'>扫码开门</view>
<view class='barcode'>
<view wx:if="{{barcodeTimeOut}}" class="timeout" bindtap="reloadBarcode">
<image src="../../images/reload.png" style="width: 160px; height: 178px;"></image>
<text>点击刷新</text>
</view>
<canvas wx:else class="barcode-canvas" style="width: 200px; height: 200px;" canvas-id="myQrcode"></canvas>
<!-- <canvas type="2d" class='title' canvas-id="myQrcode" style="width: 400rpx; height: 400rpx"></canvas>-->
</view>
</view>
<image src='../../images/22@3x.png'></image>
<view class='item'>
<view class='message'>如有问题,请联系管理员</view>
<view class='item' style='margin-top: 20rpx;'>
<view class='step' style='font-size: 56rpx; color: #ffda2e; font-weight: bold; letter-spacing: 4rpx;'>{{welcomeMsg}}</view>
</view>
</view>
</view>

View File

@@ -41,8 +41,8 @@
<view class='cell-right-white'>¥{{memberEnterDetail.payMoney}}</view>
</view>
</view>
<view wx:if="{{memberEnterDetail.payStyle == 1}}" class="note-content">
<!-- <view wx:if="{{memberEnterDetail.payStyle == 1}}" class="note-content">
本球场支持临时出门功能10分钟内返回不再二次扣费10分钟内不返回则将结算本次订单并退还剩余押金请耐心等待
</view>
</view> -->
<view class='footer-btn' bindtap='backOut'>返回</view>
</view>

View File

@@ -15,6 +15,7 @@ Page({
isGetCode: false,
code: '获取验证码',
showUnclickMask: false,
isAgree: false,
},
/**
@@ -136,8 +137,22 @@ Page({
})
},
checkboxChange(e) {
this.setData({
isAgree: e.detail.value.length > 0
})
},
// 登录
loginClick() {
if (!this.data.isAgree) {
wx.showToast({
title: '请阅读并同意服务条款及隐私政策',
icon: 'none',
duration: 2000
})
return;
}
if (!this.data.body.code) {
wx.showToast({
title: '请输入验证码',

View File

@@ -9,8 +9,12 @@
<button bindtap='getCode'>{{code}}</button>
</view>
<view class='agreement'>
<text>登录即代表同意</text>
<button bindtap='pushAgreement'>《智慧云馆服务条款》</button>
<checkbox-group bindchange="checkboxChange">
<checkbox value="agree" checked="{{isAgree}}" color="#ffda2e"/>
</checkbox-group>
<view class="agreement-text">
我已阅读并同意<text class="protocol" bindtap='pushAgreement'>《智慧云馆服务条款》及《隐私政策》</text>
</view>
</view>
<button class='login-btn' bindtap='loginClick'>登录</button>
</view>

View File

@@ -42,23 +42,23 @@
.agreement {
display: flex;
align-items: center;
align-items: flex-start;
margin-top: 30rpx;
font-size: 22rpx;
color: rgba(255, 255, 255, 0.6);
}
.agreement>button {
padding: 0;
margin: 0;
color: #b1992f;
font-size: 22rpx;
line-height: 22rpx;
background: none;
.agreement-text {
flex: 1;
line-height: 1.6;
}
.agreement>button::after {
border: none;
.agreement .protocol {
color: #b1992f;
}
.agreement checkbox {
transform: scale(0.6);
}
.login-btn {

View File

@@ -45,8 +45,8 @@
</view>
</view>
</view>
<view wx:if="{{memberEnterDetail.payStyle == 1}}" class="note-content">
<!-- <view wx:if="{{memberEnterDetail.payStyle == 1}}" class="note-content">
本球场支持临时出门功能10分钟内返回不再二次扣费10分钟内不返回则将结算本次订单并退还剩余押金请耐心等待
</view>
</view> -->
<view class='footer-btn' bindtap='backOut'>返回</view>
</view>