var _=(e,t,o)=>new Promise((s,n)=>{var r=a=>{try{i(o.next(a))}catch(c){n(c)}},p=a=>{try{i(o.throw(a))}catch(c){n(c)}},i=a=>a.done?s(a.value):Promise.resolve(a.value).then(r,p);i((o=o.apply(e,t)).next())});import{_ as v,c as w,w as C,h as m,r as V,s as g,g as y,u as d,a as l,b as N,d as h,e as f,n as $,f as L,o as b,i as k,j as I,l as S,q as T,I as D,v as M}from"./index-CZJgrp0v.js";import{s as u}from"./toast.CufGEC2G.js";const q={name:"Login",data(){return{studentId:"",isLoading:!1,errorMessage:"",userStore:d()}},computed:{isLogin(){return d().isLogin}},mounted(){return _(this,null,function*(){try{N({title:"登录中"});const e=h(),t=d(),o=e.query.token,s=e.query.redirect;if(console.log({urlObj:e,userStore:t,mpHome:t.mpHome}),o&&(yield this.userStore.setCode(o))===200){yield l().initData(),f({url:s||"/pages/tabbar/home/index"}),delete e.query.token;return}if(this.userStore.isLogin){yield l().initData();const r=h().query.redirect;f({url:r||"/pages/tabbar/home/index"})}else $({logText:"login.vue",isForceLogout:!0})}catch(e){console.log({error:e})}finally{m()}})},methods:{handleLogin(){return _(this,null,function*(){if(!this.studentId.trim()){this.errorMessage="请输入学生ID";return}this.isLoading=!0,this.errorMessage="";try{const e=yield y(this.studentId);if(e.code===0){const t=d();yield t.setToken(e.data.token),t.userInfo=e.data,u("登录成功"),yield l().initData(),this.handleRedirect()}else this.errorMessage=e.msg||"登录失败，请检查学生ID",u(this.errorMessage,"none")}catch(e){console.error("登录失败:",e),this.errorMessage="登录异常，请稍后重试",u(this.errorMessage)}finally{this.isLoading=!1}})},handleRedirect(){const t=(this.$route.query||{}).redirect;t?V({url:decodeURIComponent(t),fail:()=>{g({url:decodeURIComponent(t)})}}):g({url:"/pages/tabbar/home/index"})}},onLoad(){this.errorMessage="",m()}};function B(e,t,o,s,n,r){const p=S,i=I,a=T,c=D,j=M,x=L("layout-default-uni");return b(),w(x,null,{default:C(()=>[k("",!0)]),_:1})}const G=v(q,[["render",B],["__scopeId","data-v-fc9efaed"]]);export{G as default};
