Authored by 毕凯

Merge branch 'hotfix/wechat' into 'release/5.7.1'

微信支付问题



See merge request !618
@@ -146,42 +146,56 @@ if ($aliPayEL && $aliPayEL.length > 0 && $aliPayEL.data('href')) { @@ -146,42 +146,56 @@ if ($aliPayEL && $aliPayEL.length > 0 && $aliPayEL.data('href')) {
146 }); 146 });
147 } 147 }
148 148
149 -// 微信支付  
150 -function callpay(orderCode) { 149 +/**
  150 + * 获取微信支付数据
  151 + * @param {*} orderCode
  152 + */
  153 +function getWechatPayData(orderCode) {
151 let jsApiParameters; 154 let jsApiParameters;
152 155
  156 + $.ajax({
  157 + type: 'GET',
  158 + url: '/cart/index/new/pay',
  159 + data: {
  160 + order_code: orderCode,
  161 + payment: '22_platform',
  162 + },
  163 + dataType: 'json',
  164 + success: function(res) {
  165 + if (res.code === 200) {
  166 + jsApiParameters = res.data.jsApiParameters;
  167 + jsApiCall(orderCode, jsApiParameters);
  168 + } else {
  169 + tip.show('微信支付调取失败');
  170 + }
  171 + },
  172 + error: function() {
  173 + tip.show('请刷新本页面,完成微信支付');
  174 + },
  175 + complete: function() {
  176 + $loadingToast.addClass('hide');
  177 + }
  178 + });
  179 +}
  180 +
  181 +// 微信支付
  182 +function callpay(orderCode) {
153 $loadingToast.removeClass('hide'); 183 $loadingToast.removeClass('hide');
154 if (typeof WeixinJSBridge === 'undefined') { 184 if (typeof WeixinJSBridge === 'undefined') {
155 if (document.addEventListener) { 185 if (document.addEventListener) {
156 - document.addEventListener('WeixinJSBridgeReady', jsApiCall, false); 186 + document.addEventListener('WeixinJSBridgeReady', function() {
  187 + getWechatPayData(orderCode);
  188 + }, false);
157 } else if (document.attachEvent) { 189 } else if (document.attachEvent) {
158 - document.attachEvent('WeixinJSBridgeReady', jsApiCall);  
159 - document.attachEvent('onWeixinJSBridgeReady', jsApiCall); 190 + document.attachEvent('WeixinJSBridgeReady', function() {
  191 + getWechatPayData(orderCode);
  192 + });
  193 + document.attachEvent('onWeixinJSBridgeReady', function() {
  194 + getWechatPayData(orderCode);
  195 + });
160 } 196 }
161 } else { 197 } else {
162 - $.ajax({  
163 - type: 'GET',  
164 - url: '/cart/index/new/pay',  
165 - data: {  
166 - order_code: orderCode,  
167 - payment: '22_platform',  
168 - },  
169 - dataType: 'json',  
170 - success: function(res) {  
171 - if (res.code === 200) {  
172 - jsApiParameters = res.data.jsApiParameters;  
173 - jsApiCall(orderCode, jsApiParameters);  
174 - } else {  
175 - tip.show('微信支付调取失败');  
176 - }  
177 - },  
178 - error: function() {  
179 - tip.show('请刷新本页面,完成微信支付');  
180 - },  
181 - complete: function() {  
182 - $loadingToast.addClass('hide');  
183 - }  
184 - }); 198 + getWechatPayData(orderCode);
185 } 199 }
186 } 200 }
187 201