提交 57ee2f06 编写于 作者: yma16's avatar yma16

fix:添加超时loading

上级 c437a5f5
......@@ -28,6 +28,7 @@
type="primary"
style="margin-left: 5px"
@click="increment(userId, articleId, articleCommit)"
v-loading="submitLoading"
>提交评论</el-button
>
</div>
......@@ -43,6 +44,7 @@ export default {
// props定义则data()无需定义
data() {
return {
submitLoading: false,
noneMsg: "还没人评论>_<",
msg: "评论区",
baseurl: "/api/",
......@@ -58,7 +60,7 @@ export default {
watch: {
articleId: function (newData) {
this.childArticleId = newData;
return newData
return newData;
},
},
mounted() {
......@@ -100,7 +102,7 @@ export default {
getComments(articleId) {
let that = this;
let params = {
articleId: articleId ? articleId : that.articleId,
articleId: articleId || that.articleId,
};
axios
.post(that.baseurl + "comment/get/", params)
......@@ -138,6 +140,7 @@ export default {
});
return false;
}
that.submitLoading = true;
const userInfo = JSON.parse(localStorage.getItem("yma16siteUserInfo"));
that.userId = userInfo.username;
let params = {
......@@ -148,6 +151,7 @@ export default {
axios
.post(that.baseurl + "comment/post/", params)
.then((res) => {
that.submitLoading = false;
that.articleCommit = null;
try {
let resData = res.data;
......@@ -156,10 +160,12 @@ export default {
item.date = that.dateToString(item.date);
});
} catch (e) {
that.submitLoading = false;
throw Error(e);
}
})
.catch((r) => {
that.submitLoading = false;
that.$router
.push({
path: "/login",
......
<template>
<div class="login" style="text-align: center">
<el-card class="box-card" style="text-align: center">
<el-card class="box-card" style="text-align: center" v-loading="loading">
<el-form
:model="ruleForm"
status-icon
......@@ -11,7 +11,6 @@
style="text-align: center; margin: 0 auto"
>
<el-form-item><p style="font-size: 30px">登录</p></el-form-item>
<el-form-item label="账号" prop="name">
<el-input v-model="ruleForm.name"></el-input>
</el-form-item>
......@@ -83,6 +82,7 @@ export default {
// }
// };
return {
loading: false,
// baseurl:"http://127.0.0.1/user/login/",
baseurl: "/api/",
// baseurl: 'http://yongma16.xyz/user/login/',
......@@ -103,6 +103,7 @@ export default {
const that = this; // this指向
this.$refs[formName].validate((valid) => {
if (valid) {
that.loading = true;
// 提交数据
const loginUrl = that.baseurl + "user/login/";
const userInfo = {
......@@ -129,8 +130,10 @@ export default {
// alter("失败!" res.data.msg)
that.$message.error("用户名或密码错误");
}
that.loading = false;
})
.catch((error) => {
that.loading = false;
that.$message.error(error);
});
} else {
......
......@@ -11,6 +11,7 @@
label-width="100px"
class="demo-ruleForm"
style="text-align: center; margin: 0 auto"
v-loading="loading"
>
<el-form-item>
<!-- 弹出一个警告框 -->
......@@ -115,6 +116,7 @@ export default {
}
};
return {
loading:false,
register_success: false,
register_error: false,
// baseurl: "http://127.0.0.1/",
......@@ -137,6 +139,7 @@ export default {
this.$refs[formName].validate((valid) => {
const that = this;
if (valid) {
that.loading=false
// 提交数据
// alert("yes submit!");
that.register_success = false; // 初始化register的状态
......@@ -162,9 +165,11 @@ export default {
type: "success",
});
}
that.loading=false
})
.catch(function (res) {
// 获取res中的name
that.loading=false
that.$message({
message: "注册失败" + that.ruleForm.name + "!",
type: "error",
......
......@@ -86,7 +86,7 @@ export default {
{
type: "string",
required: true,
message: "不能为空",
message: "不能为空",
trigger: "blur",
},
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册