feat(user-center): task list go-to actions for free points
Add per-task CTAs (去签到 / 去完成 / 去看看) on the free points tasks list, with sign-in proxying to the asset-card button and bbs actions gated on forum availability.
This commit is contained in:
@@ -965,4 +965,24 @@ body.uc-modal-open {
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
.uc-points-tasks__meta {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 2px;
|
||||
}
|
||||
.uc-points-tasks__action {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
text-decoration: none;
|
||||
color: var(--muted-color, #8b9198);
|
||||
background: none;
|
||||
border: 0;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.uc-points-tasks__action:hover {
|
||||
color: var(--focus-color, #f04494);
|
||||
}
|
||||
.focus-color { color: var(--focus-color, #f59e0b); }
|
||||
|
||||
@@ -180,6 +180,28 @@
|
||||
refresh();
|
||||
}
|
||||
|
||||
// Task-list "去签到" → scroll + click the real asset-card sign-in button.
|
||||
function initSigninGoto() {
|
||||
document.querySelectorAll('[data-aksrt-signin-goto]').forEach(function (el) {
|
||||
el.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
var root = document.querySelector('[data-aksrt-signin]');
|
||||
var btn = root ? root.querySelector('[data-signin-btn]') : null;
|
||||
if (!btn) return;
|
||||
try {
|
||||
if (root && typeof root.scrollIntoView === 'function') {
|
||||
root.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
} catch (_) {}
|
||||
if (!btn.disabled) {
|
||||
btn.click();
|
||||
} else {
|
||||
btn.focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ===== 邀请 =====
|
||||
function initInvite() {
|
||||
var root = document.querySelector('[data-aksrt-invite]');
|
||||
@@ -944,6 +966,7 @@
|
||||
|
||||
function bootAssets() {
|
||||
initSignin();
|
||||
initSigninGoto();
|
||||
initInvite();
|
||||
initVipShop();
|
||||
initVipPointsExchange();
|
||||
|
||||
@@ -11,6 +11,94 @@ if (!class_exists('AKSRT_Points_Free') || !AKSRT_Points_Free::enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a "go complete" action for a free-points task row.
|
||||
*
|
||||
* @return array{type:string,label:string,href?:string}
|
||||
*/
|
||||
$aksrt_points_task_action = static function (string $key): array {
|
||||
$home = home_url('/');
|
||||
$submit = '';
|
||||
if (function_exists('aksrt_get_page_url_by_template')) {
|
||||
$submit = (string) aksrt_get_page_url_by_template('templates/pages/page-submit.php');
|
||||
}
|
||||
|
||||
$forum_on = false;
|
||||
$forum_home = '';
|
||||
$forum_compose = '';
|
||||
if (class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'get_forum_settings')) {
|
||||
$f = AKSRT_Settings::get_forum_settings();
|
||||
$forum_on = !empty($f['enabled']);
|
||||
}
|
||||
if ($forum_on) {
|
||||
if (function_exists('aksrt_get_forum_home_url')) {
|
||||
$forum_home = (string) aksrt_get_forum_home_url();
|
||||
}
|
||||
if (function_exists('aksrt_get_forum_compose_url')) {
|
||||
$forum_compose = (string) aksrt_get_forum_compose_url();
|
||||
}
|
||||
}
|
||||
|
||||
switch ($key) {
|
||||
case 'sign_in':
|
||||
return [
|
||||
'type' => 'signin',
|
||||
'label' => __('去签到', 'aksrt'),
|
||||
];
|
||||
case 'post_new':
|
||||
return [
|
||||
'type' => 'link',
|
||||
'label' => __('去完成', 'aksrt'),
|
||||
'href' => $submit !== '' ? $submit : $home,
|
||||
];
|
||||
case 'comment_new':
|
||||
return [
|
||||
'type' => 'link',
|
||||
'label' => __('去完成', 'aksrt'),
|
||||
'href' => $home,
|
||||
];
|
||||
case 'login':
|
||||
case 'post_like':
|
||||
case 'post_favorite':
|
||||
case 'followed':
|
||||
case 'comment_like':
|
||||
return [
|
||||
'type' => 'link',
|
||||
'label' => __('去看看', 'aksrt'),
|
||||
'href' => $home,
|
||||
];
|
||||
case 'bbs_posts_new':
|
||||
case 'bbs_reply':
|
||||
if (!$forum_on) {
|
||||
return ['type' => 'none', 'label' => ''];
|
||||
}
|
||||
$href = $forum_compose !== '' ? $forum_compose : $forum_home;
|
||||
if ($href === '') {
|
||||
return ['type' => 'none', 'label' => ''];
|
||||
}
|
||||
return [
|
||||
'type' => 'link',
|
||||
'label' => __('去完成', 'aksrt'),
|
||||
'href' => $href,
|
||||
];
|
||||
case 'bbs_essence':
|
||||
case 'bbs_adopt':
|
||||
case 'bbs_posts_hot':
|
||||
case 'bbs_comment_hot':
|
||||
case 'bbs_score_extra':
|
||||
if (!$forum_on || $forum_home === '') {
|
||||
return ['type' => 'none', 'label' => ''];
|
||||
}
|
||||
return [
|
||||
'type' => 'link',
|
||||
'label' => __('去看看', 'aksrt'),
|
||||
'href' => $forum_home,
|
||||
];
|
||||
default:
|
||||
return ['type' => 'none', 'label' => ''];
|
||||
}
|
||||
};
|
||||
|
||||
$user_id = (int) ($user_id ?? get_current_user_id());
|
||||
$today = AKSRT_Points_Free::today_total($user_id);
|
||||
$day_max = (int) AKSRT_Points_Free::settings()['day_max'];
|
||||
@@ -76,15 +164,30 @@ $pane = isset($points_tasks_pane) ? sanitize_key((string) $points_tasks_pane)
|
||||
|
||||
<?php if ($tasks) : ?>
|
||||
<?php foreach ($tasks as $task) : ?>
|
||||
<div class="border-bottom padding-h10">
|
||||
<?php
|
||||
$task_key = sanitize_key((string) ($task['key'] ?? ''));
|
||||
$action = $aksrt_points_task_action($task_key);
|
||||
?>
|
||||
<div class="border-bottom padding-h10 uc-points-tasks__row" data-task-key="<?php echo esc_attr($task_key); ?>">
|
||||
<div class="flex jsb ac">
|
||||
<div class="flex1 mr20">
|
||||
<div class="font-bold mb6"><?php echo esc_html((string) $task['title']); ?></div>
|
||||
<div class="muted-2-color em09"><?php echo esc_html((string) $task['desc']); ?></div>
|
||||
</div>
|
||||
<span class="focus-color em14 shrink0">
|
||||
<i class="fas fa-coins mr6 em09" aria-hidden="true"></i>+ <?php echo esc_html((string) (int) $task['points']); ?>
|
||||
</span>
|
||||
<div class="uc-points-tasks__meta shrink0 text-right">
|
||||
<div class="focus-color em14">
|
||||
<i class="fas fa-coins mr6 em09" aria-hidden="true"></i>+ <?php echo esc_html((string) (int) $task['points']); ?>
|
||||
</div>
|
||||
<?php if (($action['type'] ?? 'none') === 'signin') : ?>
|
||||
<button type="button" class="uc-points-tasks__action muted-color em09 mt6" data-aksrt-signin-goto>
|
||||
<?php echo esc_html((string) $action['label']); ?><i class="fa fa-angle-right em12 ml3" aria-hidden="true"></i>
|
||||
</button>
|
||||
<?php elseif (($action['type'] ?? 'none') === 'link' && !empty($action['href'])) : ?>
|
||||
<a class="uc-points-tasks__action muted-color em09 mt6" href="<?php echo esc_url((string) $action['href']); ?>">
|
||||
<?php echo esc_html((string) $action['label']); ?><i class="fa fa-angle-right em12 ml3" aria-hidden="true"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
Reference in New Issue
Block a user