Files
appco_dist/.output/public/_nuxt/B4OzcThK.js
T
2026-02-01 17:38:39 +03:30

2 lines
3.7 KiB
JavaScript

import{_ as H}from"./SmRI6xj_.js";import{d as U,u as E,G as T,H as $,k as b,r as a,a3 as F,a4 as M,o as L,y as f,z as x,A as i,C as u,D as j,J as l,B as G,a2 as J,a0 as K,a1 as Q,F as W,S as X,a5 as Y,a6 as Z,a7 as ee,a8 as O,P as B,a9 as se}from"./D9_UoUeZ.js";import{B as oe}from"./iCGCN3gx.js";import{_ as te,P as ne}from"./NA5IDINt.js";import{u as ae}from"./B5ydF3Jh.js";import{C as le,_ as re,d as ie,c as de}from"./DJ52LMIS.js";import{d as ue,c as ce}from"./DmGSX4DV.js";import{u as pe}from"./BkNjFAoO.js";const me={class:"px-4 flex items-center justify-between"},fe={class:"flex gap-3 py-3 items-center"},ve={class:"font-semibold"},ge={class:"pt-15 overflow-y-auto userPostScroll h-95vh pb-3rem scrollHome"},we=U({__name:"index",async setup(_e){let c,y;const r=E(),d=T(),p=$(),v=b(()=>r.currentRoute.value.query.userId),m=a(),g=a(!1),_=a(!1),P=a(),h=a(),I=a(!1),s=ae(),k=b(()=>r.currentRoute.value.query.target||null);function D(t,e){try{if(I.value=!0,O())if(t){ie(e);const n=s.posts?.findIndex(o=>o.id===e);s.posts[n]?.likes.splice(s.posts[n]?.likes?.findIndex(o=>o.user_id===p.user.id))}else{de(e);const n=s.posts?.findIndex(o=>o.id===e);s.posts[n]?.likes.push({product_id:e,user_id:p.user.id})}else r.push({name:"auth-login"}),B.warn(d.useString("pleaseLoginOrRegister"))}catch(n){console.log(n)}finally{I.value=!1}}function N(t){s.posts[s.posts.findIndex(e=>e.id===m.value)]?.comments.push({id:t})}function R(){s.posts[s.posts.findIndex(t=>t.id===m.value)]?.comments.splice(0,1)}const C=a();F(C,async([{isIntersecting:t}])=>{if(t&&!s.loading&&!s.endPage){const e=s.currentPage+1,n=await s.loadPosts(v.value,e);s.loadStateNextPage(n)}});const{data:w}=([c,y]=M(async()=>pe("productPostMainSeller",async()=>s.posts.length===0?await s.loadPosts(v.value,1):null)),c=await c,y(),c);L(()=>{w.value&&s.loadStateNextPage(w.value)});function V(t,e){if(O())if(t){ue(e);const n=s.posts?.findIndex(o=>o.id===e);s.posts[n]?.saved.splice(s.posts[n]?.saved?.findIndex(o=>o.user_id===p.user.id))}else{ce(e);const n=s.posts?.findIndex(o=>o.id===e);s.posts[n]?.saved.push({product_id:e,user_id:p.user.id})}else r.push({name:"auth-login"}),B.warn(d.useString("pleaseLoginOrRegister"))}function A(t){P.value=t,_.value=!0}function q(t,e){m.value=t,g.value=!0,h.value=e}se("ownerPostId",h);function z(){const t=document.querySelector(".userPostScroll");if(k.value)document.getElementById("post-"+k.value)?.scrollIntoView({behavior:"instant",block:"start"}),r.replace({name:"posts",query:{userId:v.value}});else{let e=sessionStorage.getItem("scrollPositionSeller");t&&e&&(t.scrollTop=parseInt(e,10),sessionStorage.removeItem("scrollPositionSeller"))}}return L(()=>z()),(t,e)=>{const n=H;return f(),x("div",null,[i("div",{class:J(["z-20 fixed w-full top-0",l(d).isNightStore?"bg-header-color-dark ":"bg-header-color"])},[i("div",me,[i("div",fe,[u(n,null,{default:j(()=>[u(oe,{icon:l(d).isRTL?"vuesax-linear:arrow-right":"vuesax-linear:arrow-left",onClick:e[0]||(e[0]=o=>l(r).back())},null,8,["icon"])]),_:1}),i("div",ve,G(l(d).sellerConfig?.store?.username),1)])])],2),i("div",ge,[(f(!0),x(K,null,Q(l(s).posts,(o,S)=>(f(),x("div",{key:o.id||S,class:"tg-item",style:ee({transitionDelay:S*50+"ms"})},[u(ne,{index:S,post:o,onOpenOption:A,onOpenComment:q,onHandleLike:D,onHandleSave:V,"scroll-save":"scrollPositionSeller","add-like-loading":I.value},null,8,["index","post","add-like-loading"])],4))),128)),l(s).loading?(f(),W(te,{key:0})):X("",!0),Y(i("div",{ref_key:"observer",ref:C,class:"w-full opacity-1 relative"}," load ",512),[[Z,!l(s).loading]])]),u(le,{id:m.value,open:g.value,"onUpdate:open":e[1]||(e[1]=o=>g.value=o),onAddCommentId:N,onDeleteCommentId:R},null,8,["id","open"]),u(re,{id:P.value,open:_.value,"onUpdate:open":e[2]||(e[2]=o=>_.value=o)},null,8,["id","open"])])}}});export{we as _};