|
@@ -1,38 +1,38 @@
|
|
|
-import { mapMutations } from 'vuex'
|
|
|
+import { mapMutations} from 'vuex'
|
|
|
export default {
|
|
|
- data () {
|
|
|
+ data() {
|
|
|
return {
|
|
|
- username: '',
|
|
|
- password: '',
|
|
|
+ loginForm:{
|
|
|
+ username:'',
|
|
|
+ password:'',
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
},
|
|
|
components: {
|
|
|
},
|
|
|
- created () {
|
|
|
+ created() {
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
methods: {
|
|
|
...mapMutations("user", ["SET_TOKEN"]),
|
|
|
- login () {
|
|
|
+ login(){
|
|
|
var digital = new URLSearchParams();
|
|
|
- digital.append("username", "admin"),
|
|
|
- digital.append("password", "admin"),
|
|
|
- this.API.post("/admin/loginvue", digital).then((res) => {
|
|
|
- const { data, code } = res;
|
|
|
- debugger
|
|
|
-
|
|
|
- console.log(localStorage.getItem('authToken'));
|
|
|
- if (code == 200) {
|
|
|
- this.SET_TOKEN(data);
|
|
|
- this.$message({
|
|
|
- message: '登陆成功',
|
|
|
- type: 'success'
|
|
|
- });
|
|
|
- this.$router.push('/'); // 跳转到首页
|
|
|
- } else {
|
|
|
- this.$message.error('登录失败');// ui弹窗提示
|
|
|
- }
|
|
|
+ digital.append("username",this.loginForm.username),
|
|
|
+ digital.append("password",this.loginForm.password),
|
|
|
+ this.API.post("/admin/loginvue", digital).then((res) => {
|
|
|
+ const {data,code} = res;
|
|
|
+ console.log(localStorage.getItem('authToken'));
|
|
|
+ if(code == 200){
|
|
|
+ this.SET_TOKEN(data);
|
|
|
+ this.$message({
|
|
|
+ message: '登陆成功',
|
|
|
+ type: 'success'
|
|
|
});
|
|
|
+ this.$router.push('/'); // 跳转到首页
|
|
|
+ } else {
|
|
|
+ this.$message.error('登录失败');// ui弹窗提示
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
- }
|
|
|
-}
|
|
|
+ }}
|