Commit 4ac6e92e authored by pengguangpu's avatar pengguangpu

添加防抖逻辑;完善支付结果页;

parent 54209913
......@@ -21,16 +21,17 @@ Page({
isNeedCountDown:false,
//金额显示
isShowPrice:false,
isShowFailedReason:true
isShowFailedReason:true,
reOpText:"重新支付",
countDownConfig:5
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
//just for test,delete this code
options.type = 1
options.isSuccess = false
options.type = parseInt(options.type)
options.isSuccess = 'true'===options.isSuccess
var payPriceYuan = options.payPriceYuan
var description = options.description
......@@ -51,11 +52,25 @@ Page({
iconUrl:"../../images/icon_fail.png",
description:"退款失败",
failedReason:options.failedReason,
isShowFailedReason:true
isShowFailedReason:true,
reOpText:"重新退款",
type:1
})
}else{
//支付结果
//支付失败
this.setData({
isSuccess:false,
isShowBackHome:true,
iconUrl:"../../images/icon_fail.png",
description:"支付失败",
failedReason:options.failedReason,
isShowFailedReason:true,
reOpText:"重新支付",
type:0,
isShowBackHome:false,
countDownConfig:30,
isNeedCountDown:true
})
}
}else{
this.setData({
......@@ -69,10 +84,20 @@ Page({
iconUrl:"../../images/icon_success.png",
description:"退款成功",
isShowFailedReason:false,
isShowPrice:true
isShowPrice:true,
type:1
})
}else{
//支付结果
this.setData({
isSuccess:true,
isShowBackHome:true,
iconUrl:"../../images/icon_success.png",
description:"支付成功",
isShowFailedReason:false,
isShowPrice:true,
type:0
})
}
}
......@@ -81,21 +106,21 @@ Page({
onShow:function(){
//回到首页倒计时
if(this.data.isNeedCountDown==true){
this.startPayCountDown()
this.startPayCountDown(this.data.countDownConfig)
}
},
/**
* 3秒倒计时结束 弹出选择支付方式
*/
startPayCountDown:function(){
startPayCountDown:function(countDownConfig){
this.setData({goHomeCountDown:"3秒后跳转到首页"})
this.setData({goHomeCountDown:countDownConfig+"s后跳转到首页"})
if (this.data.payCountDownTimer != null) {
clearInterval(this.data.payCountDownTimer)
}
var countDown = 3;
var countDown = countDownConfig;
var that = this;
var payCountDownTimer = setInterval(() => {
if(countDown <= 0){
......@@ -103,25 +128,29 @@ Page({
clearInterval(payCountDownTimer)
}else{
--countDown
that.setData({goHomeCountDown:countDown+"s后跳转到首页"})
that.setData({goHomeCountDown:countDown+"s后跳转到首页"})
}
}, 1000);
},
onReRefundClicked:throttle(1000,function(){
wx.navigateTo({
url: '/pages/refund/refund',
})
onReOpClicked:throttle(1000,function(){
if(this.data.type==0){
//重新支付
}else{
wx.navigateTo({
url: '/pages/refund/refund',
})
}
}),
/**
* 回到首页
*/
backHome(){
backHome:throttle(1000,function(){
wx.redirectTo({
url: '/pages/home/home',
})
}
})
})
\ No newline at end of file
......@@ -9,9 +9,9 @@
</view>
<!--重新退款-->
<view style="margin-top:120rpx;" hidden="{{!isShowFailedReason}}" bindtap="onReRefundClicked">
<text class="btn-re-refund">重新退款</text>
<!--重新退款or重新支付-->
<view style="margin-top:120rpx;" hidden="{{!isShowFailedReason}}" bindtap="onReOpClicked">
<text class="btn-re-refund">{{reOpText}}</text>
</view>
<view class="btn-go-home"><button style="width:572rpx;height:114rpx;display:flex; justify-content:center; align-items:center;font-size:40rpx;" type="default" bindtap="backHome" hidden="{{!isShowBackHome}}">回到首页</button>
</view>
......
......@@ -37,17 +37,24 @@ Page({
*/
onShow: function () {
//声明监听扫码器
wxfaceapp.listenCodePayment({
success(res){
//被扫码回调事件
wxfaceapp.onCodePayEvent(function (res) {
console.log("onCodePayEvent retCode = " + res.replyCode)
//被扫码到的具体的码
console.log("onCodePayEvent code scanned = " + res.code)
//去退款
startRefund(res.code)
})
}
// wxfaceapp.listenCodePayment({
// success(res){
// //被扫码回调事件
// wxfaceapp.onCodePayEvent(function (res) {
// console.log("onCodePayEvent retCode = " + res.replyCode)
// //被扫码到的具体的码
// console.log("onCodePayEvent code scanned = " + res.code)
// //去退款
// startRefund(res.code)
// })
// }
// })
},
onImageClicked:function(){
wx.redirectTo({
url: '/pages/pay_result/pay_result?isSuccess=false&type=1',
})
},
......@@ -58,7 +65,7 @@ Page({
var localAccountInfo = getApp().globalData.localAccountInfo;
console.info("localAccountInfo==>" + JSON.stringify(localAccountInfo));
if (localAccountInfo.success == true && localAccountInfo.data != null) {
if (localAccountInfo != null && localAccountInfo.success == true && localAccountInfo.data != null) {
this.data.saasid = localAccountInfo.data.store.saasid;
if (localAccountInfo.data.store.marketid != null) {
this.data.marketId = localAccountInfo.data.store.marketid;
......@@ -98,13 +105,13 @@ Page({
if (response.code == 0) {
//跳转页面
var payPriceYuan = miyapay.fen2Yuan(response.data.C7)
wx.navigateTo({
url: 'pages/pay_result/pay_result?isSuccess=true&payPriceYuan='+payPriceYuan,
wx.redirectTo({
url: '/pages/pay_result/pay_result?isSuccess=true&payPriceYuan='+payPriceYuan,
})
} else {
//提示报错
wx.navigateTo({
url: 'pages/pay_result/pay_result?isSuccess=false&failedReason='+response.data,
wx.redirectTo({
url: '/pages/pay_result/pay_result?isSuccess=false&failedReason='+response.data,
})
}
}
......
......@@ -7,7 +7,7 @@
<!--提示文字-->
<text style="color:black;font-weight:bold;font-size:40rpx;margin-left:auto;margin-right:auto;margin-top:112rpx;">请扫描订单条码退款</text>
<image src="" style="width:567rpx;height:567rpx;background-color:black;margin-left:auto;margin-right:auto;margin-top:224rpx;"></image>
<image src="" style="width:567rpx;height:567rpx;background-color:black;margin-left:auto;margin-right:auto;margin-top:224rpx;" bindtap="onImageClicked"></image>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment