pay.html 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"></script>
  7. </head>
  8. <body>
  9. <input type="text" id="sddd" value=""/>
  10. <input type="button" value="提交" onclick="sendfun();"/>
  11. <script type="application/javascript">
  12. function getQueryString(name) {
  13. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  14. var r = window.location.search.substr(1).match(reg);
  15. if (r != null) return unescape(r[2]);
  16. return null;
  17. }
  18. // 如果jsbridge已经注入则直接调用
  19. if (window.AlipayJSBridge) {
  20. // alert("注册成功");
  21. AlipayJSBridge.call("tradePay", {
  22. orderStr: decodeURI(getQueryString('paystr'))
  23. }, function(result) {
  24. alert(JSON.stringify(result));
  25. });
  26. } else {
  27. // 如果没有注入则监听注入的事件
  28. // alert("注册失败");
  29. }
  30. //上一个页面的内容
  31. function sendfun() {
  32. var ss = document.getElementById("sddd").value
  33. window.location.href = "alipays://platformapi/startapp?appId=20000067&url=" + encodeURIComponent(window.location.href+"?paystr="+encodeURIComponent(ss));
  34. }
  35. </script>
  36. </body>
  37. </html>