Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
op-web-service
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
bp
op-web-service
Commits
d69677f3
Commit
d69677f3
authored
Aug 04, 2021
by
lihui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: API
parent
0ec3923c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
315 additions
and
153 deletions
+315
-153
activity.js
server/controllers/activity.js
+34
-0
router.js
server/router.js
+3
-0
index.vue
src/pages/Activity/ActivityDetail/index.vue
+91
-56
index.vue
src/pages/Activity/Manage/index.vue
+117
-50
index.js
src/router/Activity/index.js
+31
-27
index.js
src/service/Activity/index.js
+26
-5
request.js
src/utils/request.js
+13
-15
No files found.
server/controllers/activity.js
View file @
d69677f3
...
@@ -10,3 +10,37 @@ exports.getActivityList = async ctx => {
...
@@ -10,3 +10,37 @@ exports.getActivityList = async ctx => {
};
};
ctx
.
body
=
await
req
(
ctx
,
opts
);
ctx
.
body
=
await
req
(
ctx
,
opts
);
};
};
// 修改商品
exports
.
editGoodsDetail
=
async
ctx
=>
{
const
url
=
`
${
ACTIVITY_URI
}
/goods/background/edit_goods`
;
const
opts
=
{
url
,
method
:
"POST"
,
json
:
true
,
body
:
ctx
.
request
.
body
};
ctx
.
body
=
await
req
(
ctx
,
opts
);
};
// 关闭/开启 活动
exports
.
updateActivity
=
async
ctx
=>
{
const
url
=
`
${
ACTIVITY_URI
}
/marketing/background/update_marketing`
;
const
opts
=
{
url
,
method
:
"POST"
,
json
:
true
,
body
:
ctx
.
request
.
body
};
ctx
.
body
=
await
req
(
ctx
,
opts
);
console
.
log
(
ctx
.
body
);
};
// 查看活动订单
exports
.
checkActivityDetail
=
async
ctx
=>
{
const
url
=
`
${
ACTIVITY_URI
}
/marketing/background/marketing_info`
;
const
opts
=
{
url
,
method
:
"POST"
,
json
:
true
,
body
:
ctx
.
request
.
body
};
ctx
.
body
=
await
req
(
ctx
,
opts
);
};
server/router.js
View file @
d69677f3
...
@@ -64,5 +64,8 @@ router.get(`${API_VERSION}/merchant/lifeinner/life_list`, life.get_life_list)
...
@@ -64,5 +64,8 @@ router.get(`${API_VERSION}/merchant/lifeinner/life_list`, life.get_life_list)
router
.
post
(
`
${
API_VERSION
}
/merchant/authority/get_user_info`
,
user
.
getUser_detail
)
router
.
post
(
`
${
API_VERSION
}
/merchant/authority/get_user_info`
,
user
.
getUser_detail
)
// 后台运营管理
// 后台运营管理
router
.
get
(
`
${
API_VERSION
}
/marketing/background/marketing_list`
,
activity
.
getActivityList
)
router
.
get
(
`
${
API_VERSION
}
/marketing/background/marketing_list`
,
activity
.
getActivityList
)
router
.
post
(
`
${
API_VERSION
}
/goods/background/edit_goods`
,
activity
.
editGoodsDetail
)
router
.
post
(
`
${
API_VERSION
}
/marketing/background/update_marketing`
,
activity
.
updateActivity
)
router
.
post
(
`
${
API_VERSION
}
/marketing/background/marketing_info`
,
activity
.
checkActivityDetail
)
module
.
exports
=
router
;
module
.
exports
=
router
;
src/pages/Activity/ActivityDetail/index.vue
View file @
d69677f3
<
template
>
<
template
>
<div
class=
"wrapper"
>
<div
class=
"wrapper"
v-loading=
"pageLoading"
element-loading-text=
"拼命加载中"
element-loading-spinner=
"el-icon-loading"
element-loading-background=
"rgba(0, 0, 0, 0.8)"
>
<div
class=
"activityDetail"
>
<div
class=
"activityDetail"
>
<
header
class=
"
header"
>
<
div
class=
"my-
header"
>
<h3>
<h3>
本周六四月三日 洞鞋子 周日就可以常抓这是给 请仔细阅读下面的文字
本周六四月三日 洞鞋子 周日就可以常抓这是给 请仔细阅读下面的文字
关注中澳提示
关注中澳提示
</h3>
</h3>
<p
class=
"endTime"
>
距结束 22:77:88
</p>
<p
class=
"endTime"
>
距结束 22:77:88
</p>
</
header
>
</
div
>
<section
class=
"content"
>
<section
class=
"content"
>
<el-card
class=
"activityGoods box-card"
>
<el-card
class=
"activityGoods box-card"
>
<p
class=
"title"
>
拼单商品
</p>
<p
class=
"title"
>
拼单商品
</p>
<div>
<div>
<el-image
class=
"activityImage"
<el-image
class=
"activityImage"
style=
"width: 100px; height: 100px"
style=
"width: 100px; height: 100px"
:src=
"url"
:src=
"url"
:
fit=
"fit"
fit=
"fit"
></el-image>
></el-image>
<el-image
class=
"activityImage"
<el-image
class=
"activityImage"
style=
"width: 100px; height: 100px"
style=
"width: 100px; height: 100px"
:src=
"url"
:src=
"url"
:
fit=
"fit"
fit=
"fit"
></el-image>
></el-image>
</div>
</div>
</el-card>
</el-card>
...
@@ -31,25 +39,31 @@
...
@@ -31,25 +39,31 @@
布拉布拉这是一大片介绍信息 布拉布拉这是一大片介绍信息
布拉布拉这是一大片介绍信息 布拉布拉这是一大片介绍信息
布拉布拉这是一大片介绍信息 布拉布拉这是一大片介绍信息 布拉布拉
布拉布拉这是一大片介绍信息 布拉布拉这是一大片介绍信息 布拉布拉
</p>
</p>
<el-image
class=
"activityImage"
<el-image
style=
"width: 500px; height: 400px"
class=
"activityImage"
:src=
"url"
style=
"width: 500px; height: 400px"
:fit=
"fit"
:src=
"url"
></el-image>
fit=
"fit"
></el-image>
</el-card>
</el-card>
<el-card
class=
"activities box-card"
>
<el-card
class=
"activities box-card"
>
<div
v-for=
"(item,index) in activityDetailList"
:key=
"index"
class=
"activityItem"
>
<div
<el-image
class=
"activityImage"
v-for=
"(item, index) in activityDetailList"
:key=
"index"
class=
"activityItem"
>
<el-image
class=
"activityImage"
style=
"width: 100px; height: 100px"
style=
"width: 100px; height: 100px"
:src=
"url"
:src=
"url"
:
fit=
"fit"
fit=
"fit"
></el-image>
></el-image>
<div
class=
"itemIntroduce"
>
<div
class=
"itemIntroduce"
>
<p>
f发布写干洗 戏内除菌 消毒 数遍洗干净
</p>
<p>
f发布写干洗 戏内除菌 消毒 数遍洗干净
</p>
<p>
<p>
<span>
$99
</span>
<span>
$99
</span>
<span>
$999
</span>
<span>
$999
</span>
</p>
</p>
</div>
</div>
<div>
<div>
<div
class=
"detail"
></div>
<div
class=
"detail"
></div>
...
@@ -63,21 +77,43 @@
...
@@ -63,21 +77,43 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
ActivityService
from
"@/service/Activity/index"
;
import
{
ElMessage
}
from
"element-plus"
;
export
default
{
export
default
{
components
:
{},
components
:
{},
props
:
{},
props
:
{},
data
()
{
data
()
{
return
{
return
{
fits
:
[
"fill"
,
"contain"
,
"cover"
,
"none"
,
"scale-down"
],
// 图片属性
pageLoading
:
false
,
url
:
"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"
,
activityDetailInfo
:
{},
activityDetailList
:[
1
,
2
,
3
]
url
:
"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"
,
activityDetailList
:
[
1
,
2
,
3
]
};
};
},
},
watch
:
{},
watch
:
{},
computed
:
{},
computed
:
{},
methods
:
{},
methods
:
{
created
()
{},
async
checkActivityDetail
()
{
mounted
()
{},
try
{
this
.
pageLoading
=
true
;
let
data
=
await
ActivityService
.
checkActivityDetail
({
marketing_id
:
this
.
$route
.
query
.
marketing_id
,
marketing_type
:
this
.
$route
.
query
.
marketing_type
});
console
.
log
(
data
.
result
);
this
.
pageLoading
=
false
;
}
catch
{
this
.
pageLoading
=
false
;
ElMessage
.
error
(
"加载失败"
);
}
}
},
created
()
{
this
.
checkActivityDetail
();
},
mounted
()
{}
};
};
</
script
>
</
script
>
<
style
lang=
"less"
scoped
>
<
style
lang=
"less"
scoped
>
...
@@ -87,47 +123,46 @@ export default {
...
@@ -87,47 +123,46 @@ export default {
padding: 45px 10px 0;
padding: 45px 10px 0;
.activityDetail {
.activityDetail {
width: 500px;
width: 500px;
.header {
.
my-
header {
.endTime {
.endTime {
margin: 5px 0;
margin: 5px 0;
font-size: 15px;
font-size: 15px;
color: red;
color: red;
}
}
}
}
.content{
.content {
.box-card{
.box-card {
margin: 10px 0;
margin: 10px 0;
}
.activityGoods {
.title {
}
}
.activityGoods{
.activityImage {
.title{
margin: 10px 10px 0 0;
}
.activityImage{
margin: 10px 10px 0 0;
}
}
}
.activityIntroduce{
}
padding: 5px 0;
.activityIntroduce {
.introduceText{
padding: 5px 0;
margin-bottom: 20px;
.introduceText {
}
margin-bottom: 20px;
}
}
.activities{
}
.activityItem{
.activities {
display: flex;
.activityItem {
margin:15px 0;
display: flex;
.itemIntroduce{
margin: 15px 0;
display: flex;
.itemIntroduce {
flex-direction: column;
display: flex;
justify-content: space-around;
flex-direction: column;
margin-left: 10px;
justify-content: space-around;
>p{
margin-left: 10px;
width: 200px;
> p {
}
width: 200px;
}
}
}
}
}
}
}
}
}
}
}
}
}
</
style
>
</
style
>
\ No newline at end of file
src/pages/Activity/Manage/index.vue
View file @
d69677f3
...
@@ -52,9 +52,18 @@
...
@@ -52,9 +52,18 @@
align=
"center"
align=
"center"
prop=
"activiteHead"
prop=
"activiteHead"
label=
"活动标题"
label=
"活动标题"
@
header-click=
"handleHeadline"
width=
"width"
width=
"width"
>
>
<template
#
default=
"scope"
>
<div
@
click=
"handleHeadline(scope.row)"
class=
"activityTitle"
>
<div>
{{
scope
.
row
.
activiteHead
}}
</div>
<div
class=
"activityPrice"
>
{{
` ¥ ${scope.row.minPrice
}
~¥${scope.row.maxPrice
}
`
}}
<
/div
>
<
/div
>
<
/template
>
<
/el-table-column
>
<
/el-table-column
>
<
el
-
table
-
column
<
el
-
table
-
column
align
=
"center"
align
=
"center"
...
@@ -107,34 +116,43 @@
...
@@ -107,34 +116,43 @@
<
/el-table-column
>
<
/el-table-column
>
<
el
-
table
-
column
align
=
"center"
prop
=
"scope"
label
=
"操作"
width
=
"250"
>
<
el
-
table
-
column
align
=
"center"
prop
=
"scope"
label
=
"操作"
width
=
"250"
>
<
template
#
default
=
"scope"
>
<
template
#
default
=
"scope"
>
<el-button
<
div
class
=
"button-one"
>
type=
"primary"
<
el
-
button
size=
"small"
type
=
"primary"
@
click=
"handleModify(scope.row)"
size
=
"small"
>
修改
</el-button
@
click
=
"handleModify(scope.row)"
>
>
修改
<
/el-butto
n
<el-popconfirm
title=
"确定要结束本次拼单吗?"
>
>
<template
#
reference
>
<
el
-
popconfirm
<el-button
title
=
"确定要结束本次拼单吗?"
v-show=
"scope.row.status === 1"
@
confirm
=
"updateActivity"
type=
"primary"
>
size=
"small"
<
template
#
reference
>
@
click=
"handleEnd(scope.row)"
<
el
-
button
>
结束
</el-button
v
-
show
=
"scope.row.status === 1"
>
type
=
"primary"
</
template
>
size
=
"small"
</el-popconfirm>
@
click
=
"handleEnd(scope.row)"
<el-popconfirm
title=
"确定要开启本次拼单吗?"
>
>
结束
<
/el-butto
n
<
template
#
reference
>
>
<el-button
<
/template
>
v-show=
"scope.row.status === 2 || scope.row.status === 3"
<
/el-popconfirm
>
type=
"primary"
<
el
-
popconfirm
size=
"small"
title
=
"确定要开启本次拼单吗?"
@
click=
"handleStart(scope.row)"
@
confirm
=
"updateActivity"
>
开始
</el-button
>
>
<
template
#
reference
>
</
template
>
<
el
-
button
</el-popconfirm>
v
-
show
=
"scope.row.status === 2 || scope.row.status === 3"
type
=
"primary"
size
=
"small"
@
click
=
"handleStart(scope.row)"
>
开始
<
/el-butto
n
>
<
/template
>
<
/el-popconfirm
>
<
/div
>
<
el
-
button
<
el
-
button
class
=
"checkButton"
class
=
"checkButton"
type
=
"primary"
type
=
"primary"
...
@@ -162,6 +180,7 @@
...
@@ -162,6 +180,7 @@
<
/div
>
<
/div
>
<
/template
>
<
/template
>
<
script
>
<
script
>
import
{
ElMessage
}
from
"element-plus"
;
import
ActivityService
from
"@/service/Activity/index"
;
import
ActivityService
from
"@/service/Activity/index"
;
import
dayJs
from
"dayjs"
;
import
dayJs
from
"dayjs"
;
export
default
{
export
default
{
...
@@ -175,21 +194,9 @@ export default {
...
@@ -175,21 +194,9 @@ export default {
pageCount
:
0
,
// 总条数
pageCount
:
0
,
// 总条数
currentPage
:
1
,
//当前页码
currentPage
:
1
,
//当前页码
pageSize
:
10
,
// 每页条数
pageSize
:
10
,
// 每页条数
storeQuery
:
{
}
,
// 存储开始 结束 参数
tableActivityList
:
[],
tableActivityList
:
[],
tableLoading
:
false
,
tableLoading
:
false
,
manageList
:
[
{
activiteId
:
"413315"
,
activiteHead
:
"生活圈7月29午饭"
,
activiteStatus
:
"进行中"
,
orderNumber
:
"345"
,
soldGoods
:
""
,
pay
:
""
,
discounts
:
""
,
refund
:
""
,
realized
:
"4000"
}
],
options
:
[
options
:
[
{
value
:
""
,
label
:
"全部"
}
,
{
value
:
""
,
label
:
"全部"
}
,
{
value
:
"1"
,
label
:
"未开始"
}
,
{
value
:
"1"
,
label
:
"未开始"
}
,
...
@@ -204,7 +211,8 @@ export default {
...
@@ -204,7 +211,8 @@ export default {
async
getActivityList
()
{
async
getActivityList
()
{
let
params
=
{
let
params
=
{
marketing_name
:
this
.
activity
.
activityName
,
marketing_name
:
this
.
activity
.
activityName
,
online_status
:
this
.
activity
.
online_status
,
activity_status
:
this
.
activity
.
online_status
,
//1 未开始,2进行中,3已结束 空值 全部
marketing_type
:
4
,
//1分销 2团购 3秒杀 4团餐 默认传4
// marketing_id: "",
// marketing_id: "",
page
:
this
.
currentPage
,
page
:
this
.
currentPage
,
page_size
:
this
.
pageSize
page_size
:
this
.
pageSize
...
@@ -215,17 +223,40 @@ export default {
...
@@ -215,17 +223,40 @@ export default {
this
.
filterTableActiveList
(
data
.
result
);
this
.
filterTableActiveList
(
data
.
result
);
this
.
pageCount
=
data
.
count
;
this
.
pageCount
=
data
.
count
;
this
.
tableLoading
=
false
;
this
.
tableLoading
=
false
;
}
catch
{
this
.
tableLoading
=
false
;
ElMessage
.
error
(
"加载失败"
);
}
}
,
/* API */
// 结束 开始
async
updateActivity
()
{
try
{
this
.
tableLoading
=
true
;
let
data
=
await
ActivityService
.
updateActivity
(
this
.
storeQuery
);
if
(
data
.
code
===
0
)
{
await
this
.
getActivityList
();
}
else
{
this
.
tableLoading
=
false
;
ElMessage
.
error
(
data
.
reason
);
}
}
catch
{
}
catch
{
this
.
tableLoading
=
false
;
this
.
tableLoading
=
false
;
}
}
}
,
}
,
// API数据转table展示数据
/* API */
// 修改
/* API */
// 查看订单
// 数据转换成tableData格式
filterTableActiveList
(
tableData
)
{
filterTableActiveList
(
tableData
)
{
this
.
tableActivityList
=
tableData
.
map
(
item
=>
{
this
.
tableActivityList
=
tableData
.
map
(
item
=>
{
let
activityStatusText
=
""
;
let
activityStatusText
=
""
;
let
dateNow
=
dayJs
();
let
dateNow
=
dayJs
();
if
(
dateNow
.
diff
(
dayJs
(
item
.
start_time
)))
{
if
(
dateNow
.
diff
(
dayJs
(
item
.
start_time
))
<
0
)
{
// 开始时间大于当前时间 return 未开始
// 开始时间大于当前时间 return 未开始
activityStatusText
=
"未开始"
;
activityStatusText
=
"未开始"
;
}
else
if
(
dayJs
(
item
.
end_time
).
diff
(
dayJs
(
item
.
start_time
))
>
0
)
{
}
else
if
(
dayJs
(
item
.
end_time
).
diff
(
dayJs
(
item
.
start_time
))
>
0
)
{
...
@@ -240,6 +271,9 @@ export default {
...
@@ -240,6 +271,9 @@ export default {
activiteHead
:
item
.
marketing_name
,
activiteHead
:
item
.
marketing_name
,
activiteStatus
:
activityStatusText
,
activiteStatus
:
activityStatusText
,
status
:
item
.
online_status
,
status
:
item
.
online_status
,
minPrice
:
item
.
min_price
,
maxPrice
:
item
.
max_price
,
marketing_type
:
4
,
orderNumber
:
33
,
orderNumber
:
33
,
soldGoods
:
""
,
soldGoods
:
""
,
pay
:
""
,
pay
:
""
,
...
@@ -256,18 +290,45 @@ export default {
...
@@ -256,18 +290,45 @@ export default {
this
.
getActivityList
();
this
.
getActivityList
();
}
,
}
,
// 点击活动标题
// 点击活动标题
handleHeadline
()
{},
async
handleHeadline
(
val
)
{
console
.
log
(
val
);
this
.
$router
.
push
({
name
:
"ActivityDetail"
,
query
:
{
marketing_id
:
val
.
activiteId
,
marketing_type
:
val
.
marketing_type
}
}
);
}
,
// 发布拼单
// 发布拼单
goReleaseProduc
()
{
goReleaseProduc
()
{
this
.
$router
.
push
(
"/op/activity/releaseProduc"
);
this
.
$router
.
push
(
"/op/activity/releaseProduc"
);
}
,
}
,
// 修改
// 修改
handleModify
()
{},
handleModify
(
val
)
{
this
.
$router
.
push
({
path
:
"/op/activity/releaseProduc"
,
query
:
{
marketing_id
:
val
.
activiteId
,
marketing_type
:
val
.
marketing_type
}
}
);
}
,
// 结束
// 结束
handleEnd
()
{},
handleEnd
(
val
)
{
this
.
storeQuery
=
{
marketing_id
:
val
.
activiteId
,
online_status
:
2
// 1 启用 2 关闭
}
;
}
,
// 开始
// 开始
handleStart
()
{},
handleStart
(
val
)
{
this
.
storeQuery
=
{
marketing_id
:
val
.
activiteId
,
online_status
:
1
// 1 启用 2 关闭
}
;
}
,
// 查看详情
// 查看详情
handleLook
()
{
}
handleLook
()
{
}
}
,
}
,
...
@@ -313,4 +374,10 @@ export default {
...
@@ -313,4 +374,10 @@ export default {
.
checkButton
{
.
checkButton
{
margin
-
top
:
5
px
;
margin
-
top
:
5
px
;
}
}
.
activityTitle
{
cursor
:
pointer
;
}
.
activityPrice
{
color
:
red
;
}
<
/style
>
<
/style
>
src/router/Activity/index.js
View file @
d69677f3
/**
/**
* 活动管理
* 活动管理
*/
*/
const
activityRouters
=
[
const
activityRouters
=
[
{
{
path
:
"/op/activity"
,
path
:
"/op/activity"
,
redirect
:
"/op/activity/manage"
redirect
:
"/op/activity/manage"
},
},
{
{
path
:
"/op/activity/manage"
,
path
:
"/op/activity/manage"
,
name
:
"ManageList"
,
name
:
"ManageList"
,
component
:
()
=>
import
(
/* webpackChunkName: "activity" */
"@/pages/Activity/Manage"
)
component
:
()
=>
},
import
(
/* webpackChunkName: "activity" */
"@/pages/Activity/Manage"
)
},
// 发布拼单
// 发布拼单
{
{
path
:
"/op/activity/releaseProduc"
,
path
:
"/op/activity/releaseProduc"
,
name
:
"releaseProduc"
,
name
:
"releaseProduc"
,
component
:
()
=>
import
(
/* webpackChunkName: "activity" */
"@/pages/Activity/releaseProduc"
)
component
:
()
=>
},
import
(
// 标题详情
/* webpackChunkName: "activity" */
"@/pages/Activity/releaseProduc"
{
)
path
:
"/op/activity/activityDetail"
,
},
name
:
"ActivityDetail"
,
// 标题详情
component
:
()
=>
import
(
/* webpackChunkName: "activity" */
"@/pages/Activity/ActivityDetail"
)
{
path
:
"/op/activity/activityDetail"
,
name
:
"ActivityDetail"
,
component
:
()
=>
import
(
/* webpackChunkName: "activity" */
"@/pages/Activity/ActivityDetail"
)
}
];
}
export
default
activityRouters
;
];
export
default
activityRouters
;
\ No newline at end of file
src/service/Activity/index.js
View file @
d69677f3
...
@@ -8,14 +8,35 @@ class ActivityService {
...
@@ -8,14 +8,35 @@ class ActivityService {
});
});
return
res
;
return
res
;
}
}
// 获取活动名称列表
//
获取活动状态列表
//
修改商品
static
async
postMethod
(
query
)
{
static
async
editGoodsDetail
(
query
)
{
const
res
=
await
axios
.
post
(
"/api/v1/goods/background/
online
"
,
{
const
res
=
await
axios
.
post
(
"/api/v1/goods/background/
edit_goods
"
,
{
goods_spu_id
:
query
...
query
});
});
return
res
;
return
res
;
}
}
// 关闭/开启 活动
static
async
updateActivity
(
query
)
{
const
res
=
await
axios
.
post
(
"/api/v1/marketing/background/update_marketing"
,
{
...
query
}
);
return
res
;
}
// 查看活动订单
static
async
checkActivityDetail
(
query
)
{
const
res
=
await
axios
.
post
(
"/api/v1/marketing/background/marketing_info"
,
{
...
query
}
);
return
res
;
}
}
}
export
default
ActivityService
;
export
default
ActivityService
;
src/utils/request.js
View file @
d69677f3
import
axios
from
"axios"
;
import
axios
from
"axios"
;
import
store
from
"@/store"
import
store
from
"@/store"
;
import
{
v1
as
uuidv1
}
from
'uuid'
;
import
{
v1
as
uuidv1
}
from
"uuid"
;
// import jsonBig from 'json-bigint'
// import jsonBig from 'json-bigint'
// import { ElMessage } from "element-plus";
// import { ElMessage } from "element-plus";
...
@@ -32,17 +32,16 @@ export const defaultConfig = {
...
@@ -32,17 +32,16 @@ export const defaultConfig = {
*/
*/
const
getDefaultParams
=
()
=>
{
const
getDefaultParams
=
()
=>
{
return
{
return
{
'op_cur_user'
:
store
.
state
.
userInfo
&&
store
.
state
.
userInfo
.
email
,
op_cur_user
:
store
.
state
.
userInfo
&&
store
.
state
.
userInfo
.
email
,
'reqid'
:
uuidv1
().
replace
(
/-/g
,
''
)
reqid
:
uuidv1
().
replace
(
/-/g
,
""
)
};
}
};
};
const
getDefaultHeaders
=
(
config
)
=>
{
const
getDefaultHeaders
=
config
=>
{
const
{
method
}
=
config
;
const
{
method
}
=
config
;
if
(
method
.
toLowerCase
()
===
'post'
)
{
if
(
method
.
toLowerCase
()
===
"post"
)
{
return
{
return
{
"Content-Type"
:
"application/json"
"Content-Type"
:
"application/json"
}
}
;
}
}
};
};
...
@@ -56,7 +55,7 @@ const instance = axios.create(defaultConfig);
...
@@ -56,7 +55,7 @@ const instance = axios.create(defaultConfig);
* axios instance interceptors
* axios instance interceptors
*/
*/
instance
.
interceptors
.
request
.
use
(
instance
.
interceptors
.
request
.
use
(
function
(
config
)
{
function
(
config
)
{
// network error
// network error
if
(
navigator
.
onLine
!==
undefined
&&
navigator
.
onLine
===
false
)
{
if
(
navigator
.
onLine
!==
undefined
&&
navigator
.
onLine
===
false
)
{
return
Promise
.
reject
({
message
:
"网络未链接"
,
code
:
-
1
});
return
Promise
.
reject
({
message
:
"网络未链接"
,
code
:
-
1
});
...
@@ -65,7 +64,7 @@ instance.interceptors.request.use(
...
@@ -65,7 +64,7 @@ instance.interceptors.request.use(
/**
/**
* merge headers
* merge headers
*/
*/
config
.
headers
=
{
...
getDefaultHeaders
(
config
),
...
config
.
headers
}
config
.
headers
=
{
...
getDefaultHeaders
(
config
),
...
config
.
headers
}
;
/**
/**
* merge params
* merge params
...
@@ -74,7 +73,7 @@ instance.interceptors.request.use(
...
@@ -74,7 +73,7 @@ instance.interceptors.request.use(
return
config
;
return
config
;
},
},
function
(
error
)
{
function
(
error
)
{
// handle error
// handle error
return
Promise
.
reject
(
error
);
return
Promise
.
reject
(
error
);
}
}
...
@@ -84,7 +83,7 @@ instance.interceptors.request.use(
...
@@ -84,7 +83,7 @@ instance.interceptors.request.use(
* axios response instance
* axios response instance
*/
*/
instance
.
interceptors
.
response
.
use
(
instance
.
interceptors
.
response
.
use
(
function
(
response
)
{
function
(
response
)
{
const
{
data
=
{}
}
=
response
;
const
{
data
=
{}
}
=
response
;
// const code = data.code ?? -1;
// const code = data.code ?? -1;
// if (code !== 0) {
// if (code !== 0) {
...
@@ -106,8 +105,7 @@ instance.interceptors.response.use(
...
@@ -106,8 +105,7 @@ instance.interceptors.response.use(
// return data;
// return data;
// }
// }
return
data
;
return
data
;
}
},
// function (error) {
// function (error) {
// if (!(error.code && error.code === -1)) error.message = "接口请求错误";
// if (!(error.code && error.code === -1)) error.message = "接口请求错误";
// showErrorMessage(error.message);
// showErrorMessage(error.message);
...
...
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