appointment_system/miniprogram/dist/build/h5/assets/pages-login-login-page.440b1f8e.js
2025-12-19 00:37:31 +08:00

2 lines
4.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{_ as e,k as o,l as a,m as s,p as t,q as i,u as n,n as l,C as c,o as r,c as g,w as d,v as u,i as h,e as m,f,t as p,x as k,g as T,h as _,y as L}from"./index-a09151d6.js";import{A as C}from"./AppServer.888fd24d.js";import{s as y}from"./auth.b970b80f.js";import{_ as b}from"./ic_back.5440bd15.js";const x=e({data:()=>({isLoading:!1,agreeToTerms:!1,statusBarHeight:0,appLogo:""}),onLoad(){const e=o();this.statusBarHeight=e.statusBarHeight||0,this.loadConfig()},methods:{back(){a({delta:1})},async handleWechatLogin(){if(!this.isLoading)if(this.agreeToTerms){this.isLoading=!0;try{const e=await this.getWechatLoginCode();if(console.log("微信登录 code:",e),!e||!e.code)return s({title:this.$t("login.wechatLoginFailed"),icon:"none"}),void(this.isLoading=!1);const o=new C,a=await o.WechatLogin(e.code);if(console.log("登录接口返回:",a),!a)return console.error("登录接口无响应"),s({title:this.$t("login.loginFailed"),icon:"none"}),void(this.isLoading=!1);if(0!==a.code)return console.error("登录失败code:",a.code,"message:",a.message),s({title:a.message||this.$t("login.loginFailed"),icon:"none"}),void(this.isLoading=!1);if(!a.data||!a.data.token)return console.error("Token 数据缺失:",a.data),s({title:this.$t("login.loginFailed"),icon:"none"}),void(this.isLoading=!1);console.log("登录成功,保存认证信息");const t="Bearer "+a.data.token;y(t,a.data.refreshToken,a.data.user),s({title:this.$t("login.loginSuccess")||"登录成功",icon:"success",duration:1500}),setTimeout(()=>{this.redirectToHome()},500)}catch(e){console.error("登录异常:",e),console.error("错误堆栈:",e.stack),s({title:this.$t("login.loginError")+": "+(e.message||""),icon:"none",duration:3e3})}finally{this.isLoading=!1}}else s({title:this.$t("login.mustAgreeToTerms"),icon:"none"})},getWechatLoginCode:()=>new Promise((e,o)=>{t({provider:"weixin",success:o=>{e(o)},fail:e=>{console.error("uni.login 失败:",e),o(e)}})}),redirectToHome(){const e=u();e.globalData&&(e.globalData.shouldRefresh=!0,e.globalData.loginTime=Date.now()),i({url:"/pages/index/index",success:()=>{console.log("登录成功,已跳转到首页")},fail:e=>{console.error("跳转首页失败:",e),n({url:"/pages/index/index"})}})},toggleAgreement(){this.agreeToTerms=!this.agreeToTerms},goToUserAgreement(){l({url:"/pages/me/user-agreement-page"})},goToPrivacyPolicy(){l({url:"/pages/me/privacy-policy-page"})},async loadConfig(){try{const e=await c.getPublicConfig();e.app_logo&&(this.appLogo=c.getImageUrl(e.app_logo))}catch(e){console.error("加载配置失败:",e)}}}},[["render",function(e,o,a,s,t,i){const n=T,l=h,c=_,u=L;return r(),g(l,{class:"login-container"},{default:d(()=>[m(l,{class:"header-row"},{default:d(()=>[m(l,{class:"back-button",onClick:i.back},{default:d(()=>[m(n,{src:b,class:"back-icon"})]),_:1},8,["onClick"]),m(c,{class:"title"},{default:d(()=>[f(p(e.$t("login.title")),1)]),_:1}),m(l,{class:"back-button",onClick:e.markAllRead},null,8,["onClick"])]),_:1}),m(l,{class:"logo-section"},{default:d(()=>[m(l,{class:"logo-box"},{default:d(()=>[t.appLogo?(r(),g(n,{key:0,src:t.appLogo,class:"logo-image",mode:"aspectFit"},null,8,["src"])):(r(),g(c,{key:1,class:"logo-text"},{default:d(()=>[f("LOGO")]),_:1}))]),_:1})]),_:1}),m(l,{class:"main-content"},{default:d(()=>[m(u,{class:"login-button",onClick:i.handleWechatLogin,loading:t.isLoading},{default:d(()=>[f(p(e.$t("login.oneClickLogin")),1)]),_:1},8,["onClick","loading"]),m(l,{class:"agreement-section"},{default:d(()=>[m(l,{class:"agreement-label",onClick:i.toggleAgreement},{default:d(()=>[m(n,{src:t.agreeToTerms?"/static/ic_checked.png":"/static/ic_check.png",class:"check-icon"},null,8,["src"]),m(c,{class:"agreement-text"},{default:d(()=>[f(p(e.$t("login.agreeToTerms"))+" ",1),m(c,{class:"link-text",onClick:k(i.goToUserAgreement,["stop"])},{default:d(()=>[f(p(e.$t("login.userAgreement")),1)]),_:1},8,["onClick"]),f(" "+p(e.$t("login.and"))+" ",1),m(c,{class:"link-text",onClick:k(i.goToPrivacyPolicy,["stop"])},{default:d(()=>[f(p(e.$t("login.privacyPolicy")),1)]),_:1},8,["onClick"])]),_:1})]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1})}],["__scopeId","data-v-f67ad6c1"]]);export{x as default};