dedsudiyu hace 1 mes
padre
commit
f30c7b1cb6

+ 0 - 1
src/components/voiceBroadcast/voiceBroadcast.vue

@@ -233,7 +233,6 @@
             formData.append("file", file);
             formData.append("ifAsy", false);
             systemFileUpload(formData).then(response => {
-              console.log('response',response)
               let url = localStorage.getItem('fileBrowseEnvironment') + '/' + response.data.url;
               self.iotAppSpeakerPlayVoice(url);
             });

+ 6 - 1
src/router/index.js

@@ -10,7 +10,12 @@ export const constantRoutes = [
   },
   {
     path: '/login',
-    component: (resolve) => require(['@/views/login'], resolve),
+    component: (resolve) => require(['@/views/login/login'], resolve),
+    hidden: true
+  },
+  {
+    path: '/accountLogin',
+    component: (resolve) => require(['@/views/login/accountLogin'], resolve),
     hidden: true
   },
   // {

+ 3 - 11
src/views/login.vue

@@ -1,4 +1,4 @@
-<!-- 登录 -->
+<!-- 账号登录 -->
 <template>
   <div id="accountLogin">
     <img class="login-max-big" :src="loginBanner">
@@ -106,18 +106,10 @@
               //查询是否是管理员/安全员
               this.systemSubjectCheckIsAdminOrSafeUser()
             }).catch((error) => {
-              uni.showToast({
-                title: '数据异常,请稍候再试!',
-                icon: "none",
-                duration: 3000
-              });
+              Toast.fail('数据异常,请稍候再试!');
             })
           } else {
-            uni.showToast({
-              title: '非教职工/学生账号,无法登录本系统.',
-              icon: "none",
-              duration: 3000
-            });
+            Toast.fail('非教职工/学生账号,无法登录本系统.');
           }
         })
       },

+ 123 - 0
src/views/login/login.vue

@@ -0,0 +1,123 @@
+<template>
+  <div id="login">
+    <img class="logo-img" :src="imagesUrl('commonality/logo%401x.png')">
+    <p class="title-1">欢迎使用</p>
+    <p class="title-2">实验室安全智慧化管控系统</p>
+    <p class="null-p"></p>
+    <img class="login-img" :src="imagesUrl('commonality/img_tyrzdl_ch%402x.png')">
+    <p class="ssoButton" @click="goPage('ssoLogin')">统一身份认证登录</p>
+    <p class="accountButton" @click="goPage('accountLogin')">账号密码登录</p>
+    <p class="position-top-right-box"></p>
+    <p class="position-bottom-left-box"></p>
+  </div>
+</template>
+
+<script>
+  export default {
+    name: "ssoLogin",
+    data() {
+      return {
+
+      }
+    },
+    onLoad(option) {
+
+    },
+    mounted() {
+      localStorage.setItem('loginH5','true')
+    },
+
+    methods: {
+      imagesUrl(imgUrl) {
+        return 'https://zj-wechat.oss-cn-beijing.aliyuncs.com/xcx_images/xcx_v3/' + imgUrl
+      },
+      goPage(type){
+        if(type == 'ssoLogin'){
+          this.$router.push({ path: '/miniProgramAuthentication' });
+        }else if(type == 'accountLogin'){
+          this.$router.push({ path: '/accountLogin' });
+        }
+      },
+    },
+  }
+</script>
+
+<style scoped lang="scss">
+  #login{
+    height: 100%;
+    width: 100%;
+    background:#fff;
+    position:relative;
+    display: flex;
+    flex-direction: column;
+    position: relative;
+    .logo-img{
+      width:370px;
+      height:68px;
+      margin:320px 190px 0;
+    }
+    .position-top-right-box{
+      position: absolute;
+      top:0;
+      right:0;
+      width:230px;
+      height:230px;
+      border-bottom-left-radius: 100%;
+      background-color: #E5F2FE;
+      filter: blur(4px);
+    }
+    .position-bottom-left-box{
+      position: absolute;
+      bottom:0;
+      left:0;
+      width:230px;
+      height:230px;
+      border-top-right-radius: 100%;
+      background-color: #E5F2FE;
+      filter: blur(4px);
+    }
+    .title-1{
+      font-size:38px;
+      line-height:55px;
+      height:55px;
+      text-align: center;
+      color:#333;
+      margin:90px 0 31px;
+    }
+    .title-2{
+      font-size:38px;
+      line-height:55px;
+      height:55px;
+      text-align: center;
+      color:#0183fa;
+    }
+    .null-p{
+      flex:1;
+    }
+    .login-img{
+      width:600px;
+      height:408px;
+      margin:0 auto 125px;
+    }
+    .ssoButton{
+      width:650px;
+      height:80px;
+      line-height:80px;
+      text-align: center;
+      background-color:#0183fa;
+      color:#fff;
+      font-size:32px;
+      margin:0 auto 175px;
+      border-radius:50px;
+    }
+    .accountButton{
+      width:200px;
+      height:80px;
+      line-height:80px;
+      text-align: center;
+      color:#0183fa;
+      font-size:28px;
+      margin:0 auto 40px;
+    }
+  }
+</style>

+ 95 - 11
src/views/miniProgramAuthentication/index.vue

@@ -5,6 +5,11 @@
   </div>
 </template>
 <script>
