swkzMobile.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <!doctype html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>高德地图 - 下载应用</title>
  7. <!-- iOS Smart App Banner -->
  8. <meta name="apple-itunes-app" content="app-id=461703208, app-argument=https://apps.apple.com/cn/app/id461703208" />
  9. <!-- 微信分享优化 -->
  10. <meta property="og:title" content="高德地图 - 精准导航" />
  11. <meta property="og:description" content="精准导航,出行必备" />
  12. <meta property="og:image" content="https://your-domain.com/logo.png" />
  13. <!-- 防止缓存 -->
  14. <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
  15. <meta http-equiv="Pragma" content="no-cache" />
  16. <meta http-equiv="Expires" content="0" />
  17. <style>
  18. * {
  19. margin: 0;
  20. padding: 0;
  21. box-sizing: border-box;
  22. }
  23. body {
  24. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
  25. 'Microsoft YaHei', sans-serif;
  26. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  27. min-height: 100vh;
  28. display: flex;
  29. align-items: center;
  30. justify-content: center;
  31. padding: 20px;
  32. }
  33. .container {
  34. background: white;
  35. border-radius: 20px;
  36. padding: 40px 30px;
  37. box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
  38. text-align: center;
  39. max-width: 400px;
  40. width: 100%;
  41. }
  42. .logo {
  43. width: 80px;
  44. height: 80px;
  45. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  46. border-radius: 20px;
  47. margin: 0 auto 20px;
  48. display: flex;
  49. align-items: center;
  50. justify-content: center;
  51. font-size: 32px;
  52. color: white;
  53. font-weight: bold;
  54. }
  55. .title {
  56. font-size: 28px;
  57. font-weight: bold;
  58. color: #333;
  59. margin-bottom: 10px;
  60. }
  61. .subtitle {
  62. font-size: 16px;
  63. color: #666;
  64. margin-bottom: 30px;
  65. line-height: 1.5;
  66. }
  67. .tip-text {
  68. font-size: 15px;
  69. color: #888;
  70. margin-bottom: 30px;
  71. line-height: 1.6;
  72. background: #f8f9fa;
  73. padding: 20px;
  74. border-radius: 12px;
  75. border-left: 4px solid #667eea;
  76. }
  77. .button {
  78. display: block;
  79. width: 100%;
  80. padding: 16px;
  81. margin-bottom: 15px;
  82. border: none;
  83. border-radius: 12px;
  84. font-size: 16px;
  85. font-weight: 600;
  86. cursor: pointer;
  87. transition: all 0.3s ease;
  88. text-decoration: none;
  89. color: white;
  90. }
  91. .btn-primary {
  92. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  93. }
  94. .btn-primary:hover {
  95. transform: translateY(-2px);
  96. box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
  97. }
  98. .btn-secondary {
  99. background: #f8f9fa;
  100. color: #333;
  101. border: 2px solid #e9ecef;
  102. }
  103. .btn-secondary:hover {
  104. background: #e9ecef;
  105. transform: translateY(-1px);
  106. }
  107. .success-msg {
  108. display: none;
  109. color: #28a745;
  110. font-size: 14px;
  111. margin-top: 10px;
  112. }
  113. .loading {
  114. display: none;
  115. color: #667eea;
  116. font-size: 14px;
  117. margin-top: 20px;
  118. }
  119. @keyframes spin {
  120. 0% {
  121. transform: rotate(0deg);
  122. }
  123. 100% {
  124. transform: rotate(360deg);
  125. }
  126. }
  127. .spinner {
  128. display: inline-block;
  129. width: 16px;
  130. height: 16px;
  131. border: 2px solid #f3f3f3;
  132. border-top: 2px solid #667eea;
  133. border-radius: 50%;
  134. animation: spin 1s linear infinite;
  135. margin-right: 8px;
  136. }
  137. </style>
  138. </head>
  139. <body>
  140. <div class="container">
  141. <div class="logo">高</div>
  142. <h1 class="title">高德地图</h1>
  143. <p class="subtitle">精准导航,出行必备</p>
  144. <div class="tip-text">
  145. 📱 打开App Store搜索"高德地图"下载<br />
  146. 🔗 或者复制链接在浏览器打开
  147. </div>
  148. <a href="#" class="button btn-primary" id="openAppBtn">打开高德地图应用</a>
  149. <button class="button btn-secondary" id="copyLinkBtn">复制页面链接</button>
  150. <div class="success-msg" id="successMsg">✅ 链接已复制到剪贴板</div>
  151. <div class="loading" id="loadingMsg"><span class="spinner"></span>正在检测应用...</div>
  152. </div>
  153. <script>
  154. // 高德地图URL Scheme和App Store链接
  155. const APP_SCHEME = 'iosamap://' // 高德地图iOS URL Scheme
  156. const APP_STORE_URL = 'https://apps.apple.com/cn/app/id461703208'
  157. // Universal Links (高德地图支持)
  158. const UNIVERSAL_LINK = 'https://uri.amap.com/navigation'
  159. // 检测设备类型 - 只支持iOS
  160. function getDeviceType() {
  161. const userAgent = navigator.userAgent.toLowerCase()
  162. if (/iphone|ipad|ipod/.test(userAgent)) {
  163. return 'ios'
  164. }
  165. return 'other'
  166. }
  167. // 检测浏览器类型
  168. function getBrowserType() {
  169. const userAgent = navigator.userAgent.toLowerCase()
  170. if (userAgent.indexOf('micromessenger') !== -1) {
  171. return 'wechat'
  172. }
  173. if (userAgent.indexOf('qq') !== -1) {
  174. return 'qq'
  175. }
  176. if (userAgent.indexOf('safari') !== -1 && userAgent.indexOf('chrome') === -1) {
  177. return 'safari'
  178. }
  179. if (userAgent.indexOf('chrome') !== -1) {
  180. return 'chrome'
  181. }
  182. return 'other'
  183. }
  184. // 尝试打开应用 - 改进版本
  185. function tryOpenApp() {
  186. const deviceType = getDeviceType()
  187. const browserType = getBrowserType()
  188. return new Promise((resolve) => {
  189. let opened = false
  190. // 设置超时检测
  191. const timeout = setTimeout(() => {
  192. if (!opened) {
  193. resolve(false) // 未能打开应用
  194. }
  195. }, 2500)
  196. // 监听页面可见性变化
  197. const handleVisibilityChange = () => {
  198. if (document.hidden) {
  199. opened = true
  200. clearTimeout(timeout)
  201. resolve(true) // 应用可能已打开
  202. document.removeEventListener('visibilitychange', handleVisibilityChange)
  203. }
  204. }
  205. // 监听页面失焦
  206. const handleBlur = () => {
  207. opened = true
  208. clearTimeout(timeout)
  209. resolve(true)
  210. window.removeEventListener('blur', handleBlur)
  211. }
  212. document.addEventListener('visibilitychange', handleVisibilityChange)
  213. window.addEventListener('blur', handleBlur)
  214. // 尝试打开高德地图应用
  215. if (deviceType === 'ios' && browserType === 'safari') {
  216. // Safari优先使用Universal Links,然后是URL Scheme
  217. window.location.href = UNIVERSAL_LINK || APP_SCHEME
  218. } else if (deviceType === 'ios') {
  219. // 其他iOS浏览器使用iframe方式
  220. const iframe = document.createElement('iframe')
  221. iframe.style.display = 'none'
  222. iframe.src = APP_SCHEME
  223. document.body.appendChild(iframe)
  224. setTimeout(() => {
  225. document.body.removeChild(iframe)
  226. }, 1000)
  227. } else {
  228. // 非iOS设备使用Universal Link
  229. window.location.href = UNIVERSAL_LINK
  230. }
  231. })
  232. }
  233. // 跳转到应用商店 - 只支持iOS
  234. function openAppStore() {
  235. const deviceType = getDeviceType()
  236. const browserType = getBrowserType()
  237. // 微信或QQ浏览器中,提示用户在外部浏览器打开
  238. if (browserType === 'wechat' || browserType === 'qq') {
  239. showWeChatGuide()
  240. return
  241. }
  242. if (deviceType === 'ios') {
  243. // iOS多种跳转方式
  244. const iosStores = ['itms-apps://apps.apple.com/cn/app/id461703208', APP_STORE_URL]
  245. tryMultipleUrls(iosStores)
  246. } else {
  247. // 非iOS设备直接打开网页版App Store
  248. window.open(APP_STORE_URL, '_blank')
  249. }
  250. }
  251. // 尝试多个URL
  252. function tryMultipleUrls(urls) {
  253. let index = 0
  254. function tryNext() {
  255. if (index >= urls.length) {
  256. // 所有URL都失败了,显示手动指引
  257. showManualGuide()
  258. return
  259. }
  260. const url = urls[index]
  261. index++
  262. // 监听页面可见性变化
  263. const handleVisibilityChange = () => {
  264. if (document.hidden) {
  265. // 成功跳转
  266. document.removeEventListener('visibilitychange', handleVisibilityChange)
  267. return
  268. }
  269. }
  270. document.addEventListener('visibilitychange', handleVisibilityChange)
  271. // 尝试跳转
  272. try {
  273. window.location.href = url
  274. } catch (e) {
  275. console.log('跳转失败:', url, e)
  276. }
  277. // 如果2秒后页面仍然可见,尝试下一个URL
  278. setTimeout(() => {
  279. document.removeEventListener('visibilitychange', handleVisibilityChange)
  280. if (!document.hidden) {
  281. tryNext()
  282. }
  283. }, 2000)
  284. }
  285. tryNext()
  286. }
  287. // 显示微信引导
  288. function showWeChatGuide() {
  289. const guide = document.createElement('div')
  290. guide.innerHTML = `
  291. <div style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.8); z-index: 9999; display: flex; align-items: center; justify-content: center;">
  292. <div style="background: white; padding: 30px; border-radius: 15px; text-align: center; margin: 20px;">
  293. <h3 style="margin-bottom: 20px; color: #333;">在外部浏览器中打开</h3>
  294. <p style="margin-bottom: 20px; line-height: 1.6; color: #666;">
  295. 请点击右上角的【⋯】菜单<br>
  296. 选择【在浏览器中打开】<br>
  297. 然后下载高德地图应用
  298. </p>
  299. <button onclick="this.parentElement.parentElement.remove()" style="background: #1989fa; color: white; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer;">知道了</button>
  300. </div>
  301. </div>
  302. `
  303. document.body.appendChild(guide)
  304. }
  305. // 显示手动指引
  306. function showManualGuide() {
  307. const deviceType = getDeviceType()
  308. const storeName = deviceType === 'ios' ? 'App Store' : 'App Store'
  309. alert(`请手动打开${storeName},搜索"高德地图"进行下载。`)
  310. }
  311. // 尝试打开应用的主函数
  312. async function openApp() {
  313. const loadingMsg = document.getElementById('loadingMsg')
  314. const openAppBtn = document.getElementById('openAppBtn')
  315. const deviceType = getDeviceType()
  316. const browserType = getBrowserType()
  317. loadingMsg.style.display = 'block'
  318. openAppBtn.textContent = '检测中...'
  319. openAppBtn.style.pointerEvents = 'none'
  320. try {
  321. // 微信或QQ浏览器中直接提示跳转应用商店
  322. if (browserType === 'wechat' || browserType === 'qq') {
  323. loadingMsg.style.display = 'none'
  324. openAppBtn.textContent = '下载高德地图应用'
  325. openAppBtn.style.pointerEvents = 'auto'
  326. openAppStore()
  327. return
  328. }
  329. // 只在iOS设备上尝试打开应用
  330. if (deviceType === 'ios') {
  331. const appOpened = await tryOpenApp()
  332. if (!appOpened) {
  333. // 如果应用未打开,跳转到应用商店
  334. setTimeout(() => {
  335. openAppStore()
  336. }, 500)
  337. }
  338. } else {
  339. // 非iOS设备直接跳转到App Store
  340. openAppStore()
  341. }
  342. } catch (error) {
  343. console.error('打开应用时出错:', error)
  344. openAppStore()
  345. } finally {
  346. loadingMsg.style.display = 'none'
  347. openAppBtn.textContent = '打开高德地图应用'
  348. openAppBtn.style.pointerEvents = 'auto'
  349. }
  350. }
  351. // 复制链接功能
  352. function copyCurrentUrl() {
  353. const currentUrl = window.location.href
  354. const successMsg = document.getElementById('successMsg')
  355. if (navigator.clipboard && window.isSecureContext) {
  356. // 现代浏览器
  357. navigator.clipboard
  358. .writeText(currentUrl)
  359. .then(() => {
  360. showSuccessMessage()
  361. })
  362. .catch((err) => {
  363. console.error('复制失败:', err)
  364. fallbackCopyTextToClipboard(currentUrl)
  365. })
  366. } else {
  367. // 兼容性处理
  368. fallbackCopyTextToClipboard(currentUrl)
  369. }
  370. }
  371. // 兼容性复制方法
  372. function fallbackCopyTextToClipboard(text) {
  373. const textArea = document.createElement('textarea')
  374. textArea.value = text
  375. textArea.style.position = 'fixed'
  376. textArea.style.left = '-999999px'
  377. textArea.style.top = '-999999px'
  378. document.body.appendChild(textArea)
  379. textArea.focus()
  380. textArea.select()
  381. try {
  382. const successful = document.execCommand('copy')
  383. if (successful) {
  384. showSuccessMessage()
  385. } else {
  386. alert('复制失败,请手动复制链接:' + text)
  387. }
  388. } catch (err) {
  389. console.error('复制失败:', err)
  390. alert('复制失败,请手动复制链接:' + text)
  391. } finally {
  392. document.body.removeChild(textArea)
  393. }
  394. }
  395. // 显示成功消息
  396. function showSuccessMessage() {
  397. const successMsg = document.getElementById('successMsg')
  398. successMsg.style.display = 'block'
  399. setTimeout(() => {
  400. successMsg.style.display = 'none'
  401. }, 3000)
  402. }
  403. // 页面加载完成后的初始化
  404. document.addEventListener('DOMContentLoaded', function () {
  405. const openAppBtn = document.getElementById('openAppBtn')
  406. const copyLinkBtn = document.getElementById('copyLinkBtn')
  407. const deviceType = getDeviceType()
  408. const browserType = getBrowserType()
  409. // 绑定事件
  410. openAppBtn.addEventListener('click', function (e) {
  411. e.preventDefault()
  412. openApp()
  413. })
  414. copyLinkBtn.addEventListener('click', function () {
  415. copyCurrentUrl()
  416. })
  417. // 根据浏览器类型调整按钮文字
  418. if (browserType === 'wechat' || browserType === 'qq') {
  419. openAppBtn.textContent = '下载高德地图应用'
  420. document.querySelector('.tip-text').innerHTML =
  421. '📱 请点击右上角菜单选择"在浏览器中打开"<br>🔗 然后下载高德地图应用'
  422. }
  423. // 移动端不自动检测,避免被浏览器阻止
  424. // 只有在桌面端才自动检测
  425. if (deviceType === 'other') {
  426. setTimeout(() => {
  427. openApp()
  428. }, 1000)
  429. }
  430. })
  431. // 处理页面可见性变化
  432. document.addEventListener('visibilitychange', function () {
  433. if (document.hidden) {
  434. console.log('页面被隐藏,可能是应用打开了')
  435. } else {
  436. console.log('页面重新可见')
  437. }
  438. })
  439. </script>
  440. </body>
  441. </html>