From d823c59ba0b5f73e06c90d8bcae4dd25f5dfab64 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 07 九月 2023 17:18:02 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/views/login/index.jsx |  181 ++++++++++++++++++++++++++------------------
 1 files changed, 107 insertions(+), 74 deletions(-)

diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx
index b092d43..3135c50 100644
--- a/src/views/login/index.jsx
+++ b/src/views/login/index.jsx
@@ -6,7 +6,7 @@
 import Api from '@/api'
 import Utils from '@/utils/utils.js' 
 import MKEmitter from '@/utils/events.js'
-import options, { styles } from '@/store/options.js'
+import { styles } from '@/store/options.js'
 import zhCN from '@/locales/zh-CN/login.js'
 import enUS from '@/locales/en-US/login.js'
 import asyncComponent from '@/utils/asyncComponent'
@@ -109,10 +109,17 @@
       sessionStorage.removeItem('visitorUserID')
       sessionStorage.removeItem('visitorLoginUID')
       
-      if (param.remember) { // 璁颁綇瀵嗙爜鏃惰处鍙峰瘑鐮佸瓨鍏ocalStorage
-        localStorage.setItem(_href, window.btoa(window.encodeURIComponent(JSON.stringify({username: param.username, password: param.password}))))
+      let users = localStorage.getItem(_href + 'users')
+      
+      if (users) {
+        try {
+          users = JSON.parse(window.decodeURIComponent(window.atob(users)))
+        } catch (e) {
+          console.warn('Parse Failure')
+          users = []
+        }
       } else {
-        localStorage.removeItem(_href)
+        users = []
       }
       
       // positecgroup
@@ -124,6 +131,16 @@
         })
         return
       }
+
+      users = users.filter(item => item.username !== param.username)
+
+      if (users.length > 4) {
+        users.length = 4
+      }
+
+      users.unshift({username: param.username, password: param.remember ? param.password : ''})
+
+      localStorage.setItem(_href + 'users', window.btoa(window.encodeURIComponent(JSON.stringify(users))))
 
       let level = localStorage.getItem(_href + 'pwdlevel')
 
@@ -160,8 +177,14 @@
         }
       }
 
-      this.props.history.replace('/main')
-    } else if (res.ErrCode === 'Need_Get_Appkey' && options.sysType === 'SSO') {
+      let iframe = sessionStorage.getItem('iframe')
+      if (iframe) {
+        sessionStorage.removeItem('iframe')
+        this.props.history.replace(iframe.replace(/@loginuid@/, res.LoginUID))
+      } else {
+        this.props.history.replace('/main')
+      }
+    } else if (res.ErrCode === 'Need_Get_Appkey' && window.GLOB.sysType === 'SSO') {
       message.warning('搴旂敤灏氭湭鍒涘缓锛岃鍚戜簯绔悓姝ュ簲鐢紒')
 
       this.setState({
@@ -176,7 +199,8 @@
           input.select()
         }
       } else if (res.message.indexOf('鐧诲綍鏉冮檺') > -1) {
-        const input = document.getElementById('username')
+        const wrap = document.getElementById('username')
+        const input = wrap ? wrap.getElementsByTagName('input')[0] : null
         if (input) {
           input.select()
         }
@@ -214,8 +238,14 @@
       sessionStorage.removeItem('visitorUserID')
       sessionStorage.removeItem('visitorLoginUID')
 
-      this.props.history.replace('/main')
-    } else if (res.ErrCode === 'Need_Get_Appkey' && options.sysType === 'SSO') {
+      let iframe = sessionStorage.getItem('iframe')
+      if (iframe) {
+        sessionStorage.removeItem('iframe')
+        this.props.history.replace(iframe.replace(/@loginuid@/, res.LoginUID))
+      } else {
+        this.props.history.replace('/main')
+      }
+    } else if (res.ErrCode === 'Need_Get_Appkey' && window.GLOB.sysType === 'SSO') {
       message.warning('搴旂敤灏氭湭鍒涘缓锛岃鍚戜簯绔悓姝ュ簲鐢紒')
 
       this.setState({
@@ -253,8 +283,14 @@
         sessionStorage.removeItem('visitorUserID')
         sessionStorage.removeItem('visitorLoginUID')
   
-        this.props.history.replace('/main')
-      } else if (res.ErrCode === 'Need_Get_Appkey' && options.sysType === 'SSO') {
+        let iframe = sessionStorage.getItem('iframe')
+        if (iframe) {
+          sessionStorage.removeItem('iframe')
+          this.props.history.replace(iframe.replace(/@loginuid@/, res.LoginUID))
+        } else {
+          this.props.history.replace('/main')
+        }
+      } else if (res.ErrCode === 'Need_Get_Appkey' && window.GLOB.sysType === 'SSO') {
         message.warning('搴旂敤灏氭湭鍒涘缓锛岃鍚戜簯绔悓姝ュ簲鐢紒')
   
         this.setState({
@@ -286,7 +322,7 @@
         document.getElementsByTagName('head')[0].removeChild(JSONP)
       },500)
     })
-}
+  }
 
   componentDidMount () {
     // md5("/ws/location/v1/ip?callback=callbackFunction&key=key&output=jsonp secret key")
@@ -302,27 +338,6 @@
       if (view) {
         view.style.filter = 'grayscale(100%)'
       }
-    }
-
-    if (sessionStorage.getItem('loginError')) {
-      try {
-        let res = JSON.parse(sessionStorage.getItem('loginError'))
-        console.info(res.url)
-        console.info(res.request)
-        console.info(res.response)
-
-        let result = JSON.parse(res.response)
-
-        notification.warning({
-          top: 92,
-          message: result.message,
-          duration: 5
-        })
-      } catch (e) {}
-      
-      setTimeout(() => {
-        sessionStorage.removeItem('loginError')
-      }, 2000)
     }
 
     const _addressUrl = _href + 'queryAddress'
