r.bottom)closeSheet();}});
const statusText={new:'未开始',progress:'进行中',pending:'审核中',rejected:'需补充',ready:'可领取',claimed:'已领取'};
const ctaText={new:'查看任务',progress:'查看进度',pending:'查看审核',rejected:'补充内容',ready:'领取奖励',claimed:'查看奖励'};
function taskProgress(task){if(task.id==='invite')return Math.min(state.effective,1);if(task.id==='circle')return Math.min(state.retained,3);return ['ready','claimed'].includes(state.status[task.id])?1:0;}
function render(){
applyTheme();
const ready=tasks.filter(t=>state.status[t.id]==='ready').length;
$('#earned-days').textContent=state.wallet.reduce((sum,c)=>sum+c.days,0);
$('#invited-count').textContent=state.effective;
const unused=state.wallet.filter(c=>!c.activatedAt&&c.expiresAt>Date.now()).length;
$('#wallet-count').textContent=unused;$('#claimable-count').textContent=ready;$('#ready-count').textContent=ready;
document.querySelectorAll('[data-filter]').forEach(button=>{const selected=button.dataset.filter===currentFilter;button.setAttribute('aria-selected',String(selected));button.tabIndex=selected?0:-1;});
$('#task-list').setAttribute('aria-labelledby',`tab-${currentFilter}`);
const visible=tasks.filter(t=>currentFilter==='all'||(currentFilter==='ready'?state.status[t.id]==='ready':['progress','pending','rejected'].includes(state.status[t.id])));
$('#task-list').innerHTML=visible.length?visible.map((task,index)=>{
const status=state.status[task.id], progress=taskProgress(task);
const caption=status==='pending'?'已提交,等待审核':status==='rejected'?'请补充 App 下载入口与说明':status==='claimed'?'奖励已存入卡包':task.caption;
return `${icon(task.icon)}
${task.category} · ${statusText[status]}
${task.title} ${task.description}
${task.days} 天 ${task.plan}
${caption} ${progress}/${task.target}
${ctaText[status]} ${icon(status==='ready'?'ticket':status==='claimed'?'check':'arrow')} `;
}).join(''):`${icon('spark')}
${currentFilter==='ready'?'暂无可领取奖励':'暂无进行中的任务'} ${currentFilter==='ready'?'任务完成并通过验证后,可在此领取。':'在全部任务中查看参与条件。'}
查看全部任务 `;
renderWallet();persist();
}
function dateText(time){return new Date(time).toLocaleDateString('zh-CN',{year:'numeric',month:'numeric',day:'numeric'});}
function dateTimeText(time){return new Date(time).toLocaleString('zh-CN',{year:'numeric',month:'numeric',day:'numeric',hour:'2-digit',minute:'2-digit',hour12:false});}
function renderWallet(){
$('#wallet-total').textContent=String(state.wallet.length).padStart(2,'0');
const active=state.activeUntil>Date.now()?`当前会员体验至 ${dateTimeText(state.activeUntil)}。激活新卡将从此时间顺延。
`:'';
$('#wallet-list').innerHTML=state.wallet.length?active+state.wallet.map(card=>{
const expired=!card.activatedAt&&card.expiresAt<=Date.now();
return `${card.plan} ${card.days} 天体验卡 ${card.days} 天
来自「${tasks.find(t=>t.id===card.taskId)?.title||'推荐任务'}」
${card.activatedAt?`已于 ${dateText(card.activatedAt)} 激活 · 权益已顺延`:expired?'已过激活期限':`请于 ${dateTimeText(card.expiresAt)} 前激活`}
${card.activatedAt||expired?`${expired?'已过期':'已激活'} `:`激活 ${card.days} 天 ${card.plan} ${icon('arrow')} `} `;
}).join(''):`${icon('ticket')}
暂无体验卡 完成推荐任务后即可领取体验卡。 领取后 30 天内激活。
`;
}
function scrollToSection(section){
const heading=$(section==='wallet'?'#wallet-title':'#section-title');
// Same-page navigation: keep both sections visible and move focus after closing the sheet.
lastTrigger=heading;
if(sheet.open)closeSheet();
heading.focus({preventScroll:true});
heading.scrollIntoView({behavior:matchMedia('(prefers-reduced-motion: reduce)').matches?'instant':'smooth',block:'start'});
}
function showTask(id){
const task=tasks.find(t=>t.id===id);if(!task)return;
const status=state.status[id];
if(status==='claimed'){scrollToSection('wallet');return;}
if(status==='ready'){showClaim(id);return;}
const progress=id==='circle'?`已有效邀请 ${state.effective} 人,其中 ${state.retained} / 3 人达成持续活跃。仅展示汇总状态,保护好友隐私。
`:'';
const review=status==='pending'?'内容已提交,预计 2 个工作日内反馈。通过后即可领取;若需补充,会展示具体原因。原型中可在「演示控制台」模拟审核结果。
':status==='rejected'?'需补充:请明确标注 Pixiv-Shaft 名称,补充有效的 App 下载安装入口与活动奖励说明。补充后可重新提交。
':'';
openSheet(`${task.category} · ${task.tag}
${task.title} ${task.days} 天 ${task.plan} 体验卡 完成后领取,30 天内自主激活
${progress}${review}完成条件 ${task.steps.map(s=>`${s} `).join('')} ${task.condition}
${['recommend','tutorial'].includes(id)?status==='pending'?'知道了 ':`${status==='rejected'?'补充并重新提交':'提交内容链接'} ${icon('arrow')} `:`邀请好友 ${icon('arrow')} `}`);
}
function showClaim(id){const task=tasks.find(t=>t.id===id);openSheet(`${icon('check')}
EXPERIENCE PASS
任务已完成 「${task.title}」已完成 可领取 ${task.days} 天 ${task.plan} 体验卡。
${task.days} 天 ${task.plan} ${task.days} 天体验卡 激活后开始计时 · 不自动续费
领取体验卡 ${icon('ticket')} 领取后 30 天内激活,可顺延现有体验权益。
`);}
function claim(id){if(state.status[id]!=='ready')return;const task=tasks.find(t=>t.id===id);state.status[id]='claimed';state.wallet.push({id:`${id}-${Date.now()}`,taskId:id,plan:task.plan,days:task.days,claimedAt:Date.now(),expiresAt:Date.now()+30*DAY,activatedAt:0});render();openSheet(`${icon('ticket')}
REWARD CLAIMED
已存入卡包 ${task.days} 天 ${task.plan} 体验卡已领取。 激活期限:${dateTimeText(state.wallet.at(-1).expiresAt)}
查看卡包 ${icon('arrow')} 返回任务 `);}
function showActivate(id){const card=state.wallet.find(c=>c.id===id);if(!card||card.activatedAt)return;if(card.expiresAt<=Date.now()){render();return toast('这张卡已过激活期限');}const end=Math.max(Date.now(),state.activeUntil)+card.days*DAY;openSheet(`ACTIVATE ${card.plan}
激活 ${card.days} 天 ${card.plan} ${state.activeUntil>Date.now()?'你已有体验权益,新卡会从当前结束时间顺延。':'激活后开始计时。'} 预计体验至 ${dateTimeText(end)}。
本原型只演示权益状态,不会更改真实账号。正式版激活需服务端确认;体验卡不自动续费。
确认激活 ${icon('spark')} 暂不激活 `);}
function activate(id){const card=state.wallet.find(c=>c.id===id);if(!card||card.activatedAt)return;if(card.expiresAt<=Date.now()){closeSheet();render();return toast('这张卡已过激活期限');}card.activatedAt=Date.now();state.activeUntil=Math.max(Date.now(),state.activeUntil)+card.days*DAY;render();openSheet(`${icon('spark')}
已激活 ${card.days} 天 ${card.plan} 体验已激活(演示)。 体验至 ${dateTimeText(state.activeUntil)}。
完成 ${icon('arrow')} `);}
function showInvite(){openSheet(`INVITE A FRIEND
邀请好友使用 Pixiv-Shaft 首次邀请达标后,双方各获 7 天 PRO。 好友需为新用户,无需付费。
${icon('user')}
双方各获 7 天 PRO 新用户在 7 天内使用 2 天,并完成一次收藏
示例邀请码 SHAFT-C7K2
邀请功能暂未开放。以下文案仅供预览,分享不会计入奖励。
复制邀请文案 ${icon('copy')} 查看邀请进度 `);}
async function copy(textValue){try{await navigator.clipboard.writeText(textValue);const old=$('#copy-status');if(old)old.remove();if(sheet.open){const status=document.createElement('p');status.id='copy-status';status.role='status';status.textContent='文案已复制';status.style.cssText='text-align:center;margin-top:12px;color:var(--primary)';$('#sheet-content').append(status);}else toast('文案已复制');}catch{const box=document.createElement('textarea');box.value=textValue;box.readOnly=true;box.setAttribute('aria-label','可手动复制的文案');box.style.cssText='width:100%;min-height:120px;margin-top:18px';(sheet.open?$('#sheet-content'):document.body).append(box);box.select();if(!sheet.open)toast('无法自动复制,请手动选择复制');}}
function showForm(id){const task=tasks.find(t=>t.id===id);const previous=state.submissions[id]||{};openSheet(`${task.category} · ${task.plan} ${task.days} 天
提交推荐内容 请提供公开链接和内容说明。预计 2 个工作日内完成审核。
`);}
document.addEventListener('submit',event=>{if(event.target.id!=='submission-form')return;event.preventDefault();const form=event.target, id=form.dataset.id;let url;try{url=new URL(form.elements.url.value.trim());if(!['https:','http:'].includes(url.protocol)||!url.hostname.includes('.')||url.username||url.password)throw Error();}catch{$('#form-error').textContent='请填写完整、可公开访问的 HTTP 或 HTTPS 推广链接。';return;}const description=form.elements.description.value.trim();if(description.length<20){$('#form-error').textContent='请至少填写 20 字内容介绍。';return;}state.submissions[id]={url:url.href,description,submittedAt:Date.now()};state.status[id]='pending';render();openSheet(`${icon('check')}
已提交 预计 2 个工作日内反馈,审核通过后即可领取。 原型可在页尾「演示控制台」模拟审核。
返回任务中心 `);});
function showRules(){openSheet(`PROGRAM RULES
活动规则 以下为提议的运营规则,供设计评审确认;原型中的数据和权益均为演示。
体验时长 所有任务奖励均为 7 × 24 小时,按任务发放 PRO 或 MAX 体验卡。卡片领取后 30 天内激活;过期不自动激活。已激活卡不可转赠。领取次数 首位好友安装并完成有效体验,奖励 7 天 PRO;App 推荐帖奖励 7 天 PRO;3 位好友持续活跃奖励 7 天 MAX;App 上手教程奖励 7 天 MAX。本期邀请人最多获 28 天;每位受邀新用户另获一次 7 天 PRO。首位好友可计入持续活跃任务,同一份 App 推荐内容不可重复提交。有效邀请条件 新用户安装 App、登录并主动确认绑定唯一邀请人;7 天内在两个不同自然日使用核心功能,且至少收藏一次。持续活跃任务还需前 14 天内活跃 3 天,其中 1 天在第 8–14 天。领取与激活 任务达标后卡片进入可领取状态。激活时顺延已有同档会员权益,不覆盖已付费天数;更高档会员须待可用时激活,细则正式接入时确认。不自动续费。审核与补充 内容任务预计 2 个工作日内反馈;展示未通过原因并支持重新提交。无需购买、不要求好评、不以点赞数判定。推荐内容需明确介绍 Pixiv-Shaft,并附有效的官方下载安装入口或专属邀请入口。公平参与 禁止自邀、批量账号、重复内容与骚扰式发布。异常邀请人工复核并提供申诉入口,不仅凭共享网络拒绝。活动规则调整只影响后续参与,不追溯已达成的合法奖励。了解了 `);}
function showMaterials(){openSheet(`SHARE PIXIV-SHAFT
推荐内容参考 可参考以下结构,结合自己的使用体验撰写。发布时需附下载入口,并注明活动奖励。
01 / App 推荐帖 介绍一个用过的功能,附 App 截图、下载入口和活动说明。
复制推荐帖提纲 ${icon('copy')} 查看推荐帖任务 ${icon('arrow')} 02 / 使用教程 说明下载安装步骤,演示至少一项核心功能的操作过程。
查看 App 教程任务 ${icon('arrow')} 03 / 好友邀请 介绍 App 用途,附邀请入口与使用要求。
邀请好友 ${icon('arrow')} `);}
function showDemo(){openSheet(`PROTOTYPE CONTROLS
演示控制台 仅改变本浏览器的示例数据,用于评审完整流程。不会发出邀请、提交审核或发放真实会员权益。
有效邀请 ${state.effective} 人新好友达到首次体验条件
增加 1 人 持续活跃 ${state.retained} / 3 人不得超过有效邀请人数
=Math.min(state.effective,3)?'disabled':''}>达标 1 人 ${tasks.filter(t=>['recommend','tutorial'].includes(t.id)).map(t=>`${t.title}${statusText[state.status[t.id]]}
通过 需补充
`).join('')}重置全部演示数据 `);}
document.addEventListener('click',event=>{
const button=event.target.closest('button');if(!button||button.disabled)return;const d=button.dataset;
if(d.scroll){scrollToSection(d.scroll);return;}
if(d.filter){currentFilter=d.filter;render();document.querySelector(`[role="tab"][data-filter="${currentFilter}"]`)?.focus();return;}
if(d.task){showTask(d.task);return;}if(d.claim){claim(d.claim);return;}if(d.activate){showActivate(d.activate);return;}if(d.confirmActivate){activate(d.confirmActivate);return;}if(d.submitForm){showForm(d.submitForm);return;}
if(d.sim){if(d.sim==='invite'){state.effective++;if(state.status.invite!=='claimed')state.status.invite='ready';}else if(state.retained=3&&state.status.circle!=='claimed')state.status.circle='ready';}render();showDemo();return;}
if(d.review){const [id,status]=d.review.split(':');if(state.status[id]==='pending')state.status[id]=status;render();showDemo();return;}
switch(d.action){
case 'close':closeSheet();break;
case 'theme':state.theme=state.theme==='light'?'dark':'light';applyTheme();persist();break;
case 'palette':state.accent=['violet','rose','teal'][(['violet','rose','teal'].indexOf(state.accent)+1)%3];applyTheme();persist();toast('已切换主题配色');break;
case 'rules':showRules();break;
case 'invite':showInvite();break;
case 'copy-invite':copy('Pixiv-Shaft 支持浏览插画、管理收藏。首次通过邀请完成使用要求,双方可各获 7 天 PRO。\n[示例文案,邀请活动暂未开放。]');break;
case 'invite-progress':openSheet(`INVITATION STATUS
邀请进度 ${state.effective} 人完成有效体验,${state.retained} 人达成持续活跃。 系统仅展示汇总进度,不公开好友的使用明细。
首次有效邀请:${Math.min(state.effective,1)} / 1 3 位好友持续活跃:${state.retained} / 3 邀请进度由服务端验证;本页为演示数据。
继续邀请 ${icon('arrow')} `);break;
case 'materials':showMaterials();break;
case 'copy-promo':copy('Pixiv-Shaft 使用体验\n功能:[介绍实际使用过的功能]\n体验:[优点、不足和适用场景]\n截图:[添加 App 功能截图]\n下载:[填写官方下载或邀请入口]\n活动说明:参与 App 推荐计划,内容审核通过可获得 PRO 体验卡。\n[请补全后发布。当前活动尚未开放。]');break;
case 'demo':showDemo();break;
case 'reset-confirm':openSheet('RESET DEMO
重置演示数据? 清空本浏览器的演示推广记录、体验卡与激活记录,恢复初始示例任务。
重置演示 保留当前进度 ');break;
case 'reset':{const {theme,accent}=state;state={...freshState(),theme,accent};currentFilter='all';render();closeSheet();toast('已恢复初始演示数据');break;}
}
});
$('.tabs').addEventListener('keydown',event=>{if(!['ArrowLeft','ArrowRight','Home','End'].includes(event.key))return;event.preventDefault();const filters=['all','progress','ready'];let i=filters.indexOf(currentFilter);i=event.key==='Home'?0:event.key==='End'?2:(i+(event.key==='ArrowRight'?1:2))%3;currentFilter=filters[i];render();$(`#tab-${currentFilter}`).focus();});
document.addEventListener('visibilitychange',()=>{if(!document.hidden)render();});
render();