SyuanYu 11 mesi fa
parent
commit
a5c64f0b68
2 ha cambiato i file con 34 aggiunte e 9 eliminazioni
  1. 11 0
      layouts/partials/head_single.html
  2. 23 9
      layouts/shortcodes/form.html

+ 11 - 0
layouts/partials/head_single.html

@@ -30,4 +30,15 @@
 
     gtag('config', 'G-G5H9MMGQFM');
   </script>
+
+  <!-- emailjs -->
+  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@emailjs/browser@4/dist/email.min.js">
+  </script>
+  <script type="text/javascript">
+    (function () {
+      emailjs.init({
+        publicKey: "bYDCpNE_dK67RFcJr",
+      });
+    })();
+  </script>
 </head>

+ 23 - 9
layouts/shortcodes/form.html

@@ -271,8 +271,31 @@
           $('.loading-btn').hide();
           alert("成功提交!");
         }
+
       },
     });
+
+    // 寄信
+    let templateParams = {
+      name: name,
+      phone: phone,
+      company: company,
+      email: email,
+      demand: demand,
+      caption: caption,
+      budget: budget,
+      date: date,
+      agree: agree,
+    };
+
+    emailjs.send('service_kyazqjp', 'template_n0sqgwh', templateParams).then(
+      (response) => {
+        console.log('SUCCESS!', response.status, response.text);
+      },
+      (error) => {
+        console.log('FAILED...', error);
+      },
+    );
   };
 
   $('button').on('click', function (e) {
@@ -305,14 +328,5 @@
       $('.errorText').hide();
       send();
     }
-
-    // if (name === "" || phoneCode === "" || company === "" || email === "" || demand === "" || caption === "" || budget === "" || date === "" || countryCode === "") {
-    //   $('.errorText').show();
-    //   return;
-    // } else {
-    //   $('.loading-btn').show();
-    //   $('.errorText').hide();
-    //   send();
-    // }
   });
 </script>