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 // pages/basketballGym/index.js
// import QRCode from './qrcode'; // import QRCode from './qrcode';
import drawQrcode from './weapp.qrcode.js'; // import drawQrcode from './weapp.qrcode.js';
import {getTimeoutStorage} from "../../utils/util"; import { getTimeoutStorage, getDistance } from "../../utils/util";
const app = getApp(); const app = getApp();
import { import {
getCurrentPageUrl getCurrentPageUrl
@@ -21,21 +21,16 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
barcodeClock: null,
clockTime: 0,
venues: {}, venues: {},
// isShowBuyVip: false,
// buyVipObj: {},
showUnclickMask: false, showUnclickMask: false,
barcodeTimeOut: false,
// showCardMask: false,
orderSn: '000', orderSn: '000',
payMoney: 0, payMoney: 0,
flg: 100, flg: 100,
isPayed: false,
msg: '', msg: '',
isWxLogin: false, isWxLogin: false,
isGoHome: false, isGoHome: false,
welcomeMsg: '',
isRequesting: false,
}, },
/** /**
@@ -77,14 +72,12 @@ Page({
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function () { onHide: function () {
this.endInter()
}, },
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload: function () { onUnload: function () {
this.endInter()
}, },
/** /**
@@ -99,47 +92,6 @@ Page({
*/ */
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
})
}
}, },
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
@@ -168,17 +120,6 @@ Page({
}); });
}, },
showTimeOutBarcode() {
this.endInter()
this.setData({
barcodeTimeOut: true
})
},
reloadBarcode() {
this.showBarcode('000')
},
checkIsPayed(orderSn) { checkIsPayed(orderSn) {
this.setData({ this.setData({
flg: 777, flg: 777,
@@ -194,7 +135,7 @@ Page({
flg: 0, flg: 0,
msg: '' msg: ''
}) })
that.showBarcode(orderSn) that.openDoor(orderSn, that.data.venues.enterFlag != '1')
} else { } else {
that.setData({ that.setData({
flg: 777, flg: 777,
@@ -210,7 +151,7 @@ Page({
flg: 0, flg: 0,
msg: '' msg: ''
}) })
that.showBarcode(orderSn) that.openDoor(orderSn, that.data.venues.enterFlag != '1')
} else { } else {
that.setData({ that.setData({
flg: 777, flg: 777,
@@ -226,7 +167,7 @@ Page({
flg: 0, flg: 0,
msg: '' msg: ''
}) })
that.showBarcode(orderSn) that.openDoor(orderSn, that.data.venues.enterFlag != '1')
} else { } else {
that.setData({ that.setData({
flg: 999, flg: 999,
@@ -292,23 +233,49 @@ Page({
// 我要进场 // 我要进场
enter() { enter() {
if (this.data.isRequesting) return;
let isRead = getTimeoutStorage('isReaded'); let isRead = getTimeoutStorage('isReaded');
console.log('isRead======' + isRead) console.log('isRead======' + isRead)
if (isRead == 'ojbk') { if (isRead == 'ojbk') {
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({ app.$api.venueJoin({
venueId: id venueId: id
}).then(res => { }).then(res => {
this.setData({ this.setData({
flg: res.join.flg, flg: res.join.flg,
msg: res.join.msg, msg: res.join.msg,
payMoney: res.join.money payMoney: res.join.money,
isRequesting: false
}) })
if (res.join.flg == 0) { if (res.join.flg == 0) {
this.showBarcode('000') this.openDoor('000', true)
} }
}, err => { }, err => {
console.log(err); this.setData({ isRequesting: false });
}) })
},
fail: (err) => {
this.setData({ isRequesting: false });
wx.showModal({
title: '提示',
content: '无法获取您的位置信息,可能会影响进场识别,请确保开启微信和定位权限。',
showCancel: false
});
}
});
} else { } else {
wx.navigateTo({ wx.navigateTo({
url: '/pages/disclaimers/index' url: '/pages/disclaimers/index'
@@ -318,19 +285,23 @@ Page({
// 我要出场 // 我要出场
out() { out() {
if (this.data.isRequesting) return;
this.setData({ isRequesting: true });
app.$api.venueOut({ app.$api.venueOut({
venueId: id venueId: id
}).then(res => { }).then(res => {
this.setData({ this.setData({
flg: res.out.flg, flg: res.out.flg,
msg: res.out.msg, msg: res.out.msg,
payMoney: res.out.money payMoney: res.out.money,
isRequesting: false
}) })
if (res.out.flg == 0) { if (res.out.flg == 0) {
this.showBarcode('000') this.openDoor('000', false)
} }
}, err => { }, err => {
console.log(err); console.log(err);
this.setData({ isRequesting: false });
}) })
}, },
@@ -343,9 +314,9 @@ Page({
// 关闭进场步骤弹框 // 关闭进场步骤弹框
closeInStep() { closeInStep() {
this.setData({ this.setData({
flg: 100 flg: 100,
welcomeMsg: ''
}) })
this.endInter()
this.initPage() this.initPage()
}, },
@@ -416,12 +387,6 @@ Page({
}) })
}, },
// 点击提示框确认
confirmOutDialog() {
// 出场
this.showBarcode('000')
},
// 点击提示框确认 // 点击提示框确认
confirmDeleteDialog() { confirmDeleteDialog() {
// 去支付 // 去支付
@@ -454,12 +419,15 @@ Page({
}) })
}, },
showBarcode(orderSn) { // 点击提示框确认
this.setData({ confirmOutDialog() {
barcodeTimeOut: false // 出场
}) this.openDoor('000', false)
},
openDoor(orderSn, isEnter) {
wx.showLoading({ wx.showLoading({
title: '加载中...', title: '正在开门...',
mask: true, mask: true,
}) })
app.$api.generateBarcode({ app.$api.generateBarcode({
@@ -467,25 +435,25 @@ Page({
enterFlag: this.data.venues.enterFlag, enterFlag: this.data.venues.enterFlag,
orderSn: orderSn orderSn: orderSn
}).then(res => { }).then(res => {
app.$api.checkBarcode({ code: res.barcode }).then(res2 => {
wx.hideLoading();
this.setData({ this.setData({
flg: 0 flg: 0,
welcomeMsg: isEnter ? '欢迎光临,请入场' : '再见,请出场'
}) })
drawQrcode({ }).catch(err2 => {
width: 180, wx.hideLoading();
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)
this.setData({ this.setData({
flg: 999, flg: 999,
msg: '生成二维码失败' msg: '开门失败,请联系管理员'
})
})
}, err => {
console.log(err)
wx.hideLoading();
this.setData({
flg: 999,
msg: '生成门禁信息失败'
}) })
}); });
}, },

View File

@@ -79,30 +79,17 @@
</view> </view>
<view class='in-step-popup' catchtouchmove='unMove' wx:if="{{flg == 0}}"> <view class='in-step-popup' catchtouchmove='unMove' wx:if="{{flg == 0}}">
<view class='body'> <view class='medium-body body'>
<view class='top'> <view class='top'>
<view class='title'> <view class='title'>
<image src='../../images/24@3x.png'></image> <image src='../../images/24@3x.png'></image>
<text>请向门禁读头出示本二维码</text> <text>开门成功</text>
</view> </view>
<image src='../../images/23@3x.png' bindtap='closeInStep'></image> <image src='../../images/23@3x.png' bindtap='closeInStep'></image>
</view> </view>
<view class='center'> <view class='center'>
<view class='item'> <view class='item' style='margin-top: 20rpx;'>
<view wx:if="{{barcodeTimeOut}}" class='step'>二维码超时</view> <view class='step' style='font-size: 56rpx; color: #ffda2e; font-weight: bold; letter-spacing: 4rpx;'>{{welcomeMsg}}</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> </view>
</view> </view>
</view> </view>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
//testURL //testURL
// const BASE_URL = 'http://127.0.0.1:8093'; // const BASE_URL = 'http://127.0.0.1:8093';
// const BASE_URL = 'http://192.168.1.3:8093'; // const BASE_URL = 'http://192.168.5.77:8093';
//prodURL //prodURL
const BASE_URL = 'https://api.hongyutiyu.top'; const BASE_URL = 'https://api.hongyutiyu.top';
// const platformId = 1; // const platformId = 1;
@@ -310,6 +310,9 @@ export default {
generateBarcode(params) { generateBarcode(params) {
return fetchPost('/venue/generate/barcode', params, true); return fetchPost('/venue/generate/barcode', params, true);
}, },
checkBarcode(params) {
return fetchPost('/user/check/barcode', params, true);
},
// 判断是否支付成功 // 判断是否支付成功
memberIsPayed(params) { memberIsPayed(params) {
return fetchPost('/member/isPayed', params, true); return fetchPost('/member/isPayed', params, true);

View File

@@ -52,9 +52,22 @@ const getTimeoutStorage = (key) => {
return value; return value;
} }
// 计算两点之间的距离(返回米)
const getDistance = (lat1, lng1, lat2, lng2) => {
const radLat1 = lat1 * Math.PI / 180.0;
const radLat2 = lat2 * Math.PI / 180.0;
const a = radLat1 - radLat2;
const b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
s = s * 6378.137; // 地球半径,千米
s = Math.round(s * 10000) / 10; // 换算成米
return s;
}
module.exports = { module.exports = {
formatTime: formatTime, formatTime: formatTime,
getCurrentPageUrl: getCurrentPageUrl, getCurrentPageUrl: getCurrentPageUrl,
setTimeOutStorage: setTimeOutStorage, setTimeOutStorage: setTimeOutStorage,
getTimeoutStorage: getTimeoutStorage getTimeoutStorage: getTimeoutStorage,
getDistance: getDistance
} }