Browse Source

跳转微信小程序

hwb0 3 years ago
parent
commit
340f3e6511
1 changed files with 25 additions and 4 deletions
  1. 25 4
      public/jump.html

+ 25 - 4
public/jump.html

@@ -42,10 +42,31 @@
       }
     })
 
+
+    //获取当前URL
+    var url = document.location.href;
+    //声明一个对象
+    var getRequest = new Object();
+    //获取?的位置
+    var index = url.indexOf("?")
+
+    if (index != -1) {
+      //截取出?后面的字符串
+      var str = url.substr(index + 1);
+      //将截取出来的字符串按照&变成数组
+      strs = str.split("&");
+      //将get传参存入对象中
+      for (var i = 0; i < strs.length; i++) {
+        getRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
+      }
+    }
+
+    console.log('getRequest', getRequest)
+
+
     function ajax(options) {
       return new Promise((resolve, reject) => {
         if (!options.url) {
-          alert("确认你的url");
           return;
         }
         let method = options.method || 'GET';
@@ -79,14 +100,14 @@
         async: false,
         url: 'https://test-mp-adm.quanshu123.com/test-api/api/v1/mp/wx/urlschema/generate',
         data: {
-          path: '/pages/index/index',
-          query: 'id=3847838'
+          path: '/pages/bills/detail',
+          query: `id=${ getRequest.id }`
         }
       })
 
       req.then(data => {
         console.log(data)
-        window.location.href = "weixin://";
+        window.location.href = data.data;
       })
     }