From d7ec8fbd65cd7225ce8d405a0ee0a1f166f44d7b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 16 九月 2021 17:23:54 +0800 Subject: [PATCH] 2021-09-16 --- src/views/login/index.jsx | 37 +++++++++++++++++++++---------------- 1 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx index 8469483..315618c 100644 --- a/src/views/login/index.jsx +++ b/src/views/login/index.jsx @@ -281,25 +281,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() @@ -382,6 +368,7 @@ localStorage.setItem(_addressUrl, 'false') } else { localStorage.setItem(_addressUrl, 'true') + this.queryAddress() } } else if (res.ErrCode === 'N') { localStorage.removeItem(_authUrl) @@ -563,6 +550,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