|
@@ -2,10 +2,14 @@
|
|
|
<div class="login-panel">
|
|
|
<el-form class="mg-b-16">
|
|
|
<el-form-item class="mg-b-8">
|
|
|
- <el-input v-model="username" placeholder="请输入登录名"></el-input>
|
|
|
+ <el-input v-model="username" placeholder="请输入登录名"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item class="mg-b-8">
|
|
|
- <el-input v-model="password" placeholder="请输入密码" show-password></el-input>
|
|
|
+ <el-input
|
|
|
+ v-model="password"
|
|
|
+ placeholder="请输入密码"
|
|
|
+ show-password
|
|
|
+ ></el-input>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<button style="width:100%;" class="btn" @click="Login">登录</button>
|
|
@@ -17,42 +21,98 @@ export default {
|
|
|
return {
|
|
|
username: "",
|
|
|
password: "",
|
|
|
- token:"",
|
|
|
+ token: "",
|
|
|
};
|
|
|
},
|
|
|
- props:{token:""},
|
|
|
+ props: { token: "" },
|
|
|
emits: {
|
|
|
onLogin: null,
|
|
|
},
|
|
|
methods: {
|
|
|
Login() {
|
|
|
- localStorage.setItem("token",'2222')
|
|
|
- this.token=localStorage.getItem('token')
|
|
|
- console.log("token:",this.token)
|
|
|
- // this.$emit("onLogin", {
|
|
|
- // username: this.username,
|
|
|
- // password: this.password,
|
|
|
- // token:this.token
|
|
|
- // });
|
|
|
- if(this.username !== "" && this.password !== ""){
|
|
|
- this.$router.push('/monitor/home')
|
|
|
- console.log(this.username,"---",this.password)
|
|
|
- }else{
|
|
|
- this.BASE.showMsg({
|
|
|
- type: "warning",
|
|
|
- msg: "请输入完整的账号或密码",
|
|
|
+ let that = this;
|
|
|
+ if (that.username !== "" && that.password !== "") {
|
|
|
+ that.API.requestData({
|
|
|
+ isMust: false, // 请求是否携带 token ,默认为 true ,可缺省
|
|
|
+ baseURL: "http://192.168.10.44:8082",
|
|
|
+ method: "POST", // 请求方式,默认为 GET ,可缺省
|
|
|
+ subUrl: "sys/login", // 请求接口地址,必传项
|
|
|
+ data: {
|
|
|
+ username: that.username,
|
|
|
+ password: that.password,
|
|
|
+ },
|
|
|
+ success(res) {
|
|
|
+ console.log("res:", res);
|
|
|
+ if (res.data.authToken && res.data.user.laborName) {
|
|
|
+ localStorage.setItem("authToken", res.data.authToken);
|
|
|
+ localStorage.setItem("username", res.data.user.laborName);
|
|
|
+
|
|
|
+ that.BASE.showMsg({
|
|
|
+ msg: "登录成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ that.$router.push("/"); // 跳转到首页
|
|
|
+ } else {
|
|
|
+ that.BASE.showMsg({
|
|
|
+ type: "error",
|
|
|
+ msg: "输入的账号或密码错误",
|
|
|
});
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+ // that.$router.push('/monitor/home')
|
|
|
+ // console.log(that.username,"---",that.password)
|
|
|
+ } else {
|
|
|
+ that.BASE.showMsg({
|
|
|
+ type: "warning",
|
|
|
+ msg: "请输入完整的账号或密码",
|
|
|
+ });
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
|
|
|
- // console.log("token:",this.token)
|
|
|
- // this.$router.push('/')
|
|
|
+ // localStorage.setItem("token",'2222')
|
|
|
+ // that.token=localStorage.getItem('token')
|
|
|
+ // console.log("token:",that.token)
|
|
|
+ // that.$emit("onLogin", {
|
|
|
+ // username: that.username,
|
|
|
+ // password: that.password,
|
|
|
+ // token:that.token
|
|
|
+ // });
|
|
|
+
|
|
|
+ // console.log("token:",that.token)
|
|
|
+ // that.$router.push('/')
|
|
|
},
|
|
|
},
|
|
|
- created(){
|
|
|
- console.log('username:',this.username,'----','password:',this.password)
|
|
|
- }
|
|
|
+ created() {
|
|
|
+ // console.log("username:", that.username, "----", "password:", that.password);
|
|
|
+ // that.$nextTick(() => {
|
|
|
+ // that.API.requestData({
|
|
|
+ // isMust: false, // 请求是否携带 token ,默认为 true ,可缺省
|
|
|
+ // baseURL:"http://192.168.10.44:8082",
|
|
|
+ // method: "POST", // 请求方式,默认为 GET ,可缺省
|
|
|
+ // subUrl: "admin/loginvue", // 请求接口地址,必传项
|
|
|
+ // data: {
|
|
|
+ // username: that.username,
|
|
|
+ // password: that.password,
|
|
|
+ // },
|
|
|
+ // success(res) {
|
|
|
+ // localStorage.setItem("authToken", res.data.authToken);
|
|
|
+ // localStorage.setItem("username", res.data.user.laborName);
|
|
|
+
|
|
|
+ // // that.API.requestData({
|
|
|
+ // // method: "POST", // 请求方式,默认为 GET ,可缺省
|
|
|
+ // // subUrl: "admin/usermenu", // 请求接口地址,必传项
|
|
|
+ // // success() {
|
|
|
+ // // that.BASE.showMsg({
|
|
|
+ // // msg: "登陆成功",
|
|
|
+ // // type: "success",
|
|
|
+ // // });
|
|
|
+ // // that.$router.push('/'); // 跳转到首页
|
|
|
+ // // },
|
|
|
+ // // });
|
|
|
+ // },
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ },
|
|
|
};
|
|
|
</script>
|
|
|
|