Files
silk/miniapp/dist/pages/login/index.js
T

1 line
3.9 KiB
JavaScript

"use strict";(wx["webpackJsonp"]=wx["webpackJsonp"]||[]).push([[3],{1386:function(e,n,s){var a=s(8774),t=s(2688),i=s(5861),l=s(9439),o=s(7294),r=s(1515),u=s(2954),c=s.n(u),d={loginPage:"index-module__loginPage___GpNPu",header:"index-module__header___e8fXV",logo:"index-module__logo___BRHWC",title:"index-module__title___hfVnG",subtitle:"index-module__subtitle___QCYHJ",formCard:"index-module__formCard___usoTi",formItem:"index-module__formItem___sVXxY",formLabel:"index-module__formLabel___qvBRx",inputWrap:"index-module__inputWrap___eD55v",inputIcon:"index-module__inputIcon___Z6G9X",input:"index-module__input___IkOcz",loginButton:"index-module__loginButton___ZBTH7",loginButtonText:"index-module__loginButtonText___CAUoj",hint:"index-module__hint___HW7v8",defaultCred:"index-module__defaultCred___xRMGy"},_=s(8776),x=s(3851),m=s(5893),h=function(){var e=(0,o.useState)("admin"),n=(0,l.Z)(e,2),s=n[0],a=n[1],u=(0,o.useState)("silk@123"),h=(0,l.Z)(u,2),p=h[0],f=h[1],v=(0,o.useState)(!1),g=(0,l.Z)(v,2),j=g[0],N=g[1],b=(0,x.o)(),I=b.setAuth,T=b.token;(0,o.useEffect)(function(){T&&c().switchTab({url:"/pages/dashboard/index"})},[T]);var w=function(){var e=(0,i.Z)((0,t.Z)().m(function e(){var n,a;return(0,t.Z)().w(function(e){while(1)switch(e.p=e.n){case 0:if(s.trim()&&p.trim()){e.n=1;break}return c().showToast({title:"\u8bf7\u8f93\u5165\u8d26\u53f7\u548c\u5bc6\u7801",icon:"none"}),e.a(2);case 1:return N(!0),e.p=2,e.n=3,(0,_.x)({username:s.trim(),password:p});case 3:n=e.v,I(n.accessToken,n.refreshToken,n.user),console.log("[Auth] \u767b\u5f55\u6210\u529f:",n.user.username),c().showToast({title:"\u767b\u5f55\u6210\u529f",icon:"success"}),setTimeout(function(){c().switchTab({url:"/pages/dashboard/index"})},500),e.n=5;break;case 4:e.p=4,a=e.v,console.error("[Auth] \u767b\u5f55\u5931\u8d25:",a),c().showToast({title:a instanceof Error?a.message:"\u767b\u5f55\u5931\u8d25",icon:"none"});case 5:return e.p=5,N(!1),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(){return e.apply(this,arguments)}}();return(0,m.jsxs)(r.G7,{className:d.loginPage,children:[(0,m.jsxs)(r.G7,{className:d.header,children:[(0,m.jsx)(r.G7,{className:d.logo,children:(0,m.jsx)(r.xv,{children:"\ud83d\udc1b"})}),(0,m.jsx)(r.xv,{className:d.title,children:"\u8695\u623f\u73af\u5883\u76d1\u63a7"}),(0,m.jsx)(r.xv,{className:d.subtitle,children:"\u667a\u80fd\u8695\u4e1a\u73af\u5883\u76d1\u6d4b\u7ba1\u7406\u5e73\u53f0"})]}),(0,m.jsxs)(r.G7,{className:d.formCard,children:[(0,m.jsxs)(r.G7,{className:d.formItem,children:[(0,m.jsx)(r.xv,{className:d.formLabel,children:"\u8d26\u53f7"}),(0,m.jsxs)(r.G7,{className:d.inputWrap,children:[(0,m.jsx)(r.xv,{className:d.inputIcon,children:"\ud83d\udc64"}),(0,m.jsx)(r.II,{className:d.input,type:"text",placeholder:"\u8bf7\u8f93\u5165\u8d26\u53f7",value:s,onInput:function(e){return a(e.detail.value)},maxlength:50})]})]}),(0,m.jsxs)(r.G7,{className:d.formItem,children:[(0,m.jsx)(r.xv,{className:d.formLabel,children:"\u5bc6\u7801"}),(0,m.jsxs)(r.G7,{className:d.inputWrap,children:[(0,m.jsx)(r.xv,{className:d.inputIcon,children:"\ud83d\udd12"}),(0,m.jsx)(r.II,{className:d.input,password:!0,placeholder:"\u8bf7\u8f93\u5165\u5bc6\u7801",value:p,onInput:function(e){return f(e.detail.value)},maxlength:50})]})]}),(0,m.jsx)(r.zx,{className:d.loginButton,loading:j,disabled:j,onClick:w,children:(0,m.jsx)(r.xv,{className:d.loginButtonText,children:j?"\u767b\u5f55\u4e2d...":"\u767b \u5f55"})}),(0,m.jsxs)(r.G7,{className:d.hint,children:[(0,m.jsx)(r.xv,{children:"\u9ed8\u8ba4\u8d26\u53f7: "}),(0,m.jsx)(r.xv,{className:d.defaultCred,children:"admin"}),(0,m.jsx)(r.xv,{children:" / \u5bc6\u7801: "}),(0,m.jsx)(r.xv,{className:d.defaultCred,children:"silk@123"})]})]})]})},p=h,f={navigationBarTitleText:"\u767b\u5f55",navigationStyle:"custom"},v=(0,a.R4)(p,"pages/login/index",{root:{cn:[]}},f||{});p&&p.behaviors&&(v.behaviors=(v.behaviors||[]).concat(p.behaviors));Page(v)}},function(e){var n=function(n){return e(e.s=n)};e.O(0,[107,216,592],function(){return n(1386)});e.O()}]);