1178232204@qq.com hace 3 años
padre
commit
203f1e60e2
Se han modificado 2 ficheros con 121 adiciones y 60 borrados
  1. 9 0
      src/js/index.js
  2. 112 60
      src/js/login.js

+ 9 - 0
src/js/index.js

@@ -14,9 +14,12 @@ const {api} = require('./api.js')
 const {post,pageMap,delCookie,setCookie,setLocal,getCookie,focusMenuItem,getUrlArgObject} = require('./utils.js');
 let userInfo={};
 let isPlacefile = getCookie('isPlacefile')||1
+
 let passwordComplexity = getCookie('passwordComplexity')
 const hideLogo = getUrlArgObject("hideLg");
 const otherLogo = getUrlArgObject("adLg");
+const is3His = getUrlArgObject('is3His')
+console.log(is3His);
 const modalDom = `
       <p class="tips"><img src=${WarningIcon} /><span>为确保账号安全,请及时修改初始密码</span></p>
       <div class="modalAction">
@@ -402,6 +405,12 @@ function getMenu(){
           data.menuWrappers.splice(i,1);
           continue;
         }
+        for (let j = 0;j<data.menuWrappers[i].subMenuList.length;j++){
+          if(isPlacefile==='0'&& is3His && (data.menuWrappers[i].subMenuList[j].code==='YH-ZKK-BASYHGLYSZB_XQ' || data.menuWrappers[i].subMenuList[j].code==='YH-KSZR-BASYHGLYSZB_XQ')){
+            data.menuWrappers[i].subMenuList.splice(j,1);
+            continue;
+          }
+        }
         data.menuWrappers[i].isPlacefile = isPlacefile
       }
       initMenu(data.menuWrappers,data.userLoginDTO);

+ 112 - 60
src/js/login.js

@@ -9,7 +9,8 @@ const { post, setCookie, delCookie, getUrlArgObject, toast } = require('../js/ut
 const md5 = require('js-md5');
 const hideLogo = getUrlArgObject("hideLg");
 const otherLogo = getUrlArgObject("adLg");
-let type
+let type;
+let is3His=false; //医院标记:湘雅三院1/通用0
 $(function () {
   getHospitalMark()
   if (hideLogo || otherLogo) {
@@ -21,65 +22,106 @@ $(function () {
       sureLogin()
     }
   });
-  
-  
+
+
 });
 
+//获取验证码
+function getSecurityCode() {
+  var windowUrl = window.URL || window.webkitURL;//处理浏览器兼容性
+  var xhr = new XMLHttpRequest();
+  var url = api.getCaptcha;//验证码请求地址
+  xhr.open("GET", url, true);
+  xhr.responseType = "blob";
+  xhr.onload = function () {
+    if (this.status == 200) {
+      var blob = this.response;
+      const img = document.createElement("img");
+      const qrUrl = window.URL.createObjectURL(blob);
+      img.src = qrUrl;
+      //释放对象
+      img.onload = function () {
+        console.log('释放')
+        window.URL.revokeObjectURL(qrUrl)
+      }
+      const imgDiv = document.getElementById("codeImg");
+      $(imgDiv).html(img);
+    }
+  }
+  xhr.send();
+}
 function getHospitalMark() {
   localStorage.removeItem('accessToken')
   post(api.getHospitalMark).then((res) => {
-    const data = res.data;
-    if (data.code == 0) {
-      type = parseInt(data.data)
-      if (parseInt(data.data) == 1) {
-        str = '<div class="bg2">'
-        str += '<div class="login-info">'
-        str += '<div class="info-perPub">'
-        str += ' <p> 用户名:</p>'
-        str += '<div class="info-iptWrap">'
-        str += '<input type="text" placeholder="请输入用户名" id="username" value="" autocomplete="off">'
-        str += '</div></div>'
-        str += '<div class="info-perPub">'
-        str += ' <p> 密码:</p>'
-        str += '<div class="info-iptWrap">'
-        str += '<input type="text" placeholder="请输入密码" id="password" value="" autocomplete="off">'
-        str += '</div></div>'
-        str += '<p class="waring"></p><div class="sureLogin">登录</div></div>'
-        $('.login').html(str)
-      } else {
-        str = '<div class="bg fl"><p class="title">AI病案质控平台</p></div>'
-        str += '<div class="message fr"><div class="inner"><p class="welcome">欢迎使用!</p>'
-        str += '<div class="perPub">'
-        str += ' <p> 用户名:</p>'
-        str += '<div class="iptWrap">'
-        str += '<input type="text" placeholder="请输入用户名" id="username" value="" autocomplete="off">'
-        str += '</div></div><br>'
-        str += '<div class="perPub">'
-        str += ' <p> 密码:</p>'
-        str += '<div class="iptWrap">'
-        str += '<input type="text" placeholder="请输入密码" id="password" value="" autocomplete="off">'
-        str += '</div></div>'
-        str += '<p class="waring"></p><div class="sureLogin">登录</div></div><div class="copy-right">由杭州朗通信息技术有限公司提供技术支持</div></div>',
+  const data = res.data;//{ code: 0, data: 0 }
+  if (data.code == 0) {
+    type = parseInt(data.data)
+    is3His=type===1;
+    if (is3His) {   //湘雅三院登录样式
+      str = '<div class="bg2">'
+      str += '<div class="login-info">'
+      str += '<div class="info-perPub">'
+      str += ' <p> 用户名:</p>'
+      str += '<div class="info-iptWrap">'
+      str += '<input type="text" placeholder="请输入用户名" id="username" value="" autocomplete="off">'
+      str += '</div></div>'
+      str += '<div class="info-perPub">'
+      str += ' <p> 密码:</p>'
+      str += '<div class="info-iptWrap">'
+      str += '<input type="text" placeholder="请输入密码" id="password" value="" autocomplete="off">'
+      str += '</div></div>'
+      str += '<p class="waring"></p><div class="sureLogin">登录</div></div>'
+      $('.login').html(str)
+    } else {    //通用版样式
+      str = '<div class="bg fl"><p class="title">AI病案质控平台</p></div>'
+      str += '<div class="message fr"><div class="inner"><p class="welcome">欢迎使用!</p>'
+      str += '<div class="perPub">'
+      str += ' <p> 用户名:</p>'
+      str += '<div class="iptWrap">'
+      str += '<input type="text" placeholder="请输入用户名" id="username" value="" autocomplete="off">'
+      str += '</div></div><br>'
+      str += '<div class="perPub">'
+      str += ' <p> 密码:</p>'
+      str += '<div class="iptWrap">'
+      str += '<input type="text" placeholder="请输入密码" id="password" value="" autocomplete="off">'
+      str += '</div></div><br>'
+      str += '<div class="perPub">'
+      str += ' <p> 验证码:</p>'
+      str += '<div class="iptWrap security-code">'
+      str += '<input type="text" placeholder="请输入验证码" id="code" value="" autocomplete="off">'
+      str += '<div id="codeImg" class="code-img"></div>'
+      str += '<a id="changeCode" >换一张</a>'
+      str += '</div></div>'
+      str += '<p class="waring"></p><div class="sureLogin">登录</div></div><div class="copy-right">由杭州朗通信息技术有限公司提供技术支持</div></div>',
         $('.login').html(str)
-      }
-      $(".sureLogin").click(() => {
-        sureLogin()
-      })
-      $("#password").focus(function () {
-        $(this).attr("type", "password")
-      })
-      $(".iptWrap input").focus(function () {
-        $(this).parent().addClass('inputFocus')
-      })
-      $(".iptWrap input").blur(function () {
-        $(this).parent().removeClass('inputFocus')
-      })
-      $("body").on('input', '#username,#password', function () {
-        if ($(this).val().trim() != '') {
-          $(".login .waring").html('')
-        }
-      })
+        getSecurityCode();
     }
+    $(".sureLogin").click(() => {
+      sureLogin()
+    })
+    //点击换一张事件
+    $("#codeImg,#changeCode").click(function () {
+      getSecurityCode();
+    })
+    $("#password").focus(function () {
+      $(this).attr("type", "password")
+    })
+    $(".iptWrap:not(.security-code) input").focus(function () {
+      $(this).parent().addClass('inputFocus')
+    })
+    $(".security-code input").focus(function () {
+      $(this).addClass('inputFocus')
+    })
+    $(".iptWrap input").blur(function () {
+      $(this).parent().removeClass('inputFocus')
+      $(this).removeClass('inputFocus')
+    })
+    $("body").on('input', '#username,#password', function () {
+      if ($(this).val().trim() != '') {
+        $(".login .waring").html('')
+      }
+    })
+  }
   }).catch(() => {
 
   })
@@ -89,25 +131,31 @@ function sureLogin() {
   $(".login .waring").html('')
   let username = $("#username").val().trim();
   let password = $("#password").val().trim();
-  if (!username) { 
-    if(type == 1){
+  let captcha = !is3His?$("#code").val().trim():undefined;
+  if (!username) {
+    if (is3His) {
       toast("请输入用户名!");
-    }else{
+    } else {
       $(".login .waring").css('visibility', 'visible').html('请输入用户名')
     }
     return
   } else if (!password) {
-    if (type == 1) {
+    if (is3His) {
       toast("请输入密码!");
     } else {
       $(".login .waring").css('visibility', 'visible').html('请输入密码')
     }
     return
   }
+  if (!is3His&&!captcha) {    //三院不用验证码
+      $(".login .waring").css('visibility', 'visible').html('请输入验证码')
+    return
+  }
   $.alerModal({ type: "loading" });
   post(api.getJwt, {
     username: username,
-    password: password
+    password: password,
+    captcha: captcha
   }).then((res) => {
     const data = res.data;
     if (data.code == 0) {
@@ -122,16 +170,20 @@ function sureLogin() {
         cacheCheckDatas(data.data.selRoles);
         const otherLogoPm = otherLogo ? '?adLg=1' : '';
         const hideLgPm = hideLogo ? '?hideLg=1' : '';
-        window.location.href = 'index.html' + hideLgPm + otherLogoPm;
+        window.location.href = 'index.html' + hideLgPm + otherLogoPm + "?is3His="+is3His;
       }, 600);
     } else {
+        if(!is3His){
+          getSecurityCode();
+        }//登录失败切换验证码
       $(".divModal").remove()
       if (type == 1) {
         toast(data.msg);
       } else {
         $(".login .waring").css('visibility', 'visible').html(data.msg)
+
       }
-      
+
     }
   }).catch(() => {
     $(".divModal").remove()