var WapTn = new Vue({ extends: baseVue, data: { isLoading: false, loginForm: { username: "", password: "", }, loginFormRules: { username: [{ required: true, message: "请输入用户名称", trigger: "blur" }, { min: 3, max: 20, message: "用户名称为 3 到 20 个字符", trigger: "blur" }], password: [{ required: true, message: "请输入密码", trigger: "blur" }, { min: 3, max: 20, message: "密码长度为 3 到 20 个字符", trigger: "blur" }] } }, methods: { onSubmit: function () { this.$refs["loginForm"].validate(function (valid) { if (valid) { WapTn.isLoading = true; axios.post("/login.html", { username: WapTn.loginForm.username, password: encryPassword(WapTn.loginForm.password) }).then(function (response) { Cookies.set("t", response.data.token, cookiesSettings); Cookies.set("username", response.data.username, cookiesSettings); WapTn.isLoading = false; WapTn.$refs.simplert.openSimplert({ title: "登录成功", disableOverlayClick: true, customCloseBtnText: '明白', onClose: function () { window.location = INDEX_URL; } }); }).catch(function (exception) { if (exception) { var msg; if (exception.code == "USER_OR_PWD_ERRO") { msg = "用户名或密码错误" } else if (exception.code = "USERNAME_NOT_EXIST") { msg = "用户名不存在" } else { } WapTn.isLoading = false; WapTn.$refs.simplert.openSimplert({ title: "登陆失败", message: msg, disableOverlayClick: true, customCloseBtnText: '明白', onClose: function () { } }); } }) } else { return false; } }); } }, mounted: function () { if (this.isLogin) { Cookies.remove("t", {domain: window.location.host}); Cookies.remove("token", {domain: window.location.host}); Cookies.remove("username", {domain: window.location.host}); } } });