Files
machartaa_admin_dist/dist/assets/index-13bfdaa0.js
T

2 lines
13 KiB
JavaScript
Raw Normal View History

import{_ as V}from"./button.vue_vue_type_style_index_0_lang-c84b0596.js";import{_ as Z}from"./BasicInput.vue_vue_type_style_index_0_lang-1e71e6d8.js";import{R as j,g as ee,i as O,d as B,u as M,E as R,h as E,o as m,c as I,b as c,e as p,w as f,k as S,l as a,W as ne,s as z,a0 as N,a1 as te,H as F,a2 as U,a as W,a3 as q,r as H,z as T,x as se,P as oe,a4 as ae,n as x,p as le,F as ue,q as ie,f as re}from"./index-88b436a3.js";import{n as de}from"./phone-6ff17ec0.js";import{u as ce,I as pe}from"./Icon-e9d21126.js";import{F as A,_ as D}from"./index-ad76e424.js";import{S as P}from"./index-77cb2497.js";import{_ as L,T as me}from"./index-3056cee8.js";import"./index-371b21ab.js";import"./_plugin-vue_export-helper-0965689e.js";import"./usePrice-bc935b83.js";import"./index-5b1d7174.js";import"./SearchOutlined-a51da12b.js";import"./omit-c69ba12d.js";import"./vnode-4c3cf924.js";import"./FormItemContext-0dc63d45.js";import"./isPlainObject-6af67cf0.js";import"./index-608635af.js";import"./isSymbol-5adcf314.js";import"./_flatRest-bfa472d2.js";import"./Col-dbdf0e50.js";import"./styleChecker-e121d19f.js";import"./toArray-20aa7010.js";import"./index-70730f49.js";import"./shallowequal-a265b4c4.js";import"./useState-89585daf.js";import"./useRefs-b589f2c4.js";import"./isMobile-e2e89480.js";const fe="/assets/logo-dd2a3541.png",ve=async e=>{const o=de(e.username),l=o.includes("@")?o:`${o}@example.com`;return await j.post("/auth/login-admin",{username:l,password:e.password})},ye=async e=>await j.post("/auth/login",e),he=async e=>await j.post("/auth/verify",e),G=ee("login",()=>{const e=O(""),o=O(null);return{mobile:e,id:o,setMobile:s=>{e.value=s},setId:s=>{o.value=s}}}),ge={class:"grid grid-cols-1 md:grid-cols-12 h-full bg-gradient"},_e={class:"md:col-span-3 flex justify-center items-center"},Oe={class:"min-h-[300px]"},we={key:1},be={key:1},Ie=c("div",{class:"md:col-span-9 md:flex md:justify-center md:items-center hidden"},[c("img",{src:fe,alt:"machartaa logo",class:"w-40vw"})],-1),ke=B({__name:"Panel",emits:["verify"],setup(e,{emit:o}){const l=O(0),t=O(!1),s=M(),v=R(),{prefixCls:g}=ce("login"),w=G(),u=E({username:"",password:""}),b=async i=>{var n,d,_,y;try{if(t.value=!0,i.username&&i.password){const h={...i,provider:"user"};console.log("Login payload:",h);const $=await ve(h);if(console.log("Login response:",$),(n=$==null?void 0:$.session)!=null&&n.access_token){await N($.session.access_token);try{await v.getMyInfo()}catch{te(),F.error("شما دسترسی ادمین ندارید");return}U(v.routePermissionKeys,s,v.isSuperAdmin);const r=W();await q(s,H(r.routes))}else F.error("توکن دریافتی نامعتبر است")}else F.error("وارد کردن تمامی فیلدها الزامی است")}catch(h){console.log("Login error:",h),console.log("Error response:",(d=h==null?void 0:h.response)==null?void 0:d.data),F.error(((y=(_=h==null?void 0:h.response)==null?void 0:_.data)==null?void 0:y.message)||"خطا در ورود به پنل کاربری")}finally{t.value=!1}},k=async i=>{try{if(t.value=!0,i.username!==""){w.setMobile(i.username);let n=await ye({...i,provider:"user"});w.setId(n.id),o("verify",!0)}else F.error("وارد کردن تمامی فیلدها الزامی است")}catch(n){console.log(n),F.error("خطا در ورود به پنل کاربری")}finally{t.value=!1}};return(i,n)=>{const d=Z,_=V;return m(),I("div",{class:z(["h-screen bg-image overflow-hidden",[`${a(g)}`]])},[c("div",ge,[c("div",_e,[c("div",Oe,[p(a(me),{activeKey:a(l),"onUpdate:activeKey":n[3]||(n[3]=y=>ne(l)?l.value=y:null)},{default:f(()=>[(m(),S(a(L),{tab:"ورود با شماره تلفن",key:0,"force-render":""},{default:f(()=>[p(a(A),{model:a(u),onFinish:b},{default:f(()=>[p(a(D),{label:"شماره تلفن",name:"username"},{default:f(()=>[p(d,{"place-holder":"مثال: 09123456789",value:a(u).username,"onUpdate:value":n[0]||(n[0]=y=>a(u).username=y)},null,8,["value"])]),_:1}),p(a(D),{label:"کلمه عبور",name:"password"},{default:f(()=>[p(d,{"is-password":"","place-holder":"کلمه عبور",value:a(u).password,"onUpdate:value":n[1]||(n[1]=y=>a(u).pa