| | |
| | | label: "平台logo", |
| | | des: "显示平台logo状态", |
| | | fileName: "gjdw", // gjdw, nfdw, gjdx, qwh, gdnr |
| | | value: true, |
| | | value: false, |
| | | }, |
| | | uKey: { |
| | | label: "uKey", |
| | |
| | | */ |
| | | // name: "", |
| | | // name: "sxty", // 请查看alarmPopup是否开启,logo是否开启且为gjdw |
| | | // name: 'tydc', |
| | | // name: "tydc", |
| | | // name: 'njck', |
| | | name: "ynkm", |
| | | //value: false, |
| | |
| | | alarmPopup: { |
| | | label: "告警弹出框", |
| | | des: "登录平台后,右下方告警弹出框提示", |
| | | // value: false, |
| | | value: true, |
| | | value: false, |
| | | // value: true, |
| | | }, |
| | | WHYC: { |
| | | label: "自用", |
| | |
| | | props: { |
| | | faceShow: { |
| | | type: Boolean, |
| | | default: false |
| | | } |
| | | default: false, |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | newstream: "", |
| | | intTime: null, |
| | | postTime: null, |
| | | setTime: null |
| | | setTime: null, |
| | | }; |
| | | }, |
| | | mounted() { |
| | | this.faceChange(); |
| | | }, |
| | | destroyed: function() { |
| | | destroyed: function () { |
| | | this.status = false; |
| | | this.clearVideo(); |
| | | }, |
| | | methods: { |
| | | // 关闭摄像头 |
| | | clearVideo: function() { |
| | | clearVideo: function () { |
| | | // 关闭定时器 |
| | | clearInterval(this.intTime); |
| | | clearInterval(this.postTime); |
| | |
| | | } |
| | | }, |
| | | // 获取图片 |
| | | getImg: function() { |
| | | getImg: function () { |
| | | let vm = this; |
| | | let video = vm.$refs.video; |
| | | let canvas = vm.$refs.canvas; |
| | |
| | | vm.imageBase64 = canvas.toDataURL("image/png"); |
| | | }, |
| | | // 人脸检测 |
| | | faceChange: function() { |
| | | faceChange: function () { |
| | | let vm = this; |
| | | // 恢复提示语 |
| | | vm.faceDetect = "请将正脸对准摄像头"; |
| | |
| | | } |
| | | }, |
| | | //访问用户媒体设备的兼容方法 |
| | | getUserMedia: function(constraints, success, error) { |
| | | getUserMedia: function (constraints, success, error) { |
| | | if (navigator.mediaDevices.getUserMedia) { |
| | | //最新的标准API |
| | | navigator.mediaDevices |
| | |
| | | } |
| | | }, |
| | | // 成功回调 |
| | | success: function(stream) { |
| | | success: function (stream) { |
| | | let vm = this; |
| | | //兼容webkit核心浏览器 |
| | | let CompatibleURL = window.URL || window.webkitURL; |
| | |
| | | this.intTime = setInterval(() => { |
| | | vm.getImg(); |
| | | }, 0); |
| | | setTimeout(function() { |
| | | setTimeout(function () { |
| | | vm.facePost(); |
| | | }, 0); |
| | | }, |
| | | error: function(error) { |
| | | error: function (error) { |
| | | console.log(error); |
| | | console.log(`访问用户媒体设备失败${error.name}, ${error.message}`); |
| | | }, |
| | | // 请求后台验证人脸 |
| | | facePost: function() { |
| | | facePost: function () { |
| | | if (!this.$store.state.ukey.isIn) { |
| | | this.faceDetect = "请先插入ukey"; |
| | | this.setTime = setTimeout(() => { |
| | | this.facePost(); |
| | | }, 500); |
| | | } else if (!this.imageBase64) { |
| | | this.faceDetect = "人脸识别中..."; |
| | | this.setTime = setTimeout(() => { |
| | | this.facePost(); |
| | | }, 500); |
| | |
| | | let vm = this; |
| | | faceManager |
| | | .faceVerify('"' + vm.imageBase64 + '"', this.$store.state.ukey.id) |
| | | .then(res => { |
| | | .then((res) => { |
| | | let result = res.data; |
| | | console.log(res); |
| | | if (result.code == 1 && result.data) { |
| | |
| | | } |
| | | } |
| | | }) |
| | | .catch(err => { |
| | | .catch((err) => { |
| | | vm.faceDetect = "网络链接失败"; |
| | | if (vm.status == true) { |
| | | this.setTime = setTimeout(() => { |
| | |
| | | } |
| | | }, |
| | | // 登陆设置sessionStorage |
| | | onLogin: function() { |
| | | onLogin: function () { |
| | | let vm = this; |
| | | faceManager |
| | | .getUserName() |
| | | .then(res => { |
| | | .then((res) => { |
| | | let result = res.data; |
| | | if (result.code == 1) { |
| | | let password = RSA.decrypt(result.data.usnId, const_num.privateKey); |
| | | this.uKeyLogin(result.data.uname, password); |
| | | } |
| | | }) |
| | | .catch(err => { |
| | | .catch((err) => { |
| | | console.log(err); |
| | | }); |
| | | }, |
| | | uKeyLogin(username, password) { |
| | | // ukey登录 |
| | | uKeyLogin(username, password, this.$store.state.ukey.id) |
| | | .then(res => { |
| | | .then((res) => { |
| | | // 对结果进行处理 |
| | | this.handleLogin(res, username); |
| | | }) |
| | | .catch(error => { |
| | | .catch((error) => { |
| | | // 关闭等待 |
| | | this.loading = false; |
| | | this.faceDetect = "网络异常"; |
| | |
| | | this.faceDetect = rs.msg; |
| | | this.facePost(); |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | <style lang="less" scoped> |
| | |
| | | <div class="auto-login-loading" v-if="isAutoLogin"> |
| | | <img src="../../assets/images/login_loading.gif" /> |
| | | </div> |
| | | <div v-else class="login-wrapper" |
| | | v-loading="loading" |
| | | element-loading-text="页面装载中" |
| | | element-loading-spinner="el-icon-loading" |
| | | element-loading-background="rgba(0, 0, 0, 0.2)"> |
| | | <div |
| | | v-else |
| | | class="login-wrapper" |
| | | v-loading="loading" |
| | | element-loading-text="页面装载中" |
| | | element-loading-spinner="el-icon-loading" |
| | | element-loading-background="rgba(0, 0, 0, 0.2)" |
| | | > |
| | | <div |
| | | class="login_container" |
| | | :style="{ |
| | | background: 'url(' + backgroundImg + ') 0 0 no-repeat', |
| | | backgroundSize: '100% 100%' |
| | | backgroundSize: '100% 100%', |
| | | }" |
| | | > |
| | | <div class="sliderCon"> |
| | |
| | | searchName, |
| | | getUserLoginInfo, |
| | | checkServeLicense, |
| | | getLoginVerity |
| | | getLoginVerity, |
| | | } from "@/views/login/js/api"; |
| | | import AddLicense from "./components/AddLicense"; |
| | | import ConfigInfo from "./components/configInfo"; |
| | |
| | | ConfigInfo, |
| | | AddLicense, |
| | | FaceLogin, |
| | | VSidentify |
| | | VSidentify, |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | formLabelAlign: { |
| | | name: "", |
| | | region: "", |
| | | type: "" |
| | | type: "", |
| | | }, |
| | | /* 登录表单el-form 的 数据绑定 */ |
| | | loginForm: { |
| | | username: "", |
| | | password: "", |
| | | verify: "" |
| | | verify: "", |
| | | }, |
| | | verifyCode: "", |
| | | license: { |
| | | show: false |
| | | show: false, |
| | | }, |
| | | face: { |
| | | show: false |
| | | show: false, |
| | | }, |
| | | config: { |
| | | show: false |
| | | show: false, |
| | | }, |
| | | uKey: { |
| | | show: false |
| | | show: false, |
| | | }, |
| | | platformName: "", |
| | | logoConfig: platform.logo, |
| | |
| | | watch: { |
| | | platformName: { |
| | | handler() { |
| | | document.getElementsByTagName("title")[0].innerHTML= this.platformName; |
| | | document.getElementsByTagName("title")[0].innerHTML = this.platformName; |
| | | }, |
| | | immediate: true, |
| | | }, |
| | | $route: { |
| | | handler: function(route) { |
| | | handler: function (route) { |
| | | this.redirect = route.query && route.query.redirect; |
| | | }, |
| | | immediate: true |
| | | } |
| | | immediate: true, |
| | | }, |
| | | }, |
| | | methods: { |
| | | onSubmit() { |
| | |
| | | password = this.loginForm.password, |
| | | verity = this.loginForm.verify; |
| | | login(username, password, verity) |
| | | .then(res => { |
| | | .then((res) => { |
| | | res = res.data; |
| | | // console.log(res, '======login res'); |
| | | // 关闭等待 |
| | |
| | | this.$message.error(res.msg); |
| | | } |
| | | }) |
| | | .catch(error => { |
| | | .catch((error) => { |
| | | // 关闭等待 |
| | | this.loading = false; |
| | | console.log(error); |
| | |
| | | changeVerifyCode() { |
| | | let loading = this.$layer.loading(); |
| | | getLoginVerity() |
| | | .then(res => { |
| | | .then((res) => { |
| | | this.$layer.close(loading); |
| | | res = res.data; |
| | | if (res.code) { |
| | |
| | | this.loginForm.verify = ""; |
| | | // 自动登录 |
| | | this.autoLogin(); |
| | | }).catch(error => { |
| | | }) |
| | | .catch((error) => { |
| | | this.$layer.close(loading); |
| | | this.verifyCode = ""; |
| | | this.loginForm.verify = ""; |
| | |
| | | }, |
| | | getRandomFromServer() { |
| | | getRandomFromServer() |
| | | .then(res => { |
| | | .then((res) => { |
| | | let rs = res.data; |
| | | if (rs.code == 1) { |
| | | let randomNumber = rs.data; |
| | |
| | | this.$message.error("服务器连接异常!"); |
| | | } |
| | | }) |
| | | .catch(error => { |
| | | .catch((error) => { |
| | | this.$message.error("服务器连接异常!"); |
| | | }); |
| | | }, |
| | |
| | | result.inPath = result.inPath.replace(reg, "%26"); |
| | | result.inPath = result.inPath.replace(/\\/g, "huodongwei"); |
| | | loginSignVerity(result) |
| | | .then(res => { |
| | | .then((res) => { |
| | | let rs = res.data; |
| | | if (rs.code == 1) { |
| | | this.uKeyLogin(); |
| | |
| | | this.$message.error("UKey签名校验失败!"); |
| | | } |
| | | }) |
| | | .catch(error => { |
| | | .catch((error) => { |
| | | this.$message.error("服务器连接异常!"); |
| | | }); |
| | | }, |
| | |
| | | this.loginForm.password, |
| | | this.$store.state.ukey.id |
| | | ) |
| | | .then(res => { |
| | | .then((res) => { |
| | | // 对结果进行处理 |
| | | this.handleLogin(res); |
| | | }) |
| | | .catch(error => { |
| | | .catch((error) => { |
| | | // 关闭等待 |
| | | this.loading = false; |
| | | console.log(error); |
| | |
| | | // 关闭等待 |
| | | //this.loading = false; |
| | | res = res.data; |
| | | console.log(res); |
| | | if (res.data) { |
| | | this.$message.success("登录成功"); |
| | | sessionStorage.setItem("username", res.data2[0].uname); |
| | | sessionStorage.setItem("userId", res.data2[0].uid); |
| | | sessionStorage.setItem("userPower", res.data2[0].urole); |
| | | sessionStorage.setItem("userPowerGroup", res.data2[1]); |
| | | sessionStorage.setItem("isInGroup", res.data2[2]?1:0); |
| | | sessionStorage.setItem("isInGroup", res.data2[2] ? 1 : 0); |
| | | // 自动登录无法返回登录页 |
| | | if (this.$store.state.user.autoLogin) { |
| | | this.$router.replace({ path: this.redirect || "/home" }); |
| | |
| | | checkServeLicense() { |
| | | // 校验服务器是否注册 |
| | | checkServeLicense() |
| | | .then(res => { |
| | | .then((res) => { |
| | | let rs = res.data; |
| | | if (rs.code === 1 && rs.data) { |
| | | this.register = true; |
| | |
| | | this.register = false; |
| | | } |
| | | }) |
| | | .catch(error => { |
| | | .catch((error) => { |
| | | console.log(error); |
| | | }); |
| | | }, |
| | |
| | | if (autoLogin && uid) { |
| | | this.isAutoLogin = true; |
| | | getUserLoginInfo(uid) |
| | | .then(res => { |
| | | .then((res) => { |
| | | let rs = res.data; |
| | | if (rs.code === 1) { |
| | | let data = rs.data; |
| | |
| | | this.handleLogin(res); |
| | | } |
| | | }) |
| | | .catch(error => { |
| | | .catch((error) => { |
| | | console.log(error); |
| | | this.$notify.error({ |
| | | title: "错误", |
| | | message: "输入信息无效,请手动登录!" |
| | | message: "输入信息无效,请手动登录!", |
| | | }); |
| | | console.log(error); |
| | | }); |
| | | }else { |
| | | } else { |
| | | this.isAutoLogin = false; |
| | | } |
| | | // let pattern = /(localhost)|(www\.sw-ht\.com)/; |
| | |
| | | }, |
| | | searchPlatformName() { |
| | | searchName() |
| | | .then(res => { |
| | | .then((res) => { |
| | | let rs = res.data; |
| | | if (rs.code == 1) { |
| | | let data = rs.data["1"][0]; |
| | |
| | | } |
| | | sessionStorage.setItem("platformName", this.platformName); |
| | | }) |
| | | .catch(error => { |
| | | .catch((error) => { |
| | | this.platformName = "蓄电池后台监控管理平台"; |
| | | sessionStorage.setItem("platformName", this.platformName); |
| | | }); |
| | |
| | | */ |
| | | setQRCode() { |
| | | let token = sessionStorage.getItem("qrToken"); |
| | | if(!token) { |
| | | qrCode.login().then(res=>{ |
| | | let rs = res.data; |
| | | if(rs.code == 200) { |
| | | sessionStorage.setItem("qrToken", rs.token); |
| | | }else { |
| | | sessionStorage.setItem("qrToken", ""); |
| | | } |
| | | }).catch(error=>{ |
| | | console.log(error); |
| | | }); |
| | | if (!token) { |
| | | qrCode |
| | | .login() |
| | | .then((res) => { |
| | | let rs = res.data; |
| | | if (rs.code == 200) { |
| | | sessionStorage.setItem("qrToken", rs.token); |
| | | } else { |
| | | sessionStorage.setItem("qrToken", ""); |
| | | } |
| | | }) |
| | | .catch((error) => { |
| | | console.log(error); |
| | | }); |
| | | } |
| | | }, |
| | | changeSkin() { |
| | | if(!CONFIG.skin.value) { |
| | | if (!CONFIG.skin.value) { |
| | | let skin = CONFIG.skin.skinName; |
| | | let name = CONFIG.skin.themeName; |
| | | this.$store.commit("theme/changeTheme", skin); |
| | | this.$store.dispatch("theme/changeThemeName", name); |
| | | sessionStorage.setItem("activeSkin", skin); |
| | | } |
| | | } |
| | | }, |
| | | }, |
| | | computed: { |
| | | uKeyState() { |
| | |
| | | |
| | | this.$store.dispatch("user/changeAutoLogin", 0); |
| | | |
| | | if(sysConfig.clientName.name == "sxty") { |
| | | if (sysConfig.clientName.name == "sxty") { |
| | | this.setQRCode(); |
| | | } |
| | | this.changeVerifyCode(); |
| | | } |
| | | }, |
| | | }; |
| | | </script> |
| | | |