样式修改完成,待测试

This commit is contained in:
rain
2026-07-07 17:07:34 +08:00
parent 0f6ed0cad3
commit 8a6a8acab7
32 changed files with 2097 additions and 505 deletions
+16 -2
View File
@@ -768,6 +768,19 @@ const ApiClient = {
const params = this.normalizePageParams(data || {});
const code = params.code || params.suoxie || params.lotteryCode || '';
const pageSize = params.pageSize || params.limit || params.count || 100;
const normalizeResponse = (res) => {
if (!this.isSuccess(res)) return res;
const payload = this.pickData(res, {});
const list = this.asArray(payload);
return Object.assign({}, res, {
code: 0,
success: true,
data: list,
rawData: payload,
rows: list,
records: list,
});
};
if (code && this.API.lotteryTrend) {
try {
const trendRes = await this.get(this.API.lotteryTrend, {
@@ -775,13 +788,14 @@ const ApiClient = {
pageSize,
});
if (this.isSuccess(trendRes) && this.asArray(this.pickData(trendRes, [])).length) {
return trendRes;
return normalizeResponse(trendRes);
}
} catch (e) {
// Fall back to the older result-list endpoint below.
}
}
return this.requestWithMenu('/api/web/lottery/result/list', data);
const listRes = await this.requestWithMenu('/api/web/lottery/result/list', data);
return normalizeResponse(listRes);
},
async loadLegacyExpertDetailCompat(data = {}) {
+333 -2
View File
@@ -3,6 +3,109 @@ const AuthPageUtil = {
slideUuid: '',
slideX: 0,
slideToken: '',
slideCaptchaViewportCleanup: null,
referralInviteSessionKey: 'pendingReferralInviteCode',
getSessionStorage() {
if (typeof sessionStorage !== 'undefined') return sessionStorage;
if (typeof window !== 'undefined' && window.sessionStorage) return window.sessionStorage;
return null;
},
normalizeReferralInviteCode(inviteCode) {
return String(inviteCode || '').trim();
},
getReferralInviteCodeFromUrl(search) {
const query =
search != null
? search
: (typeof window !== 'undefined' && window.location && window.location.search) || '';
const Params =
typeof URLSearchParams !== 'undefined'
? URLSearchParams
: typeof window !== 'undefined' && window.URLSearchParams;
if (!Params) return '';
try {
const params = new Params(query || '');
return this.normalizeReferralInviteCode(
params.get('inviteCode') || params.get('referralCode') || '',
);
} catch (error) {
return '';
}
},
setPendingReferralInviteCode(inviteCode) {
const code = this.normalizeReferralInviteCode(inviteCode);
const storage = this.getSessionStorage();
if (code && storage) {
storage.setItem(this.referralInviteSessionKey, code);
}
return code;
},
getPendingReferralInviteCode() {
const storage = this.getSessionStorage();
if (!storage) return '';
return this.normalizeReferralInviteCode(storage.getItem(this.referralInviteSessionKey));
},
clearPendingReferralInviteCode() {
const storage = this.getSessionStorage();
if (storage) storage.removeItem(this.referralInviteSessionKey);
},
captureReferralInviteFromUrl(search) {
const code = this.getReferralInviteCodeFromUrl(search);
if (code) {
this.setPendingReferralInviteCode(code);
}
return code;
},
bindPendingReferralInviteCode() {
const inviteCode = this.getPendingReferralInviteCode();
if (!inviteCode) {
return Promise.resolve({ skipped: true, reason: 'empty' });
}
if (
typeof ApiClient === 'undefined' ||
!ApiClient.API ||
!ApiClient.API.referralBind ||
typeof ApiClient.post !== 'function'
) {
return Promise.resolve({ skipped: true, reason: 'missing-api' });
}
if (typeof ApiClient.token === 'function' && !ApiClient.token()) {
return Promise.resolve({ skipped: true, reason: 'unauthenticated' });
}
return ApiClient.post(ApiClient.API.referralBind, { inviteCode })
.then((res) => {
const isSuccess =
typeof ApiClient.isSuccess === 'function'
? ApiClient.isSuccess(res)
: !!(res && (res.success === true || Number(res.code) === 0 || Number(res.code) === 200));
if (isSuccess) {
this.clearPendingReferralInviteCode();
return { skipped: false, success: true, res };
}
return { skipped: false, success: false, res };
})
.catch((error) => ({ skipped: false, success: false, error }));
},
isPhone(phone) {
return /^1[3-9]\d{9}$/.test(String(phone || '').trim());
@@ -122,6 +225,234 @@ const AuthPageUtil = {
}
},
blurActiveElement() {
if (typeof document === 'undefined') return;
const activeElement = document.activeElement;
if (activeElement && activeElement !== document.body && typeof activeElement.blur === 'function') {
activeElement.blur();
}
},
ensureSlideCaptchaMobileCenterStyle() {
if (typeof document === 'undefined' || document.getElementById('auth-slide-captcha-mobile-center-style')) {
return;
}
const style = document.createElement('style');
style.id = 'auth-slide-captcha-mobile-center-style';
style.textContent = `
@media (max-width: 640px) {
#rvplus-slide-captcha-root.rvplus-slide-mask {
box-sizing: border-box !important;
align-items: center !important;
justify-content: center !important;
width: 100vw;
max-width: 100vw;
min-height: 100vh;
min-height: 100dvh;
padding: 12px !important;
}
#rvplus-slide-captcha-root .rvplus-slide-modal {
box-sizing: border-box;
max-width: calc(100vw - 24px);
max-height: calc(100vh - 24px);
max-height: calc(100dvh - 24px);
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
}
`;
document.head.appendChild(style);
},
getSlideCaptchaViewport() {
const fallbackWidth =
(typeof window !== 'undefined' && window.innerWidth) ||
(typeof document !== 'undefined' && document.documentElement && document.documentElement.clientWidth) ||
0;
const fallbackHeight =
(typeof window !== 'undefined' && window.innerHeight) ||
(typeof document !== 'undefined' && document.documentElement && document.documentElement.clientHeight) ||
0;
const viewport = typeof window !== 'undefined' ? window.visualViewport : null;
const screenWidth = (typeof window !== 'undefined' && window.screen && window.screen.width) || 0;
const screenHeight = (typeof window !== 'undefined' && window.screen && window.screen.height) || 0;
const width = Math.round((viewport && viewport.width) || fallbackWidth);
const height = Math.round((viewport && viewport.height) || fallbackHeight);
let scale = Number(viewport && viewport.scale) || 1;
if (screenWidth && screenWidth <= 640 && width > screenWidth && scale === 1) {
scale = screenWidth / width;
}
return {
width,
height,
offsetLeft: Math.round((viewport && viewport.offsetLeft) || 0),
offsetTop: Math.round((viewport && viewport.offsetTop) || 0),
scale,
displayWidth: Math.round(width * scale),
displayHeight: Math.round(height * scale),
screenWidth,
screenHeight,
};
},
isCompactSlideCaptchaViewport(viewport) {
return viewport.displayWidth <= 640 || (viewport.screenWidth > 0 && viewport.screenWidth <= 640);
},
centerSlideCaptchaDialog() {
if (typeof document === 'undefined') return false;
const root = document.getElementById('rvplus-slide-captcha-root');
if (!root) return false;
const viewport = this.getSlideCaptchaViewport();
if (!viewport.width || !viewport.height) return true;
const compact = this.isCompactSlideCaptchaViewport(viewport);
const visualPadding = compact ? 12 : 20;
const padding = visualPadding / (viewport.scale || 1);
const modalWidth = Math.max(0, Math.round(viewport.width - padding * 2));
const modalHeight = Math.max(0, Math.round(viewport.height - padding * 2));
root.style.position = 'fixed';
root.style.inset = 'auto';
root.style.left = viewport.offsetLeft + 'px';
root.style.top = viewport.offsetTop + 'px';
root.style.width = viewport.width + 'px';
root.style.height = viewport.height + 'px';
root.style.display = 'flex';
root.style.alignItems = 'center';
root.style.justifyContent = 'center';
root.style.boxSizing = 'border-box';
root.style.padding = padding + 'px';
const modal = root.querySelector && root.querySelector('.rvplus-slide-modal');
if (modal) {
modal.style.boxSizing = 'border-box';
modal.style.maxWidth = modalWidth + 'px';
modal.style.maxHeight = modalHeight + 'px';
modal.style.overflowY = 'auto';
modal.style.webkitOverflowScrolling = 'touch';
modal.style.width = compact ? modalWidth + 'px' : '';
}
return true;
},
clearSlideCaptchaViewportCentering() {
if (typeof this.slideCaptchaViewportCleanup !== 'function') return;
const cleanup = this.slideCaptchaViewportCleanup;
this.slideCaptchaViewportCleanup = null;
cleanup();
},
scheduleSlideCaptchaCentering(callback) {
if (typeof window !== 'undefined' && typeof window.requestAnimationFrame === 'function') {
window.requestAnimationFrame(callback);
return;
}
callback();
},
bindSlideCaptchaViewportCentering() {
if (typeof window === 'undefined') return;
this.clearSlideCaptchaViewportCentering();
const cleanups = [];
const recenter = () => {
if (!this.centerSlideCaptchaDialog()) {
this.clearSlideCaptchaViewportCentering();
}
};
const schedule = () => this.scheduleSlideCaptchaCentering(recenter);
const addListener = (target, type) => {
if (target && typeof target.addEventListener === 'function') {
target.addEventListener(type, schedule);
cleanups.push(() => target.removeEventListener(type, schedule));
}
};
addListener(window.visualViewport, 'resize');
addListener(window.visualViewport, 'scroll');
addListener(window, 'resize');
addListener(window, 'orientationchange');
this.slideCaptchaViewportCleanup = () => {
cleanups.forEach((cleanup) => cleanup());
};
schedule();
if (typeof window.setTimeout === 'function') {
window.setTimeout(schedule, 80);
window.setTimeout(schedule, 260);
}
},
deferClearSlideCaptchaViewportCentering() {
const clear = () => this.clearSlideCaptchaViewportCentering();
if (typeof window !== 'undefined' && typeof window.setTimeout === 'function') {
window.setTimeout(clear, 320);
return;
}
clear();
},
wrapSlideCaptchaCallbacks(options = {}) {
const wrapped = { ...options };
const wrap = (callback) => (...args) => {
try {
if (typeof callback === 'function') {
return callback(...args);
}
} finally {
this.deferClearSlideCaptchaViewportCentering();
}
return undefined;
};
wrapped.onSuccess = wrap(options.onSuccess);
wrapped.onCancel = wrap(options.onCancel);
return wrapped;
},
patchSlideCaptchaMobileCentering(SlideCaptcha) {
if (!SlideCaptcha || SlideCaptcha.__authPageMobileCentered || typeof SlideCaptcha.open !== 'function') {
return SlideCaptcha;
}
const nativeOpen = SlideCaptcha.open.bind(SlideCaptcha);
const nativeClose = typeof SlideCaptcha.close === 'function' ? SlideCaptcha.close.bind(SlideCaptcha) : null;
SlideCaptcha.open = (options = {}) => {
this.blurActiveElement();
this.ensureSlideCaptchaMobileCenterStyle();
const result = nativeOpen(this.wrapSlideCaptchaCallbacks(options));
this.bindSlideCaptchaViewportCentering();
return result;
};
if (nativeClose) {
SlideCaptcha.close = (...args) => {
this.clearSlideCaptchaViewportCentering();
return nativeClose(...args);
};
}
SlideCaptcha.__authPageMobileCentered = true;
return SlideCaptcha;
},
startSmsCountdown(buttonSelector, seconds = 60) {
const $button = layui.$(buttonSelector);
let left = seconds;
@@ -140,7 +471,7 @@ const AuthPageUtil = {
loadSlideCaptchaScript() {
this.installSlideCaptchaTenantHeader();
if (window.SlideCaptcha) return Promise.resolve(window.SlideCaptcha);
if (window.SlideCaptcha) return Promise.resolve(this.patchSlideCaptchaMobileCentering(window.SlideCaptcha));
if (window.__slideCaptchaLoading) return window.__slideCaptchaLoading;
window.__slideCaptchaLoading = new Promise((resolve, reject) => {
const script = document.createElement('script');
@@ -148,7 +479,7 @@ const AuthPageUtil = {
script.dataset.apiBase = ApiClient.baseUrl || '';
script.dataset.tenantId = ApiClient.tenantId || '936208';
script.onload = () => {
if (window.SlideCaptcha) resolve(window.SlideCaptcha);
if (window.SlideCaptcha) resolve(this.patchSlideCaptchaMobileCentering(window.SlideCaptcha));
else reject(new Error('滑动验证组件加载失败'));
};
script.onerror = () => reject(new Error('滑动验证组件加载失败'));
+113
View File
@@ -148,6 +148,70 @@ const CommonUtil = {
return '会员';
},
getExpertState(user = {}) {
const truthy = (value) =>
value === true ||
value === 1 ||
value === '1' ||
String(value).toLowerCase() === 'true';
const firstPresent = (...values) => {
for (const value of values) {
if (value !== undefined && value !== null && value !== '') return value;
}
return '';
};
const statusText = String(
firstPresent(
user.expertStatus,
user.expert_status,
user.expertApplyStatus,
user.expert_apply_status,
user.applyStatus,
user.apply_status,
user.auditStatus,
user.audit_status,
user.expertAuditStatus,
user.expert_audit_status
)
).toLowerCase();
const isExpert =
truthy(user.regularExpert) ||
truthy(user.isRegularExpert) ||
truthy(user.is_regular_expert) ||
truthy(user.formalExpert) ||
truthy(user.isFormalExpert) ||
truthy(user.internExpert) ||
truthy(user.isInternExpert) ||
truthy(user.is_intern_expert) ||
truthy(user.trialExpert) ||
truthy(user.isTrialExpert) ||
truthy(user.is_expert) ||
truthy(user.isExpert) ||
truthy(user.expert) ||
/实习|正式|intern|trial|regular|formal|expert/.test(statusText);
const isApplying =
!isExpert &&
([
'0',
'pending',
'reviewing',
'review',
'audit',
'auditing',
'apply',
'applying',
'submitted',
'wait',
'waiting',
].includes(statusText) ||
/审核|待审|申请中|pending|review|audit|applying|waiting/.test(statusText));
return {
isExpert,
isApplying,
status: statusText,
};
},
getUserLevelTextLegacy(user = {}) {
if (user.regularExpert || user.isExpert === '1' || user.expertStatus === 'regular') {
return '正式专家';
@@ -1752,6 +1816,55 @@ const CommonUtil = {
$tempContainer.remove();
},
renderTrendOpenCode(openCode, options = {}) {
const value = String(openCode === undefined || openCode === null ? '' : openCode).trim();
if (!value) return '<span class="trend-open-empty">--</span>';
const mode = options.mode || 'red';
const splitTokens = (text) =>
String(text || '')
.split(/[,\s、,]+/)
.map((item) => item.trim())
.filter(Boolean);
const splitDigits = (text) => {
const tokens = splitTokens(text);
if (tokens.length > 1) return tokens;
return String(text || '')
.replace(/[^\d]/g, '')
.split('')
.filter(Boolean);
};
const pad = (num, shouldPad = true) => (shouldPad && /^\d$/.test(num) ? `0${num}` : num);
const renderNum = (num, className, shouldPad = true) =>
`<span class="trend-open-number ${className}">${this.escapeHtml(pad(String(num), shouldPad))}</span>`;
const renderGroup = (list, className, shouldPad = true) =>
list.map((num) => renderNum(num, className, shouldPad)).join('');
const renderPlus = () => '<span class="trend-open-separator">+</span>';
const parts = value.split('+');
let body = '';
if (mode === 'ssq' || mode === 'dlt' || mode === 'qlc') {
const front = splitTokens(parts[0]);
let back = parts.slice(1).flatMap(splitTokens);
const frontLimit = mode === 'ssq' ? 6 : mode === 'dlt' ? 5 : 7;
if (!back.length && front.length > frontLimit) back = front.splice(frontLimit);
body = renderGroup(front, 'trend-open-red');
if (back.length) body += renderPlus() + renderGroup(back, 'trend-open-blue');
} else if (mode === 'qxc') {
const nums = splitDigits(value);
const front = nums.slice(0, 6);
const back = nums.slice(6);
body = renderGroup(front, 'trend-open-red', false);
if (back.length) body += renderPlus() + renderGroup(back, 'trend-open-blue', false);
} else if (mode === 'position') {
body = renderGroup(splitDigits(value), 'trend-open-red', false);
} else {
body = renderGroup(splitTokens(value), 'trend-open-red');
}
return `<span class="trend-open-code">${body || this.escapeHtml(value)}</span>`;
},
sanitizeHTML(html) {
if (!html) return '';
const parser = new DOMParser();
+139
View File
@@ -0,0 +1,139 @@
(function (global) {
var DEFAULT_REQUIRED_DAILY_FREE_ARTICLES = 2;
function isTruthy(value) {
return (
value === true ||
value === 1 ||
value === '1' ||
String(value).toLowerCase() === 'true'
);
}
function firstDefined(source, keys) {
if (!source || typeof source !== 'object') return undefined;
for (var i = 0; i < keys.length; i += 1) {
var key = keys[i];
if (
Object.prototype.hasOwnProperty.call(source, key) &&
source[key] !== undefined &&
source[key] !== null
) {
return source[key];
}
}
return undefined;
}
function toNumber(value, fallback) {
var numberValue = Number(value);
return Number.isFinite(numberValue) ? numberValue : fallback;
}
function buildQuotaReason(todayCount, requiredCount) {
return (
'今天需先发布' +
requiredCount +
'篇审核通过的免费文章后,才能发布付费文章(当前' +
todayCount +
'篇)'
);
}
function parseSummary(userData, options) {
var data = userData && typeof userData === 'object' ? userData : {};
var config = options || {};
var status = String(
firstDefined(data, ['expertStatus', 'expert_status']) || ''
).toLowerCase();
var isIntern = /实习|intern|trial/.test(status);
var isRegularByStatus = /正式|regular|formal/.test(status);
var isRegularExpert =
isTruthy(
firstDefined(data, [
'is_regular_expert',
'isRegularExpert',
'regularExpert',
])
) || isRegularByStatus;
var hasExpertIdentity =
isTruthy(firstDefined(data, ['is_expert', 'isExpert', 'expert'])) ||
isTruthy(
firstDefined(data, [
'is_regular_expert',
'isRegularExpert',
'regularExpert',
])
) ||
isIntern ||
isRegularByStatus;
var requiredCount = toNumber(
firstDefined(data, [
'requiredDailyApprovedFreeArticleCount',
'required_daily_approved_free_article_count',
]),
config.requiredDailyFreeArticleCount || DEFAULT_REQUIRED_DAILY_FREE_ARTICLES
);
var todayCount = toNumber(
firstDefined(data, [
'todayApprovedFreeArticleCount',
'today_approved_free_article_count',
]),
0
);
var quotaExemptRaw = firstDefined(data, [
'payArticleFreeQuotaExempt',
'pay_article_free_quota_exempt',
]);
var canPublishRaw = firstDefined(data, [
'canPublishPayArticle',
'can_publish_pay_article',
]);
var backendReason = String(
firstDefined(data, [
'payArticlePublishReason',
'pay_article_publish_reason',
]) || ''
);
var quotaExempt = isTruthy(quotaExemptRaw);
var hasBackendPaidDecision = canPublishRaw !== undefined;
var canPaid = false;
var paidReason = '';
if (quotaExempt) {
canPaid = true;
} else if (hasBackendPaidDecision) {
canPaid = isTruthy(canPublishRaw);
paidReason = canPaid
? ''
: backendReason ||
(!hasExpertIdentity || !isRegularExpert
? '正式专家才能发布付费文章'
: buildQuotaReason(todayCount, requiredCount));
} else if (!hasExpertIdentity || !isRegularExpert) {
paidReason = '正式专家才能发布付费文章';
} else {
canPaid = todayCount >= requiredCount;
paidReason = canPaid ? '' : buildQuotaReason(todayCount, requiredCount);
}
return {
hasExpertIdentity: hasExpertIdentity,
isRegularExpert: hasExpertIdentity && isRegularExpert,
canFree: hasExpertIdentity,
canPaid: canPaid,
quotaExempt: quotaExempt,
todayFreeArticleCount: todayCount,
requiredDailyFreeArticleCount: requiredCount,
paidReason: paidReason,
reason: paidReason,
};
}
global.PublishPermission = {
isTruthy: isTruthy,
parseSummary: parseSummary,
};
})(typeof window !== 'undefined' ? window : globalThis);