商家小票页面示例.html 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <script
  8. type="text/javascript"
  9. charset="UTF-8"
  10. src="//wx.gtimg.com/pay_h5/goldplan/js/jgoldplan-1.0.0.js"
  11. ></script>
  12. <title>支付完成</title>
  13. </head>
  14. <body>
  15. <h2>商家小票页面示例</h2>
  16. <script>
  17. document.addEventListener("DOMContentLoaded", function () {
  18. console.info("app URL", window.location.href);
  19. // 展示商家小票:
  20. let mchData = {
  21. action: "onIframeReady",
  22. displayStyle: "SHOW_CUSTOM_PAGE",
  23. };
  24. let postData = JSON.stringify(mchData);
  25. parent.postMessage(postData, "https://payapp.weixin.qq.com");
  26. var sub_mch_id = getQueryString("sub_mch_id");
  27. var serviceCode = getQueryString("serviceCode");
  28. console.log("sub_mch_id", sub_mch_id);
  29. });
  30. /**
  31. * 获取链接某个参数
  32. */
  33. function getQueryString(key, url) {
  34. const reg = new RegExp(`([?&]+)${key}=([^&#]*)`);
  35. const href = url || window.location.href;
  36. const matches = href.substring(1).match(reg);
  37. return matches ? decodeURIComponent(matches[2]) : "";
  38. }
  39. </script>
  40. </body>
  41. </html>