|
@@ -22,7 +22,7 @@
|
|
<el-form-item label="Email" prop="email">
|
|
<el-form-item label="Email" prop="email">
|
|
<el-input v-model="form.email"></el-input>
|
|
<el-input v-model="form.email"></el-input>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <el-form-item label="Language Preference">
|
|
|
|
|
|
+ <el-form-item label="Language Preference" prop="language">
|
|
<el-select v-model="form.language" placeholder="Select Language">
|
|
<el-select v-model="form.language" placeholder="Select Language">
|
|
|
|
|
|
<el-option label="English" value="English"></el-option>
|
|
<el-option label="English" value="English"></el-option>
|
|
@@ -33,7 +33,7 @@
|
|
|
|
|
|
</el-select>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <el-form-item label="Your message">
|
|
|
|
|
|
+ <el-form-item label="Your message" prop="message">
|
|
<el-input type="text" v-model="form.message"></el-input>
|
|
<el-input type="text" v-model="form.message"></el-input>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-form-item>
|
|
@@ -50,6 +50,8 @@
|
|
import { elIsEmail, elIsValidatePhone } from "@/utils/el-validate";
|
|
import { elIsEmail, elIsValidatePhone } from "@/utils/el-validate";
|
|
import { send as emailSend } from "@emailjs/browser";
|
|
import { send as emailSend } from "@emailjs/browser";
|
|
import { emailConfig } from "@/utils/config"
|
|
import { emailConfig } from "@/utils/config"
|
|
|
|
+ import { SEND_COUNT_KEY, isSameDay } from "@/utils";
|
|
|
|
+ import { Store } from "@/utils/store";
|
|
|
|
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
@@ -95,11 +97,33 @@
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+
|
|
submitForm(formName) {
|
|
submitForm(formName) {
|
|
|
|
+ const store = new Store();
|
|
|
|
+ const localStorageData = store.get(SEND_COUNT_KEY, {
|
|
|
|
+ time: Date.now(),
|
|
|
|
+ count: 0,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 判断是否同一天
|
|
|
|
+ if (isSameDay(localStorageData.time, new Date().getTime())) {
|
|
|
|
+ // 同一天 超过3次 则不允许提交
|
|
|
|
+ if (localStorageData.count >= 3) {
|
|
|
|
+ this.$alert(
|
|
|
|
+ "You have reached the maximum number of submissions!",
|
|
|
|
+ "",
|
|
|
|
+ {
|
|
|
|
+ callback: (action) => {},
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
this.$refs[formName].validate(async (valid) => {
|
|
this.$refs[formName].validate(async (valid) => {
|
|
if (valid) {
|
|
if (valid) {
|
|
try {
|
|
try {
|
|
- this.isLoading=true;
|
|
|
|
|
|
+ this.isLoading = true;
|
|
|
|
|
|
const data = await emailSend(
|
|
const data = await emailSend(
|
|
emailConfig.SERVICE_ID,
|
|
emailConfig.SERVICE_ID,
|
|
@@ -113,13 +137,24 @@
|
|
message: this.form.message,
|
|
message: this.form.message,
|
|
}
|
|
}
|
|
);
|
|
);
|
|
- this.isLoading=false;
|
|
|
|
|
|
+ this.isLoading = false;
|
|
|
|
|
|
if (data.status === 200) {
|
|
if (data.status === 200) {
|
|
- this.$alert('Thank you for contacting us. We’ll get in touch with you in the next 24 hours', '', {
|
|
|
|
- callback: action => {
|
|
|
|
|
|
+ this.$alert( "Thank you for contacting us. We’ll get in touch with you in the next 24 hours", '',
|
|
|
|
+ {
|
|
|
|
+ callback: action => {
|
|
|
|
+ this.$refs[formName].resetFields();
|
|
}
|
|
}
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
+ // 发送成功后,保存发送次数
|
|
|
|
+ store.save(SEND_COUNT_KEY, {
|
|
|
|
+ time: Date.now(),
|
|
|
|
+ count:
|
|
|
|
+ localStorageData.count + 1 >= 4
|
|
|
|
+ ? 1
|
|
|
|
+ : localStorageData.count + 1,
|
|
|
|
+ });1213
|
|
|
|
|
|
} else {
|
|
} else {
|
|
window.alert("Form submitted failed!");
|
|
window.alert("Form submitted failed!");
|
|
@@ -139,7 +174,7 @@
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|
|
- <style scoped>
|
|
|
|
|
|
+ <style scoped>
|
|
.el-card{
|
|
.el-card{
|
|
background: #9bc943;
|
|
background: #9bc943;
|
|
}
|
|
}
|