登录页面改造
This commit is contained in:
@@ -4,26 +4,44 @@ Tea.context(function () {
|
||||
this.passwordMd5 = "";
|
||||
this.encodedFrom = window.encodeURIComponent(this.from);
|
||||
|
||||
this.showOTP = false
|
||||
this.showOTP = false;
|
||||
this.isSubmitting = false;
|
||||
|
||||
this.isSubmitting = false
|
||||
this.usernamePlaceholder = "\u8bf7\u8f93\u5165\u7528\u6237\u540d";
|
||||
let loginMethods = [];
|
||||
if (this.emailCanLogin) {
|
||||
loginMethods.push("\u90ae\u7bb1");
|
||||
}
|
||||
if (this.mobileCanLogin) {
|
||||
loginMethods.push("\u624b\u673a\u53f7\u7801");
|
||||
}
|
||||
if (loginMethods.length > 0) {
|
||||
this.usernamePlaceholder += "/" + loginMethods.join("/");
|
||||
}
|
||||
|
||||
this.refreshPlaceholders = function () {
|
||||
let usernameInput = document.querySelector("form input[name='username']");
|
||||
if (usernameInput != null) {
|
||||
usernameInput.setAttribute("placeholder", this.usernamePlaceholder);
|
||||
}
|
||||
|
||||
let passwordInput = document.querySelector("form input[type='password']");
|
||||
if (passwordInput != null) {
|
||||
passwordInput.setAttribute("placeholder", "\u8bf7\u8f93\u5165\u5bc6\u7801");
|
||||
}
|
||||
|
||||
let otpInput = document.querySelector("form input[name='otpCode']");
|
||||
if (otpInput != null) {
|
||||
otpInput.setAttribute("placeholder", "\u8bf7\u8f93\u5165 OTP \u52a8\u6001\u7801");
|
||||
}
|
||||
};
|
||||
|
||||
this.$delay(function () {
|
||||
this.$find("form input[name='username']").focus();
|
||||
this.changePassword();
|
||||
})
|
||||
|
||||
this.usernamePlaceholder = "请输入用户名"
|
||||
var loginMethods = []
|
||||
if (this.emailCanLogin) {
|
||||
loginMethods.push("邮箱")
|
||||
}
|
||||
if (this.mobileCanLogin) {
|
||||
loginMethods.push("手机号码")
|
||||
}
|
||||
if (loginMethods.length > 0) {
|
||||
this.usernamePlaceholder += "/" + loginMethods.join("/")
|
||||
}
|
||||
this.refreshPlaceholders();
|
||||
setTimeout(() => this.refreshPlaceholders(), 200);
|
||||
});
|
||||
|
||||
this.changeUsername = function () {
|
||||
this.$post("/checkOTP")
|
||||
@@ -31,27 +49,29 @@ Tea.context(function () {
|
||||
username: this.username
|
||||
})
|
||||
.success(function (resp) {
|
||||
this.showOTP = resp.data.requireOTP
|
||||
})
|
||||
}
|
||||
this.showOTP = resp.data.requireOTP;
|
||||
this.$delay(function () {
|
||||
this.refreshPlaceholders();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
this.changePassword = function () {
|
||||
this.passwordMd5 = md5(this.password.trim());
|
||||
}
|
||||
};
|
||||
|
||||
// 更多选项
|
||||
this.moreOptionsVisible = false;
|
||||
this.showMoreOptions = function () {
|
||||
this.moreOptionsVisible = !this.moreOptionsVisible;
|
||||
}
|
||||
};
|
||||
|
||||
this.submitBefore = function () {
|
||||
this.isSubmitting = true;
|
||||
}
|
||||
};
|
||||
|
||||
this.submitDone = function () {
|
||||
this.isSubmitting = false;
|
||||
}
|
||||
};
|
||||
|
||||
this.submitSuccess = function () {
|
||||
if (this.from.length == 0) {
|
||||
@@ -59,5 +79,5 @@ Tea.context(function () {
|
||||
} else {
|
||||
window.location = this.from;
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user