样式修改完成,待测试
This commit is contained in:
+49
-9
@@ -653,8 +653,10 @@
|
||||
}
|
||||
|
||||
function getInviteCodeFromQuery() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
return params.get("inviteCode") || params.get("referralCode") || "";
|
||||
return (
|
||||
AuthPageUtil.captureReferralInviteFromUrl() ||
|
||||
AuthPageUtil.getPendingReferralInviteCode()
|
||||
);
|
||||
}
|
||||
|
||||
function loadReferralBindPreview() {
|
||||
@@ -694,6 +696,49 @@
|
||||
});
|
||||
}
|
||||
|
||||
function saveRegisterTokenIfPresent(res) {
|
||||
const data = ApiClient.pickData(res) || {};
|
||||
if (!data || typeof data !== "object") return false;
|
||||
|
||||
const token = data.access_token || data.token || "";
|
||||
if (!token) return false;
|
||||
|
||||
localStorage.setItem("token", token);
|
||||
localStorage.setItem("userInfo", JSON.stringify(data));
|
||||
sessionStorage.removeItem("authExpiredRedirecting");
|
||||
sessionStorage.removeItem("authExpiredMessage");
|
||||
return true;
|
||||
}
|
||||
|
||||
function redirectAfterRegister(hasToken) {
|
||||
if (hasToken) {
|
||||
window.location.href =
|
||||
typeof CommonUtil !== "undefined"
|
||||
? CommonUtil.siteHref("/index.html")
|
||||
: "index.html";
|
||||
return;
|
||||
}
|
||||
|
||||
window.location.href = "login.html";
|
||||
}
|
||||
|
||||
function finishRegisterSuccess(res) {
|
||||
const hasToken = saveRegisterTokenIfPresent(res);
|
||||
layerInstance.msg(
|
||||
hasToken ? "注册成功,即将跳转到首页" : "注册成功,即将前往登录",
|
||||
{ icon: 1, time: 1200 },
|
||||
function () {
|
||||
AuthPageUtil.bindPendingReferralInviteCode()
|
||||
.then(function () {
|
||||
redirectAfterRegister(hasToken);
|
||||
})
|
||||
.catch(function () {
|
||||
redirectAfterRegister(hasToken);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function register() {
|
||||
$("#registerBtn").prop("disabled", true).text("注册中...");
|
||||
ApiClient.post(ApiClient.API.authRegister, buildRegisterData(), {
|
||||
@@ -701,13 +746,7 @@
|
||||
})
|
||||
.then(function (res) {
|
||||
if (ApiClient.isSuccess(res)) {
|
||||
layerInstance.msg(
|
||||
"注册成功,即将前往登录",
|
||||
{ icon: 1, time: 1200 },
|
||||
function () {
|
||||
window.location.href = "login.html";
|
||||
},
|
||||
);
|
||||
finishRegisterSuccess(res);
|
||||
return;
|
||||
}
|
||||
layerInstance.msg((res && res.msg) || "注册失败,请稍后重试", {
|
||||
@@ -726,6 +765,7 @@
|
||||
|
||||
layui.use(["layer", "jquery"], function () {
|
||||
layerInstance = layui.layer;
|
||||
AuthPageUtil.captureReferralInviteFromUrl();
|
||||
loadVerifyConfig().then(refreshCaptcha);
|
||||
loadReferralBindPreview();
|
||||
$("#sendSmsBtn").on("click", sendSmsCode);
|
||||
|
||||
Reference in New Issue
Block a user