index.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <title>
  7. <%= htmlWebpackPlugin.options.title %>
  8. </title>
  9. <script>
  10. var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS
  11. .supports('top: constant(a)'))
  12. document.write(
  13. '<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
  14. (coverSupport ? ', viewport-fit=cover' : '') + '" />')
  15. </script>
  16. <link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" />
  17. <link href="https://cdn.bootcdn.net/ajax/libs/normalize/8.0.1/normalize.min.css" rel="stylesheet">
  18. <script src="https://wwcdn.weixin.qq.com/node/wework/wwopen/js/wwLogin-1.2.7.js" type="text/javascript"
  19. charset="utf-8"></script>
  20. <script type="text/javascript">
  21. var userAgent = navigator.userAgent;
  22. if (userAgent.indexOf('AlipayClient') > -1) {
  23. // 支付宝小程序的 JS-SDK 防止 404 需要动态加载,如果不需要兼容支付宝小程序,则无需引用此 JS 文件。
  24. document.writeln('<script src="https://appx/web-view.min.js"' + '>' + '<' + '/' + 'script>');
  25. } else if (/QQ/i.test(userAgent) && /miniProgram/i.test(userAgent)) {
  26. // QQ 小程序
  27. document.write(
  28. '<script type="text/javascript" src="https://qqq.gtimg.cn/miniprogram/webview_jssdk/qqjssdk-1.0.0.js"><\/script>'
  29. );
  30. } else if (/miniProgram/i.test(userAgent) && /micromessenger/i.test(userAgent)) {
  31. // 微信小程序 JS-SDK 如果不需要兼容微信小程序,则无需引用此 JS 文件。
  32. document.write(
  33. '<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"><\/script>');
  34. } else if (/toutiaomicroapp/i.test(userAgent)) {
  35. // 头条小程序 JS-SDK 如果不需要兼容头条小程序,则无需引用此 JS 文件。
  36. document.write(
  37. '<script type="text/javascript" src="https://s3.pstatp.com/toutiao/tmajssdk/jssdk-1.0.1.js"><\/script>');
  38. } else if (/swan/i.test(userAgent)) {
  39. // 百度小程序 JS-SDK 如果不需要兼容百度小程序,则无需引用此 JS 文件。
  40. document.write(
  41. '<script type="text/javascript" src="https://b.bdstatic.com/searchbox/icms/searchbox/js/swan-2.0.18.js"><\/script>'
  42. );
  43. } else if (/quickapp/i.test(userAgent)) {
  44. // quickapp
  45. document.write('<script type="text/javascript" src="https://quickapp/jssdk.webview.min.js"><\/script>');
  46. }
  47. </script>
  48. <script type="text/javascript">
  49. ! function(e, n) {
  50. "object" == typeof exports && "undefined" != typeof module ? module.exports = n() : "function" ==
  51. typeof define && define.amd ? define(n) : e.uniWebview = n()
  52. }(this, function() {
  53. "use strict";
  54. var e = {},
  55. a = [],
  56. n = function(e, n) {
  57. if (0 === a.length) {
  58. var i = plus.webview.currentWebview();
  59. if (!i) throw new Error("plus.webview.currentWebview() is undefined");
  60. var t = i.parent();
  61. if (!t) throw new Error("plus.webview.currentWebview().parent() is undefined");
  62. a.push(t.id)
  63. }
  64. var r = JSON.stringify({
  65. options: {
  66. timestamp: +new Date
  67. },
  68. name: e,
  69. arg: n
  70. });
  71. plus.webview.getLaunchWebview().evalJS('UniPlusBridge.subscribeHandler("WEB_INVOKE_APPSERVICE",' + r +
  72. "," + JSON.stringify(a) + ");")
  73. };
  74. e.navigateTo = function() {
  75. var e = (0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {}).url;
  76. n("navigateTo", {
  77. url: encodeURI(e)
  78. })
  79. }, e.navigateBack = function() {
  80. var e = (0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {}).delta;
  81. n("navigateBack", {
  82. delta: parseInt(e) || 1
  83. })
  84. }, e.switchTab = function() {
  85. var e = (0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {}).url;
  86. n("switchTab", {
  87. url: encodeURI(e)
  88. })
  89. }, e.reLaunch = function() {
  90. var e = (0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {}).url;
  91. n("reLaunch", {
  92. url: encodeURI(e)
  93. })
  94. }, e.redirectTo = function() {
  95. var e = (0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {}).url;
  96. n("redirectTo", {
  97. url: encodeURI(e)
  98. })
  99. }, e.getEnv = function(e) {
  100. e({
  101. plus: !0
  102. })
  103. }, e.postMessage = function() {
  104. var e = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {};
  105. n("postMessage", e.data || {})
  106. };
  107. var i = {};
  108. "undefined" != typeof wx && wx.miniProgram && (i.navigateTo = wx.miniProgram.navigateTo, i.navigateBack = wx
  109. .miniProgram.navigateBack, i.switchTab = wx.miniProgram.switchTab, i.reLaunch = wx.miniProgram.reLaunch, i
  110. .redirectTo = wx.miniProgram.redirectTo, i.postMessage = wx.miniProgram.postMessage, i.getEnv = wx
  111. .miniProgram.getEnv);
  112. var t = /uni-app/i.test(navigator.userAgent),
  113. r = /micromessenger/i.test(navigator.userAgent),
  114. o = {},
  115. d = function() {
  116. window.UniAppJSBridge = !0, document.dispatchEvent(new CustomEvent("UniAppJSBridgeReady", {
  117. bubbles: !0,
  118. cancelable: !0
  119. }))
  120. };
  121. return t && (o = e, window.plus && /complete|loaded|interactive/.test(document.readyState) ? d() : document
  122. .addEventListener("plusready", d)), r && (o = i, window.WeixinJSBridge && WeixinJSBridge.invoke ? d() :
  123. document.addEventListener("WeixinJSBridgeReady", d)), o
  124. });
  125. </script>
  126. <script>
  127. document.addEventListener('UniAppJSBridgeReady', function() {
  128. uniWebview.getEnv(function(res) {
  129. console.log('当前环境:' + JSON.stringify(res))
  130. });
  131. });
  132. </script>
  133. </head>
  134. <body>
  135. <noscript>
  136. <strong>Please enable JavaScript to continue.</strong>
  137. </noscript>
  138. <div id="app"></div>
  139. <!-- built files will be auto injected -->
  140. </body>
  141. </html>