index.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. <style>
  8. * {
  9. margin: 0;
  10. padding: 0;
  11. box-sizing: border-box;
  12. }
  13. body {
  14. padding: 20px;
  15. font-family: Arial, sans-serif;
  16. max-width: 800px;
  17. margin: 0 auto;
  18. }
  19. .title {
  20. text-align: center;
  21. margin: 20px 0;
  22. color: #333;
  23. }
  24. .btn-box {
  25. display: flex;
  26. gap: 10px;
  27. margin-bottom: 20px;
  28. flex-wrap: wrap;
  29. }
  30. button {
  31. padding: 12px 20px;
  32. background: #409eff;
  33. color: white;
  34. border: none;
  35. border-radius: 6px;
  36. cursor: pointer;
  37. font-size: 16px;
  38. flex: 1;
  39. min-width: 150px;
  40. }
  41. button:active {
  42. background: #337ecc;
  43. }
  44. .result {
  45. padding: 15px;
  46. background: #f5f7fa;
  47. border-radius: 8px;
  48. min-height: 100px;
  49. white-space: pre-wrap;
  50. word-break: break-all;
  51. font-size: 14px;
  52. line-height: 1.6;
  53. }
  54. .tip {
  55. color: #666;
  56. margin: 10px 0;
  57. font-size: 12px;
  58. }
  59. </style>
  60. </head>
  61. <body>
  62. <h2 class="title">门店接口测试(无Token,纯前端调用)</h2>
  63. <p class="tip">✅ 页面不携带任何Token,彻底解决401问题</p>
  64. <div class="btn-box">
  65. <button onclick="getMoreStores()">获取推荐门店列表</button>
  66. <button onclick="getStoreDetail()">获取门店详情</button>
  67. </div>
  68. <div class="result" id="result">请求结果将展示在这里...</div>
  69. <script>
  70. // 接口基础地址
  71. const baseUrl = 'http://120.26.186.130:8000';
  72. // 1. 获取更多推荐门店
  73. async function getMoreStores() {
  74. const resultDom = document.getElementById('result');
  75. resultDom.textContent = '加载中...';
  76. try {
  77. // 核心:无Token、无请求头,纯GET请求
  78. const res = await fetch(`${baseUrl}/alienStore/store/info/getMoreRecommendedStores?lat=38.925771&lon=121.662472&businessSection=3`);
  79. const data = await res.json();
  80. resultDom.textContent = JSON.stringify(data, null, 2);
  81. } catch (err) {
  82. resultDom.textContent = '请求失败:' + err.message;
  83. }
  84. }
  85. // 2. 获取门店详情
  86. async function getStoreDetail() {
  87. const resultDom = document.getElementById('result');
  88. resultDom.textContent = '加载中...';
  89. try {
  90. // 核心:无Token、无请求头,纯GET请求
  91. const res = await fetch(`${baseUrl}/alienStore/store/info/getClientStoreDetail?id=436&userId=628&jingdu=121.6574543718373&weidu=38.92492394348767`);
  92. const data = await res.json();
  93. resultDom.textContent = JSON.stringify(data, null, 2);
  94. } catch (err) {
  95. resultDom.textContent = '请求失败:' + err.message;
  96. }
  97. }
  98. </script>
  99. </body>
  100. </html>