Initial commit (code only without large binaries)
This commit is contained in:
83
EdgeUser/web/views/@default/index/index.js
Normal file
83
EdgeUser/web/views/@default/index/index.js
Normal file
@@ -0,0 +1,83 @@
|
||||
Tea.context(function () {
|
||||
this.username = "";
|
||||
this.password = "";
|
||||
this.passwordMd5 = "";
|
||||
this.encodedFrom = window.encodeURIComponent(this.from);
|
||||
|
||||
this.showOTP = 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.refreshPlaceholders();
|
||||
setTimeout(() => this.refreshPlaceholders(), 200);
|
||||
});
|
||||
|
||||
this.changeUsername = function () {
|
||||
this.$post("/checkOTP")
|
||||
.params({
|
||||
username: this.username
|
||||
})
|
||||
.success(function (resp) {
|
||||
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) {
|
||||
window.location = "/dashboard";
|
||||
} else {
|
||||
window.location = this.from;
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user