Browse Source

form2.html

miacheng913 1 year ago
parent
commit
74bec558e9
1 changed files with 48 additions and 21 deletions
  1. 48 21
      layouts/shortcodes/form2.html

+ 48 - 21
layouts/shortcodes/form2.html

@@ -166,6 +166,7 @@
 
   $('.errorText').hide();
   $('.loading-btn').hide();
+  const scriptURL = 'https://script.google.com/macros/s/AKfycbzuwioqhnP2oL0AdHaYgEBvf0t0yWi2OTxZYlPYSoLuPyHhQFJKMm5mgOCoZEx-cIckbA/exec';
 
 
   async function send() {
@@ -210,32 +211,58 @@
     phone = `${countryCode} ${phoneCode}`;
 
     const insertdata = {
-      name: name,
-      email: email,
-      lineid: lineid,
-      agreeValue: agree,
-      dateValue: date,
-      phone: phone,
-      caption: caption,
-      companyValue: company
+      "name": name,
+      "phone": phone,
+      "company": company,
+      "email": email,
+      "lineid": lineid,
+      "caption": caption,
+      "date": date,
+      "agree": agree,
+      "time": time
     }
 
-    const { data, error } = await supabase
-      .from('ai_news')
-      .insert([insertdata])
-      .then(({ data, error }) => {
-        if (error) {
-          console.error('插入数据时发生错误:', error);
-        } else {
-          $('.loading-btn').hide();
-          alert("成功提交!");
+    console.log(insertdata);
 
-        }
-      })
-      .catch(e => {
+    // const { data, error } = await supabase
+    //   .from('ai_news')
+    //   .insert([insertdata])
+    //   .then(({ data, error }) => {
+    //     if (error) {
+    //       console.error('插入数据时发生错误:', error);
+    //     } else {
+    //       $('.loading-btn').hide();
+    //       alert("成功提交!");
 
-      });
+    //     }
+    //   })
+    //   .catch(e => {
+
+    //   });
     // .select()
+
+
+    $.ajax({
+      url: scriptURL,
+      method: "post",
+      data: {
+        "name": name,
+        "phone": phone,
+        "company": company,
+        "email": email,
+        "lineid": lineid,
+        "caption": caption,
+        "date": date,
+        "agree": agree,
+        "time": time
+      },
+      success: function (response) {
+        if (response == "成功") {
+          $('.loading-btn').hide();
+          alert("成功提交!");
+        }
+      },
+    });
   };