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,27 +21,22 @@ 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,
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function(options) { onLoad: function (options) {
if (options.id) { if (options.id) {
id = options.id; id = options.id;
} }
@@ -55,7 +50,7 @@ Page({
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady: function() { onReady: function () {
let pages = getCurrentPages(); let pages = getCurrentPages();
this.setData({ this.setData({
isGoHome: pages.length == 1 isGoHome: pages.length == 1
@@ -65,7 +60,7 @@ Page({
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function() { onShow: function () {
this.setData({ this.setData({
showUnclickMask: false showUnclickMask: false
// flg: 100 // flg: 100
@@ -76,75 +71,32 @@ Page({
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function() { onHide: function () {
this.endInter()
}, },
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload: function() { onUnload: function () {
this.endInter()
}, },
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh: function() { onPullDownRefresh: function () {
this.initPage() 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 { return {
title: this.data.venues.name, title: this.data.venues.name,
imageUrl: this.data.venues.images[0].url 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) { checkIsPayed(orderSn) {
this.setData({ this.setData({
flg: 777, flg: 777,
msg: '正在查询支付结果...' msg: '正在查询支付结果...'
}) })
let that = this; let that = this;
setTimeout(function(){ setTimeout(function () {
app.$api.memberIsPayed({ app.$api.memberIsPayed({
orderSn: orderSn orderSn: orderSn
}).then(res => { }).then(res => {
@@ -194,14 +135,14 @@ 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,
msg: '正在确认支付结果,请勿退出...' msg: '正在确认支付结果,请勿退出...'
}) })
//第二次 //第二次
setTimeout(function(){ setTimeout(function () {
app.$api.memberIsPayed({ app.$api.memberIsPayed({
orderSn: orderSn orderSn: orderSn
}).then(res => { }).then(res => {
@@ -210,14 +151,14 @@ 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,
msg: '最后一次确认订单状态...' msg: '最后一次确认订单状态...'
}) })
// 第三次 // 第三次
setTimeout(function(){ setTimeout(function () {
app.$api.memberIsPayed({ app.$api.memberIsPayed({
orderSn: orderSn orderSn: orderSn
}).then(res => { }).then(res => {
@@ -226,21 +167,21 @@ 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,
msg: '订单未成功支付' msg: '订单未成功支付'
}) })
} }
}); });
},5000) }, 5000)
} }
}); });
},5000) }, 5000)
} }
}); });
},5000) }, 5000)
}, },
// 打开导航, // 打开导航,
@@ -292,24 +233,50 @@ 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') {
app.$api.venueJoin({ this.setData({ isRequesting: true });
venueId: id wx.getFuzzyLocation({
}).then(res => { type: 'wgs84',
this.setData({ success: (locRes) => {
flg: res.join.flg, let distance = getDistance(locRes.latitude, locRes.longitude, Number(this.data.venues.latitude), Number(this.data.venues.longitude));
msg: res.join.msg, if (distance > 9000) {
payMoney: res.join.money this.setData({ isRequesting: false });
}) wx.showModal({
if (res.join.flg == 0) { title: '提示',
this.showBarcode('000') 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({ 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 => {
this.setData({ app.$api.checkBarcode({ code: res.barcode }).then(res2 => {
flg: 0 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 => { }, err => {
console.log(err) console.log(err)
wx.hideLoading();
this.setData({ this.setData({
flg: 999, flg: 999,
msg: '生成二维码失败' 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;
@@ -55,7 +55,7 @@ export function fetchPost(url, params, needToken, multiple) {
filePath: params.filePath, filePath: params.filePath,
name: 'image', name: 'image',
formData: {}, formData: {},
success: function(response) { success: function (response) {
console.log(response.data); console.log(response.data);
let res = JSON.parse(response.data); let res = JSON.parse(response.data);
console.log(res); console.log(res);
@@ -101,7 +101,7 @@ export function fetchPost(url, params, needToken, multiple) {
reject(response); reject(response);
} }
}, },
fail: function(err) { fail: function (err) {
console.log(err); console.log(err);
wx.hideLoading(); wx.hideLoading();
wx.showToast({ wx.showToast({
@@ -123,8 +123,8 @@ export function fetchPost(url, params, needToken, multiple) {
'content-type': 'application/x-www-form-urlencoded' 'content-type': 'application/x-www-form-urlencoded'
}, },
method: 'POST', method: 'POST',
success: function(res) { success: function (res) {
console.log("POST返回数据", url,res); console.log("POST返回数据", url, res);
if (res.data.err_code == 0) { if (res.data.err_code == 0) {
wx.hideLoading(); wx.hideLoading();
resolve(res.data); resolve(res.data);
@@ -161,7 +161,7 @@ export function fetchPost(url, params, needToken, multiple) {
} }
}, },
fail: function(res) { fail: function (res) {
wx.hideLoading(); wx.hideLoading();
wx.showToast({ wx.showToast({
title: '网络错误', title: '网络错误',
@@ -191,7 +191,7 @@ export function fetchGet(url, params, needToken) {
url: BASE_URL + url, url: BASE_URL + url,
data: params, data: params,
method: 'GET', method: 'GET',
success: function(res) { success: function (res) {
console.log("GET返回数据", url, res); console.log("GET返回数据", url, res);
if (res.statusCode == 200) { if (res.statusCode == 200) {
if (res.data.err_code == 0) { if (res.data.err_code == 0) {
@@ -232,7 +232,7 @@ export function fetchGet(url, params, needToken) {
}) })
} }
}, },
fail: function(res) { fail: function (res) {
wx.hideLoading(); wx.hideLoading();
reject(res) reject(res)
wx.showToast({ wx.showToast({
@@ -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
} }