diff --git a/utils/pay.js b/utils/pay.js index cd76b8b..ddd33e6 100644 --- a/utils/pay.js +++ b/utils/pay.js @@ -1,4 +1,4 @@ -var t = getApp(), n = t.request; +var t = getApp(), n = t.request,wx_paying=0; module.exports = { url: "/api/weshop/order/pay/createOrder", @@ -20,6 +20,10 @@ module.exports = { }); }, pay: function(t, e, a,sto,type) { + + if(wx_paying) return false; + wx_paying=1; + var i = this; var dd = { parent_sn: t, @@ -28,9 +32,11 @@ module.exports = { }; if (type == 1) dd.type = 1; + wx.showLoading(); n.post(this.url, { data: dd, success: function(t) { + wx.hideLoading(); if(t.data.code==0){ i.weixinPay(t.data.data, e, a); }else{ @@ -39,14 +45,19 @@ module.exports = { wx.redirectTo({ url: "/pages/user/order_list/order_list", }); - },1000) + },1000) + wx_paying=0; } return false; }, fail: function() { + wx.hideLoading(); + wx_paying=0; "function" == typeof a && a(); }, failStatus: function() { + wx.hideLoading(); + wx_paying=0; "function" == typeof a && a(); } }); @@ -64,9 +75,11 @@ module.exports = { paySign: n.paySign, orderInfo: n.orderInfo, // 需要新增的 订单 信息 success (n) { + wx_paying=0; t.showSuccess("支付成功!", e); }, fail (n) { + wx_paying=0; if(!n.errMsg ) { getApp().showWarning("支付失败"); "function" == typeof fail && fail(); @@ -87,9 +100,11 @@ module.exports = { signType: n.signType, paySign: n.paySign, success: function (n) { + wx_paying=0; console.log(n), t.showSuccess("支付成功!", e); }, fail: function (n) { + wx_paying=0; console.log(n), "requestPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") : t.confirmBox("支付失败:" + n.errMsg.substr("requestPayment:fail ".length)), "function" == typeof a && a(); diff --git a/utils/pay2.js b/utils/pay2.js index 3e46819..11562b3 100644 --- a/utils/pay2.js +++ b/utils/pay2.js @@ -1,12 +1,18 @@ -var t = getApp(), n = t.request; +var t = getApp(), n = t.request,wx_paying=0; module.exports = { url: "/api/weshop/plus/create/plus/order", pay: function(dd, succ,fail) { + + if(wx_paying) return false; + wx_paying=1; + + wx.showLoading(); var i = this; n.post(this.url, { data: dd, success: function(t) { + wx.hideLoading(); if(t.data.code==0){ if(t.data.data=="升级成功"){ "function" == typeof succ && succ(1); @@ -19,9 +25,13 @@ module.exports = { return false; }, fail: function() { + wx.hideLoading(); + wx_paying=0; "function" == typeof fail && fail(); }, failStatus: function() { + wx.hideLoading(); + wx_paying=0; "function" == typeof fail && fail(); } }); @@ -35,9 +45,11 @@ module.exports = { signType: n.signType, paySign: n.paySign, success: function(n) { + wx_paying=0; "function" == typeof succ && succ(); }, fail: function(n) { + wx_paying=0; "function" == typeof fail && fail(); } });