|
|
|
@ -672,13 +672,16 @@ |
|
|
|
|
// if (userAgent.match(/Alipay/i) == "alipay") { |
|
|
|
|
// this.createJSAPIOrder('ALIPAY'); |
|
|
|
|
// } else if (userAgent.match(/MicroMessenger/i) == "micromessenger") { |
|
|
|
|
this.createJSAPIOrder(); |
|
|
|
|
if (app.globalData.isClick) { |
|
|
|
|
this.createJSAPIOrder(); |
|
|
|
|
app.globalData.isClick = false; |
|
|
|
|
} |
|
|
|
|
// } |
|
|
|
|
}, |
|
|
|
|
// 创建订单 |
|
|
|
|
createJSAPIOrder(item) { |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title:'请求中' |
|
|
|
|
title: '请求中' |
|
|
|
|
}) |
|
|
|
|
// "微信:WECHAT 支付宝:ALIPAY 银联:UQRCODEPAY", |
|
|
|
|
let phone = ''; |
|
|
|
@ -699,6 +702,7 @@ |
|
|
|
|
if (res.return_code == '000000') { |
|
|
|
|
this.jsapiPay(res.return_data.outTradeNo); |
|
|
|
|
} else { |
|
|
|
|
app.globalData.isClick = true; |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: res.return_msg, |
|
|
|
|
duration: 2000, |
|
|
|
@ -709,10 +713,14 @@ |
|
|
|
|
}, |
|
|
|
|
//唤起支付参数 |
|
|
|
|
jsapiPay(item) { |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '请求中' |
|
|
|
|
}) |
|
|
|
|
let datas = { |
|
|
|
|
outTradeNo: item |
|
|
|
|
} |
|
|
|
|
jsapiPay(datas).then(res => { |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
if (res.return_code == '000000') { |
|
|
|
|
if (res.return_data.payParam && app.globalData.platformType == 'WECHAT') { |
|
|
|
|
this.wechatpayRequest(res.return_data); |
|
|
|
@ -733,6 +741,7 @@ |
|
|
|
|
duration: 2000 |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
app.globalData.isClick = true; |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: res.return_msg, |
|
|
|
|
duration: 2000, |
|
|
|
@ -848,10 +857,11 @@ |
|
|
|
|
}, |
|
|
|
|
//微信支付 |
|
|
|
|
wechatpayRequest: function(self) { |
|
|
|
|
let that = this; |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '支付中...' |
|
|
|
|
}) |
|
|
|
|
if (self.platformType == 1) { |
|
|
|
|
if (self.platformType == 1 || self.platformType == 5) { |
|
|
|
|
jweixin.config({ |
|
|
|
|
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 |
|
|
|
|
appId: self.payParam.acc_resp_fields.app_id, // 必填,公众号的唯一标识 |
|
|
|
@ -864,8 +874,12 @@ |
|
|
|
|
jweixin.ready(function() { |
|
|
|
|
jweixin.checkJsApi({ |
|
|
|
|
jsApiList: ['chooseWXPay'], // 需要检测的JS接口列表,所有JS接口列表见附录2, |
|
|
|
|
success: function(res) {}, |
|
|
|
|
fail: function(res) {} |
|
|
|
|
success: function(res) { |
|
|
|
|
app.globalData.isClick = true; |
|
|
|
|
}, |
|
|
|
|
fail: function(res) { |
|
|
|
|
app.globalData.isClick = true; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
jweixin.chooseWXPay({ |
|
|
|
|
appId: self.payParam.acc_resp_fields.app_id, |
|
|
|
@ -883,11 +897,16 @@ |
|
|
|
|
title: '支付成功' |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
cancel: function(r) {}, |
|
|
|
|
fail: function(res) {} |
|
|
|
|
cancel: function(r) { |
|
|
|
|
app.globalData.isClick = true; |
|
|
|
|
}, |
|
|
|
|
fail: function(res) { |
|
|
|
|
app.globalData.isClick = true; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
jweixin.error(function(res) { |
|
|
|
|
app.globalData.isClick = true; |
|
|
|
|
uni.showToast({ |
|
|
|
|
icon: 'none', |
|
|
|
|
title: '支付失败了', |
|
|
|
@ -924,11 +943,16 @@ |
|
|
|
|
title: '支付成功' |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
cancel: function(r) {}, |
|
|
|
|
fail: function(res) {} |
|
|
|
|
cancel: function(r) { |
|
|
|
|
app.globalData.isClick = true; |
|
|
|
|
}, |
|
|
|
|
fail: function(res) { |
|
|
|
|
app.globalData.isClick = true; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
jweixin.error(function(res) { |
|
|
|
|
app.globalData.isClick = true; |
|
|
|
|
uni.showToast({ |
|
|
|
|
icon: 'none', |
|
|
|
|
title: '支付失败了', |
|
|
|
@ -942,6 +966,7 @@ |
|
|
|
|
alipayApi.tradePay({ |
|
|
|
|
tradeNO: item |
|
|
|
|
}, function(res) { |
|
|
|
|
app.globalData.isClick = true; |
|
|
|
|
// alert(JSON.stringify(res)); |
|
|
|
|
//支付完成的逻辑 |
|
|
|
|
}); |
|
|
|
|