Commit 4ac6e92e authored by pengguangpu's avatar pengguangpu

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

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