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
78820f96
Commit
78820f96
authored
Jun 23, 2021
by
mengwenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature:商品列表开发完毕
parent
fa960d2a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
29 deletions
+75
-29
goods.js
server/controllers/goods.js
+24
-2
router.js
server/router.js
+2
-0
index.vue
src/pages/Goods/List/index.vue
+39
-26
goods.js
src/service/Goods/goods.js
+10
-1
No files found.
server/controllers/goods.js
View file @
78820f96
...
...
@@ -15,7 +15,7 @@ const req = require("../utils/request").httpReq;
* ctx.body = await req(ctx,opts); 将发送请求后的数据传递给前端页面
* };
*/
// 获取分类
exports
.
getCategoryList
=
async
ctx
=>
{
const
url
=
`
${
GOODS_URI
}
/goods/background/get_goods_category_list`
;
const
opts
=
{
...
...
@@ -24,7 +24,7 @@ exports.getCategoryList = async ctx => {
};
ctx
.
body
=
await
req
(
ctx
,
opts
);
};
// 获取商品列表
exports
.
getList
=
async
ctx
=>
{
const
url
=
`
${
GOODS_URI
}
/goods/background/get_goods_list`
;
const
opts
=
{
...
...
@@ -34,3 +34,25 @@ exports.getList = async ctx => {
};
ctx
.
body
=
await
req
(
ctx
,
opts
);
};
// 商品上架
exports
.
putOnline
=
async
ctx
=>
{
const
url
=
`
${
GOODS_URI
}
/goods/background/online`
;
const
opts
=
{
url
,
method
:
"POST"
,
json
:
true
,
body
:
ctx
.
request
.
body
};
ctx
.
body
=
await
req
(
ctx
,
opts
);
};
// 商品下架
exports
.
putOffline
=
async
ctx
=>
{
const
url
=
`
${
GOODS_URI
}
/goods/background/offline`
;
const
opts
=
{
url
,
method
:
"POST"
,
json
:
true
,
body
:
ctx
.
request
.
body
};
ctx
.
body
=
await
req
(
ctx
,
opts
);
};
\ No newline at end of file
server/router.js
View file @
78820f96
...
...
@@ -40,6 +40,8 @@ router.post(`${API_VERSION}/op_business_update`, enterprise.opBusinessUpdate);
/* 商品管理 */
router
.
get
(
`
${
API_VERSION
}
/get_goods_category_list`
,
goods
.
getCategoryList
);
router
.
get
(
`
${
API_VERSION
}
/getGoodsList`
,
goods
.
getList
);
router
.
post
(
`
${
API_VERSION
}
/goods/background/online`
,
goods
.
putOnline
);
router
.
post
(
`
${
API_VERSION
}
/goods/background/offline`
,
goods
.
putOffline
);
//生活号
router
.
post
(
`
${
API_VERSION
}
/merchant/lifeinner/life_info`
,
life
.
get_life_info
)
...
...
src/pages/Goods/List/index.vue
View file @
78820f96
...
...
@@ -82,7 +82,7 @@
>
<el-table-column
label=
"商品id"
prop=
"goods_s
k
u_id"
prop=
"goods_s
p
u_id"
align=
"center"
></el-table-column>
<el-table-column
...
...
@@ -180,7 +180,7 @@
<el-popconfirm
title=
"您确定要上架该商品吗?"
cancelButtonType=
"default"
@
confirm=
"changeGoodsState('GROUNDING')"
@
confirm=
"changeGoodsState('GROUNDING'
, scope.row.goods_spu_id
)"
>
<template
#
reference
>
<el-button
type=
"text"
>
上架
</el-button>
...
...
@@ -191,7 +191,9 @@
<el-popconfirm
title=
"您确定要下架该商品吗?"
cancelButtonType=
"default"
@
confirm=
"changeGoodsState('UNDERCARRIAGE')"
@
confirm=
"
changeGoodsState('UNDERCARRIAGE', scope.row.goods_spu_id)
"
>
<
template
#
reference
>
<el-button
type=
"text"
>
下架
</el-button>
...
...
@@ -218,7 +220,12 @@
<
style
lang=
"less"
src=
"./index.less"
scope
></
style
>
<
script
>
import
{
getGoodsList
,
getList
}
from
"@/service/Goods/goods"
;
import
{
getGoodsList
,
getList
,
putOnline
,
putOffline
}
from
"@/service/Goods/goods"
;
export
default
{
name
:
"GoodsList"
,
...
...
@@ -290,20 +297,7 @@ export default {
console
.
error
(
error
);
}
},
// 获取列表
async
getCommodityList
()
{
try
{
const
res
=
await
getList
(
this
.
searchProps
);
if
(
res
.
code
!==
0
)
return
this
.
$message
.
error
(
res
.
reason
);
console
.
log
(
"商品列表"
,
res
);
this
.
goodsList
=
res
.
result
.
list
;
this
.
totalCount
=
res
.
result
.
count
;
}
catch
(
error
)
{
console
.
error
(
error
);
}
},
// 获取数组返回值并转换为字符串
getVal
(
value
,
index
=
0
)
{
const
valueArray
=
value
.
map
(
item
=>
{
return
item
[
index
];
...
...
@@ -316,30 +310,49 @@ export default {
});
return
values
.
join
();
},
// 获取列表
async
getCommodityList
()
{
try
{
const
res
=
await
getList
(
this
.
searchProps
);
if
(
res
.
code
!==
0
)
return
this
.
$message
.
error
(
res
.
reason
);
console
.
log
(
"商品列表"
,
res
);
this
.
goodsList
=
res
.
result
.
list
;
this
.
totalCount
=
res
.
result
.
count
;
}
catch
(
error
)
{
console
.
error
(
error
);
}
},
// 所属分类赋值
handleTypeChange
(
val
)
{
this
.
searchProps
.
category_1_id
=
this
.
getVal
(
val
,
0
);
this
.
searchProps
.
category_2_id
=
this
.
getVal
(
val
,
1
);
},
// 商品状态赋值
handleStatusChange
(
val
)
{
this
.
searchProps
.
status
=
this
.
getValue
(
val
);
},
// 上架状态赋值
handleOnlineStatusChange
(
val
)
{
this
.
searchProps
.
online_status
=
this
.
getValue
(
val
);
},
// 按条件搜索
searchList
()
{
this
.
getCommodityList
();
},
// 上架/下架操作
changeGoodsState
(
state
)
{
console
.
log
(
state
);
async
changeGoodsState
(
state
,
spuId
)
{
// 上架操作
if
(
state
===
"GROUNDING"
)
{
const
res
=
await
putOnline
(
spuId
);
if
(
res
.
code
!==
0
)
return
this
.
$message
.
error
(
res
.
status
);
this
.
$message
.
success
(
"商品上架成功"
);
}
// 下架操作
else
if
(
state
===
"UNDERCARRIAGE"
)
{
const
res
=
await
putOffline
(
spuId
);
if
(
res
.
code
!==
0
)
return
this
.
$message
.
error
(
res
.
status
);
this
.
$message
.
success
(
"商品下架成功"
);
}
},
// 页码变化
...
...
@@ -350,8 +363,8 @@ export default {
},
// 去往详情页
goDetail
(
where
)
{
this
.
$router
.
push
({
name
:
"GoodsDetail"
,
params
:
{
operation
:
where
}
});
goDetail
(
operation
,
spuId
)
{
this
.
$router
.
push
({
name
:
"GoodsDetail"
,
params
:
{
operation
,
spuId
}
});
}
}
};
...
...
src/service/Goods/goods.js
View file @
78820f96
...
...
@@ -5,9 +5,18 @@ export async function getGoodsList () {
const
res
=
await
axios
.
get
(
"/api/v1/get_goods_category_list"
);
return
res
;
}
// 获取商品列表
export
async
function
getList
(
params
)
{
const
res
=
await
axios
.
get
(
"/api/v1/getGoodsList"
,
{
params
});
return
res
;
}
// 商品上架
export
async
function
putOnline
(
query
)
{
const
res
=
await
axios
.
post
(
"/api/v1/goods/background/online"
,
{
goods_spu_id
:
query
});
return
res
;
}
// 商品下架
export
async
function
putOffline
(
query
)
{
const
res
=
await
axios
.
post
(
"/api/v1/goods/background/offline"
,
{
goods_spu_id
:
query
});
return
res
;
}
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