12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- function goPay(param, success) {
- var url = "/dealer/pay/gateway";
- var sendOpt = {
- url: url,
- type: "GET",
- // 非常特殊的处理,GET带JSON参数 todo
- data: {param: JSON.stringify(param)},
- mask: "正在获取支付参数...",
- success: function (res) {
- let payload = res.payload
- if (res.result == 1) {
- if (res.payload.payUrl) {
- location.href = res.payload.payUrl;
- } else {
- function onBridgeReady() {
- // 由于微信window.WeixinJSBridge经常报错,再判断一次
- if (!window.WeixinJSBridge) {
- mui.toast("微信支付初始化失败,请重试");
- return;
- }
- window.WeixinJSBridge.invoke("getBrandWCPayRequest", {
- appId: res.para.appId,
- timeStamp: res.para.timeStamp,
- nonceStr: res.para.nonceStr,
- "package": res.para.package,
- signType: res.para.signType,
- paySign: res.para.paySign
- }, function (e) {
- if ("get_brand_wcpay_request:ok" == e.err_msg) {
- if (payload.golden) {
- console.log('wechat golden plan has ad.')
- return;
- }
- location.href = '/public/thirdReceipt.html?orderType=recharge&outTradeNo=' + payload.outTradeNo;
- } else if ("get_brand_wcpay_request:fail" == e.err_msg) {
- mui.toast("付款失败");
- }
- });
- }
- if (typeof window.WeixinJSBridge == "undefined") {
- if (document.addEventListener) {
- document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
- } else if (document.attachEvent) {
- document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
- document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
- }
- } else {
- onBridgeReady();
- }
- }
- } else {
- mui.toast(res.description);
- }
- }
- }
- sendRequest(sendOpt);
- }
|