修改功能,现已测试注册登录忘记密码
This commit is contained in:
@@ -81,7 +81,7 @@
|
||||
提示:实习期为三天,连续每天发布2篇以上的优质免费文章审核通过后,自动升级为正式专家。
|
||||
</div>
|
||||
<div class="publish-tip-item">
|
||||
免费文章标准:标题20字以上(含期号、彩种、专家名称、标题),正文500字以上,需原创。
|
||||
免费文章标准:标题15-30字(含期号、彩种、专家名称、标题),正文500字以上,需原创。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -105,11 +105,11 @@
|
||||
class="form-input"
|
||||
id="articleTitle"
|
||||
placeholder="请输入文章标题(含期号、彩种、标题)"
|
||||
maxlength="100"
|
||||
maxlength="30"
|
||||
oninput="updateTitleCount()"
|
||||
/>
|
||||
<span class="form-input-count"
|
||||
><span id="titleCount">0</span>/100</span
|
||||
><span id="titleCount">0</span>/30</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
@@ -175,6 +175,13 @@
|
||||
var layer;
|
||||
var editor;
|
||||
var pageReady = false;
|
||||
var publishPermission = {
|
||||
canFree: false,
|
||||
canPaid: false,
|
||||
};
|
||||
var REQUIRED_DAILY_FREE_ARTICLES = 2;
|
||||
var FREE_TITLE_MIN_LENGTH = 15;
|
||||
var FREE_TITLE_MAX_LENGTH = 30;
|
||||
|
||||
function autoFormatEditorContent() {
|
||||
if (!editor) return;
|
||||
@@ -227,8 +234,9 @@
|
||||
renderLoginState();
|
||||
renderNav();
|
||||
CommonUtil.requireAuth(function () {
|
||||
loadPublishIdentity().then(function (allowed) {
|
||||
if (!allowed) {
|
||||
loadPublishPermission().then(function (permission) {
|
||||
publishPermission = permission;
|
||||
if (!permission.canFree) {
|
||||
layer.alert(
|
||||
"您还不是实习或正式专家,暂不能发布文章。",
|
||||
{ title: "暂无权限" },
|
||||
@@ -381,48 +389,89 @@
|
||||
});
|
||||
}
|
||||
|
||||
function checkPaidPublishPermission() {
|
||||
function parsePublishPermission(userData) {
|
||||
var status = String(
|
||||
userData.expertStatus || userData.expert_status || "",
|
||||
).toLowerCase();
|
||||
var isIntern = /实习|intern|trial/.test(status);
|
||||
var isRegularByStatus = /正式|regular|formal/.test(status);
|
||||
var hasExpertIdentity =
|
||||
isTruthy(userData.is_expert) ||
|
||||
isTruthy(userData.isExpert) ||
|
||||
isTruthy(userData.expert) ||
|
||||
isTruthy(userData.is_regular_expert) ||
|
||||
isTruthy(userData.isRegularExpert) ||
|
||||
isTruthy(userData.regularExpert) ||
|
||||
isIntern ||
|
||||
isRegularByStatus;
|
||||
var isRegularExpert =
|
||||
isTruthy(userData.is_regular_expert) ||
|
||||
isTruthy(userData.isRegularExpert) ||
|
||||
isTruthy(userData.regularExpert) ||
|
||||
isRegularByStatus;
|
||||
|
||||
return {
|
||||
hasExpertIdentity: hasExpertIdentity,
|
||||
isRegularExpert: hasExpertIdentity && isRegularExpert,
|
||||
canFree: hasExpertIdentity,
|
||||
canPaid: false,
|
||||
todayFreeArticleCount: 0,
|
||||
paidReason: isRegularExpert
|
||||
? "今天需先发布2篇审核通过的免费文章后,才能发布付费文章"
|
||||
: "正式专家才能发布付费文章",
|
||||
};
|
||||
}
|
||||
|
||||
function loadPublishPermission() {
|
||||
return ApiClient.get(ApiClient.API.mineSummary)
|
||||
.then(function (res) {
|
||||
if (!ApiClient.isSuccess(res) || !res.data) {
|
||||
return { canPaid: false, reason: "暂时无法获取发布权限。" };
|
||||
return {
|
||||
hasExpertIdentity: false,
|
||||
isRegularExpert: false,
|
||||
canFree: false,
|
||||
canPaid: false,
|
||||
todayFreeArticleCount: 0,
|
||||
paidReason: "暂时无法获取发布权限。",
|
||||
};
|
||||
}
|
||||
|
||||
var status = String(
|
||||
res.data.expertStatus || res.data.expert_status || "",
|
||||
).toLowerCase();
|
||||
var hasExpertIdentity =
|
||||
isTruthy(res.data.is_expert) ||
|
||||
isTruthy(res.data.isExpert) ||
|
||||
isTruthy(res.data.expert) ||
|
||||
isTruthy(res.data.is_regular_expert) ||
|
||||
isTruthy(res.data.isRegularExpert) ||
|
||||
isTruthy(res.data.regularExpert) ||
|
||||
isTruthy(res.data.internExpert) ||
|
||||
isTruthy(res.data.isInternExpert) ||
|
||||
/实习|intern|trial|正式|regular|formal/.test(status);
|
||||
|
||||
if (!hasExpertIdentity) {
|
||||
return { canPaid: false, reason: "专家才能发布付费文章。" };
|
||||
}
|
||||
var permission = parsePublishPermission(res.data);
|
||||
if (!permission.canFree || !permission.isRegularExpert) return permission;
|
||||
|
||||
return loadTodayPublishedFreeCount().then(function (count) {
|
||||
return {
|
||||
canPaid: count >= 2,
|
||||
reason:
|
||||
count >= 2
|
||||
? ""
|
||||
: "今天需先发布2篇审核通过的免费文章后,才能发布付费文章(当前" +
|
||||
count +
|
||||
"篇)。",
|
||||
};
|
||||
permission.todayFreeArticleCount = count;
|
||||
permission.canPaid = count >= REQUIRED_DAILY_FREE_ARTICLES;
|
||||
permission.paidReason = permission.canPaid
|
||||
? ""
|
||||
: "今天需先发布2篇审核通过的免费文章后,才能发布付费文章(当前" +
|
||||
count +
|
||||
"篇)。";
|
||||
return permission;
|
||||
});
|
||||
})
|
||||
.catch(function () {
|
||||
return { canPaid: false, reason: "暂时无法获取发布权限。" };
|
||||
return {
|
||||
hasExpertIdentity: false,
|
||||
isRegularExpert: false,
|
||||
canFree: false,
|
||||
canPaid: false,
|
||||
todayFreeArticleCount: 0,
|
||||
paidReason: "暂时无法获取发布权限。",
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function checkPaidPublishPermission() {
|
||||
return loadPublishPermission().then(function (permission) {
|
||||
publishPermission = permission;
|
||||
return {
|
||||
canPaid: permission.canPaid,
|
||||
reason: permission.paidReason,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function isExpertUser(data) {
|
||||
if (!data) return false;
|
||||
var levelText = CommonUtil.getUserLevelText
|
||||
@@ -504,10 +553,11 @@
|
||||
item.name || item.menuName || item.title || "",
|
||||
).trim();
|
||||
var code = String(item.suoxie || item.code || "").trim();
|
||||
var type = String(item.type || "").toLowerCase();
|
||||
if (["首页", "专家推荐"].indexOf(name) > -1) return false;
|
||||
if (/^(home|index|zhuanjia|expert|expertRecommend)$/i.test(code))
|
||||
return false;
|
||||
return !!(item.id || item.menuId) && !!name;
|
||||
return type === "lottery" && !!(item.id || item.menuId) && !!name;
|
||||
}
|
||||
|
||||
function loadMenuList() {
|
||||
@@ -577,12 +627,12 @@
|
||||
layer.msg("请选择彩种", { icon: 2 });
|
||||
return;
|
||||
}
|
||||
if (title.length < 20) {
|
||||
layer.msg("标题不能少于20字", { icon: 2 });
|
||||
if (title.length < FREE_TITLE_MIN_LENGTH) {
|
||||
layer.msg("免费文章标题需控制在15-30个字之间", { icon: 2 });
|
||||
return;
|
||||
}
|
||||
if (title.length > 100) {
|
||||
layer.msg("标题不能超过100字", { icon: 2 });
|
||||
if (title.length > FREE_TITLE_MAX_LENGTH) {
|
||||
layer.msg("免费文章标题需控制在15-30个字之间", { icon: 2 });
|
||||
return;
|
||||
}
|
||||
if (!content || text.length < 500) {
|
||||
@@ -597,6 +647,9 @@
|
||||
menuId: menuId,
|
||||
title: title,
|
||||
content: content,
|
||||
accountType: 1,
|
||||
}, {
|
||||
headers: CommonUtil.authHeaders(),
|
||||
})
|
||||
.then(function (res) {
|
||||
if (isApiSuccess(res)) {
|
||||
@@ -604,7 +657,7 @@
|
||||
"发布成功,请等待审核",
|
||||
{ icon: 1, time: 1600 },
|
||||
function () {
|
||||
window.location.href = "usercenter.html";
|
||||
window.location.href = "index.html";
|
||||
},
|
||||
);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user