|
@@ -109,6 +109,9 @@
|
|
import headTop from "@/components/headTop.vue";
|
|
import headTop from "@/components/headTop.vue";
|
|
import footerMenu from "@/components/footerMenu.vue";
|
|
import footerMenu from "@/components/footerMenu.vue";
|
|
import { elIsEmail, elIsValidatePhone } from "@/utils/el-validate";
|
|
import { elIsEmail, elIsValidatePhone } from "@/utils/el-validate";
|
|
|
|
+import { send as emailSend } from "@emailjs/browser";
|
|
|
|
+import { emailConfig } from "@/utils/config"
|
|
|
|
+
|
|
export default {
|
|
export default {
|
|
name: "ContactUs",
|
|
name: "ContactUs",
|
|
data() {
|
|
data() {
|
|
@@ -147,15 +150,15 @@ export default {
|
|
{
|
|
{
|
|
required: true,
|
|
required: true,
|
|
trigger: ["blur"],
|
|
trigger: ["blur"],
|
|
- validator: elIsValidatePhone
|
|
|
|
|
|
+ validator: elIsValidatePhone,
|
|
},
|
|
},
|
|
],
|
|
],
|
|
email: [
|
|
email: [
|
|
{
|
|
{
|
|
required: true,
|
|
required: true,
|
|
trigger: ["blur"],
|
|
trigger: ["blur"],
|
|
- validator: elIsEmail
|
|
|
|
- }
|
|
|
|
|
|
+ validator: elIsEmail,
|
|
|
|
+ },
|
|
],
|
|
],
|
|
message: [{ required: true, message: "Please enter" }],
|
|
message: [{ required: true, message: "Please enter" }],
|
|
},
|
|
},
|
|
@@ -163,10 +166,36 @@ export default {
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
submitForm(formName) {
|
|
submitForm(formName) {
|
|
- this.$refs[formName].validate((valid) => {
|
|
|
|
|
|
+ this.$refs[formName].validate(async (valid) => {
|
|
if (valid) {
|
|
if (valid) {
|
|
// 在这里可以添加表单提交的逻辑,例如发送数据到服务器
|
|
// 在这里可以添加表单提交的逻辑,例如发送数据到服务器
|
|
- console.log("Form submitted:", this.form);
|
|
|
|
|
|
+ try {
|
|
|
|
+ const language = this.languages.find(
|
|
|
|
+ (item) => item.value === this.form.languagePreference
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ const data = await emailSend(
|
|
|
|
+ emailConfig.SERVICE_ID,
|
|
|
|
+ emailConfig.TEMPLATE_ID,
|
|
|
|
+ {
|
|
|
|
+ from_name: "test",
|
|
|
|
+ name: this.form.name,
|
|
|
|
+ businessName: this.form.businessName,
|
|
|
|
+ mobile: this.form.mobile,
|
|
|
|
+ email: this.form.email,
|
|
|
|
+ languagePreference: language.value,
|
|
|
|
+ message: this.form.message,
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ if (data.status === 200) {
|
|
|
|
+ window.alert("Form submitted successfully!");
|
|
|
|
+ } else {
|
|
|
|
+ window.alert("Form submitted failed!");
|
|
|
|
+ }
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.log("Error submitting form!", error);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
console.log("Error submitting form!");
|
|
console.log("Error submitting form!");
|
|
return false;
|
|
return false;
|