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