jump.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <html>
  2. <head>
  3. <title>打开小程序</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
  6. <script>
  7. function ajax(options) {
  8. return new Promise((resolve, reject) => {
  9. if (!options.url) {
  10. alert("确认你的url");
  11. return;
  12. }
  13. let method = options.method || 'GET';
  14. let async = options.async || true;
  15. let xhr = new XMLHttpRequest();
  16. if (method === 'GET') {
  17. // url后面添加随机数防止请求缓存
  18. xhr.open(method, options.url + "?" + Math.random(), async);
  19. xhr.send(null);
  20. } else if (method === 'POST') {
  21. xhr.open(method, options.url, async);
  22. xhr.setRequestHeader('Content-type', 'application/json;charset=utf-8');
  23. xhr.send(JSON.stringify(options.data));
  24. }
  25. xhr.onreadystatechange = () => {
  26. if (xhr.responseText) {
  27. resolve(xhr.responseText);
  28. }
  29. };
  30. xhr.onerror = (e) => {
  31. reject(e);
  32. }
  33. }).catch(e => {
  34. });
  35. }
  36. function openWeapp() {
  37. let req = ajax({
  38. method: 'POST',
  39. async: false,
  40. url: 'https://test-mp-adm.quanshu123.com/test-api/api/v1/mp/wx/urlschema/generate',
  41. data: {
  42. path: '/pages/index/index',
  43. query: 'id=3847838'
  44. }
  45. })
  46. req.then(data => {
  47. console.log(data)
  48. window.location.href = "weixin://";
  49. })
  50. }
  51. </script>
  52. <style>
  53. .skip-wrap {
  54. height: 100vh;
  55. width: 100%;
  56. position: relative;
  57. }
  58. .skip-theme {
  59. display: flex;
  60. align-items: center;
  61. flex-direction: column;
  62. padding: 200px 0 0;
  63. }
  64. .skip-theme-iamge {
  65. width: 60px;
  66. height: 60px;
  67. line-height: 60px;
  68. text-align: center;
  69. color: #fff;
  70. background-color: #e96737;
  71. border-radius: 50%;
  72. margin-bottom: 10px;
  73. }
  74. .skip-theme-txt {
  75. color: rgb(194, 184, 184);
  76. text-align: center;
  77. }
  78. .skip-btn {
  79. position: absolute;
  80. bottom: 50px;
  81. width: 100%;
  82. display: flex;
  83. align-items: center;
  84. justify-content: center;
  85. }
  86. .skip-btn p {
  87. height: 30px;
  88. width: 200px;
  89. background-color: rgb(7, 192, 88);
  90. border-radius: 8px;
  91. line-height: 30px;
  92. color: #fff;
  93. text-align: center;
  94. }
  95. </style>
  96. </head>
  97. <body>
  98. <div class="skip-wrap">
  99. <div class="skip-theme">
  100. <div class="skip-theme-iamge">logo</div>
  101. <div class="skip-theme-txt">小程序</div>
  102. </div>
  103. <div class="skip-btn">
  104. <p onclick="openWeapp()">打开微信小程序</p>
  105. </div>
  106. </div>
  107. </body>
  108. </html>