PageSourceSearch

https://smilebio.com.tw/assets/MemberReferral-ByyDr8rT.js

js smilebio.com.tw collected 2026-10-09 23:45:39 UTC 17,884 bytes, 11 lines download raw bytes

1import{a0 as ve,r as a,t as h,f as u,j as e,G as A,q as he,d as ye,am as We,an as Be,ao as Fe,ap as Me,aq as Qe,as as Ie}from"./index-hq7kdXWa.js";import{M as Pe}from"./MemberLayout-CkjejYBW.js";import{I as T}from"./input-BDkUznem.js";import{L as k}from"./label-FxwjLyoS.js";import{G as pe}from"./gift-CBhGyxBR.js";import{L as b}from"./loader-circle-Bofk2w5-.js";import{C as ue}from"./check-C4VtWd-0.js";import{C as be}from"./copy-CJwrd4kf.js";import{W as je}from"./wallet-DgQEjSyR.js";import{C as Ne}from"./chevron-up-BOOxdRSL.js";import{C as Ee}from"./circle-x-Berpe4zV.js";import{C as ke}from"./circle-check-BZum3PIz.js";import{C as ge}from"./clock-CXFYO0zg.js";import{P as ze}from"./pencil-BY7nYGU7.js";import{U as qe}from"./upload-DB3gMa5F.js";import"./map-pin-CKcYtsMc.js";import"./shopping-bag-DtXSzJHO.js";import"./ticket-DfXTcvav.js";import"./coins-DigsVtIM.js";import"./key-round-BZ4p2KYQ.js";import"./log-out-s6rd0D91.js";import"./useComposition-CHcVJtpR.js";/**
2 * @license lucide-react v0.453.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Oe=ve("ArrowDownRight",[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]]);/**
7 * @license lucide-react v0.453.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Ge=ve("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]),fe={pending:{label:"等待取貨",color:"text-yellow-600 bg-yellow-50",icon:ge},waiting:{label:"等待確認",color:"text-blue-600 bg-blue-50",icon:ge},confirmed:{label:"已確認",color:"text-green-600 bg-green-50",icon:ke},cancelled:{label:"已取消",color:"text-gray-500 bg-gray-50",icon:Ee},revoked:{label:"已扣回",color:"text-red-500 bg-red-50",icon:ye}},we={pending:{label:"待審核",color:"text-yellow-600 bg-yellow-50"},reviewing:{label:"審核中",color:"text-blue-600 bg-blue-50"},approved:{label:"已核准",color:"text-green-600 bg-green-50"},rejected:{label:"已拒絕",color:"text-red-500 bg-red-50"},paid:{label:"已匯款",color:"text-green-700 bg-green-50"}};function bt(){const[n,i]=a.useState(!1),[d,s]=a.useState(!1),[o,c]=a.useState(!1),[x,p]=a.useState(!0),[m,j]=a.useState(!1),[g,f]=a.useState(""),[C,B]=a.useState(!1),[V,F]=a.useState(""),[Y,M]=a.use
11State(""),[Z,Q]=a.useState(""),[ee,I]=a.useState(""),[te,P]=a.useState(""),[se,E]=a.useState(""),[ae,z]=a.useState(""),$=h.shop.referralSettings.useQuery(),S=$.data?.isActive===!0,re=h.shop.myReferralCode.useQuery(void 0,{enabled:S}),le=h.shop.myReferralWallet.useQuery(),ne=h.shop.myReferralRecords.useQuery(),ce=h.shop.myWithdrawals.useQuery();h.member.profile.get.useQuery();const ie=h.member.kyc.get.useQuery(),oe=h.useUtils(),q=h.shop.requestWithdrawal.useMutation({onSuccess:()=>{u.success("提領申請已送出,我們將盡快審核您的申請"),c(!1),Se(),oe.shop.myReferralWallet.invalidate(),oe.shop.myWithdrawals.invalidate()},onError:t=>{u.error(`申請失敗:${t.message}`)}}),[D,O]=a.useState("idle"),G=D!=="idle",Ce=h.shop.memberUploadFile.useMutation(),H=async(t,l)=>{O("compressing");try{const v=await He(t,2097152);O("uploading");const y=await _e(v),N=await Ce.mutateAsync({fileName:t.name,fileBase64:y,contentType:v.type||"image/jpeg"}),W=N?.key||N?.url;W?(l(W),u.success("上傳成功")):u.error("上傳失敗")}catch{u.error("上傳失敗")}finally{O("idle")}},Se=()=>{f(""),B(!1),F(""),M(""),Q(""),I(""),P(""),E(""),z("")},Ue=()=>{c(!0)},R=re.data?.code||"",de=R?`${window.location.origin}/?ref=${R}`:"",w=le.data,U=w?Number(w.availableBalance):0,Le=w?Number(w.totalEarned):0,Ae=w?Number(w.totalWithdrawn):0,L=ne.data||[],_=ce.data||[],Te=$.data?.rewardRate??.02,$e=a.useMemo(()=>L.filter(t=>t.status==="waiting").reduce((t,l)=>t+Number(l.rewardAmount),0),[L]),xe=async(t,l)=>{try{await navigator.clipboard.writeText(t),l==="code"?(i(!0),setTimeout(()=>i(!1),2e3)):(s(!0),setTimeout(()=>s(!1),2e3)),u.success("已複製到剪貼簿")}catch{u.error("複製失敗")}},De=()=>{const t=Number(g);if(!t||t<=0){u.error("請輸入有效金額");return}const l=C||!me?{bankName:V||void 0,branchName:Y||void 0,bankAccount:Z||void 0,accountName:ee||void 0,idCardFrontUrl:te||void 0,idCardBackUrl:se||void 0,bankBookUrl:ae||void 0}:{};q.mutate({amount:t,...l})},r=ie.data,me=!!(r?.idCardFrontUrl&&r?.idCardBackUrl&&r?.bankBookUrl&&r?.bankAccount);return e.jsxs(Pe,{title:"推薦賺獎金",children:[$.isSuccess&&!S&&e.jsx("div",{className:"bg-yellow-50 border border-yellow-200 text-yellow-700 px-4 py-3 text-sm mb-4",children:"推薦活動目前未開放"}),S&&e.jsxs("div",{className:"bg-white border border-[#e5e5e5] p-6 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(pe,{className:"w-5 h-5 text-[#e8879b]"}),e.jsx("h3",{className:"text-sm font-bold text-[#333]",children:"我的推薦碼"})]}),re.isLoading?e.jsx(b,{className:"w-5 h-5 animate-spin text-[#999]"}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-[#f9f9f9] border border-[#e5e5e5] px-4 py-2.5 font-mono text-lg font-bold text-[#333] tracking-wider text-center",children:R}),e.jsx(A,{variant:"outline",size:"sm",onClick:()=>xe(R,"code"),className:"flex-shrink-0",children:n?e.jsx(ue,{className:"w-4 h-4"}):e.jsx(be,{className:"w-4 h-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-[#999] mb-1",children:"推薦連結"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-[#f9f9f9] border border-[#e5e5e5] px-3 py-2 text-xs text-[#666] truncate",children:de}),e.jsx(A,{variant:"outline",size:"sm",onClick:()=>xe(de,"link"),className:"flex-shrink-0",children:d?e.jsx(ue,{className:"w-4 h-4"}):e.jsx(be,{className:"w-4 h-4"})})]})]}),e.jsxs("p",{className:"text-[10px] text-[#999]",children:["分享推薦碼或連結給朋友,朋友完成訂單取貨後,您可獲得訂單實付金額 ",(Te*100).toFixed(0),"% 的獎金"]})]})]}),e.jsxs("div",{className:"bg-white border border-[#e5e5e5] p-6 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(je,{className:"w-5 h-5 text-[#e8879b]"}),e.jsx("h3",{className:"text-sm font-bold text-[#333]",children:"獎金錢包"})]}),le.isLoading?e.jsx(b,{className:"w-5 h-5 animate-spin text-[#999]"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-[#999] mb-1",children:"可用餘額"}),e.jsxs("p",{className:"text-xl font-bold text-[#333]",children:["NT$",U.toLocaleStr
11ing()]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-[#999] mb-1",children:"等待確認"}),e.jsxs("p",{className:"text-xl font-bold text-blue-600",children:["NT$",$e.toLocaleString()]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-[#999] mb-1",children:"累計獲得"}),e.jsxs("p",{className:"text-xl font-bold text-green-600",children:["NT$",Le.toLocaleString()]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-[#999] mb-1",children:"已提領"}),e.jsxs("p",{className:"text-xl font-bold text-[#999]",children:["NT$",Ae.toLocaleString()]})]})]}),e.jsxs(A,{onClick:Ue,disabled:U<1e3||!S,className:"w-full bg-[#e8879b] hover:bg-[#d4768a] text-white",children:["申請提領 ",U<1e3&&"(滿 NT$1,000 可申請)"]})]})]}),e.jsxs("div",{className:"bg-white border border-[#e5e5e5] mb-4",children:[e.jsxs("button",{onClick:()=>p(!x),className:"w-full flex items-center justify-between px-4 py-3 border-b border-[#f0f0f0] hover:bg-[#fafafa] transition-colors",children:[e.jsxs("h3",{className:"text-sm font-bold text-[#333]",children:["推薦紀錄 (",L.length,")"]}),x?e.jsx(Ne,{className:"w-4 h-4 text-[#999]"}):e.jsx(he,{className:"w-4 h-4 text-[#999]"})]}),x&&e.jsx(e.Fragment,{children:ne.isLoading?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(b,{className:"w-6 h-6 animate-spin text-[#999]"})}):L.length===0?e.jsxs("div",{className:"py-12 text-center",children:[e.jsx(pe,{className:"w-8 h-8 text-[#ddd] mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-[#999]",children:"尚無推薦紀錄"}),S&&e.jsx("p",{className:"text-xs text-[#ccc] mt-1",children:"分享推薦碼給朋友開始賺獎金"})]}):e.jsx("div",{className:"divide-y divide-[#f0f0f0]",children:L.map(t=>{const l=fe[t.status]||fe.pending,v=l.icon,y=Number(t.rewardAmount),N=Number(t.orderAmount),W=$.data?.confirmDays??8;let K=0;if(t.status==="waiting"&&t.pickedUpAt){const Re=new Date(t.pickedUpAt),X=new Date(Re);X.setDate(X.getDate()+W),K=Math.max(0,Math.ceil((X.getTime()-Date.now())/(1e3*60*60*24)))}return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${l.color}`,children:e.jsx(v,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-medium text-[#333]",children:["訂單 #",t.orderNumber]}),e.jsxs("p",{className:"text-[10px] text-[#999] mt-0.5",children:["訂單金額 NT$",N.toLocaleString()," · ",new Date(t.createdAt).toLocaleDateString("zh-TW")]}),t.status==="waiting"&&K>0&&e.jsxs("p",{className:"text-[10px] text-blue-500 mt-0.5",children:["預計 ",K," 天後確認"]})]}),e.jsxs("div",{className:"flex flex-col items-end flex-shrink-0",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${l.color}`,children:l.label}),e.jsxs("span",{className:`text-sm font-bold mt-1 ${t.status==="confirmed"?"text-green-600":t.status==="revoked"?"text-red-500":"text-[#999]"}`,children:["+NT$",y.toLocaleString()]})]})]},t.id)})})})]}),e.jsxs("div",{className:"bg-white border border-[#e5e5e5]",children:[e.jsxs("button",{onClick:()=>j(!m),className:"w-full flex items-center justify-between px-4 py-3 border-b border-[#f0f0f0] hover:bg-[#fafafa] transition-colors",children:[e.jsxs("h3",{className:"text-sm font-bold text-[#333]",children:["提領紀錄 (",_.length,")"]}),m?e.jsx(Ne,{className:"w-4 h-4 text-[#999]"}):e.jsx(he,{className:"w-4 h-4 text-[#999]"})]}),m&&e.jsx(e.Fragment,{children:ce.isLoading?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(b,{className:"w-6 h-6 animate-spin text-[#999]"})}):_.length===0?e.jsxs("div",{className:"py-12 text-center",children:[e.jsx(je,{className:"w-8 h-8 text-[#ddd] mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-[#999]",children:"尚無提領紀錄"})]}):e.jsx("div",{className:"divide-y divide-[#f0f0f0]",children:_.map(t=>{const l=we[t.status]||we.pending,v=Number(t.amount),y=Number(t.
11netAmount),N=Number(t.taxAmount);return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${t.status==="paid"?"bg-green-50":"bg-gray-50"}`,children:t.status==="paid"?e.jsx(Ge,{className:"w-4 h-4 text-green-600"}):e.jsx(Oe,{className:"w-4 h-4 text-gray-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-medium text-[#333]",children:["提領 NT$",v.toLocaleString()]}),e.jsxs("p",{className:"text-[10px] text-[#999] mt-0.5",children:[N>0?`稅額 NT$${N.toLocaleString()} · 實領 NT$${y.toLocaleString()}`:`免稅 · 實領 NT$${y.toLocaleString()}`," · ",new Date(t.requestedAt).toLocaleDateString("zh-TW")]}),t.adminNote&&e.jsxs("p",{className:"text-[10px] text-[#999] mt-0.5",children:["備註: ",t.adminNote]})]}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${l.color}`,children:l.label})]},t.id)})})})]}),e.jsx(We,{open:o,onOpenChange:c,children:e.jsxs(Be,{className:"max-w-md max-h-[90vh] overflow-y-auto",children:[e.jsx(Fe,{children:e.jsx(Me,{children:"申請提領獎金"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-[#f9f9f9] border border-[#e5e5e5] p-3 text-sm",children:[e.jsx("p",{className:"text-[#999]",children:"可用餘額"}),e.jsxs("p",{className:"text-lg font-bold text-[#333]",children:["NT$",U.toLocaleString()]})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-xs",children:"提領金額"}),e.jsx(T,{type:"number",value:g,onChange:t=>f(t.target.value),placeholder:"最低 1,000 元",min:1e3,max:U}),Number(g)>=2e4&&e.jsx("p",{className:"text-[10px] text-orange-500 mt-1",children:"單次提領 NT$20,000 以上需扣繳 10% 所得稅"})]}),e.jsx("div",{className:"border-t border-[#f0f0f0] pt-4",children:ie.isLoading?e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx(b,{className:"w-4 h-4 animate-spin text-[#999]"}),e.jsx("span",{className:"text-xs text-[#999]",children:"載入驗證資料..."})]}):me&&!C?e.jsxs("div",{className:"bg-green-50 border border-green-200 p-3 rounded",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"w-4 h-4 text-green-500"}),e.jsx("p",{className:"text-xs font-bold text-green-700",children:"已完成身份驗證"})]}),e.jsxs("button",{type:"button",className:"text-[10px] text-[#999] flex items-center gap-1 hover:text-[#333]",onClick:()=>{B(!0),F(r?.bankName||""),M(r?.branchName||""),Q(r?.bankAccount||""),I(r?.accountName||""),P(r?.idCardFrontUrl||""),E(r?.idCardBackUrl||""),z(r?.bankBookUrl||"")},children:[e.jsx(ze,{className:"w-3 h-3"}),"更新資料"]})]}),e.jsxs("p",{className:"text-xs text-green-700",children:[r?.bankName," ",r?.branchName?`${r.branchName} `:"","****",r?.bankAccount?.slice(-4)]}),e.jsx("p",{className:"text-[10px] text-green-600 mt-1",children:"本次提領將沿用已驗證的身份及銀行資料"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("p",{className:"text-xs font-bold text-[#333]",children:C?"更新身份驗證資料":"身份驗證 & 銀行帳戶"}),C&&e.jsx("button",{type:"button",className:"text-[10px] text-[#999] underline",onClick:()=>{B(!1)},children:"取消更新"})]}),!C&&e.jsxs("div",{className:"flex items-center gap-2 bg-amber-50 border border-amber-200 p-2 rounded mb-3",children:[e.jsx(ye,{className:"w-3.5 h-3.5 text-amber-500 flex-shrink-0"}),e.jsx("p",{className:"text-[10px] text-amber-700",children:"首次提領需上傳身份證正反面及銀行存摺封面"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-xs",children:"戶名"}),e.jsx(T,{value:ee,onChange:t=>I(t.target.value),placeholder:"請輸入戶名"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-xs",children:"銀行名稱"}),e.jsx(T,{value:V,onChange:t=>F(t.target.value),placeholder:"如:中國信託"})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-xs",children:"分行名稱"}),e.jsx(T,{value:Y,onChange:t=>M(t.target.value),placeholder:"如:忠孝分行"})]})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-xs",children:"銀行帳號"}),e.jsx(T,{value:Z,onChange:t=>Q(t.target.value),placeholder:"請輸入銀行帳號"})]}),e.jsx(J,{label:"身份證正面",value:te,onUpload:t=>H(t,P),uploading:G,uploadStatus:D}),e.jsx(J,{label:"身份證反面",value:se,onUpload:t=>H(t,E),uploading:G,uploadStatus:D}),e.jsx(J,{label:"銀行存摺封面",value:ae,onUpload:t=>H(t,z),uploading:G,uploadStatus:D})]})]})})]}),e.jsxs(Qe,{children:[e.jsx(A,{variant:"outline",onClick:()=>c(!1),children:"取消"}),e.jsxs(A,{onClick:De,disabled:q.isPending||!g||Number(g)<1e3,className:"bg-[#e8879b] hover:bg-[#d4768a] text-white",children:[q.isPending?e.jsx(b,{className:"w-4 h-4 animate-spin mr-1"}):null,"送出申請"]})]})]})})]})}function J({label:n,value:i,onUpload:d,uploading:s,uploadStatus:o}){const{url:c,isLoading:x}=Ie(i||null,!!i),p=o==="compressing"?"壓縮中...":o==="uploading"?"上傳中...":"點擊上傳";return e.jsxs("div",{children:[e.jsx(k,{className:"text-xs",children:n}),i?e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[x?e.jsx("div",{className:"w-16 h-10 border border-[#e5e5e5] rounded bg-gray-100 flex items-center justify-center",children:e.jsx(b,{className:"w-4 h-4 animate-spin text-[#999]"})}):e.jsx("img",{src:c??"",alt:n,className:"w-16 h-10 object-cover border border-[#e5e5e5] rounded"}),e.jsx("span",{className:"text-[10px] text-green-600",children:"已上傳"})]}):e.jsxs("label",{className:`flex items-center gap-2 mt-1 px-3 py-2 border border-dashed rounded transition-colors ${s?"border-[#e8879b] cursor-not-allowed":"border-[#ccc] cursor-pointer hover:border-[#999]"}`,children:[s?e.jsx(b,{className:"w-4 h-4 animate-spin text-[#e8879b]"}):e.jsx(qe,{className:"w-4 h-4 text-[#999]"}),e.jsx("span",{className:`text-xs ${s?"text-[#e8879b]":"text-[#999]"}`,children:p}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:s,onChange:m=>{const j=m.target.files?.[0];j&&!s&&d(j)}})]})]})}function He(n,i){return new Promise(d=>{if(n.size<=i){d(n);return}const s=new Image,o=URL.createObjectURL(n);s.onload=()=>{URL.revokeObjectURL(o);const c=document.createElement("canvas");let{width:x,height:p}=s,m=.85;const j=()=>{c.width=x,c.height=p,c.getContext("2d").drawImage(s,0,0,x,p),c.toBlob(f=>{if(!f){d(n);return}f.size<=i||m<=.3?d(new File([f],n.name,{type:"image/jpeg"})):(m>.5?m-=.15:(x=Math.floor(x*.8),p=Math.floor(p*.8)),j())},"image/jpeg",m)};j()},s.onerror=()=>{URL.revokeObjectURL(o),d(n)},s.src=o})}function _e(n){return new Promise((i,d)=>{const s=new FileReader;s.onload=()=>{const o=s.result,c=o.split(",")[1]||o;i(c)},s.onerror=d,s.readAsDataURL(n)})}
11export{bt as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.