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

fix:提示信息

上级 57ee2f06
......@@ -21,6 +21,10 @@ module.exports = {
],
// add your custom rules here
rules: {
'indent': [2, 4], // 强制使用一致的缩进
'eqeqeq': [2, 'always'], // 要求使用 === 和 !==
'semi': [2, 'never'], // 要求或禁止使用分号代替 ASI
'quotes': [2, 'single'] ,
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
......
......@@ -43,110 +43,94 @@
</template>
<script>
import store from "@/store";
import store from '@/store'
export default {
name: "Login",
data() {
name: 'Login',
data () {
const checkName = (rule, value, callback) => {
if (!value) {
return callback(new Error("账号不能为空"));
return callback(new Error('账号不能为空'))
}
setTimeout(() => {
// if (!Number.isInteger(value)) {
// callback(new Error('请输入密码'));
// } if {
if (value.length < 2) {
callback(new Error("名字至少两位"));
callback(new Error('名字至少两位'))
} else {
callback();
callback()
}
}, 1000)
}
}, 1000);
};
const validatePass = (rule, value, callback) => {
if (value === "") {
callback(new Error("请输入密码"));
if (value === '') {
callback(new Error('请输入密码'))
} else {
// if (this.ruleForm.checkPass !== '') {
// this.$refs.ruleForm.validateField('checkPass');
// }
callback();
callback()
}
}
};
// var validatePass2 = (rule, value, callback) => {
// if (value === '') {
// callback(new Error('请再次输入密码'));
// } else if (value !== this.ruleForm.pass) {
// callback(new Error('两次输入密码不一致!'));
// } else {
// callback();
// }
// };
return {
loading: false,
// baseurl:"http://127.0.0.1/user/login/",
baseurl: "/api/",
baseurl: '/api/',
// baseurl: 'http://yongma16.xyz/user/login/',
ruleForm: {
pass: "",
pass: '',
// checkPass: '',
name: "",
name: ''
},
rules: {
pass: [{ validator: validatePass, trigger: "blur" }],
checkPass: [{ validator: validatePass, trigger: "blur" }],
name: [{ validator: checkName, trigger: "blur" }],
},
};
pass: [{ validator: validatePass, trigger: 'blur' }],
checkPass: [{ validator: validatePass, trigger: 'blur' }],
name: [{ validator: checkName, trigger: 'blur' }]
}
}
},
methods: {
submitForm(formName) {
const that = this; // this指向
submitForm (formName) {
const that = this // this指向
this.$refs[formName].validate((valid) => {
if (valid) {
that.loading = true;
that.loading = true
// 提交数据
const loginUrl = that.baseurl + "user/login/";
const loginUrl = that.baseurl + 'user/login/'
const userInfo = {
name: that.ruleForm.name,
password: that.ruleForm.pass,
};
password: that.ruleForm.pass
}
that.$axios
.post(loginUrl, userInfo)
.then((res) => {
// alter('提交中');
if (res.data.code == 1) {
if (res.data.code === 1) {
localStorage.setItem(
"yma16siteUserInfo",
'yma16siteUserInfo',
JSON.stringify({
username: userInfo.name,
password: userInfo.password,
password: userInfo.password
})
);
store.commit("setUserInfo", userInfo); // store信息
document.cookie = `user=${that.ruleForm.name}`;
that.$router.push({ path: "/" });
)
store.commit('setUserInfo', userInfo) // store信息
document.cookie = `user=${that.ruleForm.name}`
that.$router.push({ path: '/' })
// 添加cookie
} else if (res.data.code == 0) {
} else if (res.data.code === 0) {
// alter("失败!" res.data.msg)
that.$message.error("用户名或密码错误");
that.$message.error('用户名或密码错误')
}
that.loading = false;
that.loading = false
})
.catch((error) => {
that.loading = false;
that.$message.error(error);
});
that.loading = false
that.$message.error(error)
})
} else {
that.$message.error("请输入账号密码");
return false;
return false
}
});
},
resetForm(formName) {
this.$refs[formName].resetFields();
},
})
},
};
resetForm (formName) {
this.$refs[formName].resetFields()
}
}
}
</script>
<style scoped>
......
......@@ -176,10 +176,6 @@ export default {
});
});
} else {
that.$message({
message: "注册失败" + that.ruleForm.name + "!",
type: "error",
});
return false;
}
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册