+  import {
+    getConfigByType,
+    systemSubjectCheckIsAdminOrSafeUser,
+    securityDataStatisticsGetUserIdentity
+  } from '@/api/index.js'
   import wx from "weixin-webview-jssdk";
   export default {
     name: 'index',
@@ -12,6 +17,7 @@
       return {}
     },
     created () {
+      let self = this;
       let url = decodeURIComponent(window.location.href);
       if (url.indexOf('token') != -1) {
         let list = url.split("?")[1].split("&");
@@ -19,21 +25,54 @@
         list.forEach((item) => {
           codeData[item.split("=")[0]] = item.split("=")[1];
         });
-        wx.miniProgram.navigateTo({
-          url: '/pages/views/login/ssoCertification?token='+codeData.token
-        })
+        if(localStorage.getItem('loginH5')){
+          localStorage.setItem('touken',codeData.token);
+          localStorage.removeItem('loginH5');
+          setTimeout(function(){
+            //等待配置与字段获取到后跳转
+            Promise.all([
+              //获取开发配置
+              self.getConfigByType(),
+            ]).then((result) => {
+              //查询是否是管理员/安全员
+              self.systemSubjectCheckIsAdminOrSafeUser()
+            }).catch((error) => {
+              Toast.fail('数据异常,请稍候再试!');
+            })
+          },500);
+        }else{
+          wx.miniProgram.navigateTo({
+            url: '/pages/views/login/ssoCertification?token='+codeData.token
+          })
+        }
       } else if (url.indexOf('code') != -1) {
         //code 异常状态处理
         if(url.split('=')[1] == '10100'){
-          //当前用户不存在,请联系管理员!
-          wx.miniProgram.navigateTo({
-            url: '/pages/views/login/ssoCertification?code=10100'
-          })
+          if(localStorage.getItem('loginH5')){
+            localStorage.removeItem('loginH5');
+            Toast.fail('当前用户不存在,请联系管理员!');
+            setTimeout(function(){
+              self.$router.push({ path: '/login' });
+            },2000);
+          }else{
+            //当前用户不存在,请联系管理员!
+            wx.miniProgram.navigateTo({
+              url: '/pages/views/login/ssoCertification?code=10100'
+            })
+          }
         }else if(url.split('=')[1] == '500'){
-          //服务异常,请稍候再试!
-          wx.miniProgram.navigateTo({
-            url: '/pages/views/login/ssoCertification?code=500'
-          })
+          if(localStorage.getItem('loginH5')){
+            localStorage.removeItem('loginH5')
+            Toast.fail('服务异常,请稍候再试!');
+            setTimeout(function(){
+              self.$router.push({ path: '/login' });
+            },2000);
+          }else{
+            //服务异常,请稍候再试!
+            wx.miniProgram.navigateTo({
+              url: '/pages/views/login/ssoCertification?code=500'
+            })
+          }
         }
       } else {
         //跳转至认证页面
@@ -45,6 +84,51 @@
     },
     methods: {
 
+      //获取开发配置
+      getConfigByType() {
+        getConfigByType({category: 2, configType: 5}).then(response => {
+          let obj = JSON.parse(response.data.configValue)
+          //文件预览地址
+          localStorage.setItem('filePreviewUrl', 'https://' + obj.fileExtranetUrl)
+          //小程序视频地址
+          localStorage.setItem('cameraExtranetAgent', 'https://' + obj.cameraExtranetAgent)
+          //MQTT地址
+          localStorage.setItem('mqttUrl', Decrypt(obj.mqttExtranetUrl))
+          //MQTT地址-内网
+          localStorage.setItem('mqttIntranetUrl', Decrypt(obj.mqttIntranetUrl))
+          //MQTT账号
+          localStorage.setItem('mqttUser', Decrypt(obj.mqttExtranetUser))
+          //MQTT密码
+          localStorage.setItem('mqttPassword', Decrypt(obj.mqttExtranetPassword))
+          //文件浏览环境
+          localStorage.setItem('fileBrowseEnvironment', 'http://' + Decrypt(obj.fileBrowseEnvironment))
+          localStorage.setItem('fileBrowseEnvironmentExtranet', 'http://' + Decrypt(obj.fileBrowseEnvironmentExtranet))
+        })
+      },
+      //查询是否是管理员/安全员
+      systemSubjectCheckIsAdminOrSafeUser(){
+        systemSubjectCheckIsAdminOrSafeUser({}).then(response => {
+          if (response.data.isSafe || response.data.isAdmin) {
+            window.location.href = localStorage.getItem('alarmUrl');
+          }else{
+            this.securityDataStatisticsGetUserIdentity();
+          }
+        })
+      },
+      //查询是否是校级管理员/院级管理员
+      securityDataStatisticsGetUserIdentity(){
+        let self = this;
+        securityDataStatisticsGetUserIdentity({}).then(response => {
+          if(response.data.schoolAdmin || response.data.collegeAdmin){
+            window.location.href = localStorage.getItem('alarmUrl');
+          }else{
+            Toast.fail('您无权查看报警信息,请联系管理员.');
+            setTimeout(function(){
+              self.$router.push({ path: '/login' });
+            },2000);
+          }
+        })
+      },
     },
   }
 </script>