3636 </el-form-item >
3737 <!-- 按钮区域 -->
3838 <el-form-item class =" btns" >
39- <el-button type =" primary" @click =" login" >登录</el-button >
39+ <el-button type =" primary" @click =" login" :loading = " loginLoading " >登录</el-button >
4040 <el-button type =" info" @click =" resetLoginForm" >重置</el-button >
4141 </el-form-item >
4242 </el-form >
@@ -106,6 +106,7 @@ export default {
106106 },
107107 ],
108108 },
109+ loginLoading: false
109110 };
110111 },
111112 methods: {
@@ -119,32 +120,44 @@ export default {
119120 if (! valid) {
120121 return ;
121122 }
123+ this .loginLoading = true ;
124+ // 进行md5加密
125+ const salt = " xiaobaitiao" ;
126+ const username = this .loginForm .username ;
127+ const password = CryptoJS .MD5 (
128+ salt + this .loginForm .password
129+ ).toString ();
122130 // 向数据库发送axios请求,如果登录成功,就跳转
123- const {data: res } = await this .$http .post (' bookadmin/login' ,this .loginForm )
131+ const { data: res } = await this .$http .post (" bookadmin/login" , {
132+ username,
133+ password,
134+ });
124135 // console.log(res);
125- if (res .status !== 200 ){
126- return this .$message .error (res .msg );
127- }
128- this .$message .success (' 登录成功' )
129- window .sessionStorage .setItem (' token' ,res .map .token )
130- window .sessionStorage .setItem (' bookAdminId' ,res .map .id )
131- this .$router .push (' /homemange' )
136+ if (res .status !== 200 ) {
137+ this .loginLoading = false ;
138+ return this .$message .error (res .msg );
139+ }
140+ this .$message .success (" 登录成功" );
141+ this .loginLoading = false ;
142+ window .sessionStorage .setItem (" token" , res .map .token );
143+ window .sessionStorage .setItem (" bookAdminId" , res .map .id );
144+ this .$router .push (" /homemange" );
132145 // window.sessionStorage.setItem("token", token);
133146 // this.$router.push("/home"); //跳转到home页面下
134147 });
135148 },
136- goUser (){
137- this .$router .push (' /login' );
149+ goUser () {
150+ this .$router .push (" /login" );
151+ },
152+ goAdmin () {
153+ this .$router .push (" /loginadmin" );
138154 },
139- goAdmin (){
140- this .$router .push (' /loginadmin' );
141- }
142155 },
143156};
144157 </script >
145158
146159 <style lang="less" scoped>
147- .footer2 {
160+ .footer2 {
148161 position : absolute ;
149162 bottom : 0px ;
150163 left : 45% ;
@@ -155,8 +168,8 @@ export default {
155168}
156169.login_container {
157170 // background-color: #2b4b6b;
158- background : url(http://xxx.xiaobaitiao.club/img/digitalCityMin.png )
159- no-repeat 0px 0px ;
171+ background : url(http://xxx.xiaobaitiao.club/img/digitalCityMin.png ) no-repeat
172+ 0px 0px ;
160173 background-size : cover ;
161174 height : 100% ;
162175}
0 commit comments