样式修改完成,待测试
This commit is contained in:
+67
-33
@@ -139,28 +139,6 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wechatBindCard" id="wechat-bind-card">
|
||||
<div class="wechatBindTop">
|
||||
<div class="wechatBindIconBox">
|
||||
<img class="wechatBindIcon" src="../public/img/pay-wechat.png" alt="微信" />
|
||||
</div>
|
||||
<div class="wechatBindInfo">
|
||||
<div class="wechatBindTitle">微信账号</div>
|
||||
<div class="wechatBindDesc" id="wechat-bind-desc">正在检测绑定状态...</div>
|
||||
</div>
|
||||
<div class="wechatBindStateDot"></div>
|
||||
</div>
|
||||
<div class="wechatBindLine"></div>
|
||||
<button
|
||||
type="button"
|
||||
class="wechatBindButton"
|
||||
id="wechat-bind-button"
|
||||
onclick="openWeChatBindPopup()"
|
||||
>
|
||||
绑定微信
|
||||
</button>
|
||||
</div>
|
||||
<!-- Balance Cards -->
|
||||
<div class="uc-balance-grid">
|
||||
<div class="uc-balance-item">
|
||||
@@ -535,9 +513,24 @@
|
||||
}
|
||||
|
||||
function updateExpertActions(data) {
|
||||
var expert = isExpertUser(data);
|
||||
$("#expertApplyBtn").toggle(!expert);
|
||||
$("#publishArticleBtn").toggle(expert);
|
||||
var state = CommonUtil.getExpertState
|
||||
? CommonUtil.getExpertState(data)
|
||||
: { isExpert: isExpertUser(data), isApplying: false };
|
||||
var $applyBtn = $("#expertApplyBtn");
|
||||
var $publishBtn = $("#publishArticleBtn");
|
||||
$publishBtn.toggle(state.isExpert);
|
||||
$applyBtn.toggle(!state.isExpert);
|
||||
if (state.isExpert) {
|
||||
return;
|
||||
}
|
||||
$applyBtn
|
||||
.text(state.isApplying ? "申请审核中" : "专家申请")
|
||||
.prop("disabled", !!state.isApplying);
|
||||
if (state.isApplying) {
|
||||
$applyBtn.removeAttr("onclick");
|
||||
} else {
|
||||
$applyBtn.attr("onclick", "window.location.href = 'apply.html'");
|
||||
}
|
||||
}
|
||||
|
||||
function loadAccountInfoForWechat() {
|
||||
@@ -1379,7 +1372,7 @@
|
||||
? currentUserData.nickName || currentUserData.username || ""
|
||||
: "";
|
||||
|
||||
uploadedAvatarUrl = "";
|
||||
uploadedAvatarId = "";
|
||||
userAvatarFile = null;
|
||||
|
||||
var content =
|
||||
@@ -1422,14 +1415,14 @@
|
||||
content: content,
|
||||
end: function () {
|
||||
editProfileLayerIndex = null;
|
||||
uploadedAvatarUrl = "";
|
||||
uploadedAvatarId = "";
|
||||
userAvatarFile = null;
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var uploadedAvatarUrl = "";
|
||||
var uploadedAvatarId = "";
|
||||
var editProfileLayerIndex = null;
|
||||
var userAvatarFile = null;
|
||||
|
||||
@@ -1443,14 +1436,19 @@
|
||||
if (!input.files || !input.files[0]) return;
|
||||
|
||||
var file = input.files[0];
|
||||
if (!/^image\//.test(file.type || "")) {
|
||||
layui.layer.msg("请选择图片文件", { icon: 2 });
|
||||
if (!/^(image\/jpeg|image\/png)$/.test(file.type || "")) {
|
||||
layui.layer.msg("只支持 JPG/PNG 格式的图片", { icon: 2 });
|
||||
input.value = "";
|
||||
return;
|
||||
}
|
||||
if (file.size > 2 * 1024 * 1024) {
|
||||
layui.layer.msg("图片大小不能超过 2MB", { icon: 2 });
|
||||
input.value = "";
|
||||
return;
|
||||
}
|
||||
|
||||
userAvatarFile = file;
|
||||
uploadedAvatarUrl = "";
|
||||
uploadedAvatarId = "";
|
||||
|
||||
var reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
@@ -1504,31 +1502,67 @@
|
||||
if (!avatarId) {
|
||||
throw new Error("头像上传返回缺少文件编号");
|
||||
}
|
||||
uploadedAvatarUrl = avatarId;
|
||||
uploadedAvatarId = avatarId;
|
||||
return avatarId;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function validateEditProfileNickname(nickName) {
|
||||
var nicknameWidth = Array.from(nickName).reduce(function (total, char) {
|
||||
return total + (/[\u4e00-\u9fa5\uff00-\uffef]/.test(char) ? 2 : 1);
|
||||
}, 0);
|
||||
|
||||
if (nickName.length < 2 || nicknameWidth > 12) {
|
||||
layui.layer.msg("昵称长度应为2-6个汉字或2-12个英文", { icon: 2 });
|
||||
$("#editNickName").focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function submitEditProfile() {
|
||||
var nickName = $("#editNickName").val().trim();
|
||||
var password = $("#editPassword").val();
|
||||
var passwordConfirm = $("#editPasswordConfirm").val();
|
||||
var currentNickName = currentUserData
|
||||
? currentUserData.nickName || currentUserData.username || ""
|
||||
: "";
|
||||
|
||||
if (!nickName) {
|
||||
layui.layer.msg("昵称不能为空", { icon: 2 });
|
||||
return;
|
||||
}
|
||||
if (nickName !== currentNickName && !validateEditProfileNickname(nickName)) {
|
||||
return;
|
||||
}
|
||||
if ((password || passwordConfirm) && (!password || !passwordConfirm)) {
|
||||
layui.layer.msg("请输入并确认新密码", { icon: 2 });
|
||||
return;
|
||||
}
|
||||
if (password && password !== passwordConfirm) {
|
||||
layui.layer.msg("两次密码输入不一致", { icon: 2 });
|
||||
return;
|
||||
}
|
||||
if (password && (password.length < 6 || password.length > 20)) {
|
||||
layui.layer.msg("密码长度应为6-20位", { icon: 2 });
|
||||
return;
|
||||
}
|
||||
|
||||
var params = { username: nickName };
|
||||
var params = {};
|
||||
if (nickName !== currentNickName) {
|
||||
params.nickName = nickName;
|
||||
}
|
||||
if (password) {
|
||||
params.password = hex_md5(password);
|
||||
}
|
||||
|
||||
if (!userAvatarFile && Object.keys(params).length === 0) {
|
||||
layui.layer.msg("暂无修改", { icon: 0 });
|
||||
return;
|
||||
}
|
||||
|
||||
var $submitBtn = $("#editProfileSubmitBtn");
|
||||
$submitBtn.prop("disabled", true).text("保存中...");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user