|
|
|
@ -39,6 +39,7 @@ import { lognis } from "@/request/ruquset"; |
|
|
|
import { yzstr } from "@/utlis/validate.js"; |
|
|
|
import { yztoken, writetoken } from "@/utlis/istoken"; |
|
|
|
import mm from "@/utlis/mm"; |
|
|
|
import { getapi, postapi } from "@/api/api"; |
|
|
|
|
|
|
|
export default { |
|
|
|
data() { |
|
|
|
@ -60,65 +61,164 @@ export default { |
|
|
|
}; |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
async onSubmit() { |
|
|
|
onSubmit() { |
|
|
|
this.$refs.form.validate((valid) => { |
|
|
|
if (valid) { |
|
|
|
// lognis({ |
|
|
|
// client_id: "Peis_App", |
|
|
|
// grant_type: "password", |
|
|
|
// username: "admin", |
|
|
|
// password: "1q2w3E*", |
|
|
|
// scope: "Peis", |
|
|
|
// }).then(res=>{ |
|
|
|
// console.log(res,'222') |
|
|
|
// }) |
|
|
|
// lognis({ |
|
|
|
// client_id: "Peis_App", |
|
|
|
// grant_type: "password", |
|
|
|
// username: "admin", |
|
|
|
// password: "1q2w3E*", |
|
|
|
// scope: "Peis", |
|
|
|
// }).then((res) => { |
|
|
|
// console.log(res); |
|
|
|
// }); "http://81.70.217.145:9529/connect/token", |
|
|
|
this.$axios |
|
|
|
.post( |
|
|
|
mm.apiurl + "/connect/token", |
|
|
|
{ |
|
|
|
client_id: "Peis_App", |
|
|
|
grant_type: "password", |
|
|
|
username: this.form.Username, //admin |
|
|
|
password: this.form.Password, //1q2w3E |
|
|
|
scope: "Peis offline_access", |
|
|
|
}, |
|
|
|
{ |
|
|
|
headers: { |
|
|
|
"Content-Type": "application/x-www-form-urlencoded", |
|
|
|
}, |
|
|
|
} |
|
|
|
) |
|
|
|
.then((res) => { |
|
|
|
console.log(res, "222222"); |
|
|
|
|
|
|
|
if (res.status == 200) { |
|
|
|
//console.log(res.data) |
|
|
|
writetoken(res.data.expires_in); |
|
|
|
window.localStorage.setItem("token", res.data.access_token); |
|
|
|
window.localStorage.setItem( |
|
|
|
"refresh_token", |
|
|
|
res.data.refresh_token |
|
|
|
// let res = await getapi("/api/identity/users/login", { |
|
|
|
// username: this.form.Username, |
|
|
|
// password: this.form.Password, |
|
|
|
// }); |
|
|
|
var msgs = ""; |
|
|
|
getapi("/api/identity/users/login", { |
|
|
|
username: this.form.Username, |
|
|
|
password: this.form.Password, |
|
|
|
}) |
|
|
|
.then((ret) => { |
|
|
|
msgs = ret.data.msg; |
|
|
|
if (ret.code != -1 && ret.data.code == 1 && ret.code == 1) { |
|
|
|
return this.$axios.post( |
|
|
|
mm.apiurl + "/connect/token", |
|
|
|
{ |
|
|
|
client_id: "Peis_App", |
|
|
|
grant_type: "password", |
|
|
|
username: this.form.Username, |
|
|
|
password: this.form.Password, |
|
|
|
scope: "Peis offline_access", |
|
|
|
}, |
|
|
|
{ |
|
|
|
headers: { |
|
|
|
"Content-Type": "application/x-www-form-urlencoded", |
|
|
|
}, |
|
|
|
} |
|
|
|
); |
|
|
|
// window.localStorage.setItem("expires_in", res.data.expires_in); |
|
|
|
window.localStorage.setItem("tokentype", res.data.token_type); |
|
|
|
window.localStorage.setItem("user", this.form.Username); |
|
|
|
this.$message.success("登录成功"); |
|
|
|
this.$router.push({ path: "home" }); |
|
|
|
// this.$store.dispatch('changepassword',this.form.Password) |
|
|
|
this.$store.state.changepassword = this.form.Password; |
|
|
|
} else { |
|
|
|
this.$message.warning("用户名或密码错误"); |
|
|
|
this.$message.warning(ret.data.msg); |
|
|
|
} |
|
|
|
}); |
|
|
|
}) |
|
|
|
.then((res) => { |
|
|
|
writetoken(res.data.expires_in); |
|
|
|
window.localStorage.setItem("token", res.data.access_token); |
|
|
|
window.localStorage.setItem( |
|
|
|
"refresh_token", |
|
|
|
res.data.refresh_token |
|
|
|
); |
|
|
|
window.localStorage.setItem("tokentype", res.data.token_type); |
|
|
|
window.localStorage.setItem("user", this.form.Username); |
|
|
|
this.$message.success(msgs,+"登录成功"); |
|
|
|
this.$router.push({ path: "home" }); |
|
|
|
}) |
|
|
|
.catch((err) => {}); |
|
|
|
|
|
|
|
// console.log(res); |
|
|
|
// if (res.data.code == 1 && res.code == 1) { |
|
|
|
// console.log(res.data.msg); |
|
|
|
// postapi() |
|
|
|
// let ress = await this.$axios.post( |
|
|
|
// mm.apiurl + "/connect/token", |
|
|
|
// { |
|
|
|
// client_id: "Peis_App", |
|
|
|
// grant_type: "password", |
|
|
|
// username: this.form.Username, |
|
|
|
// password: this.form.Password, |
|
|
|
// scope: "Peis offline_access", |
|
|
|
// }, |
|
|
|
// { |
|
|
|
// headers: { |
|
|
|
// "Content-Type": "application/x-www-form-urlencoded", |
|
|
|
// }, |
|
|
|
// } |
|
|
|
// ); |
|
|
|
// if (ress.status == 200) { |
|
|
|
// writetoken(ress.data.expires_in); |
|
|
|
// window.localStorage.setItem("token", ress.data.access_token); |
|
|
|
// window.localStorage.setItem( |
|
|
|
// "refresh_token", |
|
|
|
// ress.data.refresh_token |
|
|
|
// ); |
|
|
|
// window.localStorage.setItem("tokentype", ress.data.token_type); |
|
|
|
// window.localStorage.setItem("user", this.form.Username); |
|
|
|
// this.$message.success(res.data.msg, "登录成功"); |
|
|
|
// this.$router.push({ path: "home" }); |
|
|
|
// } |
|
|
|
// } else { |
|
|
|
// console.log(); |
|
|
|
// this.$message.warning(res.data.msg); |
|
|
|
// } |
|
|
|
// } catch (err) { |
|
|
|
// console.log(err); |
|
|
|
// } |
|
|
|
|
|
|
|
// await getapi("/api/identity/users/login", { |
|
|
|
// username: this.form.Username, |
|
|
|
// password: this.form.Password, |
|
|
|
// }).then((ress) => { |
|
|
|
// if (ress.data.code == 1 && ress.code == 1) { |
|
|
|
// // console.log(msg); |
|
|
|
// postapi(mm.apiurl + "/connect/token", { |
|
|
|
// client_id: "Peis_App", |
|
|
|
// grant_type: "password", |
|
|
|
// username: this.form.Username, |
|
|
|
// password: this.form.Password, |
|
|
|
// scope: "Peis offline_access", |
|
|
|
// }).then((res) => { |
|
|
|
// console.log(res); |
|
|
|
|
|
|
|
// writetoken(res.data.expires_in); |
|
|
|
// window.localStorage.setItem("token", res.data.access_token); |
|
|
|
// window.localStorage.setItem( |
|
|
|
// "refresh_token", |
|
|
|
// res.data.refresh_token |
|
|
|
// ); |
|
|
|
// window.localStorage.setItem("tokentype", res.data.token_type); |
|
|
|
// window.localStorage.setItem("user", this.form.Username); |
|
|
|
// this.$message.success("登录成功"); |
|
|
|
// this.$router.push({ path: "home" }); |
|
|
|
|
|
|
|
// this.$store.state.changepassword = this.form.Password; |
|
|
|
// }); |
|
|
|
// } else { |
|
|
|
// this.$message.warning(res.data.msg); |
|
|
|
// } |
|
|
|
// }); |
|
|
|
|
|
|
|
// this.$axios |
|
|
|
// .post( |
|
|
|
// mm.apiurl + "/connect/token", |
|
|
|
// { |
|
|
|
// client_id: "Peis_App", |
|
|
|
// grant_type: "password", |
|
|
|
// username: this.form.Username, //admin |
|
|
|
// password: this.form.Password, //1q2w3E |
|
|
|
// scope: "Peis offline_access", |
|
|
|
// }, |
|
|
|
// { |
|
|
|
// headers: { |
|
|
|
// "Content-Type": "application/x-www-form-urlencoded", |
|
|
|
// }, |
|
|
|
// } |
|
|
|
// ) |
|
|
|
// .then((res) => { |
|
|
|
// console.log(res, "222222"); |
|
|
|
|
|
|
|
// if (res.status == 200) { |
|
|
|
// //console.log(res.data) |
|
|
|
// writetoken(res.data.expires_in); |
|
|
|
// window.localStorage.setItem("token", res.data.access_token); |
|
|
|
// window.localStorage.setItem( |
|
|
|
// "refresh_token", |
|
|
|
// res.data.refresh_token |
|
|
|
// ); |
|
|
|
// // window.localStorage.setItem("expires_in", res.data.expires_in); |
|
|
|
// window.localStorage.setItem("tokentype", res.data.token_type); |
|
|
|
// window.localStorage.setItem("user", this.form.Username); |
|
|
|
// this.$message.success("登录成功"); |
|
|
|
// this.$router.push({ path: "home" }); |
|
|
|
// // this.$store.dispatch('changepassword',this.form.Password) |
|
|
|
// this.$store.state.changepassword = this.form.Password; |
|
|
|
// } else { |
|
|
|
// this.$message.warning("用户名或密码错误"); |
|
|
|
// } |
|
|
|
// }); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|