|
@@ -3,8 +3,7 @@
|
|
<head>
|
|
<head>
|
|
<title>打开小程序</title>
|
|
<title>打开小程序</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
- <meta name="viewport"
|
|
|
|
- content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
|
|
|
|
|
|
+ <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
|
|
<script>
|
|
<script>
|
|
window.onerror = e => {
|
|
window.onerror = e => {
|
|
console.error(e)
|
|
console.error(e)
|
|
@@ -25,9 +24,7 @@
|
|
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
|
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
- import {urlschemaGeneratee} from "../src/api/business/ticket";
|
|
|
|
-
|
|
|
|
- function docReady (fn) {
|
|
|
|
|
|
+ function docReady(fn) {
|
|
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
|
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
|
fn()
|
|
fn()
|
|
} else {
|
|
} else {
|
|
@@ -108,28 +105,66 @@
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
- async function openWeapp (onBeforeJump) {
|
|
|
|
- function GetRequest (name) {
|
|
|
|
- var url = window.parent.location.search; //获取url中"?"符后的字串
|
|
|
|
- // var theRequest = new Object();
|
|
|
|
- if (url.indexOf("?") != -1) {
|
|
|
|
- var str = url.substr(1);
|
|
|
|
- if (str.indexOf("#" != -1)) {
|
|
|
|
- str = str.substr(0);
|
|
|
|
|
|
+
|
|
|
|
+ function ajax(options) {
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
|
+ if (!options.url) {
|
|
|
|
+ alert("确认你的url");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ let method = options.method || 'GET';
|
|
|
|
+ let async = options.async || true;
|
|
|
|
+ let xhr = new XMLHttpRequest();
|
|
|
|
+ if (method === 'GET') {
|
|
|
|
+ // url后面添加随机数防止请求缓存
|
|
|
|
+ xhr.open(method, options.url + "?" + Math.random(), async);
|
|
|
|
+ xhr.send(null);
|
|
|
|
+ } else if (method === 'POST') {
|
|
|
|
+ xhr.open(method, options.url, async);
|
|
|
|
+ xhr.setRequestHeader('Content-type', 'application/json;charset=utf-8');
|
|
|
|
+ xhr.send(JSON.stringify(options.data));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ xhr.onreadystatechange = () => {
|
|
|
|
+ if (xhr.responseText) {
|
|
|
|
+ resolve(xhr.responseText);
|
|
}
|
|
}
|
|
- strs = str.split("&");
|
|
|
|
- for (var i = 0; i < strs.length; i++) {
|
|
|
|
- if (strs[i].indexOf(name) != -1) {
|
|
|
|
- return strs[i].split("=")[1];
|
|
|
|
- }
|
|
|
|
|
|
+ };
|
|
|
|
+ xhr.onerror = (e) => {
|
|
|
|
+ reject(e);
|
|
|
|
+ }
|
|
|
|
+ }).catch(e => {
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function GetRequest(name) {
|
|
|
|
+ var url = window.parent.location.search; //获取url中"?"符后的字串
|
|
|
|
+ // var theRequest = new Object();
|
|
|
|
+ if (url.indexOf("?") != -1) {
|
|
|
|
+ var str = url.substr(1);
|
|
|
|
+ if (str.indexOf("#" != -1)) {
|
|
|
|
+ str = str.substr(0);
|
|
|
|
+ }
|
|
|
|
+ strs = str.split("&");
|
|
|
|
+ for (var i = 0; i < strs.length; i++) {
|
|
|
|
+ if (strs[i].indexOf(name) != -1) {
|
|
|
|
+ return strs[i].split("=")[1];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // return strs || null;
|
|
|
|
}
|
|
}
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
|
|
- var aa = GetRequest()
|
|
|
|
|
|
|
|
- urlschemaGeneratee({}).then(res => {
|
|
|
|
|
|
+ function openWeapp() {
|
|
|
|
+ ajax({
|
|
|
|
+ method: 'POST',
|
|
|
|
+ url: 'https://test-mp.quanshu123.com/api/v1/mp/wx/urlschema/generate',
|
|
|
|
+ data: {
|
|
|
|
+ path: '/pages/index/index',
|
|
|
|
+ query: 'id=3847838'
|
|
|
|
+ }
|
|
|
|
+ }).then(res => {
|
|
console.log('res', res)
|
|
console.log('res', res)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
@@ -198,37 +233,34 @@
|
|
</head>
|
|
</head>
|
|
|
|
|
|
<body>
|
|
<body>
|
|
-<div className="page full">
|
|
|
|
- <div id="public-web-container" className="hidden">
|
|
|
|
- <p className="">正在打开 “盲票小程序”...</p> <!-- replace -->
|
|
|
|
- <a id="public-web-jump-button" href="javascript:"
|
|
|
|
- className="weui-btn weui-btn_primary weui-btn_loading"
|
|
|
|
- onClick="openWeapp()">
|
|
|
|
- <span id="public-web-jump-button-loading"
|
|
|
|
- className="weui-primary-loading weui-primary-loading_transparent"><i
|
|
|
|
- className="weui-primary-loading__dot"></i></span>
|
|
|
|
- 打开小程序
|
|
|
|
- </a>
|
|
|
|
- </div>
|
|
|
|
- <div id="wechat-web-container" className="hidden">
|
|
|
|
- <p className="">点击以下按钮打开 “盲票小程序”</p> <!-- replace -->
|
|
|
|
- <!-- 跳转小程序的开放标签。文档 https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_Open_Tag.html -->
|
|
|
|
- <wx-open-launch-weapp id="launch-btn" username="gh_cf2872611f66"
|
|
|
|
- path="pages/index/index?id=123456"
|
|
|
|
- env-version="trial">
|
|
|
|
- <!-- replace -->
|
|
|
|
- <template>
|
|
|
|
- <button
|
|
|
|
- style="width: 200px; height: 45px; text-align: center; font-size: 17px; display: block; margin: 0 auto; padding: 8px 24px; border: none; border-radius: 4px; background-color: #07c160; color:#fff;">
|
|
|
|
- 打开小程序
|
|
|
|
- </button>
|
|
|
|
- </template>
|
|
|
|
- </wx-open-launch-weapp>
|
|
|
|
- </div>
|
|
|
|
- <div id="desktop-web-container" className="hidden">
|
|
|
|
- <p className="">请在手机打开网页链接</p>
|
|
|
|
|
|
+ <div className="page full">
|
|
|
|
+ <div id="public-web-container" className="hidden">
|
|
|
|
+ <p className="">正在打开 “盲票小程序”...</p> <!-- replace -->
|
|
|
|
+ <a id="public-web-jump-button" href="javascript:" className="weui-btn weui-btn_primary weui-btn_loading"
|
|
|
|
+ onClick="openWeapp()">
|
|
|
|
+ <span id="public-web-jump-button-loading" className="weui-primary-loading weui-primary-loading_transparent"><i
|
|
|
|
+ className="weui-primary-loading__dot"></i></span>
|
|
|
|
+ 打开小程序
|
|
|
|
+ </a>
|
|
|
|
+ </div>
|
|
|
|
+ <div id="wechat-web-container" className="hidden">
|
|
|
|
+ <p className="">点击以下按钮打开 “盲票小程序”</p> <!-- replace -->
|
|
|
|
+ <!-- 跳转小程序的开放标签。文档 https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_Open_Tag.html -->
|
|
|
|
+ <wx-open-launch-weapp id="launch-btn" username="gh_cf2872611f66" path="pages/index/index?id=123456"
|
|
|
|
+ env-version="trial">
|
|
|
|
+ <!-- replace -->
|
|
|
|
+ <template>
|
|
|
|
+ <button
|
|
|
|
+ style="width: 200px; height: 45px; text-align: center; font-size: 17px; display: block; margin: 0 auto; padding: 8px 24px; border: none; border-radius: 4px; background-color: #07c160; color:#fff;">
|
|
|
|
+ 打开小程序
|
|
|
|
+ </button>
|
|
|
|
+ </template>
|
|
|
|
+ </wx-open-launch-weapp>
|
|
|
|
+ </div>
|
|
|
|
+ <div id="desktop-web-container" className="hidden">
|
|
|
|
+ <p className="">请在手机打开网页链接</p>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
-</div>
|
|
|
|
</body>
|
|
</body>
|
|
|
|
|
|
-</html>
|
|
|
|
|
|
+</html>
|