后台访问登陆验证
This commit is contained in:
@@ -23,126 +23,141 @@
|
||||
type="primary">登录
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-form>
|
||||
</section>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
components: {
|
||||
|
||||
},
|
||||
data: function() {
|
||||
return {
|
||||
loginByNormal: true,
|
||||
disabled: false,
|
||||
vaildimg: '',
|
||||
data: {
|
||||
Logincode: "",
|
||||
Password: "",
|
||||
Code: "",
|
||||
CodeKey: "",
|
||||
Appcpde: ""
|
||||
},
|
||||
rules: {
|
||||
Logincode: [this.$vaild.required("账号")],
|
||||
Password: [this.$vaild.required("密码")],
|
||||
Code: [this.$vaild.required("验证码")]
|
||||
},
|
||||
menus:[]
|
||||
}
|
||||
},
|
||||
created: function() {
|
||||
this.getvaild();
|
||||
import Fingerprint from './../../../../static/js/fingerprint.js'
|
||||
|
||||
let finger = new Fingerprint()
|
||||
export default {
|
||||
components: {
|
||||
|
||||
},
|
||||
data: function () {
|
||||
return {
|
||||
loginByNormal: true,
|
||||
disabled: false,
|
||||
vaildimg: '',
|
||||
data: {
|
||||
Logincode: '',
|
||||
Password: '',
|
||||
Code: '',
|
||||
CodeKey: '',
|
||||
Appcpde: ''
|
||||
},
|
||||
rules: {
|
||||
Logincode: [this.$vaild.required('账号')],
|
||||
Password: [this.$vaild.required('密码')],
|
||||
Code: [this.$vaild.required('验证码')]
|
||||
},
|
||||
menus: []
|
||||
}
|
||||
},
|
||||
created: function () {
|
||||
this.getvaild()
|
||||
this.confire_finger()
|
||||
},
|
||||
beforeDestroy: function () {
|
||||
clearTimeout(this.timerId)
|
||||
},
|
||||
methods: {
|
||||
|
||||
// 验证web指纹
|
||||
confire_finger () {
|
||||
let finger_code = finger.get()
|
||||
this.$api.post(this.$api.phpURL + 'api/Verify/index', {code: finger_code}).then(res => {
|
||||
if (res.msg == 'false') {
|
||||
// eslint-disable-next-line camelcase
|
||||
alert('访问错误!错误码:' + finger_code)
|
||||
window.location.href = 'http://www.juip.com'
|
||||
}
|
||||
})
|
||||
},
|
||||
beforeDestroy: function() {
|
||||
clearTimeout(this.timerId);
|
||||
},
|
||||
methods: {
|
||||
getMenus() {
|
||||
getMenus () {
|
||||
this.$api
|
||||
.get("manage/v1/ManagerToPermission/GetPermissions")
|
||||
.then(res => {
|
||||
var menus = res.Data;
|
||||
this.$local.setMenus(menus);
|
||||
this.$store.commit('setMnus', menus);
|
||||
var defulat=this.getDefaultMenu(menus);
|
||||
this.$router.replace(defulat);
|
||||
});
|
||||
.get('manage/v1/ManagerToPermission/GetPermissions')
|
||||
.then(res => {
|
||||
var menus = res.Data
|
||||
this.$local.setMenus(menus)
|
||||
this.$store.commit('setMnus', menus)
|
||||
var defulat = this.getDefaultMenu(menus)
|
||||
this.$router.replace(defulat)
|
||||
})
|
||||
},
|
||||
getDefaultMenu(menus){
|
||||
if(menus.length==0)return "/login"
|
||||
var sumMenus;
|
||||
for(var i=0;i<menus.length;i++){
|
||||
sumMenus=menus[i].Children;
|
||||
if(sumMenus) break;
|
||||
}
|
||||
if(sumMenus.length==0) return "/login";
|
||||
return sumMenus[0].Permissionurl;
|
||||
},
|
||||
getvaild() {
|
||||
this.$api.get('baseinfo/v1/manager/GetValidateCode').then(res=>{
|
||||
var img = "data:image/jpg;base64," + res.Data.img;
|
||||
this.vaildimg = img;
|
||||
this.data.CodeKey = res.Data.key;
|
||||
clearTimeout(this.timerId);
|
||||
this.timerId = setTimeout(() => {
|
||||
this.getvaild();
|
||||
}, 10 * 60 * 1000)
|
||||
})
|
||||
|
||||
},
|
||||
submit: function(e) {
|
||||
e.preventDefault();
|
||||
this.$refs.form.validate(pass => {
|
||||
if (!pass) return;
|
||||
this.login();
|
||||
})
|
||||
},
|
||||
loginSuccess: function(data) {
|
||||
this.userInfo = data;
|
||||
window.localStorage.clear(); //防止有未清理的缓存
|
||||
this.$local.setUserCache(data)
|
||||
this.$store.commit('updateUserInfo', data);
|
||||
window.localStorage.setItem("loginType", "property");
|
||||
this.getMenus();
|
||||
// this.$router.replace('/user/index');
|
||||
|
||||
},
|
||||
isNewUser(id) {
|
||||
this.$api.get({
|
||||
url: 'Manager/Account',
|
||||
params: {
|
||||
params: {
|
||||
ID: id
|
||||
}
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.Data.LoginCount <= 1) return this.$router.push({
|
||||
name: "initlogin"
|
||||
});
|
||||
this.$router.push('/home');
|
||||
},
|
||||
failTip: '登录失败'
|
||||
})
|
||||
},
|
||||
login() {
|
||||
this.$api.post('baseinfo/v1/manager/Login',this.data).then(
|
||||
res=>{
|
||||
if (res.Data){
|
||||
this.loginSuccess(res.Data);
|
||||
return;
|
||||
}
|
||||
return this.$message({
|
||||
type: "error",
|
||||
message: "无此用户信息"
|
||||
})
|
||||
},err=>{
|
||||
this.getvaild();
|
||||
})
|
||||
getDefaultMenu (menus) {
|
||||
if (menus.length == 0) return '/login'
|
||||
var sumMenus
|
||||
for (var i = 0; i < menus.length; i++) {
|
||||
sumMenus = menus[i].Children
|
||||
if (sumMenus) break
|
||||
}
|
||||
if (sumMenus.length == 0) return '/login'
|
||||
return sumMenus[0].Permissionurl
|
||||
},
|
||||
getvaild () {
|
||||
this.$api.get('baseinfo/v1/manager/GetValidateCode').then(res => {
|
||||
var img = 'data:image/jpg;base64,' + res.Data.img
|
||||
this.vaildimg = img
|
||||
this.data.CodeKey = res.Data.key
|
||||
clearTimeout(this.timerId)
|
||||
this.timerId = setTimeout(() => {
|
||||
this.getvaild()
|
||||
}, 10 * 60 * 1000)
|
||||
})
|
||||
},
|
||||
submit: function (e) {
|
||||
e.preventDefault()
|
||||
this.$refs.form.validate(pass => {
|
||||
if (!pass) return
|
||||
this.login()
|
||||
})
|
||||
},
|
||||
loginSuccess: function (data) {
|
||||
this.userInfo = data
|
||||
window.localStorage.clear() // 防止有未清理的缓存
|
||||
this.$local.setUserCache(data)
|
||||
this.$store.commit('updateUserInfo', data)
|
||||
window.localStorage.setItem('loginType', 'property')
|
||||
this.getMenus()
|
||||
// this.$router.replace('/user/index');
|
||||
},
|
||||
isNewUser (id) {
|
||||
this.$api.get({
|
||||
url: 'Manager/Account',
|
||||
params: {
|
||||
params: {
|
||||
ID: id
|
||||
}
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.Data.LoginCount <= 1) {
|
||||
return this.$router.push({
|
||||
name: 'initlogin'
|
||||
})
|
||||
}
|
||||
this.$router.push('/home')
|
||||
},
|
||||
failTip: '登录失败'
|
||||
})
|
||||
},
|
||||
login () {
|
||||
this.$api.post('baseinfo/v1/manager/Login', this.data).then(
|
||||
res => {
|
||||
if (res.Data) {
|
||||
this.loginSuccess(res.Data)
|
||||
return
|
||||
}
|
||||
return this.$message({
|
||||
type: 'error',
|
||||
message: '无此用户信息'
|
||||
})
|
||||
}, err => {
|
||||
this.getvaild()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user