aliChoice:类目 cat_fb 回退 + 失败记录带 errItems;记录首次批量成败分类(健康类目强制商品说明书)
This commit is contained in:
1 parent
0466698490
commit
a5c32e4726
3 files changed
+84
-2
No files matched your search
@@ -62,3 +62,20 @@ pinia._s.get('smtChoiceAddStore').$state.describeInfoData.detail = html;
|
|||||||
3. 点开下拉后按 `.pop()` 取最后一个可见下拉,容易读到**上一个字段残留**的列表
|
3. 点开下拉后按 `.pop()` 取最后一个可见下拉,容易读到**上一个字段残留**的列表
|
||||||
(曾把化学物列表当国家列表)→ 现在①每次点前先 `Esc` ②按**与点击点的距离**挑下拉
|
(曾把化学物列表当国家列表)→ 现在①每次点前先 `Esc` ②按**与点击点的距离**挑下拉
|
||||||
③产地/Origin 先 `Input.insertText('中国')` 过滤
|
③产地/Origin 先 `Input.insertText('中国')` 过滤
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ⚠️ 批量首次运行的成败分类(6 条:2 成功 / 4 失败)→ 已停批量
|
||||||
|
|
||||||
|
| 现象 | 根因 | 处置 |
|
||||||
|
|---|---|---|
|
||||||
|
| `请上传文件!`(`商品说明书`) | **健康/医疗类目强制资质文件**(与 HOOK.md 里速卖通 POP 那条同源) | 换不要求说明书的类目;无干净替代类目的商品只能人工处理 |
|
||||||
|
| `请选择产品属性`(`是否包含电池`) | 该下拉**点不开**(`no-dd`),疑似要先把别的属性选完才可用 | 待查:单独 dump 这个控件的依赖关系 |
|
||||||
|
| `请选择物流属性` | 已知,走「保存①→点 icon_edit2→勾普货→保存②」 | 批量里已实现 |
|
||||||
|
| `选类目失败:no-path` | `cat_kw` 在 aliChoice 类目树里搜不到 | **已修**:依次回退 `cat_fb`(tk_input 里给的后备品类词) |
|
||||||
|
|
||||||
|
**结论**:aliChoice 能不能铺,取决于**类目能不能选到不要求资质文件的那一支**。
|
||||||
|
下一轮建议:先把 48 条的 `cat_kw → 实际类目` 跑一遍 dry(不保存),
|
||||||
|
把落到健康/医疗/化妆品等强资质类目的商品挑出来,再决定是换词还是跳过。
|
||||||
|
|
||||||
|
失败记录现在会带 `errItems`(例如 `商品说明书:请上传文件!`),见 `alc_done.json`。
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/** 诊断 aliChoice 保存失败:打印所有报错项(含无 label 的)与类目搜索结果数 */
|
||||||
|
import { newPage, closePage, wait, installHook, readHook } from '/home/admin9webs/shein建品/sh_lib.mjs';
|
||||||
|
import { selectCategory, fillRequiredSelects } from '/home/admin9webs/shein建品/sh_build.mjs';
|
||||||
|
import { SAN as S } from '/tmp/cdp3.mjs';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
const P = `document.querySelector('#app').__vue_app__.config.globalProperties.$pinia`;
|
||||||
|
const pid = process.argv[2];
|
||||||
|
const it = JSON.parse(readFileSync('/home/admin9webs/tiktok建品/tk_input.json','utf8'))[pid];
|
||||||
|
const c = await newPage('https://www.dianxiaomi.com/web/smtChoice/add');
|
||||||
|
await wait(12000); await installHook(c);
|
||||||
|
const pick = async (re) => {
|
||||||
|
const p = JSON.parse(String(await c.evalJS(`(()=>{const f=[...document.querySelectorAll('.ant-form-item')].filter(e=>e.offsetParent!==null).find(e=>new RegExp(${JSON.stringify(re)}).test((e.querySelector('label')||{}).innerText||''));
|
||||||
|
const s=f?f.querySelector('.ant-select-selector'):null; if(!s) return '[]'; s.scrollIntoView({block:'center'});
|
||||||
|
const r=s.getBoundingClientRect(); return JSON.stringify([Math.round(r.x+r.width/2),Math.round(r.y+r.height/2)]);})()`)));
|
||||||
|
if(!p.length) return 'no-sel';
|
||||||
|
await c.send('Input.dispatchMouseEvent',{type:'mouseMoved',x:p[0],y:p[1],buttons:0}); await wait(300);
|
||||||
|
for(const t of ['mousePressed','mouseReleased']) await c.send('Input.dispatchMouseEvent',{type:t,x:p[0],y:p[1],button:'left',clickCount:1,buttons:1});
|
||||||
|
await wait(2000);
|
||||||
|
return c.evalJS(`(()=>{const dd=[...document.querySelectorAll('.ant-select-dropdown')].filter(e=>e.offsetParent!==null).pop();
|
||||||
|
if(!dd) return 'no-dd'; const op=[...dd.querySelectorAll('.ant-select-item-option')].filter(e=>e.offsetParent!==null)[0]; if(!op) return 'no-op';
|
||||||
|
const r=op.getBoundingClientRect();
|
||||||
|
for(const ev of ['mousedown','mouseup','click']) op.dispatchEvent(new MouseEvent(ev,{bubbles:true,cancelable:true,view:window,clientX:r.x+r.width/2,clientY:r.y+r.height/2}));
|
||||||
|
return 'picked:'+(op.innerText||'').trim().slice(0,14);})()`);
|
||||||
|
};
|
||||||
|
console.log('店:', await pick('店铺名称')); await wait(6000);
|
||||||
|
console.log('备货:', await pick('备货类型')); await wait(3000);
|
||||||
|
console.log('类目:', S(String(await selectCategory(c, it.cat_kw||'发夹', it.cat_kw))).slice(0,100));
|
||||||
|
await wait(6000);
|
||||||
|
const fill = await c.evalJS(`(()=>{const p=${P}; const imgs=${JSON.stringify((it.imgs||[]).slice(0,6))};
|
||||||
|
const mk=(u,i)=>({url:u,imgUrl:u,name:'img'+(i+1)+'.jpg',width:800,height:800});
|
||||||
|
p._s.get('smtChoiceAddBasicStore').$state.formState.subject=${JSON.stringify(it.title)};
|
||||||
|
p._s.get('smtChoiceAddProductStore').$state.formState.mainImage=imgs.map(mk);
|
||||||
|
const sd=p._s.get('smtChoiceSkuDataStore').$state.formState;
|
||||||
|
(sd.skuDataList||[]).forEach(r=>{ r.skuPrice=String(${JSON.stringify(String(it.price_cny||'19.90'))}); r.skuCode='AC-'+${JSON.stringify(pid)}; r.packageWeight='100'; r.packageLength='20'; r.packageWidth='15'; r.packageHeight='3'; });
|
||||||
|
const d=p._s.get('smtChoiceAddStore').$state.describeInfoData; if(d) d.detail=${JSON.stringify((it.bullets||[]).join('<br/>'))};
|
||||||
|
return 'ok';})()`);
|
||||||
|
console.log('填充:', String(fill)); await wait(3000);
|
||||||
|
console.log('必填属性:', S(String(await fillRequiredSelects(c))).slice(0,220));
|
||||||
|
await wait(1500);
|
||||||
|
await c.evalJS(`window.scrollTo(0,0)`); await wait(500);
|
||||||
|
await c.evalJS(`(()=>{const xs=[...document.querySelectorAll('button')].filter(e=>e.offsetParent!==null);
|
||||||
|
const b=xs.find(e=>/^\\s*保存\\s*$/.test((e.innerText||'').trim()))||xs.find(e=>/保存/.test(e.innerText||''));
|
||||||
|
if(b) for(const ev of ['mousedown','mouseup','click']) b.dispatchEvent(new MouseEvent(ev,{bubbles:true,cancelable:true,view:window})); return 1;})()`);
|
||||||
|
await wait(12000);
|
||||||
|
const err = await c.evalJS(`(()=>{const bad=[...document.querySelectorAll('.ant-form-item-has-error')].map(x=>{
|
||||||
|
const l=x.querySelector('label'); const t=l?(l.innerText||'').replace(/\\s+/g,' ').trim().slice(0,34):'(无label)';
|
||||||
|
const red=[...x.querySelectorAll('.text-red-500,[class*=explain]')].map(e=>(e.innerText||'').trim().slice(0,40)).filter(Boolean);
|
||||||
|
return {t, red:red.slice(0,2)};});
|
||||||
|
const ex=[...document.querySelectorAll('.ant-form-item-explain-error')].map(e=>(e.innerText||'').trim()).filter(Boolean);
|
||||||
|
return JSON.stringify({bad:bad.slice(0,10), ex:[...new Set(ex)].slice(0,6)});})()`);
|
||||||
|
console.log('报错项:', S(String(err)).slice(0,1200));
|
||||||
|
console.log('hook:', String(await readHook(c)).slice(-200));
|
||||||
|
try{ await c.shot('/tmp/alc_diag.jpg'); console.log('shot ok'); }catch(e){}
|
||||||
|
await closePage(c); process.exit(0);
|
||||||
@@ -109,7 +109,14 @@ for (const t of tasks) {
|
|||||||
await wait(6000);
|
await wait(6000);
|
||||||
log(` 备货类型: ${await pickFirstOption(c, '备货类型')}`);
|
log(` 备货类型: ${await pickFirstOption(c, '备货类型')}`);
|
||||||
await wait(3000);
|
await wait(3000);
|
||||||
const cat = await selectCategory(c, it.cat_kw || '发夹', it.cat_kw);
|
// 类目:cat_kw 搜不到就依次试 cat_fb(tk_input 里给的后备品类词)
|
||||||
|
let cat = await selectCategory(c, it.cat_kw || '发夹', it.cat_kw);
|
||||||
|
if (!String(cat).startsWith('path:')) {
|
||||||
|
for (const fb of (it.cat_fb || []).slice(0, 3)) {
|
||||||
|
cat = await selectCategory(c, fb, fb);
|
||||||
|
if (String(cat).startsWith('path:')) { log(` 类目回退到「${fb}」`); break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
log(` 类目: ${String(cat).slice(0, 110)}`);
|
log(` 类目: ${String(cat).slice(0, 110)}`);
|
||||||
if (!String(cat).startsWith('path:')) throw new Error('选类目失败:' + cat);
|
if (!String(cat).startsWith('path:')) throw new Error('选类目失败:' + cat);
|
||||||
await wait(6000);
|
await wait(6000);
|
||||||
@@ -144,8 +151,12 @@ for (const t of tasks) {
|
|||||||
mods = String(await c.evalJS(`JSON.stringify([...document.querySelectorAll('.ant-modal')].filter(e=>e.offsetParent!==null).map(e=>(e.innerText||'').replace(/\\s+/g,' ').trim().slice(0,110)))`));
|
mods = String(await c.evalJS(`JSON.stringify([...document.querySelectorAll('.ant-modal')].filter(e=>e.offsetParent!==null).map(e=>(e.innerText||'').replace(/\\s+/g,' ').trim().slice(0,110)))`));
|
||||||
}
|
}
|
||||||
const cap = await readHook(c);
|
const cap = await readHook(c);
|
||||||
|
const errItems = String(await c.evalJS(`JSON.stringify([...document.querySelectorAll('.ant-form-item-has-error')].map(x=>{
|
||||||
|
const l=x.querySelector('label'); const t=l?(l.innerText||'').replace(/\\s+/g,' ').trim().slice(0,30):'(无label)';
|
||||||
|
const red=[...x.querySelectorAll('.text-red-500')].map(e=>(e.innerText||'').trim().slice(0,30)).filter(Boolean);
|
||||||
|
return t+':'+red.join('/');}).slice(0,6))`));
|
||||||
const ok = /已保存|保存成功|待发布/.test(mods);
|
const ok = /已保存|保存成功|待发布/.test(mods);
|
||||||
done[t.pid] = ok ? { ok: true } : { ok: false, mods: mods.slice(0, 160), hook: String(cap).slice(-240) };
|
done[t.pid] = ok ? { ok: true } : { ok: false, errItems: errItems.slice(0, 260), mods: mods.slice(0, 120), hook: String(cap).slice(-200) };
|
||||||
log(ok ? ' ✓ 已保存到待发布' : ` ✗ 失败 ${mods.slice(0, 110)} | ${String(cap).slice(-170)}`);
|
log(ok ? ' ✓ 已保存到待发布' : ` ✗ 失败 ${mods.slice(0, 110)} | ${String(cap).slice(-170)}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
done[t.pid] = { ok: false, msg: String(e).slice(0, 240) };
|
done[t.pid] = { ok: false, msg: String(e).slice(0, 240) };
|
||||||
|
|||||||
Reference in new issue
Block a user