From 9c47af200c2fe54d42263ae36d4bf8e3da2255ef Mon Sep 17 00:00:00 2001 From: yma16 <17685043634@163.com> Date: Sat, 9 Jul 2022 14:47:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=8F=8D=E9=A6=88=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 4 +- src/components/Article.vue | 2 +- src/components/email/Email.vue | 82 +++++++++++++++++++--------------- 3 files changed, 50 insertions(+), 38 deletions(-) diff --git a/src/App.vue b/src/App.vue index c9fe01b..c847b7c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -179,9 +179,9 @@ export default { const that = this; let clientIp = "未知"; try { - console.log("ip待定"); + console.warn("ip待定"); } catch (e) { - console.log(e); + console.warn(e); } that.$axios .post(this.baseUrl + "count/add/", { diff --git a/src/components/Article.vue b/src/components/Article.vue index a472017..5fe4676 100644 --- a/src/components/Article.vue +++ b/src/components/Article.vue @@ -207,7 +207,7 @@ diff --git a/src/components/email/Email.vue b/src/components/email/Email.vue index 5718466..a1ed72f 100644 --- a/src/components/email/Email.vue +++ b/src/components/email/Email.vue @@ -62,7 +62,7 @@ export default { msgDrawTitle: "~邮件沟通~", direction: "rtl", msgDraw: false, - baseUrl: "http://localhost:8006/", + baseUrl: "/api/", basePath: "send-email/", loading: false, emailForm: { @@ -93,10 +93,10 @@ export default { /^([0-9a-zA-Z_\.\-\])+\@([0-9a-zA-Z_\.\-\])+\.([a-zA-Z]+)$/; let testEmail = patter.test(value); if (!testEmail) { - return Promise.reject("请输入正确的邮箱格式"); + return Promise.reject("邮箱格式有误"); } } - return Promise.resolve(); + return Promise.resolve(""); }, trigger: "blur", }, @@ -115,46 +115,58 @@ export default { }, methods: { //关闭抽屉 - handleDrawClose(done) { + handleDrawClose() { const that = this; that.drawObj.show = false; }, // 发送消息 sendEmail(formName) { // 发送email内容 - const that = this; - that.loading = true; - that.$refs[formName].validate((valid) => { - if (valid) { - const params = { - title: that.emailForm.title, - email: that.emailForm.email, - content: that.emailForm.content, - }; - try { - axios.post(that.baseUrl + that.basePath, params).then((res) => { - if (res && res.code && res.code === 20000) { - that.loading = false; - that.$message({ - message: "邮件发送成功!", - type: "success", - }); - that.drawObj.show = false; - }else{ - that.$message({ - message: "邮件发送失败!", - type: "warning", - }); - } - }); - } catch (r) { + try { + const that = this; + that.loading = true; + that.$refs[formName].validate((valid) => { + if (valid) { + const params = { + title: that.emailForm.title, + email: that.emailForm.email, + content: that.emailForm.content, + }; + try { + axios.post(that.baseUrl + that.basePath, params).then((res) => { + console.log(res); + if ( + res && + res.data && + res.data.code && + res.data.code === 20000 + ) { + that.loading = false; + that.$message({ + message: "邮件发送成功!", + type: "success", + }); + that.drawObj.show = false; + } else { + that.loading = false; + that.$message({ + message: "邮件发送失败!", + type: "warning", + }); + } + }); + } catch (r) { + that.loading = false; + throw Error(r); + } + } else { that.loading = false; - throw Error(r); } - } else { - that.loading = false; - } - }); + }); + } catch (r) { + that.loading = false; + throw Error(r); + } }, }, }; -- GitLab