下单页:撕凭证改为亲手撕;失败单能重渲没出图的模板;确认收货后不能再免费重渲
- 撕凭证:按住存根往外拉,拉够才撕下(没拉够弹回);撕下那一刻才发确认收货, 关弹窗 / 先不收货 = 没发生。留「直接撕下」按钮和回车键兜底。 - 重渲弹窗:把应出未出的模板列成「没出图」项(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:
@@ -2047,6 +2047,7 @@ class H(BaseHTTPRequestHandler):
|
|||||||
"name": f.get("name"),
|
"name": f.get("name"),
|
||||||
"size": fsz,
|
"size": fsz,
|
||||||
"skin": f.get("skin"),
|
"skin": f.get("skin"),
|
||||||
|
"tpl": f.get("tpl") or "", # 重渲弹窗要知道哪个模板已经出图(2026-10-07)
|
||||||
"is_raw": ("无压缩" in (f.get("name") or "")),
|
"is_raw": ("无压缩" in (f.get("name") or "")),
|
||||||
# 收货前:给预览地址;收货后:给原图地址
|
# 收货前:给预览地址;收货后:给原图地址
|
||||||
# ⚠️ 必须带 v=<文件 mtime>:重渲会把同名文件原地覆盖,URL 不变的话
|
# ⚠️ 必须带 v=<文件 mtime>:重渲会把同名文件原地覆盖,URL 不变的话
|
||||||
@@ -2103,6 +2104,10 @@ class H(BaseHTTPRequestHandler):
|
|||||||
"accepted": accepted,
|
"accepted": accepted,
|
||||||
# 买家自助重渲:用过没有 + 上次选了什么(页面按钮据此置灰)
|
# 买家自助重渲:用过没有 + 上次选了什么(页面按钮据此置灰)
|
||||||
"redo_used": bool(m.get("redo_used")),
|
"redo_used": bool(m.get("redo_used")),
|
||||||
|
# 直发单没有收货这一步(accepted 恒为真),免费重渲照样给;
|
||||||
|
# 买家亲手点过「确认收货」的单才关掉重渲 —— 前端靠这个区分(2026-10-07)
|
||||||
|
"direct": bool(m.get("direct")),
|
||||||
|
"accepted_by_buyer": bool(m.get("accepted")),
|
||||||
"redo_files": m.get("redo_files") or [],
|
"redo_files": m.get("redo_files") or [],
|
||||||
"amount": amount,
|
"amount": amount,
|
||||||
"amount": amount,
|
"amount": amount,
|
||||||
@@ -2636,7 +2641,14 @@ class H(BaseHTTPRequestHandler):
|
|||||||
return self.err("这一单还没渲完(或正在渲),等它停下来再说")
|
return self.err("这一单还没渲完(或正在渲),等它停下来再说")
|
||||||
if m.get("redo_used"):
|
if m.get("redo_used"):
|
||||||
return self.err("这一单已经用过一次免费重渲了。还不行的话进官方群找金钻,他看着办。")
|
return self.err("这一单已经用过一次免费重渲了。还不行的话进官方群找金钻,他看着办。")
|
||||||
|
# ⚠️ 2026-10-07:确认收货 = 买家认可了成品、原图已经放出去了。以前收货后照样能点免费重渲,
|
||||||
|
# 等于原图拿走了还能再白出一套。直发单(没有收货这一步)不受影响。
|
||||||
|
if m.get("accepted") and not m.get("direct"):
|
||||||
|
return self.err("这一单已经确认收货了,免费重渲只能在确认收货之前用。图有问题请进官方群找金钻。")
|
||||||
files = [str(x)[:60] for x in (d.get("files") or [])][:12]
|
files = [str(x)[:60] for x in (d.get("files") or [])][:12]
|
||||||
|
# 没渲出来的模板(渲染失败的那几张根本没有成品文件,勾不了文件名 → 直接报模板 key)
|
||||||
|
miss = [t for t in (d.get("miss_tpls") or []) if t in TPL_KEYS
|
||||||
|
and t in (m.get("templates") or [])][:MAX_IMAGES]
|
||||||
note = str(d.get("note") or "").strip()[:200]
|
note = str(d.get("note") or "").strip()[:200]
|
||||||
# 换皮肤(金钻 2026-10-02:「或者他皮肤填错了重新换」)——
|
# 换皮肤(金钻 2026-10-02:「或者他皮肤填错了重新换」)——
|
||||||
# 传错了很正常,他上传时只看到 512 预览,不该卡在这儿。
|
# 传错了很正常,他上传时只看到 512 预览,不该卡在这儿。
|
||||||
@@ -2700,12 +2712,15 @@ class H(BaseHTTPRequestHandler):
|
|||||||
for f in (m.get("files") or []):
|
for f in (m.get("files") or []):
|
||||||
if (f.get("name") or "") in want and f.get("tpl") and f["tpl"] not in redo_tpls:
|
if (f.get("name") or "") in want and f.get("tpl") and f["tpl"] not in redo_tpls:
|
||||||
redo_tpls.append(f["tpl"])
|
redo_tpls.append(f["tpl"])
|
||||||
|
for t in miss:
|
||||||
|
if t not in redo_tpls:
|
||||||
|
redo_tpls.append(t)
|
||||||
if not redo_tpls and files:
|
if not redo_tpls and files:
|
||||||
# 勾的图找不到模板(老单缺 tpl 字段)→ 退回整单,别让玩家点了没反应
|
# 勾的图找不到模板(老单缺 tpl 字段)→ 退回整单,别让玩家点了没反应
|
||||||
redo_tpls = []
|
redo_tpls = []
|
||||||
m["redo_tpls"] = redo_tpls
|
m["redo_tpls"] = redo_tpls
|
||||||
# 没换皮肤、只重渲一部分 → **保留**其它成品(claim 里清了就再也找不回来了)
|
# 没换皮肤、只重渲一部分 → **保留**其它成品(claim 里清了就再也找不回来了)
|
||||||
if files and redo_tpls:
|
if redo_tpls:
|
||||||
log("免费重渲 %s:只重出 %s" % (oid, "、".join(redo_tpls)))
|
log("免费重渲 %s:只重出 %s" % (oid, "、".join(redo_tpls)))
|
||||||
# 重渲中的那几张先从列表里撤掉(渲染机交新的回来时同名字覆盖)
|
# 重渲中的那几张先从列表里撤掉(渲染机交新的回来时同名字覆盖)
|
||||||
if files:
|
if files:
|
||||||
@@ -2713,8 +2728,8 @@ class H(BaseHTTPRequestHandler):
|
|||||||
m["state"] = "waiting"
|
m["state"] = "waiting"
|
||||||
m["started"] = m["finished"] = None
|
m["started"] = m["finished"] = None
|
||||||
m["note"] = "买家申请免费重渲%s:%s" % (
|
m["note"] = "买家申请免费重渲%s:%s" % (
|
||||||
("(只重出 %d 张:%s)" % (len(files), "、".join(files))
|
("(只重出:%s)" % "、".join((files or []) + ["%s(上次没出来)" % t for t in miss])
|
||||||
if (files and redo_tpls) else "(整单重出)"),
|
if redo_tpls else "(整单重出)"),
|
||||||
note or "(没写原因)")
|
note or "(没写原因)")
|
||||||
with LOCK:
|
with LOCK:
|
||||||
write_meta(oid, m)
|
write_meta(oid, m)
|
||||||
|
|||||||
@@ -234,6 +234,35 @@ S.write_meta(r2, dict(S.read_meta(r2), state="done"))
|
|||||||
st, j, _ = req("POST", "/api/redo", {"oid": r2, "token": t2, "skin": durl(png(seed=9)), "skin_id": "s1", "all": 1})
|
st, j, _ = req("POST", "/api/redo", {"oid": r2, "token": t2, "skin": durl(png(seed=9)), "skin_id": "s1", "all": 1})
|
||||||
check("回归:重渲换一张正常皮肤照常可以", st == 200 and j.get("ok"), str(j)[:80])
|
check("回归:重渲换一张正常皮肤照常可以", st == 200 and j.get("ok"), str(j)[:80])
|
||||||
|
|
||||||
|
# 2026-10-07:确认收货后不能再免费重渲(原图都拿走了还能白出一套)
|
||||||
|
st, j, _ = submit([S.gen_codes(1)[0]], ["stand"])
|
||||||
|
a_oid, a_tok = j["order"], j["token"]
|
||||||
|
S.write_meta(a_oid, dict(S.read_meta(a_oid), state="done", accepted=True, accepted_at="2026-10-07T10:00:00"))
|
||||||
|
st, j, _ = req("POST", "/api/redo", {"oid": a_oid, "token": a_tok, "files": [], "all": 1})
|
||||||
|
check("洞:确认收货后还能点免费重渲 → 必须拒", not (st == 200 and j.get("ok"))
|
||||||
|
and (S.read_meta(a_oid) or {}).get("state") == "done" and not (S.read_meta(a_oid) or {}).get("redo_used"),
|
||||||
|
"server 说:%s" % (j.get("error") if isinstance(j, dict) else j))
|
||||||
|
st, j, _ = submit([S.gen_codes(1)[0]], ["stand"])
|
||||||
|
d_oid, d_tok = j["order"], j["token"]
|
||||||
|
S.write_meta(d_oid, dict(S.read_meta(d_oid), state="done", direct=True))
|
||||||
|
st, j, _ = req("POST", "/api/redo", {"oid": d_oid, "token": d_tok, "files": [], "all": 1})
|
||||||
|
check("回归:直发单(没有收货这一步)照常能免费重渲", st == 200 and j.get("ok"), str(j)[:80])
|
||||||
|
|
||||||
|
# 2026-10-07:渲染失败的模板没有成品文件 —— 只报模板 key 也要能重渲,而且只重渲没出来的那几个
|
||||||
|
st, j, _ = submit([S.gen_codes(1, n_fix=2)[0]], ["stand", "wheat"], nTotal=2)
|
||||||
|
f_oid, f_tok = j["order"], j["token"]
|
||||||
|
S.write_meta(f_oid, dict(S.read_meta(f_oid), state="failed",
|
||||||
|
files=[{"name": "站立正反.png", "path": "x.png", "tpl": "stand"}]))
|
||||||
|
st, j, _ = req("GET", "/api/order/%s?t=%s" % (f_oid, f_tok))
|
||||||
|
check("状态接口:成品带模板 key、带 direct 标记(重渲弹窗靠它算哪张没出来)",
|
||||||
|
st == 200 and (j.get("files") or [{}])[0].get("tpl") == "stand" and "direct" in j, str(j)[:120])
|
||||||
|
st, j, _ = req("POST", "/api/redo", {"oid": f_oid, "token": f_tok, "files": [], "miss_tpls": ["wheat", "boom"]})
|
||||||
|
mf = S.read_meta(f_oid) or {}
|
||||||
|
check("修:失败单只勾「没出图」的模板也能重渲,只重出那一个(不认这单以外的模板)",
|
||||||
|
st == 200 and j.get("ok") and mf.get("state") == "waiting" and mf.get("redo_tpls") == ["wheat"]
|
||||||
|
and [x.get("name") for x in mf.get("files") or []] == ["站立正反.png"],
|
||||||
|
"redo_tpls=%s files=%s err=%s" % (mf.get("redo_tpls"), mf.get("files"), j.get("error") if isinstance(j, dict) else j))
|
||||||
|
|
||||||
# ================================================================== 6. 反馈接口灌盘
|
# ================================================================== 6. 反馈接口灌盘
|
||||||
ip = new_ip()
|
ip = new_ip()
|
||||||
codes_ = []
|
codes_ = []
|
||||||
|
|||||||
+121
-29
@@ -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 小时,请立刻下载并备份到本地/网盘。';
|
||||||
|
|||||||
Reference in New Issue
Block a user