2 lines
6.3 KiB
JavaScript
2 lines
6.3 KiB
JavaScript
import{d as w,C as u,dy as q,a2 as P,J as L,k as U,r as h,a1 as j,o as N,y as g,z as c,a3 as H,e3 as V,af as F,a4 as y,A as l,B as S,u as O,G as E,d7 as G,e4 as J,e5 as K,S as Q,H as p,F as k,D as X,ak as Y,U as Z,e6 as ee}from"./UdOyBpMP.js";import{b as x,c as b,h as R,w as $,m as z,k as te,t as W,l as ae}from"./DYx1ck_T.js";import{s as se}from"./zStr3CH7.js";import{B as A}from"./j0GddizS.js";import{U as re}from"./Ci8_aquE.js";import{B as ne}from"./MR5gpPl5.js";import{_ as D}from"./DlAUqK2U.js";import"./DWEdiVkG.js";import"./Bo4eekoy.js";import"./C9wgtwsA.js";import"./GUCsZWHE.js";import"./BZQsegbX.js";import"./BkHRfldW.js";import"./CXuQDmsx.js";import"./DbfF5PD3.js";import"./D6qJbdzf.js";import"./B6Dbx7FY.js";const[oe,ie]=b("skeleton-title"),le={round:Boolean,titleWidth:x};var ue=w({name:oe,props:le,setup(e){return()=>u("h3",{class:ie([{round:e.round}]),style:{width:R(e.titleWidth)}},null)}});const ce=$(ue);var de=ce;const[ve,me]=b("skeleton-avatar"),fe={avatarSize:x,avatarShape:z("round")};var he=w({name:ve,props:fe,setup(e){return()=>u("div",{class:me([e.avatarShape]),style:te(e.avatarSize)},null)}});const _e=$(he);var pe=_e;const T="100%",ge={round:Boolean,rowWidth:{type:x,default:T}},[we,ye]=b("skeleton-paragraph");var ke=w({name:we,props:ge,setup(e){return()=>u("div",{class:ye([{round:e.round}]),style:{width:e.rowWidth}},null)}});const xe=$(ke);var Se=xe;const[be,I]=b("skeleton"),Ce="60%",$e={row:ae(0),round:Boolean,title:Boolean,titleWidth:x,avatar:Boolean,avatarSize:x,avatarShape:z("round"),loading:W,animate:W,rowWidth:{type:[Number,String,Array],default:T}};var Te=w({name:be,inheritAttrs:!1,props:$e,setup(e,{slots:i,attrs:s}){const m=()=>{if(e.avatar)return u(pe,{avatarShape:e.avatarShape,avatarSize:e.avatarSize},null)},d=()=>{if(e.title)return u(de,{round:e.round,titleWidth:e.titleWidth},null)},f=n=>{const{rowWidth:t}=e;return t===T&&n===+e.row-1?Ce:Array.isArray(t)?t[n]:t},r=()=>Array(+e.row).fill("").map((n,t)=>u(Se,{key:t,round:e.round,rowWidth:R(f(t))},null)),_=()=>i.template?i.template():u(P,null,[m(),u("div",{class:I("content")},[d(),r()])]);return()=>{var n;return e.loading?u("div",q({class:I({animate:e.animate,round:e.round})},s),[_()]):(n=i.default)==null?void 0:n.call(i)}}});const Be="data:image/svg+xml,%3csvg%20width='22'%20height='20'%20viewBox='0%200%2022%2020'%20fill='white'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M21.0031%201H1.00311L8.50311%208.5M21.0031%201L10.5031%2018.5L8.50311%208.5M21.0031%201L8.50311%208.5'%20stroke='%23733af9'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",We={class:"message-bubble"},Ae={class:"time"},Ie=w({__name:"Conversation",props:{chatId:{}},setup(e,{expose:i}){const s=e,m=L(),d=U(()=>m.user),f=h([]),r=h(null),_=v=>new Date(v).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});async function n(){if(!s.chatId)return;const v=await V(s.chatId,1,1e3);f.value=Array.isArray(v)?v:v.data||[]}function t(){r.value&&F(()=>{const v=r.value;v.scrollTo({top:v.scrollHeight,behavior:"smooth"})})}return j(f,()=>{t()}),i({request:n,scrollToBottom:t}),N(async()=>{await n()}),(v,o)=>(c(),g("div",{class:"chat-container",ref_key:"chatContainer",ref:r},[(c(!0),g(P,null,H(f.value,a=>(c(),g("div",{key:a.id,class:y(["message",{sent:a.sender_id===d.value.id,received:a.sender_id!==d.value.id}])},[l("div",We,[l("p",null,S(a.text),1),l("span",Ae,S(_(a.created_at)),1)])],2))),128))],512))}}),Pe=D(Ie,[["__scopeId","data-v-3b999e95"]]),Le={class:"flex justify-between items-center w-full p4"},Ue={class:"flex items-center gap-5"},Ne={key:0,class:"flex gap-24px items-center"},Re={class:"font-semibold flex items-center"},ze={class:"flex font-200 text-xs items-center"},De={dir:"ltr",class:"h-98vh pb-10 overflow-hidden"},Me=["alt"],qe=w({__name:"index",setup(e){const i=O(),s=E(),m=L(),d=h(""),f=h(null),r=h(void 0);U(()=>s.sellerConfig?.store?.main&&m.user.id!==s.sellerConfig?.store?.id);const _=h(!1),n=h(!1),t=h(void 0);N(async()=>{try{if(_.value=!0,i.currentRoute.value.query?.id?.length){const o=await G(i.currentRoute.value.query?.id);m.user.id===o?.user1_id?r.value=o?.user2:o.user1&&(r.value=o?.user1),t.value={chat_id:i.currentRoute.value.query.id}}else{const o=i.currentRoute.value.query?.user_id??s.sellerConfig?.store?.id,a=await J(o,m.user.id);if(a?.length)t.value=a[0];else{const C=await K(o,m.user.id);t.value=C}m.user.id===t.value?.user1_id?r.value=t.value?.user2:t.value.user1&&(r.value=t.value?.user1)}}catch(o){console.log("e ===>",o)}finally{_.value=!1}});const v=async()=>{if(d.value.length)try{n.value=!0;const o=await ee(t.value.chat_id,d.value);await f.value.request(),f.value.scrollToBottom(),setTimeout(()=>{d.value=""},100)}catch(o){console.log("e ===>",o)}finally{n.value=!1}};return(o,a)=>{const C=Te,M=se;return c(),g("div",null,[l("div",{class:y(["fixed top-0 w-inherit right-0 left-0",p(s).isNightStore?"bg-black":"bg-white"])},[l("div",Le,[l("div",Ue,[u(A,{icon:p(s).isRTL?"vuesax-linear:arrow-right":"vuesax-linear:arrow-left",onClick:a[0]||(a[0]=B=>p(i).back())},null,8,["icon"]),r.value?.id?(c(),g("div",Ne,[u(re,{width:"40",src:r.value?.avatar,justShowProfile:""},null,8,["src"]),l("div",null,[l("div",Re,S(r.value?.name),1),l("div",ze,S(r.value?.username),1)])])):Q("",!0)]),a[2]||(a[2]=l("div",{class:"flex w-fit gap-4 h-1.3rem items-center"},null,-1))])],2),l("div",De,[_.value?(c(),k(C,{key:0})):(c(),k(Pe,{key:1,ref_key:"conversation",ref:f,chatId:t.value?.chat_id},null,8,["chatId"]))]),l("div",{class:y(["fixed bottom-0 w-inherit right-0 left-0 p-3",p(s).isNightStore?"bg-black":"bg-white"])},[l("div",{class:y(["flex items-center gap-5 rounded-full px-2",p(s).isNightStore?"bg-gray-700":"bg-gray-100"])},[u(ne,{value:d.value,"onUpdate:value":a[1]||(a[1]=B=>d.value=B),"place-holder":`${p(s).useString("message")}...`,class:"!rounded-full border-transparent !bg-transparent message-placeholder !py-3 flex-1",rows:1},null,8,["value","place-holder"]),u(Z,{name:"fade",mode:"out-in"},{default:X(()=>[d.value===""?(c(),k(A,{key:0,icon:"vuesax-linear:add-circle"})):(c(),g("div",{key:1,class:y(["w-4rem h-2rem bg-#733af9 flex items-center rounded-full p-1 pt-2 text-white justify-center",{"bg-gray-500":n.value}]),onClick:v},[n.value?(c(),k(M,{key:1,class:"!text-white",type:"spinner",size:"20px"})):(c(),g("img",{key:0,src:Be,alt:p(Y),class:"h-full rtl:-scale-x-100"},null,8,Me))],2))]),_:1})],2)],2)])}}}),je=D(qe,[["__scopeId","data-v-61d04548"]]),nt=w({__name:"detail_message",setup(e){return(i,s)=>(c(),k(je))}});export{nt as default};
|