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