{"id":1595,"date":"2023-03-25T20:00:56","date_gmt":"2023-03-25T12:00:56","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1595"},"modified":"2023-04-27T21:26:12","modified_gmt":"2023-04-27T13:26:12","slug":"wechat-payment-weixinjsbridge","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/25\/wechat-payment-weixinjsbridge\/","title":{"rendered":"\u5fae\u4fe1\u652f\u4ed8WeixinJSBridge"},"content":{"rendered":"<ul>\n<li>\u652f\u4ed8\u4ea7\u54c1\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/pay.weixin.qq.com\/wiki\/doc\/api\/external\/sl.html\">https:\/\/pay.weixin.qq.com\/wiki\/doc\/api\/external\/sl.html<\/a><\/li>\n<li>\u7edf\u4e00\u4e0b\u5355\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/pay.weixin.qq.com\/wiki\/doc\/api\/external\/native_sl.php?chapter=9_1\">https:\/\/pay.weixin.qq.com\/wiki\/doc\/api\/external\/native_sl.php?chapter=9_1<\/a><\/li>\n<li>\u5fae\u4fe1\u5185H5\u8c03\u8d77\u652f\u4ed8\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/pay.weixin.qq.com\/wiki\/doc\/api\/external\/jsapi_sl.php?chapter=7_7&amp;index=6\">https:\/\/pay.weixin.qq.com\/wiki\/doc\/api\/external\/jsapi_sl.php?chapter=7_7&#038;index=6<\/a><\/li>\n<\/ul>\n<p><!-- more --><\/p>\n<pre><code class=\"language-html\">&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n\n&lt;head&gt;\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\n    &lt;title&gt;&lt;\/title&gt;\n    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0,user-scalable=no&quot;&gt;\n    &lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot; \/&gt;\n    &lt;meta name=&quot;apple-mobile-web-app-status-bar-style&quot; content=&quot;black&quot;&gt;\n    &lt;script type=&quot;text\/javascript&quot; src=&quot;assets\/js\/lib\/jquery.js&quot;&gt;&lt;\/script&gt;\n    &lt;script src=&quot;http:\/\/res.wx.qq.com\/open\/js\/jweixin-1.0.0.js&quot;&gt;&lt;\/script&gt;\n    &lt;script type=&quot;text\/javascript&quot;&gt;\n        $(function() {\n            $(&#039;a&#039;).on(&#039;click&#039;, function() {\n                onBridgeReady();\n            });\n        });\n\n        function onBridgeReady() {\n            WeixinJSBridge.invoke(\n                &#039;getBrandWCPayRequest&#039;, {\n                    &quot;appId&quot;: &quot;wx23841cce7185b550&quot;, \/\/\u516c\u4f17\u53f7\u540d\u79f0\uff0c\u7531\u5546\u6237\u4f20\u5165     \n                    &quot;timeStamp&quot;: &quot;1461299152&quot;, \/\/\u65f6\u95f4\u6233\uff0c\u81ea1970\u5e74\u4ee5\u6765\u7684\u79d2\u6570     \n                    &quot;nonceStr&quot;: &quot;5719a7d0dcfe9&quot;, \/\/\u968f\u673a\u4e32     \n                    &quot;package&quot;: &quot;prepay_id=wx2016042212255470a7f75ae80873019950&quot;,\n                    &quot;signType&quot;: &quot;MD5&quot;, \/\/\u5fae\u4fe1\u7b7e\u540d\u65b9\u5f0f\uff1a     \n                    &quot;paySign&quot;: &quot;A867D7C2E837646581832F3B3833BB4B&quot; \/\/\u5fae\u4fe1\u7b7e\u540d \n                },\n                function(res) {\n                    if (res.err_msg == &quot;get_brand_wcpay_request\uff1aok&quot;) {} \/\/ \u4f7f\u7528\u4ee5\u4e0a\u65b9\u5f0f\u5224\u65ad\u524d\u7aef\u8fd4\u56de,\u5fae\u4fe1\u56e2\u961f\u90d1\u91cd\u63d0\u793a\uff1ares.err_msg\u5c06\u5728\u7528\u6237\u652f\u4ed8\u6210\u529f\u540e\u8fd4\u56de    ok\uff0c\u4f46\u5e76\u4e0d\u4fdd\u8bc1\u5b83\u7edd\u5bf9\u53ef\u9760\u3002 \n                }\n            );\n        }\n        if (typeof WeixinJSBridge == &quot;undefined&quot;) {\n            if (document.addEventListener) {\n                document.addEventListener(&#039;WeixinJSBridgeReady&#039;, onBridgeReady, false);\n            } else if (document.attachEvent) {\n                document.attachEvent(&#039;WeixinJSBridgeReady&#039;, onBridgeReady);\n                document.attachEvent(&#039;onWeixinJSBridgeReady&#039;, onBridgeReady);\n            }\n        } else {\n            onBridgeReady();\n        }\n    &lt;\/script&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n    &lt;a style=&quot;font-size: 20px;&quot;&gt;\u5206\u4eab\u4e00\u4e0b&lt;\/a&gt;\n&lt;\/body&gt;\n\n&lt;\/html&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u652f\u4ed8\u4ea7\u54c1\uff1ahttps:\/\/pay.weixin.qq.com\/wiki\/doc\/api\/external\/sl [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[371],"tags":[320],"class_list":["post-1595","post","type-post","status-publish","format-standard","hentry","category-wechat-pay","tag-jsbridge"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1595"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1595\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}