parking.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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, maximum-scale=1.0, user-scalable=no">
  6. <title>停车减免查询</title>
  7. <style>
  8. * {
  9. margin: 0;
  10. padding: 0;
  11. box-sizing: border-box;
  12. }
  13. body {
  14. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  15. background-color: #f5f5f5;
  16. color: #333;
  17. line-height: 1.6;
  18. min-height: 100vh;
  19. display: flex;
  20. flex-direction: column;
  21. }
  22. .container {
  23. max-width: 600px;
  24. width: 100%;
  25. margin: 0 auto;
  26. background-color: #fff;
  27. border-radius: 8px;
  28. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  29. margin-top: 20px;
  30. margin-bottom: 20px;
  31. overflow: hidden;
  32. }
  33. .header {
  34. text-align: center;
  35. padding: 24px 20px;
  36. background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
  37. color: white;
  38. }
  39. h1 {
  40. font-size: 24px;
  41. margin-bottom: 8px;
  42. }
  43. .subtitle {
  44. font-size: 14px;
  45. opacity: 0.9;
  46. }
  47. .form-section {
  48. padding: 24px 20px;
  49. }
  50. .form-group {
  51. margin-bottom: 20px;
  52. }
  53. label {
  54. display: block;
  55. margin-bottom: 8px;
  56. font-weight: 500;
  57. color: #555;
  58. font-size: 14px;
  59. }
  60. input {
  61. width: 100%;
  62. padding: 12px 16px;
  63. border: 1px solid #ddd;
  64. border-radius: 8px;
  65. font-size: 16px;
  66. transition: border-color 0.3s, box-shadow 0.3s;
  67. -webkit-appearance: none;
  68. }
  69. input:focus {
  70. outline: none;
  71. border-color: #4CAF50;
  72. box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
  73. }
  74. .btn {
  75. width: 100%;
  76. padding: 14px;
  77. background-color: #4CAF50;
  78. color: white;
  79. border: none;
  80. border-radius: 8px;
  81. font-size: 16px;
  82. font-weight: 600;
  83. cursor: pointer;
  84. transition: background-color 0.3s, transform 0.15s, opacity 0.3s;
  85. }
  86. .btn:hover:not(:disabled) {
  87. background-color: #45a049;
  88. }
  89. .btn:active:not(:disabled) {
  90. transform: scale(0.98);
  91. }
  92. .btn:disabled {
  93. opacity: 0.65;
  94. cursor: not-allowed;
  95. }
  96. .btn-collect {
  97. margin-top: 16px;
  98. background-color: #2196F3;
  99. }
  100. .btn-collect:hover:not(:disabled) {
  101. background-color: #0b7dda;
  102. }
  103. .result-container {
  104. margin: 0 20px 24px;
  105. padding: 20px;
  106. border-radius: 8px;
  107. display: none;
  108. }
  109. .result-container.eligible {
  110. background-color: #e8f5e9;
  111. border: 1px solid #4CAF50;
  112. display: block;
  113. }
  114. .result-container.not-eligible {
  115. background-color: #fff3e0;
  116. border: 1px solid #ff9800;
  117. display: block;
  118. }
  119. .result-container.network-error {
  120. background-color: #ffebee;
  121. border: 1px solid #f44336;
  122. display: block;
  123. }
  124. .result-title {
  125. font-weight: 600;
  126. margin-bottom: 8px;
  127. font-size: 18px;
  128. }
  129. .result-title.eligible {
  130. color: #4CAF50;
  131. }
  132. .result-title.not-eligible {
  133. color: #e65100;
  134. }
  135. .result-title.network-error {
  136. color: #c62828;
  137. }
  138. .result-content {
  139. font-size: 15px;
  140. color: #555;
  141. line-height: 1.6;
  142. }
  143. .loading {
  144. display: none;
  145. text-align: center;
  146. padding: 20px;
  147. color: #666;
  148. }
  149. .loading.active {
  150. display: flex;
  151. align-items: center;
  152. justify-content: center;
  153. gap: 10px;
  154. }
  155. @keyframes spin {
  156. from { transform: rotate(0deg); }
  157. to { transform: rotate(360deg); }
  158. }
  159. .loading svg {
  160. animation: spin 1.5s linear infinite;
  161. }
  162. .footer {
  163. text-align: center;
  164. padding: 20px;
  165. font-size: 14px;
  166. color: #999;
  167. margin-top: auto;
  168. }
  169. .hint-text {
  170. color: #999;
  171. font-size: 12px;
  172. text-align: center;
  173. margin-top: 12px;
  174. line-height: 1.5;
  175. }
  176. @media (max-width: 768px) {
  177. .container {
  178. margin: 0;
  179. border-radius: 0;
  180. min-height: 100vh;
  181. box-shadow: none;
  182. }
  183. }
  184. @media (max-width: 480px) {
  185. h1 {
  186. font-size: 20px;
  187. }
  188. input,
  189. .btn {
  190. font-size: 15px;
  191. padding: 12px 14px;
  192. }
  193. }
  194. </style>
  195. </head>
  196. <body>
  197. <div class="container">
  198. <div class="header">
  199. <h1>停车减免查询</h1>
  200. <div class="subtitle">输入手机号查询是否可以领取停车优惠券</div>
  201. </div>
  202. <div class="form-section">
  203. <form id="queryForm">
  204. <div class="form-group">
  205. <label for="phoneNumber">手机号</label>
  206. <input
  207. type="tel"
  208. id="phoneNumber"
  209. placeholder="请输入需要查询的手机号"
  210. maxlength="11"
  211. pattern="^1[3-9]\d{9}$"
  212. required
  213. >
  214. </div>
  215. <button type="submit" class="btn" id="submitBtn">查询</button>
  216. <p class="hint-text">
  217. <span>- 温馨提示 -</span><br>
  218. 领取后请尽快出场,避免产生二次费用
  219. </p>
  220. </form>
  221. </div>
  222. <div class="loading" id="loading">
  223. <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
  224. <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
  225. </svg>
  226. <span>查询中,请稍候...</span>
  227. </div>
  228. <div id="resultContainer" class="result-container">
  229. <h2 id="resultTitle" class="result-title"></h2>
  230. <p id="resultContent" class="result-content"></p>
  231. <button id="collectBtn" class="btn btn-collect">领取停车券</button>
  232. </div>
  233. </div>
  234. <div class="footer">
  235. Yeswash 超级进化车生活
  236. </div>
  237. <script>
  238. const queryForm = document.getElementById('queryForm');
  239. const phoneInput = document.getElementById('phoneNumber');
  240. const submitBtn = document.getElementById('submitBtn');
  241. const loadingEl = document.getElementById('loading');
  242. const resultContainer = document.getElementById('resultContainer');
  243. const resultTitle = document.getElementById('resultTitle');
  244. const resultContent = document.getElementById('resultContent');
  245. const collectBtn = document.getElementById('collectBtn');
  246. var redirectUrl = null;
  247. function setLoading(loading) {
  248. if (loading) {
  249. loadingEl.classList.add('active');
  250. submitBtn.disabled = true;
  251. collectBtn.disabled = true;
  252. resultContainer.style.display = 'none';
  253. } else {
  254. loadingEl.classList.remove('active');
  255. submitBtn.disabled = false;
  256. collectBtn.disabled = false;
  257. }
  258. }
  259. function showResult(type, title, content) {
  260. resultContainer.classList.remove('eligible', 'not-eligible', 'network-error');
  261. resultTitle.classList.remove('eligible', 'not-eligible', 'network-error');
  262. if (type === 'eligible') {
  263. resultContainer.classList.add('eligible');
  264. resultTitle.classList.add('eligible');
  265. collectBtn.style.display = 'block';
  266. } else if (type === 'not-eligible') {
  267. resultContainer.classList.add('not-eligible');
  268. resultTitle.classList.add('not-eligible');
  269. collectBtn.style.display = 'none';
  270. } else if (type === 'network-error') {
  271. resultContainer.classList.add('network-error');
  272. resultTitle.classList.add('network-error');
  273. collectBtn.style.display = 'none';
  274. }
  275. resultTitle.textContent = title;
  276. resultContent.textContent = content;
  277. resultContainer.style.display = 'block';
  278. resultContainer.scrollIntoView({ behavior: 'smooth' });
  279. }
  280. queryForm.addEventListener('submit', function(event) {
  281. event.preventDefault();
  282. var phoneNumber = phoneInput.value.trim();
  283. var phoneRegex = /^1[3-9]\d{9}$/;
  284. if (!phoneRegex.test(phoneNumber)) {
  285. alert('请输入正确的11位手机号码');
  286. return;
  287. }
  288. setLoading(true);
  289. fetch('https://dev-wash-cloud.kuaiyuman.cn/api/parking-coupon/checkParkingCoupon?mobilePhone=' + encodeURIComponent(phoneNumber))
  290. .then(function(response) {
  291. if (!response.ok) {
  292. throw new Error('服务器繁忙,请稍后重试');
  293. }
  294. return response.json();
  295. })
  296. .then(function(result) {
  297. setLoading(false);
  298. if (result.code === 200) {
  299. redirectUrl = result.data;
  300. showResult('eligible', '恭喜您,满足领取条件!', '您的手机号符合停车券领取资格,可以立即领取一张停车优惠券。');
  301. } else {
  302. showResult('not-eligible', '抱歉,暂不满足领取条件', result.message || '暂不符合停车券领取资格,请稍后再试。');
  303. }
  304. })
  305. .catch(function(error) {
  306. setLoading(false);
  307. showResult('network-error', '网络异常', error.message || '网络连接失败,请检查网络后重试。');
  308. });
  309. });
  310. collectBtn.addEventListener('click', function() {
  311. if (redirectUrl) {
  312. setLoading(true);
  313. location.href = redirectUrl;
  314. }
  315. });
  316. phoneInput.addEventListener('input', function() {
  317. this.value = this.value.replace(/\D/g, '');
  318. });
  319. window.addEventListener('load', function() {
  320. phoneInput.focus();
  321. });
  322. </script>
  323. </body>
  324. </html>