Commit 65bff2be by wangshuo

微信支付

parent 7cce25fa
...@@ -124,7 +124,8 @@ export default class PayOrder extends Component { ...@@ -124,7 +124,8 @@ export default class PayOrder extends Component {
} }
// 微信内部支付 // 微信内部支付
isweixinPay = () => { isweixinPay = () => {
let weixin_code = getParam('code') let _this = this;
let weixin_code = getParam('code');
if (weixin_code) { if (weixin_code) {
if (getParam('oid') === undefined) { if (getParam('oid') === undefined) {
return return
...@@ -132,20 +133,10 @@ export default class PayOrder extends Component { ...@@ -132,20 +133,10 @@ export default class PayOrder extends Component {
http.get(`${API['base-api']}/pay/wxpay/pub_charge/oid/${getParam('oid')}/code/${weixin_code}`).then((res) => { http.get(`${API['base-api']}/pay/wxpay/pub_charge/oid/${getParam('oid')}/code/${weixin_code}`).then((res) => {
if (res.data.errno === 0) { if (res.data.errno === 0) {
let data = res.data.data; let data = res.data.data;
// this.BridgeData = res.data.data;
// Toast.info(this.BridgeData.appId, 1);
// this.onBridgeReady(this.BridgeData); // 这个应该不需要
function onBridgeReady() { function onBridgeReady() {
Toast.info(data.appId, 2);
console.log(`181 line data: ${JSON.stringify(data)}`);
let _this = this;
// data = data || _this.BridgeData;
console.log(`184 line data: ${JSON.stringify(data)}`);
Toast.info(data.appId, 5);
WeixinJSBridge.invoke( WeixinJSBridge.invoke(
'getBrandWCPayRequest', { 'getBrandWCPayRequest', {
appId:"wx23dac6775ac82877", //公众号名称,由商户传入 appId:data.appId, //公众号名称,由商户传入
timeStamp:data.timeStamp, //时间戳,自1970年以来的秒数 timeStamp:data.timeStamp, //时间戳,自1970年以来的秒数
nonceStr:data.nonceStr, //随机串 nonceStr:data.nonceStr, //随机串
package:data.package, package:data.package,
...@@ -155,7 +146,24 @@ export default class PayOrder extends Component { ...@@ -155,7 +146,24 @@ export default class PayOrder extends Component {
function (res) { function (res) {
if (res.err_msg == "get_brand_wcpay_request:ok") { if (res.err_msg == "get_brand_wcpay_request:ok") {
Toast.info('支付成功', 2); Toast.info('支付成功', 2);
_this.payCallback(); _this.intervalPayStatus = setInterval(function(){
http.get(`${API['base-api']}/m/orderState/oid/${getParam('oid')}`).then(res => {
if (res.data.errno === 401) {
clearInterval(_this.intervalPayStatus);
_this.intervalPayStatus = null;
// 获取课程类型
http.get(`${API.home}/m/app_order/detail/${getParam('oid')}`).then(res => {
if(res.data.data.course_type === '2') {
this.props.history.replace(`/togroup?id=${getParam('oid')}`);
}else{
// 跳转到已购课程 /purchased 不需要传递任何参数
this.props.history.replace(`/purchased`);
}
});
}
})
}, 1000)
} else { } else {
alert('支付失败') alert('支付失败')
} }
......
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