wx 篮球场馆增加实时收付

This commit is contained in:
2023-12-31 02:20:32 +08:00
parent e504efbde6
commit 22c1f3e963
5 changed files with 306 additions and 155 deletions

View File

@@ -21,11 +21,14 @@ Page({
*/ */
data: { data: {
venues: {}, venues: {},
isShowBuyVip: false, // isShowBuyVip: false,
buyVipObj: {}, // buyVipObj: {},
showUnclickMask: false, showUnclickMask: false,
showCardMask: false, // showCardMask: false,
orderSn: '000',
payMoney: 0,
flg: 100, flg: 100,
isPayed: false,
msg: '', msg: '',
isWxLogin: false, isWxLogin: false,
isGoHome: false, isGoHome: false,
@@ -123,6 +126,70 @@ Page({
}); });
}, },
checkIsPayed(orderSn) {
this.setData({
flg: 777,
msg: '正在查询支付结果...'
})
let that = this;
setTimeout(function(){
app.$api.memberIsPayed({
orderSn: orderSn
}).then(res => {
if (res.isPayed) {
that.setData({
flg: 0,
msg: ''
})
that.showBarcode(orderSn)
} else {
that.setData({
flg: 777,
msg: '正在确认支付结果,请勿退出...'
})
//第二次
setTimeout(function(){
app.$api.memberIsPayed({
orderSn: orderSn
}).then(res => {
if (res.isPayed) {
that.setData({
flg: 0,
msg: ''
})
that.showBarcode(orderSn)
} else {
that.setData({
flg: 777,
msg: '最后一次确认订单状态...'
})
// 第三次
setTimeout(function(){
app.$api.memberIsPayed({
orderSn: orderSn
}).then(res => {
if (res.isPayed) {
that.setData({
flg: 0,
msg: ''
})
that.showBarcode(orderSn)
}else {
that.setData({
flg: 999,
msg: '订单未成功支付'
})
}
});
},5000)
}
});
},5000)
}
});
},5000)
},
// 打开导航, // 打开导航,
opnGPS() { opnGPS() {
wx.openLocation({ wx.openLocation({
@@ -134,18 +201,18 @@ Page({
}, },
// 充值 // 充值
recharge() { // recharge() {
if (!wx.getStorageSync('accessToken')) { // if (!wx.getStorageSync('accessToken')) {
wx.setStorageSync('history', getCurrentPageUrl()); // wx.setStorageSync('history', getCurrentPageUrl());
wx.redirectTo({ // wx.redirectTo({
url: '/pages/login/index', // url: '/pages/login/index',
}) // })
return // return
} // }
wx.navigateTo({ // wx.navigateTo({
url: '/pages/myAccount/index', // url: '/pages/myAccount/index',
}) // })
}, // },
// 打电话 // 打电话
callPhone() { callPhone() {
@@ -155,20 +222,20 @@ Page({
}, },
// 购买套餐 // 购买套餐
nowBuy(e) { // nowBuy(e) {
let index = e.currentTarget.dataset.index; // let index = e.currentTarget.dataset.index;
if (!wx.getStorageSync('accessToken')) { // if (!wx.getStorageSync('accessToken')) {
wx.setStorageSync('history', getCurrentPageUrl()); // wx.setStorageSync('history', getCurrentPageUrl());
wx.redirectTo({ // wx.redirectTo({
url: '/pages/login/index', // url: '/pages/login/index',
}) // })
return // return
} // }
this.setData({ // this.setData({
isShowBuyVip: true, // isShowBuyVip: true,
buyVipObj: this.data.venues.cards[index] // buyVipObj: this.data.venues.cards[index]
}) // })
}, // },
// 我要进场 // 我要进场
enter() { enter() {
@@ -177,19 +244,11 @@ Page({
}).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
}) })
if (res.join.flg == 0) { if (res.join.flg == 0) {
drawQrcode({ this.showBarcode('000')
width: 180,
height: 180,
x: 10,
y: 10,
canvasId: 'myQrcode',
// ctx: wx.createCanvasContext('myQrcode'),
typeNumber: 10,
text: res.join.barcode
})
} }
}, err => { }, err => {
console.log(err); console.log(err);
@@ -204,19 +263,11 @@ Page({
}).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
}) })
if (res.out.flg == 0) { if (res.out.flg == 0) {
drawQrcode({ this.showBarcode('000')
width: 180,
height: 180,
x: 10,
y: 10,
canvasId: 'myQrcode',
// ctx: wx.createCanvasContext('myQrcode'),
typeNumber: 10,
text: res.out.barcode
})
} }
}, err => { }, err => {
console.log(err); console.log(err);
@@ -238,64 +289,64 @@ Page({
}, },
// 关闭购买vip弹框 // 关闭购买vip弹框
closeBuyVipPopup() { // closeBuyVipPopup() {
this.setData({ // this.setData({
isShowBuyVip: false // isShowBuyVip: false
}) // })
}, // },
// 购买Vip // 购买Vip
buyVip() { // buyVip() {
let that = this; // let that = this;
this.setData({ // this.setData({
showUnclickMask: true // showUnclickMask: true
}) // })
app.$api.memberCardOrderCreate({ // app.$api.memberCardOrderCreate({
cardType: this.data.buyVipObj.cardType, // cardType: this.data.buyVipObj.cardType,
num: 1, // num: 1,
type: this.data.venues.type, // type: this.data.venues.type,
venueId: this.data.venues.id // venueId: this.data.venues.id
}).then(res => { // }).then(res => {
app.$pay.wxPay(res.pay).then(res => { // app.$pay.wxPay(res.pay).then(res => {
that.setData({ // that.setData({
isShowBuyVip: false, // isShowBuyVip: false,
showUnclickMask: false // showUnclickMask: false
}) // })
}, err => { // }, err => {
that.setData({ // that.setData({
isShowBuyVip: false, // isShowBuyVip: false,
showUnclickMask: false // showUnclickMask: false
}) // })
//
}) // })
}, err => { // }, err => {
// console.log(err); // // console.log(err);
this.setData({ // this.setData({
isShowBuyVip: false, // isShowBuyVip: false,
showUnclickMask: false // showUnclickMask: false
}) // })
if (err.data.err_code == 30022) { // if (err.data.err_code == 30022) {
this.setData({ // this.setData({
isWxLogin: true, // isWxLogin: true,
isShowBuyVip: false // isShowBuyVip: false
}) // })
} // }
}) // })
}, // },
// 关闭 // 关闭
cancelCardMask() { // cancelCardMask() {
this.setData({ // this.setData({
showCardMask: false // showCardMask: false
}) // })
}, // },
// 开启会员卡提示 // 开启会员卡提示
showCardContent() { // showCardContent() {
this.setData({ // this.setData({
showCardMask: true // showCardMask: true
}) // })
}, // },
// 关闭提示框 // 关闭提示框
cancelDeleteDialog() { cancelDeleteDialog() {
@@ -306,16 +357,59 @@ Page({
// 点击提示框确认 // 点击提示框确认
confirmDeleteDialog() { confirmDeleteDialog() {
if (this.data.flg == 2) { // 去支付
wx.navigateTo({ app.$api.basketOrder({
url: '/pages/myAccount/index?isPass=1', venueId: this.data.venues.id,
payMoney: this.data.payMoney
}).then(res => {
this.setData({
orderSn: res.pay.orderSn
})
app.$pay.wxPay(res.pay).then(res => {
console.log('支付成功了')
this.checkIsPayed(this.data.orderSn)
}, err => {
console.log('支付失败')
this.setData({
flg: 999,
msg: '支付失败,用户取消支付'
})
})
}, err => {
if (err.data.err_code == 30022) {
this.setData({
isWxLogin: true,
}) })
} }
if (this.data.flg == 1) {
wx.navigateTo({
url: '/pages/facialCapturing/index?isPass=1',
}) })
} },
showBarcode(orderSn) {
app.$api.generateBarcode({
venueId: this.data.venues.id,
enterFlag: this.data.venues.enterFlag,
orderSn: orderSn
}).then(res => {
this.setData({
flg: 0
})
drawQrcode({
width: 180,
height: 180,
x: 10,
y: 10,
canvasId: 'myQrcode',
// ctx: wx.createCanvasContext('myQrcode'),
typeNumber: 10,
text: res.barcode
})
}, err => {
console.log(err)
this.setData({
flg: 999,
msg: '生成二维码失败'
})
});
}, },
// 取消授权登录 // 取消授权登录

View File

@@ -29,7 +29,7 @@
<view class='cell unline'> <view class='cell unline'>
<image src='../../images/25@3x.png' mode='aspectFit'></image> <image src='../../images/25@3x.png' mode='aspectFit'></image>
<text>按时间段收费</text> <text>按时间段收费</text>
<view class='cell-right-btn' bindtap='recharge'>充值</view> <!-- <view class='cell-right-btn' bindtap='recharge'>充值</view>-->
</view> </view>
<view class='dynamic-height'> <view class='dynamic-height'>
<block wx:if="{{venues.venuePriceList.length>0}}">收费说明: </block> <block wx:if="{{venues.venuePriceList.length>0}}">收费说明: </block>
@@ -43,25 +43,25 @@
</block> </block>
</view> </view>
</view> </view>
<view class='cell-box'> <!-- <view class='cell-box'>-->
<view class='cell'> <!-- <view class='cell'>-->
<image src='../../images/40@3x.png' mode='aspectFit'></image> <!-- <image src='../../images/40@3x.png' mode='aspectFit'></image>-->
<view class='title'> <!-- <view class='title'>-->
<text>VIP会员享受专属特权</text> <!-- <text>VIP会员享受专属特权</text>-->
<image src='../../images/5@3x.png' wx:if="{{venues.cardContent}}" bindtap='showCardContent'></image> <!-- <image src='../../images/5@3x.png' wx:if="{{venues.cardContent}}" bindtap='showCardContent'></image>-->
</view> <!-- </view>-->
</view> <!-- </view>-->
<view class='cell unline' wx:for="{{venues.cards}}" wx:key="{{index}}"> <!-- <view class='cell unline' wx:for="{{venues.cards}}" wx:key="{{index}}">-->
<view class='tip'>{{item.cardName}}</view> <!-- <view class='tip'>{{item.cardName}}</view>-->
<text>¥{{item.price}}</text> <!-- <text>¥{{item.price}}</text>-->
<view class='buy-btn' bindtap='nowBuy' data-index='{{index}}'>立即购买</view> <!-- <view class='buy-btn' bindtap='nowBuy' data-index='{{index}}'>立即购买</view>-->
</view> <!-- </view>-->
<view class='cell unline'> <!-- <view class='cell unline'>-->
<view class='tip'>单次</view> <!-- <view class='tip'>单次</view>-->
<text>选购</text> <!-- <text>选购</text>-->
<view class='buy-btn' bindtap='recharge'>立即购买</view> <!-- <view class='buy-btn' bindtap='recharge'>立即购买</view>-->
</view> <!-- </view>-->
</view> <!-- </view>-->
<view class='cell-box'> <view class='cell-box'>
<view class='cell'> <view class='cell'>
<image src='../../images/35@3x.png' mode='aspectFit'></image> <image src='../../images/35@3x.png' mode='aspectFit'></image>
@@ -103,23 +103,59 @@
</view> </view>
</view> </view>
<view class='buyVIPPopup' catchtouchmove='unMove' wx:if="{{isShowBuyVip}}"> <!--<view class='buyVIPPopup' catchtouchmove='unMove' wx:if="{{isShowBuyVip}}">-->
<view class='popup-body'> <!-- <view class='popup-body'>-->
<view class='popup-header'> <!-- <view class='popup-header'>-->
<text>会员卡购买</text> <!-- <text>会员卡购买</text>-->
<image src='../../images/23@3x.png' catchtap='closeBuyVipPopup'></image> <!-- <image src='../../images/23@3x.png' catchtap='closeBuyVipPopup'></image>-->
</view> <!-- </view>-->
<view class='popup-center'> <!-- <view class='popup-center'>-->
<view class='popup-cell'> <!-- <view class='popup-cell'>-->
<text>会员卡类型</text> <!-- <text>会员卡类型</text>-->
<text>{{buyVipObj.cardName}}</text> <!-- <text>{{buyVipObj.cardName}}</text>-->
</view> <!-- </view>-->
<view class='popup-cell'> <!-- <view class='popup-cell'>-->
<text>价格</text> <!-- <text>价格</text>-->
<text>¥{{buyVipObj.price}}</text> <!-- <text>¥{{buyVipObj.price}}</text>-->
<!-- </view>-->
<!-- </view>-->
<!-- <view class='popup-btn' catchtap='buyVip'>确认支付</view>-->
<!-- </view>-->
<!--</view>-->
<view class='in-step-popup' catchtouchmove='unMove' wx:if="{{flg == 777}}">
<view class='medium-body body'>
<view class='top'>
<view class='title'>
<image src='../../images/24@3x.png'></image>
<text>请稍候</text>
</view>
</view>
<view class='center'>
<view class='item'>
<view class='step'>订单确认中</view>
</view>
<view class='item'>
<view class='message'>{{msg}}</view>
</view>
</view>
</view>
</view>
<view class='in-step-popup' catchtouchmove='unMove' wx:if="{{flg == 888}}">
<view class='small-body body'>
<view class='top'>
<view class='title'>
<image src='../../images/24@3x.png'></image>
<text>提示</text>
</view>
<image src='../../images/23@3x.png' bindtap='closeInStep'></image>
</view>
<view class='center'>
<view class='item'>
<view class='step'>{{msg}}</view>
</view> </view>
</view> </view>
<view class='popup-btn' catchtap='buyVip'>确认支付</view>
</view> </view>
</view> </view>
@@ -128,7 +164,7 @@
<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>
@@ -152,7 +188,7 @@
</view> </view>
</view> </view>
<confirm-dialog title="提示" message="{{msg}}" confirmBtnTitle="充值" bindcancelselect="cancelDeleteDialog" bindconfirmselect="confirmDeleteDialog" wx:if="{{flg == 2}}"></confirm-dialog> <confirm-dialog title="提示" message="{{msg}}" confirmBtnTitle="确认支付" bindcancelselect="cancelDeleteDialog" bindconfirmselect="confirmDeleteDialog" wx:if="{{flg == 2}}"></confirm-dialog>
<!--<confirm-dialog title="提示" message="请先上传照片,以供人脸识别入场" bindcancelselect="cancelDeleteDialog" bindconfirmselect="confirmDeleteDialog" wx:if="{{flg == 1}}"></confirm-dialog>--> <!--<confirm-dialog title="提示" message="请先上传照片,以供人脸识别入场" bindcancelselect="cancelDeleteDialog" bindconfirmselect="confirmDeleteDialog" wx:if="{{flg == 1}}"></confirm-dialog>-->

View File

@@ -166,6 +166,13 @@
border-radius: 10rpx; border-radius: 10rpx;
} }
.in-step-popup .medium-body {
width: 600rpx;
height: 300rpx;
background: #252330;
border-radius: 10rpx;
}
.in-step-popup .small-body { .in-step-popup .small-body {
width: 600rpx; width: 600rpx;
height: 222rpx; height: 222rpx;

View File

@@ -110,15 +110,17 @@ Page({
rechargeId: this.data.recharges[this.data.selectIndex].id rechargeId: this.data.recharges[this.data.selectIndex].id
}).then(res => { }).then(res => {
app.$pay.wxPay(res.pay).then(res => { app.$pay.wxPay(res.pay).then(res => {
if (this.data.options.isPass == 1) { // if (this.data.options.isPass == 1) {
wx.redirectTo({ // wx.redirectTo({
url: '/pages/facialCapturing/index?isPass=' + 1, // url: '/pages/facialCapturing/index?isPass=' + 1,
}) // })
} else { // } else {
console.log('支付成功了')
this.getData(); this.getData();
this.data.isUnClick = false; this.data.isUnClick = false;
} // }
}, err => { }, err => {
console.log(err)
this.data.isUnClick = false; this.data.isUnClick = false;
}) })
}, err => { }, err => {

View File

@@ -301,6 +301,18 @@ export default {
venueOut(params) { venueOut(params) {
return fetchGet('/venue/out', params, true); return fetchGet('/venue/out', params, true);
}, },
// 篮球馆下订单
basketOrder(params) {
return fetchPost('/venue/basketball/pay', params, true);
},
// 篮球馆下订单
generateBarcode(params) {
return fetchPost('/venue/generate/barcode', params, true);
},
// 判断是否支付成功
memberIsPayed(params) {
return fetchPost('/member/isPayed', params, true);
},
/** /**
* 个人中心 * 个人中心