Mike %!s(int64=3) %!d(string=hai) anos
pai
achega
9acc95c073
Modificáronse 2 ficheiros con 62 adicións e 42 borrados
  1. 1 1
      api/main.py
  2. 61 41
      html/index.html

+ 1 - 1
api/main.py

@@ -79,7 +79,7 @@ async def checkCellphone(cellphone: str = ''):
         print('無手機號碼資料')
         return {"count": 0, "msg": "無手機號碼資料"}
     else:
-        # 有手機號碼資料
+        # 有手機號碼資料
         cellphone_list = []
         
         for r1 in db.query(q):

+ 61 - 41
html/index.html

@@ -5,6 +5,8 @@
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
+
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
     
     <!-- Bootstrap CSS -->
@@ -14,22 +16,20 @@
   </head>
   <body>
     <div class="my-5 container text-center col-sm-12 col-md-6">
-      <h2 class="mb-3"><b>幸福經紀人</b></h2>
-      <h4 class="mb-5"><b>手機號碼批次查詢系統</b></h4>
+      <h1 class="mb-3" style="color:#ea068c;"><b>幸福經紀人</b></h1>
+      <h4 class="mb-5">手機號碼批次查詢系統</h4>
       <form role="form" id="form_check">
         <div class="mb-4 form-group">
-          <textarea class="form-control" rows="10" id="cellphone" name="cellphone" placeholder="請輸入手機號碼清單"></textarea>
+          <textarea class="form-control" rows="10" id="cellphone" name="cellphone" placeholder="請輸入要查詢的手機號碼 (每列1筆手機資料)"></textarea>
         </div>
         <div>
           <button id="form_check_submit" type="submit" class="btn btn-light">
-            <span class="lead font-weight-bold">
+            <span class="font-weight-bold">
               立即查詢 <i class="ml-1 fas fa-sign-in-alt"></i>
             </span>
           </button>
         </div>
       </form>
-
-      <div class="mt-5" id="result">查詢結果</div>
     </div>
   </body>
 
@@ -40,47 +40,67 @@
 <script>
 $(document).ready(function () {
   $("#form_check").submit(function(e) {
-    var cellphone = $('#cellphone').val();
+    // 立即查詢按鈕控制
+    var buttonStyle = '<span class="font-weight-bold"> \
+                        <i class="fa fa-spinner fa-spin"></i> 查詢中,請稍待 <i class="ml-1 fas fa-sign-in-alt"></i> \
+                      </span>'
 
-    axios.get('http://139.162.121.30:8887/check', {
-      params: {
-        cellphone: cellphone
-      }
-    })
-    .then(function (response) {
-      console.log(response);
+    $('#form_check_submit').html(buttonStyle);
+    
+    var cellphone = $('#cellphone').val();
 
-      html = ''
+    if (cellphone == "") { // 未輸入手機號碼
+      Swal.fire({
+          title: '注意!',
+          icon: 'error',
+          confirmButtonColor: '#3085d6',
+          text: '請先輸入要查詢的手機號碼',
+      });
+    } else { // 已輸入手機號碼
+      axios.get('http://139.162.121.30:8887/check', {
+        params: {
+          cellphone: cellphone
+        }
+      })
+      .then(function (response) {
+        console.log(response);
+        
+        // 立即查詢按鈕控制
+        var buttonStyle = '<span class="font-weight-bold"> \
+                            立即查詢 <i class="ml-1 fas fa-sign-in-alt"></i> \
+                          </span>'
 
-      count = response.data.count;
-      cellphone = response.data.cellphone;
+    $('#form_check_submit').html(buttonStyle);
+        
+        html = ''
 
-      if (count == 0) { // 無手機號碼資料
-        $("#result").text("沒有符合的手機號碼");  
-        Swal.fire({
-            title: 'success',
-            icon: 'error',
-            confirmButtonColor: '#3085d6',
-            text: '沒有符合的手機號碼',
-        });
-      } else { // 有手機號碼資料
-        for (let i = 0; i < cellphone.length; i++) {
-          html += cellphone[i] + "<br>";
-        }
+        count = response.data.count;
+        cellphone = response.data.cellphone;
 
-        Swal.fire({
-            title: '查詢結果',
-            icon: 'success',
-            confirmButtonColor: '#3085d6',
-            html: html
-        });
+        if (count == 0) { // 無手機號碼資料
+          Swal.fire({
+              title: '查詢結果',
+              icon: 'success',
+              confirmButtonColor: '#3085d6',
+              text: '沒有符合的手機號碼',
+          });
+        } else { // 有手機號碼資料
+          for (let i = 0; i < cellphone.length; i++) {
+            html += '<div class="mb-1">' + cellphone[i] + '</div>';
+          }
 
-        $("#result").html(html);
-      }
-    })
-    .catch(function (error) {
-      console.log(error);
-    });
+          Swal.fire({
+              title: '符合的手機號碼',
+              icon: 'success',
+              confirmButtonColor: '#3085d6',
+              html: html
+          });
+        }
+      })
+      .catch(function (error) {
+        console.log(error);
+      });
+    }
 
     return false;
   });