@@ -419,22 +434,17 @@
     }
 
     if (!window.GLOB.licenseKey && (index === -1 || index > 5)) {
-      let _appId = window.GLOB.appId
-  
-      if (options.sysType === 'cloud') { // 浜戠浣跨敤绯荤粺閰嶇疆appid
-        _appId = options.caId
-      }
-  
-      let str = md5('MK19' + _appId + timeStamp)
+      let str = md5('MK19' + window.GLOB.appId + timeStamp)
       let _rduri = window.atob('aHR0cHM6Ly9lcGMubWs5aC5$mkjbi93ZWJhcGkvZG9zdGFycw=='.replace(/\$mk/ig, ''))
       let _func = window.atob('c0VtcG93ZXJDbG91$mkZF9HZXRfTGlua1VybA=='.replace(/\$mk/ig, ''))
       let _id = window.atob('YmgwYmFwYWJ0ZDQ1ZXBz$mkZ3JhNzlzZWdiY2g2YzFpYms='.replace(/\$mk/ig, ''))
   
       let param = {
         func: _func,
-        AppID: _appId,
+        AppID: window.GLOB.appId,
         TimeStamp: timeStamp,
         appkey: window.GLOB.appkey,
+        SessionUid: localStorage.getItem('SessionUid') || '',
         userid: _id,
         LoginUID: _id,
         nonc: Utils.getuuid()
@@ -460,7 +470,7 @@
       Api.directRequest({
         url: _rduri + '/' + _func,
         method: 'post',
-        data: param
+        data: JSON.stringify(param)
       }).then(res => {
         if (res.status) {
           if (res.EPC === str) {
@@ -502,7 +512,30 @@
             authError: res.message
           })
         }
-      }, () => {
+      }, (error) => {
+        if (error && error.ErrCode === 'LoginError') {
+          let param = {
+            func: 's_visitor_login',
+            timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), 
+            SessionUid: _id,
+            TypeCharOne: 'pc',
+            appkey: '202004041613277377A6A2456D34A4948AE84'
+          }
+
+          param.LText = md5(window.btoa(_id + param.timestamp))
+          param.secretkey = md5(param.LText + 'mingke' + param.timestamp)
+
+          let params = {
+            url: _rduri.replace('dostars', 'dologon'),
+            method: 'post',
+            data: JSON.stringify(param)
+          }
+
+          Api.directRequest(params)
+
+          return
+        }
+
         if (index === -1 || index > 10) {
           this.setState({
             auth: false,
@@ -514,20 +547,20 @@
 
     Api.getTouristMsg().then(result => {
       if (result.status) {
-        if (result.website && process.env.NODE_ENV === 'production') {
-          let website = result.website.replace(/http(s)?:\/\/|\/$/ig, '').toLowerCase()
-          let current = window.GLOB.baseurl.replace(/http(s)?:\/\/|\/$/ig, '').toLowerCase()
+        // if (result.website && process.env.NODE_ENV === 'production') {
+        //   let website = result.website.replace(/http(s)?:\/\/|\/$/ig, '').toLowerCase()
+        //   let current = window.GLOB.baseurl.replace(/http(s)?:\/\/|\/$/ig, '').toLowerCase()
 
-          if (website !== current) {
-            try {
-              window.history.replaceState(null, null, result.website.replace(/\/$/ig, '') + '/admin/index.html#/login')
-              window.location.reload()
-            } catch(e) {
-              window.location.href = result.website.replace(/\/$/ig, '') + '/admin/index.html#/login'
-            }
-            return
-          }
-        }
+        //   if (website !== current) {
+        //     try {
+        //       window.history.replaceState(null, null, result.website.replace(/\/$/ig, '') + '/admin/index.html#/login')
+        //       window.location.reload()
+        //     } catch(e) {
+        //       window.location.href = result.website.replace(/\/$/ig, '') + '/admin/index.html#/login'
+        //     }
+        //     return
+        //   }
+        // }
         
         sessionStorage.setItem('visitorUserID', result.UserID || '')
         sessionStorage.setItem('visitorLoginUID', result.LoginUID || '')
@@ -549,14 +582,11 @@
         _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
 
         Api.getSystemConfig(_param).then(res => {
+          if (!res) return
+          
           if (res.status) {
             // positecgroup
-            res.Banner = res.Banner ? res.Banner.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : ''
-            res.doclogo = res.doclogo ? res.doclogo.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : ''
-            res.indexlogo = res.indexlogo ? res.indexlogo.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : ''
-            res.loginlogo = res.loginlogo ? res.loginlogo.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : ''
-
-            // if (options.sysType === 'local' && window.GLOB.systemType !== 'production') {
+            // if (window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production') {
             //   if (md5(('mk' + window.GLOB.appkey + res.sys_datetime + res.member_type + res.registry_date).toLowerCase()) !== res.secret_key) {
             //     Modal.warning({
             //       title: '瀵嗛挜閿欒锛岃鑱旂郴绠$悊鍛橈紒',
@@ -595,7 +625,18 @@
               showline: res.split_line_show || 'true',
               webSite: res.WebSite || '',
               navBar: res.menu_type, // shutter 鐧惧彾绐椼�乴inkage_navigation 鑱斿姩鑿滃崟銆乴inkage 鑱斿姩鑿滃崟_鏃犲鑸爮銆乵enu_board 鑿滃崟闈㈡澘銆乵enu_board_navigation 鑿滃崟闈㈡澘_鏍囩椤�
-              app_version: res.app_version
+              app_version: res.app_version,
+              Member_Level: 0
+            }
+
+            if ([10, 20, 30, 40, 50, 60, 70, 80, 90, 100].includes(res.member_level)) {
+              systemMsg.Member_Level = md5('mksoft' + window.GLOB.appkey + res.member_level)
+              if (!window.GLOB.memberLevel) {
+                Object.defineProperty(window.GLOB, 'memberLevel', {
+                  writable: false,
+                  value: res.member_level
+                })
+              }
             }
 
             let level = res.pwd_level || ''
@@ -685,13 +726,6 @@
               document.getElementsByTagName('head')[0].appendChild(link)
             }
 
-            let memberLevel = res.member_level
-
-            if (typeof(memberLevel) === 'number' && memberLevel > 10 && parseInt(memberLevel / 10) * 10 === memberLevel) {
-              sessionStorage.setItem('Member_Level', md5('mksoft' + window.GLOB.appkey + new Date().getFullYear() + new Date().getMonth() + memberLevel))
-              window.GLOB.memberLevel = memberLevel
-            }
-
             // positecgroup
             if (res.users_upt === 'true' && window.GLOB.systemType === 'production') {
               Api.genericInterface({
@@ -773,15 +807,15 @@
       func: 's_get_app_from_cloud',
       UserName: '',
       Password: '',
-      systemType: options.sysType,
+      systemType: window.GLOB.sysType,
       Type: 'X',
       debug: 'Y'
     }
 
     param.appkey = window.GLOB.appkey || ''
 
-    if (options.cloudServiceApi) {
-      param.rduri = options.cloudServiceApi.replace('dostars', 'dostar')
+    if (window.GLOB.cloudServiceApi) {
+      param.rduri = window.GLOB.cloudServiceApi.replace('dostars', 'dostar')
     }
 
     this.logincloudRef.handleConfirm().then(result => {
@@ -901,7 +935,6 @@
         </div>
         <div className="login-middle" style={lineColor ? {borderColor: lineColor} : {}}>
           {loginWays ? <LoginForm
-            platName={this.state.platName}
             dict={this.state.dict}
             auth={this.state.auth}
             authError={this.state.authError}

--
Gitblit v1.8.0