提交 84d78079 作者: 王进

增加支付遮罩

上级 6dfe2032
......@@ -15,7 +15,6 @@ class WechatSDK {
this.sdkinit()
}
private debug: number // 1是测试模式,用于printf函数输出
private isPaying: boolean = false // 支付状态
private sdkinit() {
const that = this
//配置默认参数
......@@ -156,9 +155,7 @@ class WechatSDK {
public payOrder(Params) {
const that = this
that.MidasPaymentParams.offerId = SDKConfig.offerid
//根据支付状态来判断是否发起订单请求
if (!that.isPaying) {
that.isPaying = true
that.LoadingOn();
// 支付前先获取用户订单状态,如果没有未完成订单则继续支付
that.sdkRequest(sdkPortLinks.order, that.deepCopy({}, that.sdkParams, Params)).then(res => {
console.log("订单返回---->", res)
......@@ -178,6 +175,7 @@ class WechatSDK {
success: () => { console.log("跳转成功") },
fail: () => { console.log("跳转失败") }
}
that.LoadingOff();
that.navigateToMiniProgram(params)
} else {
// 根据返回的用户订单状态判断是新订单还是未完成订单
......@@ -197,7 +195,9 @@ class WechatSDK {
that.printf(err, 0)
}
}));
that.LoadingOff();
} else { // 已有未完成订单,弹窗提示
that.LoadingOff();
const params = {
title: SDKConfig.shareTitle,
content: '订单发货中,请稍候下单..'
......@@ -206,16 +206,16 @@ class WechatSDK {
}
}
} else { // 输出订单失败消息
that.LoadingOff();
const errmsg = res.msg || '支付失败..'
that.printf(res.msg, 1)
that.sdkAlert(res.msg)
that.sdkAlert(errmsg)
}
that.isPaying = false
}, err => {
that.isPaying = false
that.LoadingOff();
console.log(err)
})
}
}
private getCoins(orderParams) { // 通知服务端扣费
this.printf("SDK -> 通知扣费:", 0)
this.printf(orderParams, 0)
......@@ -606,6 +606,17 @@ class WechatSDK {
that.sdkAlert('微信版本不兼容,请升级..')
}
}
private LoadingOn() {
(wx as any).showLoading({
title: '请稍候..',
mask: true
})
}
private LoadingOff() {
(wx as any).hideLoading()
}
}
// md5加密
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论