Applet front-end payment and payment H5 does not need to introduce other js, only the background relevant parameters
(
timeStamp: '',
nonceStr: '',
package: '',
signType: 'MD5',
paySign: '',
)
We can return to initiate micro-channel pay.
Applet payment:
wx.requestPayment({ timeStamp: '', nonceStr: '', package: '', signType: 'MD5', paySign: '', success (res) { }, fail (res) { } })
H5 payment:
1 callpay(needData) { 2 let that = this; 3 if (typeof WeixinJSBridge == "undefined") { 4 if (document.addEventListener) { 5 document.addEventListener('WeixinJSBridgeReady', that.jsApiCall, false); 6 } else if (document.attachEvent) { 7 document.attachEvent('WeixinJSBridgeReady', that.jsApiCall); 8 document.attachEvent('onWeixinJSBridgeReady', that.jsApiCall); 9 } 10 } else { 11 that.jsApiCall(needData); 12 } 13 }, 14 jsApiCall(needData) { 15 let that = this; 16 WeixinJSBridge.invoke( 17 'getBrandWCPayRequest', { 18 "appId": needData.appId, 19 "timeStamp": needData.timeStamp, 20 "nonceStr": needData.nonceStr, 21 "package": needData.package, 22 "signType": needData.signType, 23 "paySign": needData.paySign, 24 }, 25 function (res) { 26 27 if (res.err_msg == "get_brand_wcpay_request:ok") { 28 // alert('微信支付成功!'); 29 if (that.alonePay == true) { //单独购买 30 window.location.href = "courseList.html" + "?goods_id=" + that 31 .goods_id; 32 } else { //拼团购买 33 window.location.href = "groupDetail.html" + "?group_id=" + that 34 .group_id + "&goods_id=" + that.goods_id; 35 } 36 // window.location.href = "index.html"; 37 // window.location.href="http://h5.taotiangou.cn"; 38 } else if (res.err_msg == "get_brand_wcpay_request:cancel") { 39 alert ( 'micro-channel payment has been canceled!' ); 40 // window.location.href = "index.html"; 41 is // window.location.href = "http://h5.taotiangou.cn"; 42 is } the else IF : (res.err_msg == "get_brand_wcpay_request fail" ) { 43 is ( '! micro-channel payment fails' Alert ); 44 is // window.location.href = "index.html"; 45 46 is // window.location.href = "http://h5.taotiangou.cn"; 47 } 48 } 49 ); 50 },