diff --git a/pages/basketballGym/index.js b/pages/basketballGym/index.js
index c32ba4f..eb5dc6e 100644
--- a/pages/basketballGym/index.js
+++ b/pages/basketballGym/index.js
@@ -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: '生成门禁信息失败'
})
});
},
diff --git a/pages/basketballGym/index.wxml b/pages/basketballGym/index.wxml
index 3081f11..68789c1 100644
--- a/pages/basketballGym/index.wxml
+++ b/pages/basketballGym/index.wxml
@@ -79,30 +79,17 @@
- 登录即代表同意
-
+
+
+
+
+ 我已阅读并同意《智慧云馆服务条款》及《隐私政策》
+
\ No newline at end of file
diff --git a/pages/loginIndex/index.wxss b/pages/loginIndex/index.wxss
index b37100a..36a751b 100644
--- a/pages/loginIndex/index.wxss
+++ b/pages/loginIndex/index.wxss
@@ -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 {
diff --git a/pages/myEnters/index.wxml b/pages/myEnters/index.wxml
index c689210..4da4ad2 100644
--- a/pages/myEnters/index.wxml
+++ b/pages/myEnters/index.wxml
@@ -45,8 +45,8 @@
-
+
diff --git a/utils/api.js b/utils/api.js
index 63a9654..4069724 100644
--- a/utils/api.js
+++ b/utils/api.js
@@ -1,6 +1,6 @@
//testURL
// 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
const BASE_URL = 'https://api.hongyutiyu.top';
// const platformId = 1;
@@ -55,7 +55,7 @@ export function fetchPost(url, params, needToken, multiple) {
filePath: params.filePath,
name: 'image',
formData: {},
- success: function(response) {
+ success: function (response) {
console.log(response.data);
let res = JSON.parse(response.data);
console.log(res);
@@ -101,7 +101,7 @@ export function fetchPost(url, params, needToken, multiple) {
reject(response);
}
},
- fail: function(err) {
+ fail: function (err) {
console.log(err);
wx.hideLoading();
wx.showToast({
@@ -123,8 +123,8 @@ export function fetchPost(url, params, needToken, multiple) {
'content-type': 'application/x-www-form-urlencoded'
},
method: 'POST',
- success: function(res) {
- console.log("POST返回数据", url,res);
+ success: function (res) {
+ console.log("POST返回数据", url, res);
if (res.data.err_code == 0) {
wx.hideLoading();
resolve(res.data);
@@ -161,7 +161,7 @@ export function fetchPost(url, params, needToken, multiple) {
}
},
- fail: function(res) {
+ fail: function (res) {
wx.hideLoading();
wx.showToast({
title: '网络错误',
@@ -191,7 +191,7 @@ export function fetchGet(url, params, needToken) {
url: BASE_URL + url,
data: params,
method: 'GET',
- success: function(res) {
+ success: function (res) {
console.log("GET返回数据", url, res);
if (res.statusCode == 200) {
if (res.data.err_code == 0) {
@@ -232,7 +232,7 @@ export function fetchGet(url, params, needToken) {
})
}
},
- fail: function(res) {
+ fail: function (res) {
wx.hideLoading();
reject(res)
wx.showToast({
@@ -310,6 +310,9 @@ export default {
generateBarcode(params) {
return fetchPost('/venue/generate/barcode', params, true);
},
+ checkBarcode(params) {
+ return fetchPost('/user/check/barcode', params, true);
+ },
// 判断是否支付成功
memberIsPayed(params) {
return fetchPost('/member/isPayed', params, true);
diff --git a/utils/util.js b/utils/util.js
index 9a6b15e..270d82f 100644
--- a/utils/util.js
+++ b/utils/util.js
@@ -52,9 +52,22 @@ const getTimeoutStorage = (key) => {
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 = {
formatTime: formatTime,
getCurrentPageUrl: getCurrentPageUrl,
setTimeOutStorage: setTimeOutStorage,
- getTimeoutStorage: getTimeoutStorage
+ getTimeoutStorage: getTimeoutStorage,
+ getDistance: getDistance
}