|
@@ -1,8 +1,10 @@
|
|
|
import { login, logout } from '@/api/user'
|
|
|
import { getToken, setToken, removeToken, setSessionStorage, removeSessionStorage } from '@/utils/auth'
|
|
|
import { imageByName } from '@/api/ftp'
|
|
|
+import { getCommonCode, editDictionary } from '@/api/base'
|
|
|
import { resetRouter } from '@/router'
|
|
|
import { encrypt, decrypt } from '@/utils/rsa'
|
|
|
+import { AjaxRequest } from '@/utils/request'
|
|
|
|
|
|
const sha1Hex = require('sha1-hex')
|
|
|
|
|
@@ -94,38 +96,191 @@ const actions = {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- resolve(response)
|
|
|
-
|
|
|
- }).then(res => {
|
|
|
- const tokenObj = {
|
|
|
- 'password': '6e7e4e9865539e9e71d12141f439c2ade546f3432a42b6471f232e1c484753a6699f292b9a3253349ca8831f69e8e779dbd9d54767ea786d825cf4d118edd673',
|
|
|
- 'f': 'json',
|
|
|
- 'username': '670299f4febcf1f2c68650676bd3fa17f58106273a95ee34906eef36edee0608d6c09c29de0d4a9bae3f0dc519975a662cb2e02065f502d44073c5b8548778fb',
|
|
|
- 'client': 'b02c3dee33c8826d8264f7dc148d97b8bd6a7e57d332fa88b8bc62f998e9b982f245bd265e1f028bd99a7a7a969d71a6616aab845d049ad53474ecf66f293b2e',
|
|
|
- 'referer': '',
|
|
|
- 'ip': '',
|
|
|
- 'expiration': '97dad6fa91cef2cf8231b83a300e5516daa55fdb01ff3554a2fa8dcaec326bf65bafe4a0be8fbf9958de4f50838105a3e105d5aee802a389d353695bf9be4ff6',
|
|
|
- 'encrypted': 'true'
|
|
|
- }
|
|
|
|
|
|
- $.ajax({
|
|
|
- url: 'http://36.138.232.112:6080/arcgis/tokens/generateToken',
|
|
|
-
|
|
|
- type: 'POST',
|
|
|
- data: tokenObj,
|
|
|
- xhrFields: {
|
|
|
- withCredentials: false
|
|
|
- },
|
|
|
- crossDomain: true,
|
|
|
- success: function(result) {
|
|
|
- const data = JSON.parse(result)
|
|
|
- console.log('arcgistoken', result)
|
|
|
- if (data.token) {
|
|
|
- commit('SET_ARCGISTOKEN', data.token)
|
|
|
- setSessionStorage('arcgistoken', data.token)
|
|
|
+ getCommonCode({ pCid: 66560 }).then(data => {
|
|
|
+ if (data.code !== -1) {
|
|
|
+ const tempAry = data.result[0].codeList
|
|
|
+ const arcgisToken = tempAry.filter(item => {
|
|
|
+ return item.ccode == 'token'
|
|
|
+ })[0].cname
|
|
|
+ const arcgisExpires = tempAry.filter(item => {
|
|
|
+ return item.ccode == 'expires'
|
|
|
+ })[0].cname
|
|
|
+
|
|
|
+ let arcgisTokenObject = {}
|
|
|
+
|
|
|
+ if (arcgisExpires < Date.now()) {
|
|
|
+ getCommonCode({ pCid: 66542 }).then(res => {
|
|
|
+ if (res.code !== -1) {
|
|
|
+ const parmasary = res.result[0].codeList
|
|
|
+ debugger
|
|
|
+ let tokenObj = {}
|
|
|
+ if (process.env.NODE_ENV != 'production') {
|
|
|
+ tokenObj = {
|
|
|
+ 'password': '6e7e4e9865539e9e71d12141f439c2ade546f3432a42b6471f232e1c484753a6699f292b9a3253349ca8831f69e8e779dbd9d54767ea786d825cf4d118edd673',
|
|
|
+ 'f': 'json',
|
|
|
+ 'username': '670299f4febcf1f2c68650676bd3fa17f58106273a95ee34906eef36edee0608d6c09c29de0d4a9bae3f0dc519975a662cb2e02065f502d44073c5b8548778fb',
|
|
|
+ 'client': 'b02c3dee33c8826d8264f7dc148d97b8bd6a7e57d332fa88b8bc62f998e9b982f245bd265e1f028bd99a7a7a969d71a6616aab845d049ad53474ecf66f293b2e',
|
|
|
+ 'referer': '',
|
|
|
+ 'ip': '',
|
|
|
+ 'expiration': '97dad6fa91cef2cf8231b83a300e5516daa55fdb01ff3554a2fa8dcaec326bf65bafe4a0be8fbf9958de4f50838105a3e105d5aee802a389d353695bf9be4ff6',
|
|
|
+ 'encrypted': 'true'
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tokenObj = {
|
|
|
+ 'password': parmasary.filter(item => { return item.ccode == 'password' })[0].cname,
|
|
|
+ 'f': 'pjson',
|
|
|
+ 'username': parmasary.filter(item => { return item.ccode == 'username' })[0].cname,
|
|
|
+ 'client': parmasary.filter(item => { return item.ccode == 'client' })[0].cname,
|
|
|
+ 'referer': parmasary.filter(item => { return item.ccode == 'referer' })[0].cname,
|
|
|
+ 'ip': parmasary.filter(item => { return item.ccode == 'ip' })[0].cname,
|
|
|
+ 'expiration': parmasary.filter(item => { return item.ccode == 'expiration' })[0].cname,
|
|
|
+ 'encrypted': parmasary.filter(item => { return item.ccode == 'encrypted' })[0].cname
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ debugger
|
|
|
+
|
|
|
+ AjaxRequest({
|
|
|
+ url: 'http://36.138.232.112:6080/arcgis/tokens/generateToken',
|
|
|
+ isAsync: false,
|
|
|
+ dataType: 'json',
|
|
|
+ method: 'POST',
|
|
|
+ data: tokenObj
|
|
|
+ }, function(result) {
|
|
|
+ const ajaxdata = result
|
|
|
+ arcgisTokenObject = ajaxdata
|
|
|
+ console.log('arcgistoken', ajaxdata)
|
|
|
+ if (ajaxdata.token) {
|
|
|
+ commit('SET_ARCGISTOKEN', ajaxdata.token)
|
|
|
+ setSessionStorage('arcgistoken', ajaxdata.token)
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ throw error
|
|
|
+ })
|
|
|
+
|
|
|
+ return tempAry
|
|
|
+ }
|
|
|
+ }).then(data => {
|
|
|
+ console.log('参数:', data, arcgisTokenObject, response)
|
|
|
+ if (process.env.NODE_ENV != 'production') {
|
|
|
+
|
|
|
+ const token = tempAry.filter(item => {
|
|
|
+ return item.ccode == 'token'
|
|
|
+ })[0]
|
|
|
+ token.cname = arcgisTokenObject.token
|
|
|
+ const expires = tempAry.filter(item => {
|
|
|
+ return item.ccode == 'expires'
|
|
|
+ })[0]
|
|
|
+ expires.cname = arcgisTokenObject.expires
|
|
|
+
|
|
|
+ editDictionary(token).then((res) => {
|
|
|
+ console.log('token', res)
|
|
|
+ return editDictionary(expires)
|
|
|
+ }).then((res) => {
|
|
|
+ console.log('expires', res)
|
|
|
+ resolve(response)
|
|
|
+ }).catch(error => {
|
|
|
+ throw error
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ commit('SET_ARCGISTOKEN', arcgisToken)
|
|
|
+ setSessionStorage('arcgistoken', arcgisToken)
|
|
|
+ resolve(response)
|
|
|
}
|
|
|
}
|
|
|
+ }).catch(error => {
|
|
|
+ throw error
|
|
|
})
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}).catch(error => {
|
|
|
reject(error)
|
|
|
})
|