parking.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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. padding: 20px;
  27. background-color: #fff;
  28. border-radius: 8px;
  29. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  30. margin-top: 20px;
  31. margin-bottom: 20px;
  32. }
  33. .header {
  34. text-align: center;
  35. padding: 20px 0;
  36. background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
  37. color: white;
  38. border-radius: 8px 8px 0 0;
  39. margin: -20px -20px 20px -20px;
  40. }
  41. h1 {
  42. font-size: 24px;
  43. margin-bottom: 10px;
  44. }
  45. .subtitle {
  46. font-size: 14px;
  47. opacity: 0.9;
  48. }
  49. .form-group {
  50. margin-bottom: 20px;
  51. }
  52. label {
  53. display: block;
  54. margin-bottom: 8px;
  55. font-weight: 500;
  56. color: #555;
  57. }
  58. input {
  59. width: 100%;
  60. padding: 12px 16px;
  61. border: 1px solid #ddd;
  62. border-radius: 4px;
  63. font-size: 16px;
  64. transition: border-color 0.3s;
  65. }
  66. input:focus {
  67. outline: none;
  68. border-color: #4CAF50;
  69. box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
  70. }
  71. .btn {
  72. width: 100%;
  73. padding: 12px;
  74. background-color: #4CAF50;
  75. color: white;
  76. border: none;
  77. border-radius: 4px;
  78. font-size: 16px;
  79. font-weight: 500;
  80. cursor: pointer;
  81. transition: background-color 0.3s;
  82. }
  83. .btn:hover {
  84. background-color: #45a049;
  85. }
  86. .btn:active {
  87. transform: translateY(1px);
  88. }
  89. .result-container {
  90. margin-top: 25px;
  91. padding: 20px;
  92. border-radius: 4px;
  93. display: none;
  94. }
  95. .result-container.eligible {
  96. background-color: #e8f5e8;
  97. border: 1px solid #4CAF50;
  98. display: block;
  99. }
  100. .result-container.not-eligible {
  101. background-color: #ffebee;
  102. border: 1px solid #f44336;
  103. display: block;
  104. }
  105. .result-title {
  106. font-weight: 600;
  107. margin-bottom: 10px;
  108. font-size: 18px;
  109. }
  110. .result-title.eligible {
  111. color: #4CAF50;
  112. }
  113. .result-title.not-eligible {
  114. color: #f44336;
  115. }
  116. .result-content {
  117. font-size: 16px;
  118. color: #666;
  119. }
  120. .btn-collect {
  121. margin-top: 15px;
  122. background-color: #2196F3;
  123. }
  124. .btn-collect:hover {
  125. background-color: #0b7dda;
  126. }
  127. .loading {
  128. display: none;
  129. text-align: center;
  130. padding: 20px;
  131. color: #666;
  132. }
  133. .loading.active {
  134. display: block;
  135. }
  136. .footer {
  137. text-align: center;
  138. padding: 20px;
  139. font-size: 14px;
  140. color: #999;
  141. margin-top: auto;
  142. }
  143. /* 响应式设计 */
  144. @media (max-width: 768px) {
  145. .container {
  146. margin: 0;
  147. border-radius: 0;
  148. min-height: 100vh;
  149. box-shadow: none;
  150. }
  151. .header {
  152. border-radius: 0;
  153. }
  154. }
  155. @media (max-width: 480px) {
  156. h1 {
  157. font-size: 20px;
  158. }
  159. input,
  160. .btn {
  161. font-size: 14px;
  162. padding: 10px 14px;
  163. }
  164. }
  165. .hint-text {
  166. color: #999;
  167. font-size: 12px;
  168. text-align: center;
  169. margin-top: 10px;
  170. line-height: 1.4;
  171. }
  172. </style>
  173. </head>
  174. <body>
  175. <div class="container">
  176. <div class="header">
  177. <h1>停车券查询</h1>
  178. <div class="subtitle">输入手机号查询是否可以领取停车优惠券</div>
  179. </div>
  180. <form id="queryForm">
  181. <div class="form-group">
  182. <label for="phoneNumber">查询停车券</label>
  183. <input
  184. type="tel"
  185. id="phoneNumber"
  186. placeholder="请输入需要查询的手机号"
  187. maxlength="11"
  188. pattern="^1[3-9]\d{9}$"
  189. required
  190. >
  191. </div>
  192. <button type="submit" class="btn">查询</button>
  193. <p class="hint-text">
  194. <span>-温馨提示-</span><br>
  195. 领取后请尽快出场,避免产生二次费用
  196. </p>
  197. </form>
  198. <div class="loading" id="loading">
  199. <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  200. <circle cx="12" cy="12" r="10"></circle>
  201. <path d="M12 6v6l4 2"></path>
  202. </svg>
  203. <span>查询中,请稍候...</span>
  204. </div>
  205. <div id="resultContainer" class="result-container">
  206. <h2 id="resultTitle" class="result-title"></h2>
  207. <p id="resultContent" class="result-content"></p>
  208. <button id="collectBtn" class="btn btn-collect">查询停车券</button>
  209. </div>
  210. </div>
  211. <div class="footer">
  212. Yeswash 超级进化车生活
  213. </div>
  214. <script>
  215. // 表单提交处理
  216. document.getElementById('queryForm').addEventListener('submit', function(event) {
  217. event.preventDefault();
  218. // 获取手机号并验证
  219. const phoneNumber = document.getElementById('phoneNumber').value.trim();
  220. // 简单的手机号格式验证
  221. const phoneRegex = /^1[3-9]\d{9}$/;
  222. if (!phoneRegex.test(phoneNumber)) {
  223. alert('请输入正确的11位手机号码');
  224. return;
  225. }
  226. // 显示加载状态
  227. document.getElementById('loading').classList.add('active');
  228. document.getElementById('resultContainer').style.display = 'none';
  229. let isEligible = false; // 70%的概率满足条件
  230. // 模拟API请求(实际项目中替换为真实的后端API调用)
  231. fetch(`https://dev-wash-cloud.kuaiyuman.cn/api/parking-coupon/checkParkingCoupon?mobilePhone=${phoneNumber}`).then(response => {
  232. console.log(response);
  233. // 隐藏加载状态
  234. document.getElementById('loading').classList.remove('active');
  235. isEligible =response.ok();
  236. // 显示查询结果
  237. const resultContainer = document.getElementById('resultContainer');
  238. const resultTitle = document.getElementById('resultTitle');
  239. const resultContent = document.getElementById('resultContent');
  240. const collectBtn = document.getElementById('collectBtn');
  241. // 清空之前的样式
  242. resultContainer.classList.remove('eligible', 'not-eligible');
  243. resultTitle.classList.remove('eligible', 'not-eligible');
  244. if (isEligible) {
  245. // 满足领取条件
  246. resultContainer.classList.add('eligible');
  247. resultTitle.classList.add('eligible');
  248. resultTitle.textContent = '恭喜您,满足领取条件!';
  249. resultContent.textContent = '您的手机号符合停车券领取资格,可以立即领取一张停车优惠券。';
  250. collectBtn.style.display = 'block';
  251. collectBtn['data-jump']= response.text();
  252. } else {
  253. // 不满足领取条件
  254. resultContainer.classList.add('not-eligible');
  255. resultTitle.classList.add('not-eligible');
  256. resultTitle.textContent = '抱歉,暂不满足领取条件';
  257. resultContent.textContent = '您的手机号暂不符合停车券领取资格,请稍后再试或咨询客服。';
  258. collectBtn.style.display = 'none';
  259. }
  260. // 显示结果容器
  261. resultContainer.style.display = 'block';
  262. // 滚动到结果区域
  263. resultContainer.scrollIntoView({ behavior: 'smooth' });
  264. })
  265. });
  266. // 领取停车券按钮点击事件
  267. document.getElementById('collectBtn').addEventListener('click', function() {
  268. const phoneNumber = document.getElementById('phoneNumber').value.trim();
  269. // 显示加载状态
  270. document.getElementById('loading').classList.add('active');
  271. // 模拟查询
  272. setTimeout(() => {
  273. // 隐藏加载状态
  274. document.getElementById('loading').classList.remove('active');
  275. const collectBtn = document.getElementById('collectBtn');
  276. location.href=collectBtn.dataset.jump;
  277. /* fetch(`https://dev-wash-cloud.kuaiyuman.cn/api/parking-coupon/checkParkingCoupon?mobilePhone=${phoneNumber}`).then(response => {
  278. let ok = response.ok;
  279. if(ok){
  280. // 显示领取成功提示
  281. alert('停车券领取成功!优惠码已发送到您的手机。');
  282. // 重置表单
  283. document.getElementById('queryForm').reset();
  284. document.getElementById('resultContainer').style.display = 'none';
  285. }else{
  286. alert(response.message);
  287. }
  288. })*/
  289. }, 100);
  290. });
  291. // 手机号输入框的输入限制和格式化
  292. document.getElementById('phoneNumber').addEventListener('input', function(e) {
  293. // 只允许输入数字
  294. this.value = this.value.replace(/\D/g, '');
  295. // 自动格式化手机号(如:138 1234 5678)
  296. let value = this.value;
  297. if (value.length > 0) {
  298. let formattedValue = '';
  299. if (value.length > 3) {
  300. formattedValue += value.slice(0, 3) + '';
  301. value = value.slice(3);
  302. }
  303. if (value.length > 4) {
  304. formattedValue += value.slice(0, 4) + '';
  305. value = value.slice(4);
  306. }
  307. formattedValue += value;
  308. this.value = formattedValue;
  309. }
  310. });
  311. // 页面加载完成后的初始化
  312. window.addEventListener('load', function() {
  313. // 自动聚焦到手机号输入框
  314. document.getElementById('phoneNumber').focus();
  315. });
  316. </script>
  317. </body>
  318. </html>