欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

uniapp實現(xiàn)微信公眾號支付的方法步驟

 更新時間:2022年05月07日 09:09:29   作者:小馬總  
本文主要介紹了uniapp實現(xiàn)微信公眾號支付的方法步驟,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

1、申請企業(yè)服務(wù)號(必須企業(yè)認證)

https://mp.weixin.qq.com

2、獲取appid 和秘鑰

菜單 開發(fā)-基本配置 獲取秘鑰 、設(shè)置ip白名單

3、安全域名設(shè)置

進入公眾號設(shè)置-功能設(shè)置配置

4、代碼實現(xiàn)

點擊請求優(yōu)先去請求后臺訂單支付接口數(shù)據(jù)

將獲取到的數(shù)據(jù)放入以下請求數(shù)據(jù)里面 

callPay: function(response) {
				if (typeof WeixinJSBridge === "undefined") {
					if (document.addEventListener) {
						document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
					} else if (document.attachEvent) {
						document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
						document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
					}
				} else {
					this.onBridgeReady(response);
				}
			},
			onBridgeReady: function(response) {
				let that = this;
				if (!response.package) {
					return;
				}
				WeixinJSBridge.invoke(
					'getBrandWCPayRequest', {
						"appId": response.appid, //公眾號名稱,由商戶傳入
						"timeStamp": response.timestamp, //時間戳,自1970年以來的秒數(shù)
						"nonceStr": response.noncestr, //隨機串
						"package": response.package,
						"signType": response.signType, //微信簽名方式:
						"paySign": response.sign //微信簽名
					},
					function(res) {
						if (res.err_msg === "get_brand_wcpay_request:ok") {
							// 使用以上方式判斷前端返回,微信團隊鄭重提示:
							//res.err_msg將在用戶支付成功后返回ok,但并不保證它絕對可靠。
							uni.showLoading({
								title: '支付成功'
							});
							setTimeout(function() {
								uni.hideLoading();
								uni.redirectTo({
									url: '../member/orderdetail?id=' + that.id
								});
							}, 1000);
						} else {
							uni.hideLoading();
						}
						WeixinJSBridge.log(response.err_msg);
					}
				);
			},

到此這篇關(guān)于uniapp實現(xiàn)微信公眾號支付的方法步驟的文章就介紹到這了,更多相關(guān)uniapp 微信公眾號支付內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論