Ver Fonte

修复无法提交表白的问题

UnknownO há 4 anos atrás
pai
commit
40fbdf83cc
2 ficheiros alterados com 29 adições e 57 exclusões
  1. 11 9
      api/submit.php
  2. 18 48
      pages/submit.php

+ 11 - 9
api/submit.php

@@ -29,17 +29,19 @@ if (md5($all) != $_POST['key']) {
 
 try {
     $pdo = pdoConnect();
-    $stmt = $pdo->prepare("insert into loveway_data(id,confessor,contact,time,to_who,introduction,content,image)values(?,?,?,?,?,?,?,?)");
+    $stmt = $pdo->prepare("insert into loveway_data(id,favorite,confessor,contact,time,to_who,introduction,content,image,comment)values(?,?,?,?,?,?,?,?,?,?)");
     $stmt->bindValue(1, rand(100000000, 999999999));
-    $stmt->bindValue(2, $confessor);
-    $stmt->bindValue(3, $contact);
-    $stmt->bindValue(4, date("Y-m-d H:i:s", time()));
-    $stmt->bindValue(5, $ta);
-    $stmt->bindValue(6, $introduction);
-    $stmt->bindValue(7, $content);
-    $stmt->bindValue(8, $image);
+    $stmt->bindValue(2, 0);
+    $stmt->bindValue(3, $confessor);
+    $stmt->bindValue(4, $contact);
+    $stmt->bindValue(5, date("Y-m-d H:i:s", time()));
+    $stmt->bindValue(6, $ta);
+    $stmt->bindValue(7, $introduction);
+    $stmt->bindValue(8, $content);
+    $stmt->bindValue(9, $image);
+    $stmt->bindValue(10, "[]");
     if ($stmt->execute()) {
-        exit('{"code":1,"msg":"success"}');
+        exit('{"code":1,"msg":"表白信息提交成功!"}');
     } else {
         exit('{"code":-2,"msg":"抱歉,出现了一个未知错误!请与管理员联系!"}');
     }

+ 18 - 48
pages/submit.php

@@ -75,7 +75,6 @@ if ($templateMode) {
         }
 
         function request(vCode) {
-            $("#submitbtn").attr("disabled", true);
             var contact = $("#qq").val();
             var name = $("#name").val();
             var taName = $("#taName").val();
@@ -92,53 +91,24 @@ if ($templateMode) {
                 introduceTA +
                 toTA +
                 timestamp)
-            $.ajax({
-                type: 'post',
-                url: '/api/submit.php',
-                data: {
-                    key: key,
-                    timestamp: timestamp,
-                    contact: contact,
-                    name: name,
-                    taName: taName,
-                    image: image,
-                    introduceTA: introduceTA,
-                    toTA: toTA,
-                    vCode:vCode
-                },
-                dataType: 'text',
-                success: function(data) {
-                    console.log(data)
-                    data = JSON.parse(data);
-                    if (data.code == 1) {
-                        mdui.snackbar({
-                            message: '提交成功!',
-                            position: 'right-top'
-                        });
-                        $("#qq").val("");
-                        $("#name").val("");
-                        $("#taName").val("");
-                        $("#image").val("");
-                        $("#introduceTA").val("");
-                        $("#toTA").val("");
-                    } else {
-                        mdui.snackbar({
-                            message: data.msg,
-                            position: 'right-top'
-                        });
-                    }
-                    $("#submitbtn").attr("disabled", false);
-                },
-                error: function(data) {
-                    var errors = data.responseJSON;
-                    $.each(errors.errors, function(key, value) {
-                        mdui.snackbar({
-                            message: "出现了一个未知错误",
-                            position: 'right-top'
-                        });
-                    });
-                },
-            });
+            requestApi("submit", {
+                key: key,
+                timestamp: timestamp,
+                contact: contact,
+                name: name,
+                taName: taName,
+                image: image,
+                introduceTA: introduceTA,
+                toTA: toTA,
+                vCode: vCode
+            }, function(data) {
+                $("#qq").val("");
+                $("#name").val("");
+                $("#taName").val("");
+                $("#image").val("");
+                $("#introduceTA").val("");
+                $("#toTA").val("");
+            }, true, true, "#submitbtn")
         }
     </script>
 </div>