Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
h5
/
glsx-posters
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 5548179b
authored
Mar 07, 2023
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复线上问题
1 parent
79c2ce29
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
118 additions
and
5 deletions
src/main.ts
src/utils/config.ts
src/utils/config1.ts
src/utils/http1.ts
src/utils/request.ts
src/main.ts
View file @
5548179
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
* @Author: huyue
* @Author: huyue
* @Date: 2022-10-10 10:54:14
* @Date: 2022-10-10 10:54:14
* @LastEditors: huyue
* @LastEditors: huyue
* @LastEditTime: 202
2-11-21 10:08:12
* @LastEditTime: 202
3-03-07 10:21:50
*/
*/
import
{
createApp
}
from
'vue'
import
{
createApp
}
from
'vue'
import
store
from
'./store'
import
store
from
'./store'
...
@@ -13,6 +13,7 @@ import App from './App.vue'
...
@@ -13,6 +13,7 @@ import App from './App.vue'
import
'lib-flexible/flexible'
import
'lib-flexible/flexible'
import
'utils/rem'
import
'utils/rem'
import
fetchConfig
from
'./utils/config'
import
fetchConfig
from
'./utils/config'
import
fetchConfig1
from
'./utils/config1'
import
VConsole
from
'vconsole'
import
VConsole
from
'vconsole'
import
'assets/styles/common.scss'
import
'assets/styles/common.scss'
const
app
=
createApp
(
App
)
const
app
=
createApp
(
App
)
...
@@ -30,6 +31,9 @@ fetchConfig().then(res => {
...
@@ -30,6 +31,9 @@ fetchConfig().then(res => {
version
:
res
.
version
version
:
res
.
version
})
})
localStorage
.
setItem
(
'config'
,
JSON
.
stringify
(
res
))
localStorage
.
setItem
(
'config'
,
JSON
.
stringify
(
res
))
fetchConfig1
().
then
(
result
=>
{
localStorage
.
setItem
(
'config1'
,
JSON
.
stringify
(
result
))
})
// if (res.vconsole) vConsole = new VConsole()
// if (res.vconsole) vConsole = new VConsole()
app
.
use
(
store
)
app
.
use
(
store
)
setupRouter
(
app
)
setupRouter
(
app
)
...
...
src/utils/config.ts
View file @
5548179
...
@@ -3,11 +3,11 @@
...
@@ -3,11 +3,11 @@
* @Author: huyue
* @Author: huyue
* @Date: 2022-10-10 10:54:14
* @Date: 2022-10-10 10:54:14
* @LastEditors: huyue
* @LastEditors: huyue
* @LastEditTime: 2023-03-0
3 18:31:40
* @LastEditTime: 2023-03-0
7 09:31:38
*/
*/
const
fetchConfig
=
function
(
isEnv
=
true
)
{
const
fetchConfig
=
function
(
isEnv
=
true
)
{
//
return window.fetch('https://oss-config.dev.glsx.com.cn/mock/618cb9331072f92988f05a23/wx/h5-config', {}).then(res => res.json())
return
window
.
fetch
(
'https://oss-config.dev.glsx.com.cn/mock/618cb9331072f92988f05a23/wx/h5-config'
,
{}).
then
(
res
=>
res
.
json
())
return
window
.
fetch
(
'https://oss-config.test.glsx.com.cn/mock/618cb9331072f92988f05a23/wx/h5-config'
,
{}).
then
(
res
=>
res
.
json
())
//
return window.fetch('https://oss-config.test.glsx.com.cn/mock/618cb9331072f92988f05a23/wx/h5-config', {}).then(res => res.json())
}
}
// const $mockConfig = await fetchConfig()
// const $mockConfig = await fetchConfig()
export
default
fetchConfig
export
default
fetchConfig
\ No newline at end of file
\ No newline at end of file
src/utils/config1.ts
0 → 100644
View file @
5548179
/*
* @Description: 配置
* @Author: huyue
* @Date: 2022-10-10 10:54:14
* @LastEditors: huyue
* @LastEditTime: 2023-03-07 10:33:10
*/
const
fetchConfig1
=
function
(
isEnv
=
true
)
{
// return window.fetch('http://oss-config.dev.glsx.com.cn/mock/618cb9331072f92988f05a23/wx/djposter-config', {}).then(res => res.json())
return
window
.
fetch
(
'https://oss-config.test.glsx.com.cn/mock/618cb9331072f92988f05a23/wx/djposter-config'
,
{}).
then
(
res
=>
res
.
json
())
}
// const $mockConfig = await fetchConfig()
export
default
fetchConfig1
\ No newline at end of file
\ No newline at end of file
src/utils/http1.ts
0 → 100644
View file @
5548179
/*
* @Description:
* @Author: huyue
* @Date: 2022-08-23 11:04:56
* @LastEditors: huyue
* @LastEditTime: 2023-03-07 10:24:47
*/
import
axios
,
{
AxiosInstance
,
AxiosRequestConfig
,
AxiosResponse
,
AxiosError
}
from
'axios'
import
{
Toast
}
from
'vant'
;
import
qs
from
'qs'
import
{
createSign
}
from
'./util'
const
options
:
any
=
localStorage
.
getItem
(
'config1'
)
interface
Config
{
response
:
{
'code_key'
:
string
,
'code_success_value'
:
0
,
'data_key'
:
string
,
'errId_logout_value'
:
string
,
'errId'
?:
string
,
'code_error_value'
:
string
},
request
:
{
baseURL
:
string
},
secret
:
string
,
sign
:
object
,
vconsole
:
boolean
}
const
mockConfig
:
Config
=
JSON
.
parse
(
options
)
const
{
response
,
request
,
sign
,
secret
}
=
mockConfig
// axios.defaults.baseURL = request.baseURL
// 配置新建一个axios 实例
const
service
:
AxiosInstance
=
axios
.
create
({
timeout
:
50000
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded; charset=UTF-8'
}
})
// 添加请求拦截器
service
.
interceptors
.
request
.
use
((
config
:
AxiosRequestConfig
)
=>
{
let
{
data
=
{},
domain
}
=
config
data
=
createSign
(
Object
.
assign
({},
sign
,
data
),
secret
)
config
.
baseURL
=
mockConfig
[
domain
].
baseURL
if
(
config
.
method
)
{
const
method
=
config
.
method
.
toLowerCase
()
if
(
method
==
'get'
)
{
config
.
params
=
data
}
else
if
(
method
==
'post'
)
{
config
.
data
=
qs
.
stringify
(
data
)
}
}
return
config
},
(
error
:
AxiosError
)
=>
{
return
Promise
.
reject
(
error
)
})
// 添加响应拦截器
service
.
interceptors
.
response
.
use
((
r
:
AxiosResponse
)
=>
{
const
{
data
:
res
,
config
:
{
returnAll
}
}
=
r
const
{
code_key
,
code_success_value
,
data_key
=
'data'
,
errId
=
'errId'
,
code_error_value
,
errId_logout_value
}
=
response
let
codekey
=
Array
.
isArray
(
code_key
)
?
code_key
.
find
(
key
=>
res
.
hasOwnProperty
(
key
))
:
code_key
let
code
=
res
[
codekey
]
let
errValue
=
res
[
errId
]
// 特殊的code处理,可以增加
switch
(
code
+
''
)
{
case
code_success_value
+
''
:
if
(
returnAll
)
return
res
break
case
code_error_value
+
''
:
if
(
errValue
&&
errValue
==
errId_logout_value
)
{
localStorage
.
removeItem
(
'sessionId'
)
const
[
href
]
=
window
.
location
.
href
.
split
(
'/#/'
)
location
.
href
=
`
${
href
}
/#/login`
}
Toast
(
res
.
message
)
break
default
:
Toast
(
res
.
message
||
res
.
msg
||
'出错了,请联系管理员'
)
break
}
if
(
returnAll
)
return
res
return
res
[
data_key
]
},
error
=>
{
Toast
(
error
.
message
)
return
Promise
.
reject
(
error
)
})
export
default
service
\ No newline at end of file
\ No newline at end of file
src/utils/request.ts
View file @
5548179
/*
* @Description:
* @Author: huyue
* @Date: 2022-12-06 16:17:36
* @LastEditors: huyue
* @LastEditTime: 2023-03-07 10:26:01
*/
import
http
from
'./http'
import
http
from
'./http'
import
http1
from
'./http1'
import
{
useUserStore
}
from
'../store/user'
import
{
useUserStore
}
from
'../store/user'
const
PATH
=
'rop-scrm-shopmall/router'
const
PATH
=
'rop-scrm-shopmall/router'
const
DJPATH
=
'rop-dj-smartcarlife/router'
const
DJPATH
=
'rop-dj-smartcarlife/router'
...
@@ -22,7 +30,7 @@ const djReq: any = (url: string, data: any = {}, returnAll = false, method = 'PO
...
@@ -22,7 +30,7 @@ const djReq: any = (url: string, data: any = {}, returnAll = false, method = 'PO
data
,
data
,
returnAll
returnAll
}
}
return
http
(
options
)
return
http
1
(
options
)
}
}
export
{
export
{
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment