From 1da6506bf58270bacc2a4345002c6b082835580e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 21 十月 2021 23:17:08 +0800 Subject: [PATCH] 2021-10-21 --- src/views/login/index.jsx | 49 +++++++++++++++++++++++++++---------------------- 1 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx index 5315abd..3f4b01d 100644 --- a/src/views/login/index.jsx +++ b/src/views/login/index.jsx @@ -319,25 +319,11 @@ // }) const _addressUrl = window.location.href.split('#')[0] + 'queryAddress' - if (_addressUrl !== 'true') { + if (localStorage.getItem(_addressUrl) !== 'true') { sessionStorage.setItem('city', '') sessionStorage.setItem('ipAddress', '') } else { - window.callbackFunction = (res) => { - if (res.result && res.result.ad_info) { - sessionStorage.setItem('city', res.result.ad_info.city) - sessionStorage.setItem('ipAddress', res.result.ip) - } - } - - const JSONP = document.createElement('script') - JSONP.type = 'text/javascript' - JSONP.src = 'https://apis.map.qq.com/ws/location/v1/ip?callback=callbackFunction&key=BA7BZ-4QB65-LFCIA-QPDA6-4G6O7-MJB4Q&output=jsonp&sig=3e5ebecb324ba266bf80014dcc8380db' - document.getElementsByTagName('head')[0].appendChild(JSONP) - - setTimeout(() => { - document.getElementsByTagName('head')[0].removeChild(JSONP) - },500) + this.queryAddress() } const timeStamp = new Date().getTime() @@ -420,6 +406,7 @@ localStorage.setItem(_addressUrl, 'false') } else { localStorage.setItem(_addressUrl, 'true') + this.queryAddress() } } else if (res.ErrCode === 'N') { localStorage.removeItem(_authUrl) @@ -474,7 +461,8 @@ style: res.CSS || '', showline: res.split_line_show || 'true', webSite: res.WebSite || '', - navBar: res.menu_type + navBar: res.menu_type, + app_version: res.app_version } sessionStorage.setItem('home_background', res.index_background_color || '') @@ -488,7 +476,7 @@ try { localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify(systemMsg)))) - } catch { + } catch (e) { localStorage.removeItem(_url) } @@ -504,14 +492,12 @@ login_types.push(item.way_no) login_ways.push({ - label: item.way_name, type: item.way_no, smsId: item.sms_id }) }) } else { login_ways.push({ - label: '璐﹀彿瀵嗙爜鐧诲綍', type: 'uname_pwd', smsId: '' }) @@ -519,7 +505,7 @@ try { localStorage.setItem(_loginurl, window.btoa(window.encodeURIComponent(JSON.stringify(login_ways)))) - } catch { + } catch (e) { localStorage.removeItem(_loginurl) } @@ -532,6 +518,7 @@ window.GLOB.mainlogo = systemMsg.mainlogo window.GLOB.style = systemMsg.style window.GLOB.navBar = systemMsg.navBar + window.GLOB.appVersion = systemMsg.app_version if (window.GLOB.style && styles[window.GLOB.style]) { document.body.className = styles[window.GLOB.style] + ' ' + (res.split_line_show === 'false' ? 'hidden-split-line' : '') @@ -591,7 +578,7 @@ if (loginWays) { try { loginWays = JSON.parse(window.decodeURIComponent(window.atob(loginWays))) - } catch { + } catch (e) { loginWays = null } @@ -601,6 +588,24 @@ } } + queryAddress = () => { + window.callbackFunction = (res) => { + if (res.result && res.result.ad_info) { + sessionStorage.setItem('city', res.result.ad_info.city) + sessionStorage.setItem('ipAddress', res.result.ip) + } + } + + const JSONP = document.createElement('script') + JSONP.type = 'text/javascript' + JSONP.src = 'https://apis.map.qq.com/ws/location/v1/ip?callback=callbackFunction&key=BA7BZ-4QB65-LFCIA-QPDA6-4G6O7-MJB4Q&output=jsonp&sig=3e5ebecb324ba266bf80014dcc8380db' + document.getElementsByTagName('head')[0].appendChild(JSONP) + + setTimeout(() => { + document.getElementsByTagName('head')[0].removeChild(JSONP) + },500) + } + syncSubmit = () => { this.setState({ syncing: true -- Gitblit v1.8.0