Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
million
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
viitto
million
Commits
c597d335
Commit
c597d335
authored
Jun 23, 2020
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增文件
parent
1e2a1fa8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
66 deletions
+69
-66
quasar.conf.js
quasar.conf.js
+1
-1
axios.js
src/boot/axios.js
+0
-65
utils.js
src/boot/utils.js
+68
-0
No files found.
quasar.conf.js
View file @
c597d335
...
...
@@ -21,9 +21,9 @@ module.exports = function( /* ctx */ ) {
// --> boot files are part of "main.js"
// https://quasar.dev/quasar-cli/cli-documentation/boot-files
boot
:
[
'i18n'
,
'axios'
,
"utils"
],
ssr
:
{
pwa
:
true
,
...
...
src/boot/axios.js
View file @
c597d335
...
...
@@ -4,71 +4,6 @@ import md5 from 'js-md5'
Vue
.
prototype
.
$axios
=
axios
//域名管理对象
Vue
.
prototype
.
domainManager
=
function
()
{
let
domainUrl
=
''
;
domainUrl
=
"http://127.0.0.1"
;
let
locationName
=
window
.
location
.
hostname
;
if
(
locationName
.
indexOf
(
'testerp.oytour'
)
!==
-
1
)
{
domainUrl
=
"http://testapi.oytour.com"
;
}
else
if
(
locationName
.
indexOf
(
'oytour'
)
!==
-
1
)
{
domainUrl
=
"http://reborn.oytour.com"
;
}
var
obj
=
{
//主地址
DomainUrl
:
domainUrl
,
//常用提交数据URL
PostUrl
:
domainUrl
+
"/api/common/post"
,
};
return
obj
;
}
//HTTP提交数据
Vue
.
prototype
.
apipost
=
function
(
cmd
,
msg
,
successCall
,
faildCall
)
{
if
(
msg
==
null
||
msg
==
""
)
{
msg
=
{}
}
var
timestamp
=
(
new
Date
()).
valueOf
();
var
apiurl
=
this
.
domainManager
().
PostUrl
;
var
token
=
""
;
var
key
=
""
;
var
tempLanguage
=
0
;
if
(
this
.
getLocalStorage
()
!=
null
)
{
token
=
this
.
getLocalStorage
().
token
;
key
=
this
.
getLocalStorage
().
SecretKey
;
}
var
encodeMsg
=
encodeURIComponent
(
JSON
.
stringify
(
msg
)).
toLowerCase
();
var
md5Str
=
md5
(
`cmd=
${
cmd
}
&msg=
${
encodeMsg
}
×tamp=
${
timestamp
}
&token=
${
token
}
&key=
${
key
}
`
);
var
postData
=
{
"msg"
:
msg
,
"cmd"
:
cmd
,
"timestamp"
:
timestamp
,
"token"
:
token
,
"sign"
:
md5Str
,
"languageId"
:
tempLanguage
}
this
.
$axios
.
post
(
apiurl
,
postData
,
{
headers
:
{
'Content-Type'
:
'application/json'
,
'Referer-Viitto'
:
this
.
$route
.
path
}
})
.
then
(
res
=>
{
successCall
(
res
);
},
faildCall
)
}
//获取缓存
Vue
.
prototype
.
getLocalStorage
=
function
()
{
var
localStorageData
=
window
.
localStorage
[
"b2bUser"
];
if
(
localStorageData
!==
undefined
&&
localStorageData
!=
'undefined'
)
{
return
JSON
.
parse
(
localStorageData
);
}
else
{
return
null
;
}
}
export
default
({
app
})
=>
{
...
...
src/boot/utils.js
0 → 100644
View file @
c597d335
import
Vue
from
'vue'
import
axios
from
'axios'
import
md5
from
'js-md5'
//域名管理对象
Vue
.
prototype
.
domainManager
=
function
()
{
let
domainUrl
=
''
;
domainUrl
=
"http://127.0.0.1"
;
let
locationName
=
window
.
location
.
hostname
;
if
(
locationName
.
indexOf
(
'testerp.oytour'
)
!==
-
1
)
{
domainUrl
=
"http://testapi.oytour.com"
;
}
else
if
(
locationName
.
indexOf
(
'oytour'
)
!==
-
1
)
{
domainUrl
=
"http://reborn.oytour.com"
;
}
var
obj
=
{
//主地址
DomainUrl
:
domainUrl
,
//常用提交数据URL
PostUrl
:
domainUrl
+
"/api/common/post"
,
};
return
obj
;
}
//HTTP提交数据
Vue
.
prototype
.
apipost
=
function
(
cmd
,
msg
,
successCall
,
faildCall
)
{
if
(
msg
==
null
||
msg
==
""
)
{
msg
=
{}
}
var
timestamp
=
(
new
Date
()).
valueOf
();
var
apiurl
=
this
.
domainManager
().
PostUrl
;
var
token
=
""
;
var
key
=
""
;
var
tempLanguage
=
0
;
if
(
this
.
getLocalStorage
()
!=
null
)
{
token
=
this
.
getLocalStorage
().
token
;
key
=
this
.
getLocalStorage
().
SecretKey
;
}
var
encodeMsg
=
encodeURIComponent
(
JSON
.
stringify
(
msg
)).
toLowerCase
();
var
md5Str
=
md5
(
`cmd=
${
cmd
}
&msg=
${
encodeMsg
}
×tamp=
${
timestamp
}
&token=
${
token
}
&key=
${
key
}
`
);
var
postData
=
{
msg
:
msg
,
cmd
:
cmd
,
timestamp
:
timestamp
,
token
:
token
,
sign
:
md5Str
,
languageId
:
tempLanguage
}
this
.
$axios
.
post
(
apiurl
,
postData
,
{
headers
:
{
'Content-Type'
:
'application/json'
,
'Referer-Viitto'
:
this
.
$route
.
path
}
})
.
then
(
res
=>
{
successCall
(
res
);
},
faildCall
)
}
//获取缓存
Vue
.
prototype
.
getLocalStorage
=
function
()
{
var
localStorageData
=
window
.
localStorage
[
"b2bUser"
];
if
(
localStorageData
!==
undefined
&&
localStorageData
!=
'undefined'
)
{
return
JSON
.
parse
(
localStorageData
);
}
else
{
return
null
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment