日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

小程序支付及H5支付前端代码小结

發(fā)布時間:2023/12/2 HTML 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 小程序支付及H5支付前端代码小结 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

小程序支付和H5支付前端都不需要引入其他的js , 只需要后臺將相關(guān)的參數(shù)

timeStamp: '', nonceStr: '', package: '', signType: 'MD5', paySign: '',

返回來就可以發(fā)起微信支付。

?

小程序支付:

wx.requestPayment({timeStamp: '',nonceStr: '',package: '',signType: 'MD5',paySign: '',success (res) { },fail (res) { } })

?

H5支付:

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) { //單獨(dú)購買 30 window.location.href = "courseList.html" + "?goods_id=" + that 31 .goods_id; 32 } else { //拼團(tuán)購買 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('已取消微信支付!'); 40 // window.location.href = "index.html"; 41 // window.location.href="http://h5.taotiangou.cn"; 42 } else if (res.err_msg == "get_brand_wcpay_request:fail") { 43 alert('微信支付失敗!'); 44 // window.location.href = "index.html"; 45 46 // window.location.href="http://h5.taotiangou.cn"; 47 } 48 } 49 ); 50 },

?

轉(zhuǎn)載于:https://www.cnblogs.com/teamemory/p/10977953.html

總結(jié)

以上是生活随笔為你收集整理的小程序支付及H5支付前端代码小结的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。