1+ <template >
2+ <global-bg class =" site-wrapper site-page--login" >
3+ <template slot="content">
4+ <!-- <div class="sub-logo">
5+ <img src="../assets/logo.png" />
6+ </div>-->
7+ <div class =" site-content__wrapper" >
8+ <div class =" site-content" >
9+ <div class =" login-main" >
10+ <img class =" img" :src =" logo" />
11+ <a-form-model
12+ :model =" dataForm"
13+ :rules =" dataRule"
14+ ref =" dataForm"
15+ @keyup.enter.native =" dataFormSubmit()"
16+ status-icon
17+ :label-col =" labelCol"
18+ :wrapper-col =" wrapperCol"
19+ >
20+ <a-form-model-item prop =" username" >
21+ <a-input size =" large" v-model =" dataForm.username" placeholder =" 请输入用户名" ></a-input >
22+ </a-form-model-item >
23+ <a-form-model-item prop =" password" >
24+ <a-input
25+ size =" large"
26+ v-model =" dataForm.password"
27+ type =" password"
28+ placeholder =" 请输入密码"
29+ ></a-input >
30+ </a-form-model-item >
31+ <!-- <a-form-model-item prop="captcha">
32+ <a-row :gutter="20" style="display:flex;flex-flow: row nowrap;align-items: center;">
33+ <a-col :span="16">
34+ <a-input size="large" v-model="dataForm.captcha" placeholder="请输入验证码"></a-input>
35+ </a-col>
36+ <a-col :span="8" class="login-captcha">
37+ <img :src="captchaPath" @click="getCaptcha()" alt style="height: 38px;" />
38+ </a-col>
39+ </a-row>
40+ </a-form-model-item>-->
41+ <a-form-model-item :wrapper-col =" { span: 18, offset: 3 }" >
42+ <a-button
43+ size =" large"
44+ class =" login-btn-submit"
45+ type =" primary"
46+ @click =" dataFormSubmit"
47+ >登录</a-button >
48+ </a-form-model-item >
49+ </a-form-model >
50+ </div >
51+ </div >
52+ </div >
53+ <p class =" notice" >
54+ 建议使用Chrome浏览器(版本:
55+ <span style =" color :#1890ff " >84.0.4147.89</span >
56+ 及以上)在分辨率为
57+ <span style =" color :#1890ff " >1920x1080</span >
58+ 下访问本平台
59+ </p >
60+ </template >
61+ </global-bg >
62+ </template >
63+
64+ <script lang="ts">
65+ import uuid from " uuid/v1" ;
66+ import GlobalBg from " @/components/GlobalBg.vue" ;
67+ import { User } from " ./index" ; // 引入模块接口
68+ import { setToken } from " @/utils/token" ;
69+ import { UserModule } from " @/store/modules/user" ;
70+ import { login } from " @/api/users" ;
71+ import { Component , Vue } from " vue-property-decorator" ;
72+ import { FormModel , Row , Col , Button , Input } from " ant-design-vue" ;
73+
74+ @Component ({
75+ components: {
76+ AFormModel: FormModel ,
77+ AFormModelItem: FormModel .Item ,
78+ ARow: Row ,
79+ ACol: Col ,
80+ AButton: Button ,
81+ AInput: Input ,
82+ GlobalBg
83+ }
84+ })
85+ export default class Login extends Vue {
86+ // initial data
87+ private labelCol: object = { span: 4 };
88+ private wrapperCol: object = { span: 18 , offset: 3 };
89+ private captchaPath: string = " " ;
90+ private logo: string = " " ;
91+ private dataRule: any = {
92+ username: [{ required: true , message: " 用户名不能为空" , trigger: " blur" }],
93+ password: [{ required: true , message: " 密码不能为空" , trigger: " blur" }],
94+ captcha: [{ required: true , message: " 验证码不能为空" , trigger: " blur" }]
95+ };
96+ private dataForm: User .Login = {
97+ username: " " ,
98+ password: " " ,
99+ captcha: " " ,
100+ uuid: " "
101+ };
102+
103+ mounted() {
104+ this .$nextTick (() => {
105+ this .getCaptcha ();
106+ });
107+ }
108+
109+ // login提交
110+ private dataFormSubmit() {
111+ (this .$refs [" dataForm" ] as FormModel ).validate (async (valid : boolean ) => {
112+ if (valid ) {
113+ try {
114+ let { data } = await login (this .dataForm );
115+ // 将token存储到store
116+ UserModule .SET_TOKEN (data .token );
117+ // 将token存储到sessionStorage
118+ setToken (data .token );
119+ sessionStorage .setItem (" userInfo" , JSON .stringify (data [" userInfo" ]));
120+ window .location .href = " /control" ;
121+ } catch (error ) {
122+ this .getCaptcha ();
123+ }
124+ }
125+ });
126+ }
127+
128+ // 加载验证码
129+ private getCaptcha() {
130+ this .dataForm .uuid = uuid ();
131+ this .captchaPath = ` /dbd-authority/captcha.jpg?uuid=${this .dataForm .uuid } ` ;
132+ }
133+ }
134+ </script >
135+
136+ <style lang="less" scope>
137+ .site-wrapper.site-page--login {
138+ .notice {
139+ position : absolute ;
140+ bottom : 10px ;
141+ font-size : 13px ;
142+ color : rgba (255 , 255 , 255 , 0.8 );
143+ width : 100% ;
144+ text-align : center ;
145+ }
146+ .sub-logo {
147+ position : absolute ;
148+ width : 100px ;
149+ height : 64px ;
150+ top : 20px ;
151+ left : 20px ;
152+ img {
153+ height : 100% ;
154+ width : 100% ;
155+ }
156+ }
157+ & :before {
158+ position : fixed ;
159+ top : 0 ;
160+ left : 0 ;
161+ z-index : -1 ;
162+ width : 100% ;
163+ height : 100% ;
164+ content : " " ;
165+ // background-image: url(~@/assets/img/bgc.jpg);
166+ background-size : cover ;
167+ }
168+ .site-content__wrapper {
169+ margin : 0 auto ;
170+ align-self : center ;
171+ .site-content {
172+ min-height : 100% ;
173+ padding : 30px ;
174+ }
175+ }
176+
177+ .login-main {
178+ padding : 10px ;
179+ min-height : 100% ;
180+ min-width : 520px ;
181+ .img {
182+ width : 500px ;
183+ margin-bottom : 46px ;
184+ }
185+ // opacity: 0.9;
186+ }
187+ .login-title {
188+ font-size : 22px ;
189+ font-weight : 700 ;
190+ color : #fff ;
191+ text-align : center ;
192+ margin-bottom : 15px ;
193+ }
194+ .login-captcha {
195+ overflow : hidden ;
196+ > img {
197+ width : 100% ;
198+ cursor : pointer ;
199+ }
200+ }
201+ .login-btn-submit {
202+ width : 100% ;
203+ margin-top : 15px ;
204+ }
205+ .ant-form-item-label > label {
206+ font-weight : 800 ;
207+ color : #fff !important ;
208+ font-size : 16px !important ;
209+ display : flex ;
210+ justify-content : space-between ;
211+ }
212+ .ant-form-item-required ::before {
213+ margin-top : 15px ;
214+ }
215+ }
216+ </style >
0 commit comments