@@ -1,10 +1,10 @@
import { j as e , r , b as Fe , c as aa , d as Ra } from "./react-vendor-C_od1ZSF.js" ; import { L as $a , U as la , M as ts , C as ss , B as ra , S as na , Z as as , a as yt , b as us , c as hs , d as gs , e as Pa , f as rt , A as ks , D as Da , g as Cs , P as ia , h as At , E as oa , T as Ea , i as Ta , j as Re , X as $e , k as Fa , l as Ma , m as bs , n as ca , o as He , Q as Qt , p as ot , q as Ke , r as ft , s as It , t as Ss , R as Be , u as da , v as qa , w as Qe , K as Ba , x as it , y as lt , z as tt , F as Ls , G as _t , H as jt , I as Ot , J as xa , N as za , O as Os , V as Is , W as Ua , Y as Wa , _ as Va , $ as Ja , a0 as Gt , a1 as Dt , a2 as ls , a3 as Qa , a4 as Ga , a5 as rs , a6 as Ka , a7 as Ha , a8 as ns , a9 as As , aa as zt , ab as ma , ac as Za , ad as Ya , ae as Wt , af as pa , ag as Xa , ah as el , ai as tl , aj as sl , ak as al , al as ll , am as rl } from "./icons-vendor-DjsKcZkz.js" ; import { R as Et , B as nl , X as Rs , Y as $s , T as Tt , a as il , C as Kt , A as ol , b as cl , c as dl , P as Ps , d as Ds , L as xl } from "./charts-vendor-BxxJOyEX.js" ; import "./vendor-D-Edl3pr.js" ; ( function ( ) { const s = document . createElement ( "link" ) . relList ; if ( s && s . supports && s . supports ( "modulepreload" ) ) return ; for ( const x of document . querySelectorAll ( 'link[rel="modulepreload"]' ) ) i ( x ) ; new MutationObserver ( x => { for ( const v of x ) if ( v . type === "childList" ) for ( const S of v . addedNodes ) S . tagName === "LINK" && S . rel === "modulepreload" && i ( S ) } ) . observe ( document , { childList : ! 0 , subtree : ! 0 } ) ; function l ( x ) { const v = { } ; return x . integrity && ( v . integrity = x . integrity ) , x . referrerPolicy && ( v . referrerPolicy = x . referrerPolicy ) , x . crossOrigin === "use-credentials" ? v . credentials = "include" : x . crossOrigin === "anonymous" ? v . credentials = "omit" : v . credentials = "same-origin" , v } function i ( x ) { if ( x . ep ) return ; x . ep = ! 0 ; const v = l ( x ) ; fetch ( x . href , v ) } } ) ( ) ; const ml = ( { className : t = "w-full h-full text-white" } ) => e . jsx ( "svg" , { className : t , viewBox : "0 0 256 256" , "aria-hidden" : "true" , children : e . jsx ( "g" , { stroke : "none" , fill : "none" , fillRule : "evenodd" , children : e . jsx ( "path" , { d : "M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z" , fill : "currentColor" } ) } ) } ) , is = ( { sizeClass : t = "w-12 h-12" , logoClassName : s = "w-full h-full text-white" } ) => e . jsxs ( "div" , { className : "relative z-10 flex items-center justify-center" , children : [ e . jsx ( "div" , { className : "absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25" } ) , e . jsxs ( "div" , { className : ` relative ${ t } rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300 ` , children : [ e . jsxs ( "svg" , { className : "absolute inset-0 w-full h-full" , viewBox : "0 0 120 120" , "aria-hidden" : "true" , children : [ e . jsx ( "defs" , { children : e . jsxs ( "linearGradient" , { id : "login-squircle-gradient" , x1 : "0" , y1 : "0" , x2 : "1" , y2 : "1" , children : [ e . jsx ( "stop" , { offset : "0%" , stopColor : "#0094f7" } ) , e . jsx ( "stop" , { offset : "100%" , stopColor : "#287efe" } ) ] } ) } ) , e . jsx ( "path" , { d : " M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23.51 12.25 L 27.29 10.34 L 31.54 8.78 L 36.33 7.56 L 41.8 Line truncated
import { j as e , r , b as Fe , c as ra , d as Pa } from "./react-vendor-C_od1ZSF.js" ; import { L as Da , U as na , M as ts , C as ss , B as ia , S as oa , Z as as , a as yt , b as us , c as hs , d as gs , e as Ea , f as rt , A as ks , D as Ta , g as Cs , P as ca , h as At , E as da , T as Fa , i as Ma , j as Re , X as $e , k as qa , l as Ba , m as bs , n as xa , o as He , Q as Qt , p as ot , q as Ke , r as ft , s as It , t as Ss , R as Be , u as ma , v as za , w as Qe , K as Ua , x as it , y as lt , z as tt , F as Ls , G as _t , H as jt , I as Ot , J as pa , N as Wa , O as Os , V as Is , W as Va , Y as Ja , _ as Qa , $ as Ga , a0 as Gt , a1 as Dt , a2 as ls , a3 as Ka , a4 as Ha , a5 as rs , a6 as Za , a7 as Ya , a8 as ns , a9 as As , aa as zt , ab as ua , ac as Xa , ad as el , ae as Wt , af as ha , ag as tl , ah as sl , ai as al , aj as ll , ak as rl , al as nl , am as il } from "./icons-vendor-DjsKcZkz.js" ; import { R as Et , B as ol , X as Rs , Y as $s , T as Tt , a as cl , C as Kt , A as dl , b as xl , c as ml , P as Ps , d as Ds , L as pl } from "./charts-vendor-BxxJOyEX.js" ; import "./vendor-D-Edl3pr.js" ; ( function ( ) { const s = document . createElement ( "link" ) . relList ; if ( s && s . supports && s . supports ( "modulepreload" ) ) return ; for ( const x of document . querySelectorAll ( 'link[rel="modulepreload"]' ) ) i ( x ) ; new MutationObserver ( x => { for ( const v of x ) if ( v . type === "childList" ) for ( const S of v . addedNodes ) S . tagName === "LINK" && S . rel === "modulepreload" && i ( S ) } ) . observe ( document , { childList : ! 0 , subtree : ! 0 } ) ; function l ( x ) { const v = { } ; return x . integrity && ( v . integrity = x . integrity ) , x . referrerPolicy && ( v . referrerPolicy = x . referrerPolicy ) , x . crossOrigin === "use-credentials" ? v . credentials = "include" : x . crossOrigin === "anonymous" ? v . credentials = "omit" : v . credentials = "same-origin" , v } function i ( x ) { if ( x . ep ) return ; x . ep = ! 0 ; const v = l ( x ) ; fetch ( x . href , v ) } } ) ( ) ; const ul = ( { className : t = "w-full h-full text-white" } ) => e . jsx ( "svg" , { className : t , viewBox : "0 0 256 256" , "aria-hidden" : "true" , children : e . jsx ( "g" , { stroke : "none" , fill : "none" , fillRule : "evenodd" , children : e . jsx ( "path" , { d : "M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z" , fill : "currentColor" } ) } ) } ) , is = ( { sizeClass : t = "w-12 h-12" , logoClassName : s = "w-full h-full text-white" } ) => e . jsxs ( "div" , { className : "relative z-10 flex items-center justify-center" , children : [ e . jsx ( "div" , { className : "absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25" } ) , e . jsxs ( "div" , { className : ` relative ${ t } rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300 ` , children : [ e . jsxs ( "svg" , { className : "absolute inset-0 w-full h-full" , viewBox : "0 0 120 120" , "aria-hidden" : "true" , children : [ e . jsx ( "defs" , { children : e . jsxs ( "linearGradient" , { id : "login-squircle-gradient" , x1 : "0" , y1 : "0" , x2 : "1" , y2 : "1" , children : [ e . jsx ( "stop" , { offset : "0%" , stopColor : "#0094f7" } ) , e . jsx ( "stop" , { offset : "100%" , stopColor : "#287efe" } ) ] } ) } ) , e . jsx ( "path" , { d : " M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23.51 12.25 L 27.29 10.34 L 31.54 8.78 L 36.33 7.56 L 41.8 Line truncated
例如 : 回复时保持礼貌专业 、 使用简洁的语言 、 强调产品质量等 ` ,className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-bold text-blue-900 mb-2 flex items-center gap-2",children:[e.jsx(us,{className:"w-4 h-4"}),"AI如何工作"]}),e.jsxs("ul",{className:"text-xs text-blue-800 space-y-1",children:[e.jsx("li",{children:"• 自动识别买家的砍价请求"}),e.jsx("li",{children:"• 根据设定的策略智能回复"}),e.jsx("li",{children:"• 在合理范围内同意降价或礼貌拒绝"}),e.jsx("li",{children:"• 保持专业友好的沟通风格"})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:Pt,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:R,children:"取消"}),e.jsxs("button",{onClick:Je,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:R,children:[R?e.jsx(Re,{className:"w-4 h-4 animate-spin"}):e.jsx(He,{className:"w-4 h-4"}),R?"保存中...":"保存"]})]})})]})}),document.body)]})},Qr=t=>({total:Number((t==null?void 0:t.total)||0),success_count:Number((t==null?void 0:t.success_count)||0),failed_count:Number((t==null?void 0:t.failed_count)||0),results:Array.isArray(t==null?void 0:t.results)?t.results.map(s=>({order_id:String((s==null?void 0:s.order_id)||"unknown"),success:(s==null?void 0:s.success)===!0,message:String((s==null?void 0:s.message)||"")})):[]}),Gr=t=>(t==null?void 0:t.results.filter(s=>!s.success))||[],Qs=({status:t})=>{const s={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-[#0094f7] text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},l={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className: ` px - 3 py - 1.5 rounded - lg text - xs font - bold $ { s [ t ] || s . cancelled } ` ,children:l[t]||t})},Kr=()=>{const[t,s]=r.useState([]),[l,i]=r.useState([]),[x,v]=r.useState([]),[S, $ ]=r.useState({}),[f,I]=r.useState("all"),[y,J]=r.useState(""),[H,me]=r.useState(""),[ne,N]=r.useState(""),M=r.useRef(0),[ie,G]=r.useState(1),[Z,W]=r.useState(1),[ge,ue]=r.useState(!1),[O,Q]=r.useState(!1),[ce,q]=r.useState(!1),[V,A]=r.useState(!1),[D,ae]=r.useState(null),[E,le]=r.useState(null),[Se,je]=r.useState({}),[pe,u]=r.useState(!1),[b,z]=r.useState(""),[w,Y]=r.useState(!1),[oe,he]=r.useState(null),[Ie,fe]=r.useState(null),[d,k]=r.useState(null),[p,c]=r.useState(!1),[_,R]=r.useState(null),[U,K]=r.useState(null),te=async()=>{const g=++M.current;ue(!0);try{const B=await zl(y||void 0,f,ie,20,ne);if(g!==M.current)return;s(B.data),W(B.total_pages)}catch(B){console.error("加载订单失败:",B)}finally{g===M.current&&ue(!1)}},Ne=(g,B,_e)=>{if(_e&&_e.trim())return _e;if(S[ ` $ { g } : $ { B } ` ])return S[ ` $ { g } : $ { B } ` ];const Oe=l.find(Ye=>{if(_e&&Ye.item_title){const st=_e.toLowerCase(),Xe=Ye.item_title.toLowerCase();return Xe.includes(st)||st.includes(Xe)}return!1});return Oe!=null&&Oe.item_title?Oe.item_title:"未知商品"},h=g=>{const B={};g.forEach(_e=>{_e.item_id&&(B[ ` $ { _e . cookie _id } : $ { _e . item _id } ` ]=_e.item_title||_e.item_id)}), $ (B)};r.useEffect(()=>{const g=window.setTimeout(()=>{G(1),N(H.trim())},300);return()=>window.clearTimeout(g)},[H]),r.useEffect(()=>{te()},[y,f,ie,ne]),r.useEffect(()=>{Promise.all([Rt(),Nt()]).then(([g,B])=>{v(g),i(B),h(B)}).catch(g=>{console.error("加载商品列表失败:",g)})},[]);const C=r.useMemo(()=>new Map(x.map(g=>[g.id,g])),[x]),F=g=>{const B=C.get(g),_e=(B==null?void 0:B.remark)||(B==null?void 0:B.nickname);return _e? ` $ { _e } · $ { g . slice ( 0 , 6 ) } ` : ` 账号 $ { g . slice ( 0 , 8 ) } ` },T=g=>{const B=C.get(g);return(B==null?void 0:B.remark)||(B==null?void 0:B.nickname)||"未命名账号"},ve=async()=>{ue(!0);try{const g=await Vl(y||void 0,f);await te(),g!=null&&g.message&&alert(g.message)}catch(g){console.error("同步订单失败:",g),alert((g==null?void 0:g.message)||"同步失败,请重试")}finally{ue(!1)}},Ee=g=>{z(g),he(null),u(!0)},we=async g=>{var B;Y(!0),he(null);try{const _e=await Ql([b],g),Oe=(B=_e==null?void 0:_e.results)==null?void 0:B[0];Oe!=null&&Oe.success?(he({success:!0,message:Oe.message}),te()):he({success:!1,message:(Oe==null?void 0:Oe.message)||"发货失败"})}catch(_e){he({success:!1,message:(_e==null?void 0:_e.message)||"请求失败"})}finally{Y(!1)}},Pe=g=>{ae(g),Q(!0)},de=g=>{le({...g}),q(!0)},Te=async()=>{if(!(!E||!E.order_id))try{const g={};E.status!==void 0&&(g.order_status=E.status),E.buyer_id!==void 0&&(g.buyer_id=E.buyer_id),E.amount!==void 0&&(g.amount=E.amount),E.receiver_name!==void 0&&(g.receiver_name=E.receiver_name),E.receiver_phon
Line truncated
例如 : 回复时保持礼貌专业 、 使用简洁的语言 、 强调产品质量等 ` ,className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-bold text-blue-900 mb-2 flex items-center gap-2",children:[e.jsx(us,{className:"w-4 h-4"}),"AI如何工作"]}),e.jsxs("ul",{className:"text-xs text-blue-800 space-y-1",children:[e.jsx("li",{children:"• 自动识别买家的砍价请求"}),e.jsx("li",{children:"• 根据设定的策略智能回复"}),e.jsx("li",{children:"• 在合理范围内同意降价或礼貌拒绝"}),e.jsx("li",{children:"• 保持专业友好的沟通风格"})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:Pt,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:R,children:"取消"}),e.jsxs("button",{onClick:Je,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:R,children:[R?e.jsx(Re,{className:"w-4 h-4 animate-spin"}):e.jsx(He,{className:"w-4 h-4"}),R?"保存中...":"保存"]})]})})]})}),document.body)]})},Kr=t=>({total:Number((t==null?void 0:t.total)||0),success_count:Number((t==null?void 0:t.success_count)||0),failed_count:Number((t==null?void 0:t.failed_count)||0),results:Array.isArray(t==null?void 0:t.results)?t.results.map(s=>({order_id:String((s==null?void 0:s.order_id)||"unknown"),success:(s==null?void 0:s.success)===!0,message:String((s==null?void 0:s.message)||"")})):[]}),Hr=t=>(t==null?void 0:t.results.filter(s=>!s.success))||[],Qs=({status:t})=>{const s={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-[#0094f7] text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},l={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className: ` px - 3 py - 1.5 rounded - lg text - xs font - bold $ { s [ t ] || s . cancelled } ` ,children:l[t]||t})},Zr=()=>{const[t,s]=r.useState([]),[l,i]=r.useState([]),[x,v]=r.useState([]),[S, $ ]=r.useState({}),[f,I]=r.useState("all"),[y,J]=r.useState(""),[H,me]=r.useState(""),[ne,N]=r.useState(""),M=r.useRef(0),[ie,G]=r.useState(1),[Z,W]=r.useState(1),[ge,ue]=r.useState(!1),[O,Q]=r.useState(!1),[ce,q]=r.useState(!1),[V,A]=r.useState(!1),[D,ae]=r.useState(null),[E,le]=r.useState(null),[Se,je]=r.useState({}),[pe,h]=r.useState(!1),[b,z]=r.useState(""),[w,Y]=r.useState(!1),[oe,he]=r.useState(null),[Ie,fe]=r.useState(null),[d,k]=r.useState(null),[p,c]=r.useState(!1),[_,R]=r.useState(null),[U,K]=r.useState(null),te=async()=>{const g=++M.current;ue(!0);try{const B=await Wl(y||void 0,f,ie,20,ne);if(g!==M.current)return;s(B.data),W(B.total_pages)}catch(B){console.error("加载订单失败:",B)}finally{g===M.current&&ue(!1)}},Ne=(g,B,_e)=>{if(_e&&_e.trim())return _e;if(S[ ` $ { g } : $ { B } ` ])return S[ ` $ { g } : $ { B } ` ];const Oe=l.find(Ye=>{if(_e&&Ye.item_title){const st=_e.toLowerCase(),Xe=Ye.item_title.toLowerCase();return Xe.includes(st)||st.includes(Xe)}return!1});return Oe!=null&&Oe.item_title?Oe.item_title:"未知商品"},u=g=>{const B={};g.forEach(_e=>{_e.item_id&&(B[ ` $ { _e . cookie _id } : $ { _e . item _id } ` ]=_e.item_title||_e.item_id)}), $ (B)};r.useEffect(()=>{const g=window.setTimeout(()=>{G(1),N(H.trim())},300);return()=>window.clearTimeout(g)},[H]),r.useEffect(()=>{te()},[y,f,ie,ne]),r.useEffect(()=>{Promise.all([Rt(),Nt()]).then(([g,B])=>{v(g),i(B),u(B)}).catch(g=>{console.error("加载商品列表失败:",g)})},[]);const C=r.useMemo(()=>new Map(x.map(g=>[g.id,g])),[x]),T=g=>{const B=C.get(g),_e=(B==null?void 0:B.remark)||(B==null?void 0:B.nickname);return _e? ` $ { _e } · $ { g . slice ( 0 , 6 ) } ` : ` 账号 $ { g . slice ( 0 , 8 ) } ` },F=g=>{const B=C.get(g);return(B==null?void 0:B.remark)||(B==null?void 0:B.nickname)||"未命名账号"},ve=async()=>{ue(!0);try{const g=await Ql(y||void 0,f);await te(),g!=null&&g.message&&alert(g.message)}catch(g){console.error("同步订单失败:",g),alert((g==null?void 0:g.message)||"同步失败,请重试")}finally{ue(!1)}},Ee=g=>{z(g),he(null),h(!0)},we=async g=>{var B;Y(!0),he(null);try{const _e=await Kl([b],g),Oe=(B=_e==null?void 0:_e.results)==null?void 0:B[0];Oe!=null&&Oe.success?(he({success:!0,message:Oe.message}),te()):he({success:!1,message:(Oe==null?void 0:Oe.message)||"发货失败"})}catch(_e){he({success:!1,message:(_e==null?void 0:_e.message)||"请求失败"})}finally{Y(!1)}},Pe=g=>{ae(g),Q(!0)},de=g=>{le({...g}),q(!0)},Te=async()=>{if(!(!E||!E.order_id))try{const g={};E.status!==void 0&&(g.order_status=E.status),E.buyer_id!==void 0&&(g.buyer_id=E.buyer_id),E.amount!==void 0&&(g.amount=E.amount),E.receiver_name!==void 0&&(g.receiver_name=E.receiver_name),E.receiver_phon
Line truncated
VIP - MONTH - 002
VIP - MONTH - 003 ` ,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map(U=>U.map(K=> ` "${String(K).replace(/" / g , '""' ) } "`).join(" , " ) ) . join ( `
` ),c=new Blob([" \u FEFF"+p],{type:"text/csv;charset=utf-8"}),_=URL.createObjectURL(c),R=document.createElement("a");R.href=_,R.download="卡密组批量导入模板.csv",document.body.appendChild(R),R.click(),R.remove(),URL.revokeObjectURL(_)},he=async()=>{if(M){ge(!0),Z(null);try{const d=await e r(M);if(Z(d),d.created>0){const k=await et();s(k)}}catch(d){Z({error:(d==null?void 0:d.message)||"上传失败"})}finally{ge(!1)}}},Ie=async()=>{if(!(!ue||!Q.trim())){ge(!0),V(null);try{const d=await t r(ue,Q);V({added:d.added}),ce("");const k=await et();s(k)}catch(d){alert("追加失败:"+((d==null?void 0:d.message)||"未知错误"))}finally{ge(!1)}}},fe=()=>{var d;N("create"),ie(null),Z(null),O((d=w[0])!=null&&d.id?String(w[0].id):""),ce(""),V(null),me(!0)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"卡密库存"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理自动发货的卡密、链接或图片资源。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:fe,className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 rounded-2xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(Ot,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>v(!0),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(tt,{className:"w-5 h-5"}),"添加新卡密"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-gray-50 bg-[#FAFAFA] p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative sm:w-48",children:[e.jsx(x a,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按卡密类型筛选",value:A,onChange:d=>D(d.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部类型"}),e.jsx("option",{value:"data",children:"批量卡密"}),e.jsx("option",{value:"text",children:"文本"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"image",children:"图片"})]})]}),e.jsxs("div",{className:"relative w-full sm:max-w-sm",children:[e.jsx(_t,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"按卡密名称搜索",placeholder:"搜索卡密名称...",value:ae,onChange:d=>E(d.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]})]}),e.jsxs("div",{className:"whitespace-nowrap px-1 text-xs font-bold text-gray-400",children:["显示 ",Y.length," / ",t.length," 组"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full table-fixed text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"w-[23%] px-5 py-5",children:"卡密名称"}),e.jsx("th",{className:"w-[8%] px-3 py-5",children:"卡密组ID"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"类型"}),e.jsx("th",{className:"w-[27%] px-5 py-5",children:"内容/库存"}),e.jsx("th",{className:"w-[19%] px-5 py-5",children:"描述"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"状态"}),e.jsx("th",{className:"w-[9%] px-3 py-5 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:Y.map(d=>{let k="";return d.type==="data"&&d.data_content?k= ` 库存 : $ { d . data _content . split ( `
` ).filter(c=>c.trim()).length} 条 ` : d . type === "text" && d . text _content ? k = d . text _content : d . type === "api" && d . api _config ? k = d . api _config . url : d . type === "image" && d . image _url && ( k = "图片链接" ) , e . jsxs ( "tr" , { className : "hover:bg-[#FFFDE7]/50 transition-colors group" , children : [ e . jsx ( "td" , { className : "px-5 py-5 align-middle" , children : e . jsxs ( "div" , { className : "flex items-center gap-2.5" , children : [ e . jsx ( "div" , { className : "shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white" , children : e . jsx ( le , { type : d . type } ) } ) , e . jsx ( "span" , { className : "line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900" , title : d . name , children : d . name } ) ] } ) } ) , e . jsx ( "td" , { className : "px-3 py-5" , children : e . jsxs ( "button" , { onClick : ( ) => z ( d . id ) , className : "inline-flex max-w-full items-center gap-1 rounded-lg bg-gray-100 px-2 py-1.5 font-mono text-[11px] font-extrabold text-gray-700 transition-colors hover:bg-gray-200" , title : "复制卡密组ID,用于批量铺货表格" , children : [ e . jsx ( "span" , { className : "truncate" , children : d . id } ) , e . jsx ( za , { className : "h-3 w-3 shrink-0" } ) ] } ) } ) , e . jsx ( "td" , { className : "px-2 py-5" , children : e . jsx ( "span" , { className : ` inline-flex rounded-md px-2 py-1 text-[11px] font-bold ${ d . type === "text" ? "bg-blue-50 text-blue-600" : d . type === "data" ? "bg-purple-50 text-purple-600" : d . type === "api" ? "bg-blue-50 text-blue-600" : "bg-pink-50 text-pink-600" } ` , children : d . type === "text" ? "文本" : d . type === "data" ? "批量" : d . type === "api" ? "API" : "图片" } ) } ) , e . jsx ( "td" , { className : "px-5 py-5" , children : e . jsx ( "span" , { className : "line-clamp-3 break-all font-mono text-sm leading-5 text-gray-600" , title : k , children : k } ) } ) , e . jsx ( "td" , { className : "px-5 py-5" , children : e . jsx ( "span" , { className : "block truncate text-sm text-gray-500" , title : d . description || "-" , children : d . description || "-" } ) } ) , e . jsx ( "td" , { className : "px-2 py-5" , children : e . jsx ( "button" , { onClick : ( ) => b ( d ) , className : ` w-12 h-8 rounded-full relative transition-colors ${ d . enabled ? "bg-green-500" : "bg-gray-300" } ` , children : e . jsx ( "div" , { className : ` absolute top-1 w-6 h-6 bg-white rounded-full shadow-sm transition-transform ${ d . enabled ? "left-5" : "left-1" } ` } ) } ) } ) , e . jsx ( "td" , { className : "px-3 py-5" , children : e . jsxs ( "div" , { className : "flex items-center justify-end gap-0.5" , children : [ e . jsx ( "button" , { onClick : ( ) => Se ( d ) , className : "rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black" , title : "编辑" , children : e . jsx ( jt , { className : "w-4 h-4" } ) } ) , e . jsx ( "button" , { onClick : ( ) => pe ( d . id ) , className : "rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500" , children : e . jsx ( Qe , { className : "h-4 w-4" } ) } ) ] } ) } ) ] } , d . id ) } ) } ) ] } ) } ) , Y . length === 0 && e . jsxs ( "div" , { className : "py-20 text-center text-gray-400" , children : [ e . jsx ( ia , { className : "w-12 h-12 mx-auto mb-4 opacity-30" } ) , e . jsx ( "p" , { children : t . length === 0 ? "暂无卡密配置,请点击右上角添加。" : "没有符合当前筛选条件的卡密组。" } ) ] } ) ] } ) , l && S && Fe . createPortal ( e . jsx ( "div" , { className : "modal-overlay-centered" , children : e . jsxs ( "div" , { className : "modal-container" , children : [ e . jsxs ( "div" , { className : "modal-header" , children : [ e . jsx ( "h3" , { className : "text-2xl font-extrabold text-gray-900" , children : "编辑卡密" } ) , e . jsx ( "button" , { onClick : ( ) => i ( ! 1 ) , className : "p-2 rounded-xl hover:bg-gray-100 transition-colors" , children : e . jsx ( $e , { className : "w-5 h-5 text-gray-500" } ) } ) ] } ) , e . jsx ( "div" , { className : "modal-body" , children : e . jsxs ( "div" , { className : "space-y-5" , children : [ e . jsxs ( "div" , { className : "grid grid-cols-1 md:grid-cols-2 gap-4" , children : [ e . jsxs ( "div" , { children : [ e . jsxs ( "label" , { className : "block text-sm font-bold text-gray-700 mb-2" , children : [ "卡密名称 " , e . jsx ( "span" , { className : "text-red-500" , children : "*" } ) ] } ) , e . jsx ( "input" , { type : "text" , value : f . name || "" , onChange : d => I ( { ... f , name : d . target . value } ) , className : "w-full ios-input px-4 py-3 rounded-xl" , placeholder : "例如:游戏点卡、会员卡等" } ) ] } ) , e . jsxs ( "div" , { children : [ e . jsx ( "label" , { className : "block text-sm font-bold text-gray-700 mb-2" , children : "卡券类型" } ) , e . jsxs ( "select" , { value : f . type || "text" , onChange : d => I ( { ... f , type : d . target . value } ) , className : "w-full ios-input px-4 py-3 rounded-xl" , children : [ e . jsx ( "option" , { value : "" , children : "请选择类型" } ) , e . jsx ( "option" , { value : "text" , children : "固定文字" } ) , e . jsx ( "option" , { value : "data" , children : "批量数据" } ) , ( S == null ? void 0 : S . type ) === "api" && e . jsx ( "option" , { value : "api" , children : "API接口(仅保留现有配置)" } ) , e . jsx ( "option" , { value : "image" , children : "图片" } ) ] } ) ] } ) ] } ) , f . type === "api" && e . jsxs ( "div" , { className : "border border-gray-200 rounded-xl p-4 space-y-4 bg-gray-50" , children : [ e . jsx ( "h3" , { className : "font-bold text-gray-900" , children : "API 配置" } ) , e . jsxs ( "div" , { children : [ e . jsx ( "label" , { className : "block text-sm font-bold text-gray-700 mb-2" , children : "API 地址" } ) , e . jsx ( "input" , { type : "url" , value : f . api _url || "" , onChange : d => I ( { ... f , api _url : d . target . value } ) , className : "w-full ios-input px-4 py-3 rounded-xl font-mono text-sm" , placeholder : "https://api.example.com/get-card" } ) ] } ) , e . jsxs ( "div" , { className : "grid grid-cols-2 gap-4" , children : [ e . jsx Line truncated
` ),c=new Blob([" \u FEFF"+p],{type:"text/csv;charset=utf-8"}),_=URL.createObjectURL(c),R=document.createElement("a");R.href=_,R.download="卡密组批量导入模板.csv",document.body.appendChild(R),R.click(),R.remove(),URL.revokeObjectURL(_)},he=async()=>{if(M){ge(!0),Z(null);try{const d=await s r(M);if(Z(d),d.created>0){const k=await et();s(k)}}catch(d){Z({error:(d==null?void 0:d.message)||"上传失败"})}finally{ge(!1)}}},Ie=async()=>{if(!(!ue||!Q.trim())){ge(!0),V(null);try{const d=await a r(ue,Q);V({added:d.added}),ce("");const k=await et();s(k)}catch(d){alert("追加失败:"+((d==null?void 0:d.message)||"未知错误"))}finally{ge(!1)}}},fe=()=>{var d;N("create"),ie(null),Z(null),O((d=w[0])!=null&&d.id?String(w[0].id):""),ce(""),V(null),me(!0)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"卡密库存"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理自动发货的卡密、链接或图片资源。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:fe,className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 rounded-2xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(Ot,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>v(!0),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(tt,{className:"w-5 h-5"}),"添加新卡密"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-gray-50 bg-[#FAFAFA] p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative sm:w-48",children:[e.jsx(p a,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按卡密类型筛选",value:A,onChange:d=>D(d.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部类型"}),e.jsx("option",{value:"data",children:"批量卡密"}),e.jsx("option",{value:"text",children:"文本"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"image",children:"图片"})]})]}),e.jsxs("div",{className:"relative w-full sm:max-w-sm",children:[e.jsx(_t,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"按卡密名称搜索",placeholder:"搜索卡密名称...",value:ae,onChange:d=>E(d.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]})]}),e.jsxs("div",{className:"whitespace-nowrap px-1 text-xs font-bold text-gray-400",children:["显示 ",Y.length," / ",t.length," 组"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full table-fixed text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"w-[23%] px-5 py-5",children:"卡密名称"}),e.jsx("th",{className:"w-[8%] px-3 py-5",children:"卡密组ID"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"类型"}),e.jsx("th",{className:"w-[27%] px-5 py-5",children:"内容/库存"}),e.jsx("th",{className:"w-[19%] px-5 py-5",children:"描述"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"状态"}),e.jsx("th",{className:"w-[9%] px-3 py-5 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:Y.map(d=>{let k="";return d.type==="data"&&d.data_content?k= ` 库存 : $ { d . data _content . split ( `
` ).filter(c=>c.trim()).length} 条 ` : d . type === "text" && d . text _content ? k = d . text _content : d . type === "api" && d . api _config ? k = d . api _config . url : d . type === "image" && d . image _url && ( k = "图片链接" ) , e . jsxs ( "tr" , { className : "hover:bg-[#FFFDE7]/50 transition-colors group" , children : [ e . jsx ( "td" , { className : "px-5 py-5 align-middle" , children : e . jsxs ( "div" , { className : "flex items-center gap-2.5" , children : [ e . jsx ( "div" , { className : "shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white" , children : e . jsx ( le , { type : d . type } ) } ) , e . jsx ( "span" , { className : "line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900" , title : d . name , children : d . name } ) ] } ) } ) , e . jsx ( "td" , { className : "px-3 py-5" , children : e . jsxs ( "button" , { onClick : ( ) => z ( d . id ) , className : "inline-flex max-w-full items-center gap-1 rounded-lg bg-gray-100 px-2 py-1.5 font-mono text-[11px] font-extrabold text-gray-700 transition-colors hover:bg-gray-200" , title : "复制卡密组ID,用于批量铺货表格" , children : [ e . jsx ( "span" , { className : "truncate" , children : d . id } ) , e . jsx ( Wa , { className : "h-3 w-3 shrink-0" } ) ] } ) } ) , e . jsx ( "td" , { className : "px-2 py-5" , children : e . jsx ( "span" , { className : ` inline-flex rounded-md px-2 py-1 text-[11px] font-bold ${ d . type === "text" ? "bg-blue-50 text-blue-600" : d . type === "data" ? "bg-purple-50 text-purple-600" : d . type === "api" ? "bg-blue-50 text-blue-600" : "bg-pink-50 text-pink-600" } ` , children : d . type === "text" ? "文本" : d . type === "data" ? "批量" : d . type === "api" ? "API" : "图片" } ) } ) , e . jsx ( "td" , { className : "px-5 py-5" , children : e . jsx ( "span" , { className : "line-clamp-3 break-all font-mono text-sm leading-5 text-gray-600" , title : k , children : k } ) } ) , e . jsx ( "td" , { className : "px-5 py-5" , children : e . jsx ( "span" , { className : "block truncate text-sm text-gray-500" , title : d . description || "-" , children : d . description || "-" } ) } ) , e . jsx ( "td" , { className : "px-2 py-5" , children : e . jsx ( "button" , { onClick : ( ) => b ( d ) , className : ` w-12 h-8 rounded-full relative transition-colors ${ d . enabled ? "bg-green-500" : "bg-gray-300" } ` , children : e . jsx ( "div" , { className : ` absolute top-1 w-6 h-6 bg-white rounded-full shadow-sm transition-transform ${ d . enabled ? "left-5" : "left-1" } ` } ) } ) } ) , e . jsx ( "td" , { className : "px-3 py-5" , children : e . jsxs ( "div" , { className : "flex items-center justify-end gap-0.5" , children : [ e . jsx ( "button" , { onClick : ( ) => Se ( d ) , className : "rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black" , title : "编辑" , children : e . jsx ( jt , { className : "w-4 h-4" } ) } ) , e . jsx ( "button" , { onClick : ( ) => pe ( d . id ) , className : "rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500" , children : e . jsx ( Qe , { className : "h-4 w-4" } ) } ) ] } ) } ) ] } , d . id ) } ) } ) ] } ) } ) , Y . length === 0 && e . jsxs ( "div" , { className : "py-20 text-center text-gray-400" , children : [ e . jsx ( ca , { className : "w-12 h-12 mx-auto mb-4 opacity-30" } ) , e . jsx ( "p" , { children : t . length === 0 ? "暂无卡密配置,请点击右上角添加。" : "没有符合当前筛选条件的卡密组。" } ) ] } ) ] } ) , l && S && Fe . createPortal ( e . jsx ( "div" , { className : "modal-overlay-centered" , children : e . jsxs ( "div" , { className : "modal-container" , children : [ e . jsxs ( "div" , { className : "modal-header" , children : [ e . jsx ( "h3" , { className : "text-2xl font-extrabold text-gray-900" , children : "编辑卡密" } ) , e . jsx ( "button" , { onClick : ( ) => i ( ! 1 ) , className : "p-2 rounded-xl hover:bg-gray-100 transition-colors" , children : e . jsx ( $e , { className : "w-5 h-5 text-gray-500" } ) } ) ] } ) , e . jsx ( "div" , { className : "modal-body" , children : e . jsxs ( "div" , { className : "space-y-5" , children : [ e . jsxs ( "div" , { className : "grid grid-cols-1 md:grid-cols-2 gap-4" , children : [ e . jsxs ( "div" , { children : [ e . jsxs ( "label" , { className : "block text-sm font-bold text-gray-700 mb-2" , children : [ "卡密名称 " , e . jsx ( "span" , { className : "text-red-500" , children : "*" } ) ] } ) , e . jsx ( "input" , { type : "text" , value : f . name || "" , onChange : d => I ( { ... f , name : d . target . value } ) , className : "w-full ios-input px-4 py-3 rounded-xl" , placeholder : "例如:游戏点卡、会员卡等" } ) ] } ) , e . jsxs ( "div" , { children : [ e . jsx ( "label" , { className : "block text-sm font-bold text-gray-700 mb-2" , children : "卡券类型" } ) , e . jsxs ( "select" , { value : f . type || "text" , onChange : d => I ( { ... f , type : d . target . value } ) , className : "w-full ios-input px-4 py-3 rounded-xl" , children : [ e . jsx ( "option" , { value : "" , children : "请选择类型" } ) , e . jsx ( "option" , { value : "text" , children : "固定文字" } ) , e . jsx ( "option" , { value : "data" , children : "批量数据" } ) , ( S == null ? void 0 : S . type ) === "api" && e . jsx ( "option" , { value : "api" , children : "API接口(仅保留现有配置)" } ) , e . jsx ( "option" , { value : "image" , children : "图片" } ) ] } ) ] } ) ] } ) , f . type === "api" && e . jsxs ( "div" , { className : "border border-gray-200 rounded-xl p-4 space-y-4 bg-gray-50" , children : [ e . jsx ( "h3" , { className : "font-bold text-gray-900" , children : "API 配置" } ) , e . jsxs ( "div" , { children : [ e . jsx ( "label" , { className : "block text-sm font-bold text-gray-700 mb-2" , children : "API 地址" } ) , e . jsx ( "input" , { type : "url" , value : f . api _url || "" , onChange : d => I ( { ... f , api _url : d . target . value } ) , className : "w-full ios-input px-4 py-3 rounded-xl font-mono text-sm" , placeholder : "https://api.example.com/get-card" } ) ] } ) , e . jsxs ( "div" , { className : "grid grid-cols-2 gap-4" , children : [ e . jsx Line truncated
卡号1 : 密码1
卡号2 : 密码2
或者
@@ -13,7 +13,7 @@ VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文
` ).filter(d=>d.trim()).length:0})," 条"]})]})]}),f.type==="image"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"图片配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{type:"url",value:f.image_url||"",onChange:d=>I({...f,image_url:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://example.com/image.png"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"输入图片卡密的 URL 地址"})]}),f.image_url&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片预览"}),e.jsx("img",{src:f.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:d=>{d.currentTarget.src="https://via.placeholder.com/400x200?text=图片加载失败"}})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"延时发货时间(秒)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",value:f.delay_seconds||0,onChange:d=>I({...f,delay_seconds:parseInt(d.target.value)||0}),className:"flex-1 ios-input px-4 py-3 rounded-xl",min:"0",max:"3600",placeholder:"0"}),e.jsx("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:"秒"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"0表示立即发货,最大3600秒(1小时)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注信息"}),e.jsx("textarea",{value:f.description||"",onChange:d=>I({...f,description:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none",placeholder:"可选的备注信息"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsx("span",{className:"font-bold text-gray-900",children:"启用状态"}),e.jsx("button",{type:"button",onClick:()=>I({...f,enabled:!f.enabled}),className: ` w - 14 h - 8 rounded - full transition - colors duration - 300 relative $ { f . enabled ? "bg-[#0094f7]" : "bg-gray-300" } ` ,children:e.jsx("span",{className: ` absolute top - 1 w - 6 h - 6 bg - white rounded - full shadow - md transition - transform duration - 300 block $ { f . enabled ? "translate-x-7" : "translate-x-1" } ` })})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>i(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:je,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(He,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),x&&Fe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"780px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"添加新卡密"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"选择交付方式并录入自动发货内容"})]}),e.jsx("button",{onClick:()=>v(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx( $ e,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡密名称"}),e.jsx("input",{type:"text",value:y.name,onChange:d=>J({...y,name:d.target.value}),placeholder:"例如:VIP会员卡密",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"类型"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>J({...y,type:"data",content:""}),className: ` p - 3 rounded - xl font - bold transition - all $ { y . type === "data" ? "bg-[#0094f7] text-white" : "bg-gray-100 text-gray-600 hover:bg-gray-200" } ` ,children:[e.jsx(ss,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:()=>J({...y,type:"text",content:""}),className: ` p - 3 rounded - xl font - bold transition - all $ { y . type === "text" ? "bg-[#0094f7] text-white" : "bg-gray-100 text-gray-600" } ` ,children:[e.jsx(Os,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:()=>J({...y,type:"image",content:""}),className: ` p - 3 rounded - xl font - bold transition - all $ { y . type === "image" ? "bg-[#0094f7] text-white" : " bg - gray - 100 text - gray Line truncated
CODE - 789012
... ` :"请输入每次发货时发送的固定文字"}),y.type==="data"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-[#0094f7]",children:y.content.split( `
` ).filter(d=>d.trim()).length})," 条"]})]}),y.type==="api"&&e.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求方法"}),e.jsxs("select",{value:y.api_method,onChange:d=>J({...y,api_method:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"超时时间(秒)"}),e.jsx("input",{type:"number",min:"1",max:"60",value:y.api_timeout,onChange:d=>J({...y,api_timeout:parseInt(d.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求头(JSON) "}),e.jsx("textarea",{value:y.api_headers,onChange:d=>J({...y,api_headers:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"Authorization":"Bearer token"}'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求参数(JSON) "}),e.jsx("textarea",{value:y.api_params,onChange:d=>J({...y,api_params:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"order_id":"{order_id}"}'})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"描述"}),e.jsx("input",{value:y.description,onChange:d=>J({...y,description:d.target.value}),placeholder:"卡密用途描述(可选)",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"延时发货(秒)"}),e.jsx("input",{type:"number",value:y.delay_seconds,onChange:d=>J({...y,delay_seconds:parseInt(d.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>v(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:u,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(tt,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),H&&Fe.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"40rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量导入卡密"}),e.jsx("button",{onClick:()=>me(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx( $ e,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[e.jsxs("button",{onClick:()=>N("create"),className: ` flex - 1 inline - flex items - center justify - center gap - 2 px - 4 py - 2.5 rounded - xl text - sm font - bold transition - all $ { ne === "create" ? "bg-[#0094f7] text-white shadow-md" : "bg-white text-gray-600 hover:bg-gray-50" } ` ,children:[e.jsx(Ua,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:()=>N("append"),className: ` flex - 1 inline - flex items - center justify - center gap - 2 px - 4 py - 2.5 rounded - xl text - sm font - bold transition - all $ { ne === "append" ? "bg-[#0094f7] text-white shadow-md" : "bg-white text-gray-600 hover:bg-gray-50" } ` ,children:[e.jsx(Ot,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),ne==="create"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-4 text-xs text-blue-900 leading-5",children:["上传表格,每行一个卡密组。表头:",e.jsx("code",{className:"bg-blue-100/70 px-1.5 py-0.5 rounded",children:"名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值"}),'。 类型填 text/data/image; data 类型的"内容"按行存卡密(CSV 单元格内换行需用引号包裹)。']}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:oe,className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text
Line truncated
` ).filter(d=>d.trim()).length})," 条"]})]}),y.type==="api"&&e.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求方法"}),e.jsxs("select",{value:y.api_method,onChange:d=>J({...y,api_method:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"超时时间(秒)"}),e.jsx("input",{type:"number",min:"1",max:"60",value:y.api_timeout,onChange:d=>J({...y,api_timeout:parseInt(d.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求头(JSON) "}),e.jsx("textarea",{value:y.api_headers,onChange:d=>J({...y,api_headers:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"Authorization":"Bearer token"}'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求参数(JSON) "}),e.jsx("textarea",{value:y.api_params,onChange:d=>J({...y,api_params:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"order_id":"{order_id}"}'})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"描述"}),e.jsx("input",{value:y.description,onChange:d=>J({...y,description:d.target.value}),placeholder:"卡密用途描述(可选)",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"延时发货(秒)"}),e.jsx("input",{type:"number",value:y.delay_seconds,onChange:d=>J({...y,delay_seconds:parseInt(d.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>v(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:h,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(tt,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),H&&Fe.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"40rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量导入卡密"}),e.jsx("button",{onClick:()=>me(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx( $ e,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[e.jsxs("button",{onClick:()=>N("create"),className: ` flex - 1 inline - flex items - center justify - center gap - 2 px - 4 py - 2.5 rounded - xl text - sm font - bold transition - all $ { ne === "create" ? "bg-[#0094f7] text-white shadow-md" : "bg-white text-gray-600 hover:bg-gray-50" } ` ,children:[e.jsx(Va,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:()=>N("append"),className: ` flex - 1 inline - flex items - center justify - center gap - 2 px - 4 py - 2.5 rounded - xl text - sm font - bold transition - all $ { ne === "append" ? "bg-[#0094f7] text-white shadow-md" : "bg-white text-gray-600 hover:bg-gray-50" } ` ,children:[e.jsx(Ot,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),ne==="create"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-4 text-xs text-blue-900 leading-5",children:["上传表格,每行一个卡密组。表头:",e.jsx("code",{className:"bg-blue-100/70 px-1.5 py-0.5 rounded",children:"名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值"}),'。 类型填 text/data/image; data 类型的"内容"按行存卡密(CSV 单元格内换行需用引号包裹)。']}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:oe,className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text
Line truncated
VIP - 002
VIP - 003 ` ,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),e.jsx("p",{className:"text-xs text-gray-500",children:"一行一个卡密号,空行自动忽略。会追加到该组现有库存末尾。"})]}),q&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",q.added," 个卡密"]})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>me(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),ne==="create"?e.jsxs("button",{onClick:he,disabled:!M||W,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[W?e.jsx(Re,{className:"w-4 h-4 animate-spin"}):e.jsx(Ot,{className:"w-4 h-4"}),W?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:Ie,disabled:!ue||!Q.trim()||W||w.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[W?e.jsx(Re,{className:"w-4 h-4 animate-spin"}):e.jsx(tt,{className:"w-4 h-4"}),W?"处理中...":"追加卡密"]})]})]})}),document.body)]})},Yr=t=>t.find(s=>s.status==="running"||s.status==="canceling"),Xr=t=>{const s=String(t||"").trim();return s?/^[¥¥]/.test(s)?s: ` ¥ $ { s } ` :"-"},en=({onConfigureDelivery:t})=>{const[s,l]=r.useState([]),[i,x]=r.useState([]),[v,S]=r.useState([]),[ $ ,f]=r.useState(""),[I,y]=r.useState(""),[J,H]=r.useState(!1),[me,ne]=r.useState(!1),[N,M]=r.useState(!1),[ie,G]=r.useState(!1),[Z,W]=r.useState(!1),[ge,ue]=r.useState(!1),[O,Q]=r.useState(!1),[ce,q]=r.useState("upload"),[V,A]=r.useState(null),[D,ae]=r.useState(null),[E,le]=r.useState(""),[Se,je]=r.useState(!1),[pe,u]=r.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[b,z]=r.useState(null),[w,Y]=r.useState(null),[oe,he]=r.useState(null),Ie=r.useRef(!1),[fe,d]=r.useState(null),[k,p]=r.useState({}),[c,_]=r.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[R,U]=r.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),[K,te]=r.useState([]);r.useEffect(()=>{if(!ge||R.images.length===0){te([]);return}const n=R.images.map((L,re)=>({key:L.name+re,url:URL.createObjectURL(L)}));return te(n),()=>{n.forEach(L=>URL.revokeObjectURL(L.url))}},[ge,R.images]);const Ne=async()=>{const n=await Nt();l(n)},h=async()=>{x(await xs())};r.useEffect(()=>{Promise.all([Rt(),Nt(),xs(),Bs(20)]).then(([n,L,re,Ve])=>{S(n),l(L),x(re);const Je=Ve.find(qe=>["running","canceling"].includes(qe.status))||Ve.find(qe=>qe.status!=="preview");he(Je||null)}).catch(n=>console.error("加载商品配置失败:",n))},[]),r.useEffect(()=>{if(!O||!(w!=null&&w.id)||!["running","canceling"].includes(w.status))return;const n=window.setInterval(async()=>{if(!Ie.current){Ie.current=!0;try{const L=await gt(w.id);Y(L),he(L),["running","canceling"].includes(L.status)||(q("done"),await Ne(),await h())}catch(L){console.error("刷新批量铺货进度失败:",L)}finally{Ie.current=!1}}},3e3);return()=>{window.clearInterval(n)}},[O,w==null?void 0:w.id,w==null?void 0:w.status]);const C=async()=>{if(! $ )return alert("请先选择账号");H(!0);try{const n=await sr( $ );await Ne(),alert((n==null?void 0:n.message)||"商品同步完成")}catch(n){console.error("同步商品失败:",n),alert((n==null?void 0:n.message)||"同步失败,请重试")}finally{H(!1)}},F=n=>{d(n),p({...n}),G(!0)},T=async()=>{if(fe)try{await mr(fe.cookie_id,fe.item_id,{item_title:k.item_title||"",item_description:k.item_description||"",item_category:k.item_category||"",item_price:k.item_price||"",item_detail:k.item_detail||fe.item_detail||""}),await Ne(),await h(),G(!1),d(null)}catch(n){console.error("更新商品失败:",n),alert("更新失败,请重试")}},ve=async n=>{if(confirm( ` 确认删除商品 "${n.item_title}" 吗 ? ` ))try{await ar(n.cookie_id,n.item_id),l(L=>L.filter(re=>!(re.cookie_id===n.cookie_id&&re.item_id===n.item_id)))}catch(L){console.error("删除商品失败:",L),alert("删除失败,请重试")}},Ee=async()=>{try{if(!c.cookie_id||!c.item_id){alert("请选择账号并填写商品ID");return}await lr(c.cookie_id,{item_id:c.item_id,item_title:c.item_title,item_price:c.item_price,item_detail:c.item_image?JSON.stringify({item_image:c.item_image}):""}),await Ne(),W(!1),_({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(n){console.error("添加商品失败:",n),alert("添加失败,请重试")}},we=async()=>{if(!R.cookie_id)return alert("请选择发布账号");if(!R.title.trim())return alert("请填写商品标题");if(!R.price.trim())return alert("请填写商品价格");if(!R.quantity||Number(R.quantity)<=0)return alert("库存数量必须大于 0");if(R.images.length===0)return alert("至少上传 1 张商品图片");if(R.postage_mode==="fixe
Line truncated
` ),Ve=new Blob([" \u FEFF"+re],{type:"text/csv;charset=utf-8"}),Je=URL.createObjectURL(Ve),qe=document.createElement("a");qe.href=Je,qe.download="批量铺货模板.csv",document.body.appendChild(qe),qe.click(),qe.remove(),URL.revokeObjectURL(Je)},Oe=()=>{_(n=>({...n,cookie_id: $ ||n.cookie_id})),W(!0)},Ye=()=>{U(n=>({...n,cookie_id: $ ||n.cookie_id})),ue(!0)},st=n=>i.filter(L=>L.cookie_id===n.cookie_id&&L.item_id===n.item_id).length>0?i.filter(L=>L.cookie_id===n.cookie_id&&L.item_id===n.item_id):i.filter(L=>L.cookie_id===n.cookie_id&&!L.item_id),Xe=n=>{switch(n){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return n||"-"}},ze=n=>{switch(n){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}},We=r.useMemo(()=>new Map(v.map(n=>[n.id,n])),[v]),ct=r.useMemo(()=>I?s.filter(n=>n.cookie_id===I):s,[I,s]),Ge=n=>{const L=We.get(n),re=(L==null?void 0:L.remark)||(L==null?void 0:L.nickname);return re? ` $ { re } · $ { n . slice ( 0 , 6 ) } ` : ` 账号 $ { n . slice ( 0 , 8 ) } ` },dt=n=>{const L=We.get(n);return(L==null?void 0:L.remark)||(L==null?void 0:L.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ja,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:I,onChange:n=>y(n.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),v.map(n=>e.jsx("option",{value:n.id,children:Ge(n.id)},n.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(ot,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value: $ ,onChange:n=>f(n.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),v.map(n=>e.jsx("option",{value:n.id,children:Ge(n.id)},n.id))]})]})]}),e.jsxs("button",{onClick:C,disabled:J||! $ ,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(Be,{className: ` w - 4 h - 4 $ { J ? "animate-spin" : "" } ` }),"同步商品"]}),e.jsxs("button",{onClick:Oe,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(tt,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:Ye,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-600 text-white hover:bg-emerald-700 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(Gt,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void Pe(),className:"px-5 py-3 rounded-2xl font-bold bg-blue-600 text-white hover:bg-blue-700 transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(Dt,{className:"w-4 h-4"}),oe&&["running","canceling"].includes(oe.status)?"继续批量任务":"批量铺货"]}),oe&&!["running","canceling"].includes(oe.status)&&e.jsx("button",{onClick:()=>void Te(),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[ct.map(n=>{const L=st(n),re=L.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group r
Line truncated
VIP - 003 ` ,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),e.jsx("p",{className:"text-xs text-gray-500",children:"一行一个卡密号,空行自动忽略。会追加到该组现有库存末尾。"})]}),q&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",q.added," 个卡密"]})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>me(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),ne==="create"?e.jsxs("button",{onClick:he,disabled:!M||W,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[W?e.jsx(Re,{className:"w-4 h-4 animate-spin"}):e.jsx(Ot,{className:"w-4 h-4"}),W?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:Ie,disabled:!ue||!Q.trim()||W||w.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[W?e.jsx(Re,{className:"w-4 h-4 animate-spin"}):e.jsx(tt,{className:"w-4 h-4"}),W?"处理中...":"追加卡密"]})]})]})}),document.body)]})},en=t=>t.find(s=>s.status==="running"||s.status==="canceling"),tn=t=>{const s=String(t||"").trim();return s?/^[¥¥]/.test(s)?s: ` ¥ $ { s } ` :"-"},sn=({onConfigureDelivery:t})=>{const[s,l]=r.useState([]),[i,x]=r.useState([]),[v,S]=r.useState([]),[ $ ,f]=r.useState(""),[I,y]=r.useState(""),[J,H]=r.useState(!1),[me,ne]=r.useState(!1),[N,M]=r.useState(!1),[ie,G]=r.useState(!1),[Z,W]=r.useState(!1),[ge,ue]=r.useState(!1),[O,Q]=r.useState(!1),[ce,q]=r.useState("upload"),[V,A]=r.useState(null),[D,ae]=r.useState(null),[E,le]=r.useState(""),[Se,je]=r.useState(!1),[pe,h]=r.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[b,z]=r.useState(null),[w,Y]=r.useState(null),[oe,he]=r.useState(null),Ie=r.useRef(!1),[fe,d]=r.useState(null),[k,p]=r.useState({}),[c,_]=r.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[R,U]=r.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),[K,te]=r.useState([]);r.useEffect(()=>{if(!ge||R.images.length===0){te([]);return}const n=R.images.map((L,re)=>({key:L.name+re,url:URL.createObjectURL(L)}));return te(n),()=>{n.forEach(L=>URL.revokeObjectURL(L.url))}},[ge,R.images]);const Ne=async()=>{const n=await Nt();l(n)},u=async()=>{x(await xs())};r.useEffect(()=>{Promise.all([Rt(),Nt(),xs(),Bs(20)]).then(([n,L,re,Ve])=>{S(n),l(L),x(re);const Je=Ve.find(qe=>["running","canceling"].includes(qe.status))||Ve.find(qe=>qe.status!=="preview");he(Je||null)}).catch(n=>console.error("加载商品配置失败:",n))},[]),r.useEffect(()=>{if(!O||!(w!=null&&w.id)||!["running","canceling"].includes(w.status))return;const n=window.setInterval(async()=>{if(!Ie.current){Ie.current=!0;try{const L=await gt(w.id);Y(L),he(L),["running","canceling"].includes(L.status)||(q("done"),await Ne(),await u())}catch(L){console.error("刷新批量铺货进度失败:",L)}finally{Ie.current=!1}}},3e3);return()=>{window.clearInterval(n)}},[O,w==null?void 0:w.id,w==null?void 0:w.status]);const C=async()=>{if(! $ )return alert("请先选择账号");H(!0);try{const n=await lr( $ );await Ne(),alert((n==null?void 0:n.message)||"商品同步完成")}catch(n){console.error("同步商品失败:",n),alert((n==null?void 0:n.message)||"同步失败,请重试")}finally{H(!1)}},T=n=>{d(n),p({...n}),G(!0)},F=async()=>{if(fe)try{await ur(fe.cookie_id,fe.item_id,{item_title:k.item_title||"",item_description:k.item_description||"",item_category:k.item_category||"",item_price:k.item_price||"",item_detail:k.item_detail||fe.item_detail||""}),await Ne(),await u(),G(!1),d(null)}catch(n){console.error("更新商品失败:",n),alert("更新失败,请重试")}},ve=async n=>{if(confirm( ` 确认删除商品 "${n.item_title}" 吗 ? ` ))try{await rr(n.cookie_id,n.item_id),l(L=>L.filter(re=>!(re.cookie_id===n.cookie_id&&re.item_id===n.item_id)))}catch(L){console.error("删除商品失败:",L),alert("删除失败,请重试")}},Ee=async()=>{try{if(!c.cookie_id||!c.item_id){alert("请选择账号并填写商品ID");return}await nr(c.cookie_id,{item_id:c.item_id,item_title:c.item_title,item_price:c.item_price,item_detail:c.item_image?JSON.stringify({item_image:c.item_image}):""}),await Ne(),W(!1),_({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(n){console.error("添加商品失败:",n),alert("添加失败,请重试")}},we=async()=>{if(!R.cookie_id)return alert("请选择发布账号");if(!R.title.trim())return alert("请填写商品标题");if(!R.price.trim())return alert("请填写商品价格");if(!R.quantity||Number(R.quantity)<=0)return alert("库存数量必须大于 0");if(R.images.length===0)return alert("至少上传 1 张商品图片");if(R.postage_mode==="fixe
Line truncated
` ),Ve=new Blob([" \u FEFF"+re],{type:"text/csv;charset=utf-8"}),Je=URL.createObjectURL(Ve),qe=document.createElement("a");qe.href=Je,qe.download="批量铺货模板.csv",document.body.appendChild(qe),qe.click(),qe.remove(),URL.revokeObjectURL(Je)},Oe=()=>{_(n=>({...n,cookie_id: $ ||n.cookie_id})),W(!0)},Ye=()=>{U(n=>({...n,cookie_id: $ ||n.cookie_id})),ue(!0)},st=n=>i.filter(L=>L.cookie_id===n.cookie_id&&L.item_id===n.item_id).length>0?i.filter(L=>L.cookie_id===n.cookie_id&&L.item_id===n.item_id):i.filter(L=>L.cookie_id===n.cookie_id&&!L.item_id),Xe=n=>{switch(n){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return n||"-"}},ze=n=>{switch(n){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}},We=r.useMemo(()=>new Map(v.map(n=>[n.id,n])),[v]),ct=r.useMemo(()=>I?s.filter(n=>n.cookie_id===I):s,[I,s]),Ge=n=>{const L=We.get(n),re=(L==null?void 0:L.remark)||(L==null?void 0:L.nickname);return re? ` $ { re } · $ { n . slice ( 0 , 6 ) } ` : ` 账号 $ { n . slice ( 0 , 8 ) } ` },dt=n=>{const L=We.get(n);return(L==null?void 0:L.remark)||(L==null?void 0:L.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ga,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:I,onChange:n=>y(n.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),v.map(n=>e.jsx("option",{value:n.id,children:Ge(n.id)},n.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(ot,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value: $ ,onChange:n=>f(n.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),v.map(n=>e.jsx("option",{value:n.id,children:Ge(n.id)},n.id))]})]})]}),e.jsxs("button",{onClick:C,disabled:J||! $ ,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(Be,{className: ` w - 4 h - 4 $ { J ? "animate-spin" : "" } ` }),"同步商品"]}),e.jsxs("button",{onClick:Oe,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(tt,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:Ye,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-600 text-white hover:bg-emerald-700 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(Gt,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void Pe(),className:"px-5 py-3 rounded-2xl font-bold bg-blue-600 text-white hover:bg-blue-700 transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(Dt,{className:"w-4 h-4"}),oe&&["running","canceling"].includes(oe.status)?"继续批量任务":"批量铺货"]}),oe&&!["running","canceling"].includes(oe.status)&&e.jsx("button",{onClick:()=>void Te(),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[ct.map(n=>{const L=st(n),re=L.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group r
Line truncated