Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
junlebao-milk-20240619
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
SparkProjects
junlebao-milk-20240619
Commits
5b1cad8c
Commit
5b1cad8c
authored
Jun 24, 2024
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
eab6b9df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
31 deletions
+62
-31
config.ts
miniprogram/utils/config.ts
+17
-7
request.ts
miniprogram/utils/request.ts
+45
-24
No files found.
miniprogram/utils/config.ts
View file @
5b1cad8c
// 【开发环境】
// 【开发环境】
export
const
devOptions
=
{
export
const
devOptions
=
{
BASE_URL
:
'https://activity.m.duibadev.com.cn/'
,
BASE_URL
:
'https://activity.m.duibadev.com.cn/'
,
appKey
:
'jlg88lyxz7siqtmr'
,
appKey
:
'jlg88lyxz7siqtmr'
,
}
}
// 【测试环境】
// 【测试环境】
export
const
testOptions
=
{
export
const
testOptions
=
{
BASE_URL
:
'https://activity.m.duibatest.com.cn/'
,
BASE_URL
:
'https://activity.m.duibatest.com.cn/'
,
appKey
:
'3tWCs93A2ZfuvMyJkWxC7xddg6qA'
,
appKey
:
'3tWCs93A2ZfuvMyJkWxC7xddg6qA'
,
projectId
:
"test"
,
}
}
// 【预发环境】
// 【预发环境】
export
const
prevOptions
=
{
export
const
prevOptions
=
{
BASE_URL
:
'https://activity-pre.m.duiba.com.cn/'
,
// 免登接口有预发的环境
BASE_URL
:
'https://activity-pre.m.duiba.com.cn/'
,
// 免登接口有预发的环境
appKey
:
'388ENcX8CGJBEdn2hyZA5zDkqpR6'
,
appKey
:
'388ENcX8CGJBEdn2hyZA5zDkqpR6'
,
projectId
:
"prev"
,
}
}
// 【线上环境】
// 【线上环境】
export
const
publishOptions
=
{
export
const
publishOptions
=
{
BASE_URL
:
'https://activity.m.duiba.com.cn/'
,
BASE_URL
:
'https://activity.m.duiba.com.cn/'
,
appKey
:
'388ENcX8CGJBEdn2hyZA5zDkqpR6'
,
appKey
:
'388ENcX8CGJBEdn2hyZA5zDkqpR6'
,
projectId
:
"publish"
,
}
}
export
default
publishOptions
export
default
publishOptions
;
\ No newline at end of file
export
enum
API_PATH
{
index
=
"/home/coop_index.do"
,
activity
=
"/home/coop_activity.do"
,
login
=
"/wechat/jlb/login"
,
subscribe
=
"/home/coop_subscribe.do"
,
}
\ No newline at end of file
miniprogram/utils/request.ts
View file @
5b1cad8c
import
env
from
'./config'
;
import
env
from
'./config'
;
const
headersConfig
=
{
const
headersConfig
=
{
'Content-Type'
:
'application/x-www-form-urlencoded; charset=UTF-8'
,
'Content-Type'
:
'application/x-www-form-urlencoded; charset=UTF-8'
,
}
}
export
let
request
=
(
config
:
any
)
=>
new
Promise
((
resolve
,
reject
)
=>
{
type
IReqMethod
=
'OPTIONS'
|
'GET'
|
'HEAD'
|
'POST'
|
'PUT'
|
'DELETE'
|
'TRACE'
|
'CONNECT'
;
const
method
=
config
.
method
.
toUpperCase
()
||
'GET'
;
const
{
BASE_URL
}
=
env
;
interface
IReqConfig
{
url
:
string
;
wx
.
request
({
headers
?:
object
;
method
,
data
?:
object
;
url
:
config
.
url
?
`
${
BASE_URL
}${
config
.
url
}
`
:
''
,
method
?:
IReqMethod
;
data
:
config
.
data
,
}
header
:
{
...
headersConfig
,
let
loginToken
:
string
=
""
;
...
config
.
headers
},
export
const
request
=
(
config
:
IReqConfig
)
=>
new
Promise
((
resolve
,
reject
)
=>
{
success
(
response
)
{
const
{
BASE_URL
,
projectId
}
=
env
;
if
(
+
response
.
statusCode
===
200
)
{
resolve
(
response
.
data
);
const
{
url
,
headers
,
data
,
method
=
"GET"
}
=
config
;
}
else
{
reject
(
new
Error
(
`请求失败 statusCode:
${
response
.
statusCode
}
`
));
const
type
=
(
method
.
toUpperCase
()
as
IReqMethod
)
||
'GET'
;
}
},
const
header
=
{
fail
(
error
)
{
...
headersConfig
,
reject
(
new
Error
(
error
.
errMsg
));
...
headers
,
},
loginToken
,
})
};
const
params
=
{
...
data
,
};
wx
.
request
({
method
:
type
,
url
:
`
${
BASE_URL
}${
projectId
}${
url
}
`
,
data
:
params
,
header
,
success
(
response
)
{
if
(
+
response
.
statusCode
===
200
)
{
resolve
(
response
.
data
);
}
else
{
reject
(
new
Error
(
`请求失败 statusCode:
${
response
.
statusCode
}
`
));
}
},
fail
(
error
)
{
reject
(
new
Error
(
error
.
errMsg
));
},
})
})
})
\ No newline at end of file
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