下单页:撕凭证改为亲手撕;失败单能重渲没出图的模板;确认收货后不能再免费重渲

Browse Source
- 撕凭证:按住存根往外拉,拉够才撕下(没拉够弹回);撕下那一刻才发确认收货,
  关弹窗 / 先不收货 = 没发生。留「直接撕下」按钮和回车键兜底。
- 重渲弹窗:把应出未出的模板列成「没出图」项(miss_tpls),失败单不再卡在「至少勾一张」;
  什么信息都没有的老失败单直接整单重渲。服务器只认本单模板。
- 确认收货后:前端不再给免费重渲按钮,/api/redo 同样拒(直发单不受影响)。
- 状态接口给 files[].tpl、direct、accepted_by_buyer。
- 测试 +4(回执复现 33 条全过;数据库 38、内容后台 86 全过);浏览器实测 24 项全过。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
yws
2026-10-07 02:59:48 +00:00
co-authored by Claude Opus 5.5
parent bc8402ca67
commit 675e096675
3 changed files with 168 additions and 32 deletions
+121 -29
View File
@@ -295,6 +295,13 @@ body[data-step="5"] .prog i:nth-child(-n+4){background:var(--acc)}
@keyframes stampIn{from{opacity:0;transform:translateY(4px) scale(.96)}to{opacity:.9;transform:none}} @keyframes stampIn{from{opacity:0;transform:translateY(4px) scale(.96)}to{opacity:.9;transform:none}}
.tear-stamp{opacity:0;font-size:11.5px;color:var(--warn,#e8b23a);letter-spacing:.06em;margin-top:8px} .tear-stamp{opacity:0;font-size:11.5px;color:var(--warn,#e8b23a);letter-spacing:.06em;margin-top:8px}
.tearwrap.torn ~ .tear-stamp{animation:stampIn .5s .95s var(--ease-out) both} .tearwrap.torn ~ .tear-stamp{animation:stampIn .5s .95s var(--ease-out) both}
/* 2026-10-07:存根改成买家亲手撕 —— 能抓、能拖,拉的过程中撕线跟着变亮 */
.tear-grab{position:relative;z-index:2;cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none;
box-shadow:0 0 0 1px rgba(232,178,58,.25) inset}
.tear-grab:hover{border-color:rgba(232,178,58,.55)}
.tear-grab.grabbing{cursor:grabbing;box-shadow:0 10px 26px rgba(0,0,0,.28),0 0 0 1px rgba(232,178,58,.45) inset}
.tear-grab:focus-visible{outline:2px solid var(--acc);outline-offset:2px}
.tearwrap .tear-edge{opacity:calc(.55 + var(--tear-p,0)*.45);transform:scaleY(calc(1 + var(--tear-p,0)*.5))}
/* 收货凭证(小票)弹窗 */ /* 收货凭证(小票)弹窗 */
.ticket{white-space:pre;overflow:auto;max-width:100%;-webkit-overflow-scrolling:touch;max-height:62vh;font:11.5px/1.5 ui-monospace,Menlo,Consolas,monospace; .ticket{white-space:pre;overflow:auto;max-width:100%;-webkit-overflow-scrolling:touch;max-height:62vh;font:11.5px/1.5 ui-monospace,Menlo,Consolas,monospace;
@@ -1881,12 +1888,26 @@ function redoBtn(j){
} }
function openRedo(j){ function openRedo(j){
const files=(j.files||[]).filter(f=>!f.is_raw && f.name); const files=(j.files||[]).filter(f=>!f.is_raw && f.name);
const rows=files.map((f,i)=>'<label style="display:flex;align-items:center;gap:9px;padding:8px 10px;' /* 没渲出来的模板(2026-10-07):渲染失败的那几张根本没有成品文件,以前勾选列表里就是空的,
+'border:1px solid var(--line);border-radius:7px;margin-bottom:7px;cursor:pointer">' 点「重渲」只会提示「至少勾一张」—— 失败单反而重渲不了。现在把「应该有、但没出来」的模板也列出来。 */
const tplName=k=>((TEMPLATES_ALL.find(t=>t.k===k)||{}).n||k);
const want=[].concat.apply([], (j.skins||[]).map(s=>s.tpls||[])).concat(j.templates||[])
.filter((v,i,a)=>v&&a.indexOf(v)===i);
const got=new Set(files.map(f=>f.tpl).filter(Boolean));
/* 老单的文件没带模板信息 → 判断不了哪张缺,就只在一张图都没有时才列 */
const miss=(files.length&&!got.size)?[]:want.filter(k=>!got.has(k));
const rowCss='display:flex;align-items:center;gap:9px;padding:8px 10px;'
+'border:1px solid var(--line);border-radius:7px;margin-bottom:7px;cursor:pointer';
const rows=files.map((f,i)=>'<label style="'+rowCss+'">'
+'<input type="checkbox" class="redochk" value="'+esc(f.name)+'" checked>' +'<input type="checkbox" class="redochk" value="'+esc(f.name)+'" checked>'
+(f.prev?('<img src="'+esc(f.prev)+'" alt="" style="width:44px;height:44px;object-fit:cover;' +(f.prev?('<img src="'+esc(f.prev)+'" alt="" style="width:44px;height:44px;object-fit:cover;'
+'border-radius:5px;border:1px solid var(--line)">'):'') +'border-radius:5px;border:1px solid var(--line)">'):'')
+'<span style="font-size:12.5px;color:var(--txt-3)">'+esc(f.name)+'</span></label>').join(''); +'<span style="font-size:12.5px;color:var(--txt-3)">'+esc(f.name)+'</span></label>').join('')
+ miss.map(k=>'<label style="'+rowCss+';border-style:dashed">'
+'<input type="checkbox" class="redomiss" value="'+esc(k)+'" checked>'
+'<span style="width:44px;height:44px;flex:0 0 44px;border-radius:5px;border:1px dashed var(--line);'
+'display:grid;place-items:center;font-size:11px;color:#e8b23a">没出图</span>'
+'<span style="font-size:12.5px;color:var(--txt-3)">'+esc(tplName(k))+'</span></label>').join('');
openModal('<div style="font-size:14px;font-weight:700;color:var(--txt-2);margin-bottom:8px">有问题?免费重渲一次</div>' openModal('<div style="font-size:14px;font-weight:700;color:var(--txt-2);margin-bottom:8px">有问题?免费重渲一次</div>'
+'<div style="font-size:12.5px;color:var(--dim);line-height:1.75;margin-bottom:11px">' +'<div style="font-size:12.5px;color:var(--dim);line-height:1.75;margin-bottom:11px">'
+'上传时你只看到 512 预览,出问题不该你吃亏 —— <b style="color:var(--txt-3)">这单免费重渲一次</b>' +'上传时你只看到 512 预览,出问题不该你吃亏 —— <b style="color:var(--txt-3)">这单免费重渲一次</b>'
@@ -1894,7 +1915,7 @@ function openRedo(j){
+'<div style="font-size:12.5px;color:#e8b23a;line-height:1.75;margin-bottom:10px">' +'<div style="font-size:12.5px;color:#e8b23a;line-height:1.75;margin-bottom:10px">'
+'⚠️ 重渲是<b>整单重出</b>(换了皮肤更是全都得重出),不是只重出勾的那几张。' +'⚠️ 重渲是<b>整单重出</b>(换了皮肤更是全都得重出),不是只重出勾的那几张。'
+'下面勾选只是告诉金钻「哪几张有问题」。</div>' +'下面勾选只是告诉金钻「哪几张有问题」。</div>'
+(rows||'<div style="font-size:12.5px;color:var(--dim2)">这单还没有可勾的图。</div>') +(rows||'<div style="font-size:12.5px;color:var(--dim2)">这单一张图都没出来,点下面直接整单重渲。</div>')
+((j.skins&&j.skins.length)?('<div style="font-size:12.5px;color:var(--dim);margin-top:11px">' +((j.skins&&j.skins.length)?('<div style="font-size:12.5px;color:var(--dim);margin-top:11px">'
+'<b style="color:var(--txt-3)">皮肤传错了?</b>可以顺手换掉:先选是哪张皮肤,再挑新文件(不换就留空)</div>' +'<b style="color:var(--txt-3)">皮肤传错了?</b>可以顺手换掉:先选是哪张皮肤,再挑新文件(不换就留空)</div>'
+'<div style="display:flex;gap:8px;flex-wrap:wrap;margin-top:7px">' +'<div style="display:flex;gap:8px;flex-wrap:wrap;margin-top:7px">'
@@ -1989,14 +2010,17 @@ function openRedo(j){
}; };
$('#redoGo').onclick=async()=>{ $('#redoGo').onclick=async()=>{
const names=[...document.querySelectorAll('.redochk:checked')].map(x=>x.value); const names=[...document.querySelectorAll('.redochk:checked')].map(x=>x.value);
if(!names.length){ $('#redoMsg').innerHTML='<span style="color:#e08a8a">至少勾一张</span>'; return; } const missOn=[...document.querySelectorAll('.redomiss:checked')].map(x=>x.value);
/* 列表里一项都没有(老的失败单,连模板都对不上)→ 整单重出,别卡住 */
const anyRow=document.querySelector('.redochk,.redomiss');
if(anyRow && !names.length && !missOn.length){ $('#redoMsg').innerHTML='<span style="color:#e08a8a">至少勾一张</span>'; return; }
const b=$('#redoGo'); b.disabled=true; b.textContent='提交中…'; const b=$('#redoGo'); b.disabled=true; b.textContent='提交中…';
try{ try{
const rr=await fetch(API+'/redo',{method:'POST',headers:{'Content-Type':'application/json'}, const rr=await fetch(API+'/redo',{method:'POST',headers:{'Content-Type':'application/json'},
body:JSON.stringify({oid:S.order, token:S.token, files:names, note:$('#redoNote').value||'', body:JSON.stringify({oid:S.order, token:S.token, files:names, note:$('#redoNote').value||'',
/* 模板真换过才传;没动就不传,省得白跑一次规则校验 */ /* 模板真换过才传;没动就不传,省得白跑一次规则校验 */
tpls:([...chosen].join(',')!==curTpls.join(','))?[...chosen]:[], tpls:([...chosen].join(',')!==curTpls.join(','))?[...chosen]:[],
all:!!(($('#redoAll')||{}).checked), all:!!(($('#redoAll')||{}).checked) || !anyRow, miss_tpls:missOn,
skin:newSkinData||'', skin_id:(($('#redoSkin')||{}).value||''), skin_name:newSkinName||''})}); skin:newSkinData||'', skin_id:(($('#redoSkin')||{}).value||''), skin_name:newSkinName||''})});
const jj=await rr.json(); const jj=await rr.json();
if(!jj.ok) throw new Error(jj.error||'提交失败'); if(!jj.ok) throw new Error(jj.error||'提交失败');
@@ -2012,15 +2036,12 @@ function openRedo(j){
/* 确认收货 = 撕小票(金钻 2026-10-02:要有仪式感 —— 点下确认,把小票那截撕掉) /* 确认收货 = 撕小票(金钻 2026-10-02:要有仪式感 —— 点下确认,把小票那截撕掉)
· 小票内容用**真的** /api/receipt(不是摆设) · 小票内容用**真的** /api/receipt(不是摆设)
· 动画和"确认收货"请求**同时**跑,不耽误时间 · 2026-10-07(金钻:「动画太快,留给用户可交互撕凭证」):不再自动播 ——
· 撕完才关弹窗,画面上真的"撕掉一截" */ 买家**亲手**按住存根往外拉,拉够了才撕下来;没拉够松手就弹回去。
撕下来的那一刻才真正发「确认收货」;没撕就关掉弹窗 = 什么都没发生(按钮恢复)。
拖不动的(读屏 / 键盘 / 老设备)用「直接撕下」按钮,或聚焦存根按回车。 */
async function tearAndAccept(btn, oid, token, after){ async function tearAndAccept(btn, oid, token, after){
const keep=btn.textContent; btn.disabled=true; btn.textContent='确认中…'; const keep=btn.textContent; btn.disabled=true; btn.textContent='撕凭证确认收货…';
const req=(async()=>{
const rr=await fetch(API+'/accept',{method:'POST',headers:{'Content-Type':'application/json'},
body:JSON.stringify({oid:oid, token:token})});
return rr.json();
})();
let txt=''; let txt='';
try{ try{
const r=await fetch(API+'/receipt/'+oid+'?t='+encodeURIComponent(token),{cache:'no-store'}); const r=await fetch(API+'/receipt/'+oid+'?t='+encodeURIComponent(token),{cache:'no-store'});
@@ -2034,20 +2055,88 @@ async function tearAndAccept(btn, oid, token, after){
+'<div class="tearwrap" id="tearWrap">' +'<div class="tearwrap" id="tearWrap">'
+ '<pre class="ticket tear-card">'+esc(head)+'</pre>' + '<pre class="ticket tear-card">'+esc(head)+'</pre>'
+ '<div class="tear-edge"></div>' + '<div class="tear-edge"></div>'
+ '<pre class="tear-stub">'+esc(stub)+'</pre>' + '<pre class="tear-stub tear-grab" id="tearStub" tabindex="0" role="button" '
+ 'aria-label="撕下存根,确认收货">'+esc(stub)+'</pre>'
+'</div>' +'</div>'
+'<div style="font-size:12px;color:var(--dim2);margin-top:10px" id="tearTip">' +'<div style="font-size:12px;color:var(--dim2);margin-top:10px" id="tearTip">'
+'上面这截留在你手里,下面那截(存根)撕走归档。</div>' +'按住下面那截存根,往外一撕 —— 撕下来就算确认收货。</div>'
+'<div class="tear-stamp">✓ 已归档 · 原图已开放下载</div>'); +'<div class="tear-stamp">✓ 已归档 · 原图已开放下载</div>'
/* 节奏(金钻 2026-10-02:动画太短):入场 0.8s → 撕 1.05s → 收尾,总共约 2.8s +'<div class="btns" style="margin-top:10px" id="tearBtns">'
(确认请求同时在跑,动画时间长不影响实际耗时) */ +'<button class="ghost" type="button" id="tearNow">直接撕下</button>'
setTimeout(()=>{ +'<button class="ghost" type="button" id="tearCancel">先不收货</button></div>');
const w=$('#tearWrap'); if(w) w.classList.add('torn'); const wrap=$('#tearWrap'), st=$('#tearStub'), tip=$('#tearTip'), card=wrap.querySelector('.tear-card');
const tip=$('#tearTip'); if(tip) tip.textContent='嘶 —— 存根撕下来了'; const reduce=matchMedia('(prefers-reduced-motion: reduce)').matches;
}, 900); const NEED=110; /* 拉多远才撕得下来(px) */
let done=false, cancelled=false, finish;
const outcome=new Promise(r=>{ finish=r; });
/* 弹窗被关掉(点遮罩 / 先不收货)而还没撕 → 当没发生 */
const mo=new MutationObserver(()=>{
if(!done && !$('#mask').classList.contains('show')){ cancelled=true; finish('cancel'); }
});
mo.observe($('#mask'),{attributes:true,attributeFilter:['class']});
$('#tearCancel').onclick=()=>{ closeModal(); };
function pose(dx,dy){
const d=Math.hypot(dx,dy), p=Math.min(1,d/NEED);
const rot=Math.max(-18,Math.min(18, dx*0.07 + Math.max(0,dy)*0.035*(dx<0?-1:1)));
st.style.transform='translate('+(dx*0.62).toFixed(1)+'px,'+(dy*0.82).toFixed(1)+'px) rotate('+rot.toFixed(2)+'deg)';
if(card) card.style.transform='rotate('+(-p*0.5).toFixed(2)+'deg)';
wrap.style.setProperty('--tear-p', p.toFixed(3));
tip.textContent = p<0.15 ? '按住下面那截存根,往外一撕 —— 撕下来就算确认收货。'
: p<0.75 ? '再用点力……' : '松手就撕下来了';
return p;
}
function tear(dx,dy){
if(done) return; done=true;
const ang=Math.atan2(Math.max(dy,40), dx||8);
st.style.transition=reduce?'opacity .3s':'transform 1.1s var(--ease-drawer),opacity 1s var(--ease-out)';
st.style.transform=reduce?'':'translate('+(Math.cos(ang)*260).toFixed(0)+'px,'+(Math.sin(ang)*260).toFixed(0)+'px) '
+'rotate('+((dx<0?-1:1)*(22+Math.random()*10)).toFixed(1)+'deg)';
st.style.opacity='0';
if(card){ card.style.transition='transform .5s var(--ease-out)'; card.style.transform=''; }
wrap.classList.add('torn');
tip.textContent='嘶 —— 存根撕下来了';
const b=$('#tearBtns'); if(b) b.style.visibility='hidden';
finish('tear');
}
/* 拖:pointer 事件 + capture;没拉够松手 → 弹回 */
let sx=0, sy=0, dragging=false, lx=0, ly=0;
st.addEventListener('pointerdown',e=>{
if(done) return;
dragging=true; sx=e.clientX; sy=e.clientY; lx=ly=0;
st.setPointerCapture(e.pointerId); st.style.transition='none'; if(card) card.style.transition='none';
st.classList.add('grabbing'); e.preventDefault();
});
st.addEventListener('pointermove',e=>{
if(!dragging||done) return;
lx=e.clientX-sx; ly=e.clientY-sy; pose(lx,ly);
});
const up=()=>{
if(!dragging) return; dragging=false; st.classList.remove('grabbing');
if(done) return;
if(Math.hypot(lx,ly)>=NEED){ tear(lx,ly); return; }
st.style.transition='transform .5s cubic-bezier(.3,1.5,.5,1)';
if(card) card.style.transition='transform .5s var(--ease-out)';
st.style.transform=''; if(card) card.style.transform='';
wrap.style.setProperty('--tear-p','0');
tip.textContent='没撕下来 —— 再用力往外拉一点';
};
st.addEventListener('pointerup',up); st.addEventListener('pointercancel',up);
st.addEventListener('keydown',e=>{ if(e.key==='Enter'||e.key===' '){ e.preventDefault(); tear(30,90); } });
$('#tearNow').onclick=()=>tear(30,90);
const how=await outcome;
mo.disconnect();
if(how==='cancel'){ btn.disabled=false; btn.textContent=keep; return; }
/* 撕下来了 → 这时才真的确认收货;动画演完(约 1.6s)再关 */
let jj=null; let jj=null;
try{ jj=await req; }catch(e){ jj={ok:false, error:(e&&e.message)||'网络错误'}; } const t0=Date.now();
await new Promise(r=>setTimeout(r, 2600)); /* 等动画演完再关(一共约 2.8s) */ try{
const rr=await fetch(API+'/accept',{method:'POST',headers:{'Content-Type':'application/json'},
body:JSON.stringify({oid:oid, token:token})});
jj=await rr.json();
}catch(e){ jj={ok:false, error:(e&&e.message)||'网络错误'}; }
await new Promise(r=>setTimeout(r, Math.max(0, (reduce?600:1700)-(Date.now()-t0))));
closeModal(); closeModal();
if(!jj || !jj.ok){ if(!jj || !jj.ok){
toast('确认失败:'+((jj&&jj.error)||'未知')); toast('确认失败:'+((jj&&jj.error)||'未知'));
@@ -2846,10 +2935,13 @@ async function checkOrder(){
+'?t='+encodeURIComponent(S.token)+'&dl=1'; }; +'?t='+encodeURIComponent(S.token)+'&dl=1'; };
trow.appendChild(tdl); trow.appendChild(tdl);
d.appendChild(trow); d.appendChild(trow);
/* 收货后也可能发现不对 —— 重渲按钮两边都给(金钻 2026-10-02) */ /* 收货后:买家亲手确认过收货的单不再给免费重渲(2026-10-07:原图都拿走了还能再白出一套,
const rrow=document.createElement('div'); rrow.style.cssText='display:flex;gap:8px;margin-top:8px'; 会多渲)。直发单没有收货这一步,照旧给。服务器 /api/redo 同样拦着。 */
rrow.appendChild(redoBtn(j)); if(j.direct && !j.accepted_by_buyer){
d.appendChild(rrow); const rrow=document.createElement('div'); rrow.style.cssText='display:flex;gap:8px;margin-top:8px';
rrow.appendChild(redoBtn(j));
d.appendChild(rrow);
}
} }
const tip=document.createElement('div'); tip.className='notice'; const tip=document.createElement('div'); tip.className='notice';
tip.textContent='成品在服务器只保留 72 小时,请立刻下载并备份到本地/网盘。'; tip.textContent='成品在服务器只保留 72 小时,请立刻下载并备份到本地/网盘。';