import{A as e,C as t,M as n,O as r,_ as i,a,b as o,f as s,g as c,k as l,l as u,m as d,o as f,p,s as m,w as h,x as g,y as _}from"./index-vhvNh9F8.js";var v={class:`page checkin-page`},y={class:`points-card`},b={class:`points-header`},x={class:`points-value`},S={class:`points-sub`},C={class:`highlight`},w={class:`checkin-action`},T=[`disabled`],E={key:0},D={key:1},O={key:0,class:`checkin-reward`},k={class:`reward-section`},A={class:`reward-grid`},j={class:`reward-days`},M={class:`reward-points`},N={class:`reward-desc`},P={class:`history-section`},F={key:0,class:`history-list`},I={class:`history-date`},L={class:`history-points`},R={key:1,class:`empty-hint`},z=m({__name:`Checkin`,setup(m){let z=u(),B=r({}),V=r({streak:0,checked_today:!1,records:[]}),H=[{days:1,points:5,desc:`首日签到`},{days:3,points:10,desc:`连续3天`},{days:7,points:30,desc:`连续7天`},{days:15,points:50,desc:`连续15天`},{days:30,points:100,desc:`连续30天`},{days:60,points:200,desc:`连续60天`}],U=p(()=>{let e=(V.value.streak||0)+1;for(let t=H.length-1;t>=0;t--)if(e>=H[t].days)return H[t].points;return 5});function W(e){let t=new Date(e);return`${t.getMonth()+1}月${t.getDate()}日`}async function G(){let e=localStorage.getItem(`token`);if(e)try{let t=await a.get(`/user/info`,{headers:{Authorization:`Bearer `+e}});t.code===0&&(B.value=t.data||{})}catch{}}async function K(){let e=localStorage.getItem(`token`);if(e)try{let t=await a.get(`/marketing/checkin/status`,{headers:{Authorization:`Bearer `+e}});t.code===0&&(V.value=t.data||{streak:0,checked_today:!1,records:[]})}catch{}}async function q(){let e=localStorage.getItem(`token`);if(!e){z.push(`/login`);return}try{let t=await a.post(`/marketing/checkin`,{},{headers:{Authorization:`Bearer `+e}});t.code===0?(alert(`🎉 签到成功！获得 ${t.data?.points||5} 积分`),K(),G()):alert(t.message||`签到失败`)}catch{alert(`网络错误`)}}return g(()=>{G(),K()}),(r,a)=>(t(),i(`div`,v,[o(f,{title:`每日签到`,onBack:a[0]||=e=>l(z).push(`/user`)}),d(`div`,y,[d(`div`,b,[a[1]||=d(`div`,{class:`points-label`},`我的积分`,-1),d(`div`,x,n(B.value.points||0),1)]),d(`div`,S,[a[2]||=_(` 已连续签到 `,-1),d(`span`,C,n(V.value.streak||0),1),a[3]||=_(` 天 `,-1)])]),d(`div`,w,[d(`button`,{class:e([`checkin-btn`,{checked:V.value.checked_today}]),onClick:q,disabled:V.value.checked_today},[V.value.checked_today?(t(),i(`span`,E,`✅ 今日已签到`)):(t(),i(`span`,D,`📅 立即签到`))],10,T),V.value.checked_today?c(``,!0):(t(),i(`div`,O,[a[4]||=_(` 今日签到可得 `,-1),d(`strong`,null,n(U.value),1),a[5]||=_(` 积分 `,-1)]))]),d(`div`,k,[a[6]||=d(`div`,{class:`section-title`},`连续签到奖励`,-1),d(`div`,A,[(t(),i(s,null,h(H,t=>d(`div`,{class:e([`reward-item`,{active:(V.value.streak||0)>=t.days,current:(V.value.streak||0)+1===t.days}]),key:t.days},[d(`div`,j,n(t.days)+`天`,1),d(`div`,M,`+`+n(t.points),1),d(`div`,N,n(t.desc),1)],2)),64))])]),d(`div`,P,[a[7]||=d(`div`,{class:`section-title`},`签到记录`,-1),V.value.records&&V.value.records.length>0?(t(),i(`div`,F,[(t(!0),i(s,null,h(V.value.records,e=>(t(),i(`div`,{class:`history-item`,key:e.id},[d(`div`,I,n(W(e.created_at)),1),d(`div`,L,`+`+n(e.points)+` 积分`,1)]))),128))])):(t(),i(`div`,R,`暂无签到记录`))])]))}},[[`__scopeId`,`data-v-dce951a4`]]);export{z as default};