Files
machartaa_admin_dist/dist/assets/index-9dca680c.js
T

2 lines
12 KiB
JavaScript
Raw Normal View History

2026-06-15 11:54:19 +03:30
import{_ as L}from"./button.vue_vue_type_style_index_0_lang-9d5d26a1.js";import{_ as Q}from"./BasicInput.vue_vue_type_style_index_0_lang-fac93654.js";import{H as X,N as V,f as Y,g as w,d as D,u as M,z as E,r as N,o as p,c as I,a as d,b as c,w as f,i as $,j as o,x as Z,p as R,a4 as z,a5 as ee,C as F,a6 as U,K as T,v as ne,a7 as te,a8 as se,k as W,l as ae,F as oe,n as le,e as ue}from"./index-96107119.js";import{n as ie}from"./phone-6ff17ec0.js";import{u as re,I as de}from"./Icon-10f11b08.js";import{F as P,_ as B}from"./index-c0db17f3.js";import{S as A}from"./index-3de84383.js";import{a as K,T as ce}from"./index-32cbef66.js";import"./_plugin-vue_export-helper-081dcfd4.js";import"./usePrice-7afab779.js";import"./index-6f043c51.js";import"./FormItemContext-dc7be399.js";import"./vnode-e147c015.js";import"./isPlainObject-4f3f1958.js";import"./shallowequal-7fda91ae.js";import"./Col-5c28624e.js";import"./toArray-b1390e28.js";import"./useState-00a24a9a.js";import"./useRefs-e24ee44c.js";const pe="/assets/logo-dd2a3541.png",me=async e=>{const a=ie(e.username),{data:l,error:n}=await X.auth.signInWithPassword({email:`${a}@example.com`,password:e.password});if(n)throw n;return l},fe=async e=>await V.post("/auth/login",e),ve=async e=>await V.post("/auth/verify",e),H=Y("login",()=>{const e=w(""),a=w(null);return{mobile:e,id:a,setMobile:s=>{e.value=s},setId:s=>{a.value=s}}}),ye={class:"grid grid-cols-1 md:grid-cols-12 h-full bg-gradient"},he={class:"md:col-span-3 flex justify-center items-center"},ge={class:"min-h-[300px]"},_e={key:1},we={key:1},Oe=d("div",{class:"md:col-span-9 md:flex md:justify-center md:items-center hidden"},[d("img",{src:pe,alt:"machartaa logo",class:"w-40vw"})],-1),be=D({__name:"Panel",emits:["verify"],setup(e,{emit:a}){const l=w(0),n=w(!1),s=M(),y=E(),{prefixCls:g}=re("login"),O=H(),u=N({username:"",password:""}),b=async i=>{var t,m,_,v;try{if(n.value=!0,i.username&&i.password){const h={...i,provider:"user"};console.log("Login payload:",h);const S=await me(h);if(console.log("Login response:",S),(t=S==null?void 0:S.session)!=null&&t.access_token){await z(S.session.access_token);try{await y.getMyInfo()}catch{ee(),F.error("شما دسترسی ادمین ندارید");return}U(y.routePermissionKeys,s,y.isSuperAdmin),await s.push({name:"dashboard"})}else F.error("توکن دریافتی نامعتبر است")}else F.error("وارد کردن تمامی فیلدها الزامی است")}catch(h){console.log("Login error:",h),console.log("Error response:",(m=h==null?void 0:h.response)==null?void 0:m.data),F.error(((v=(_=h==null?void 0:h.response)==null?void 0:_.data)==null?void 0:v.message)||"خطا در ورود به پنل کاربری")}finally{n.value=!1}},k=async i=>{try{if(n.value=!0,i.username!==""){O.setMobile(i.username);let t=await fe({...i,provider:"user"});O.setId(t.id),a("verify",!0)}else F.error("وارد کردن تمامی فیلدها الزامی است")}catch(t){console.log(t),F.error("خطا در ورود به پنل کاربری")}finally{n.value=!1}};return(i,t)=>{const m=Q,_=L;return p(),I("div",{class:R(["h-screen bg-image overflow-hidden",[`${o(g)}`]])},[d("div",ye,[d("div",he,[d("div",ge,[c(o(ce),{activeKey:o(l),"onUpdate:activeKey":t[3]||(t[3]=v=>Z(l)?l.value=v:null)},{default:f(()=>[(p(),$(o(K),{tab:"ورود با شماره تلفن",key:0,"force-render":""},{default:f(()=>[c(o(P),{model:o(u),onFinish:b},{default:f(()=>[c(o(B),{label:"شماره تلفن",name:"username"},{default:f(()=>[c(m,{"place-holder":"مثال: 09123456789",value:o(u).username,"onUpdate:value":t[0]||(t[0]=v=>o(u).username=v)},null,8,["value"])]),_:1}),c(o(B),{label:"کلمه عبور",name:"password"},{default:f(()=>[c(m,{"is-password":"","place-holder":"کلمه عبور",value:o(u).password,"onUpdate:value":t[1]||(t[1]=v=>o(u).password=v)},null,8,["value"])]),_:1}),c(o(B),null,{default:f(()=>[c(_,{class:"mt-5 w-full",disabled:o(n),type:"primary","html-type":"submit"},{default:f(()=>[d("div",null,[o(n)?(p(),$(o(A),{key:0,size:"small"})):(p(),I("div",_e,"ورود"))])]),_:1},8,["disabled"])]),_:1})]),_:1},8,["model"]