Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
admin
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
华润手术跟台
admin
Commits
66779696
提交
66779696
authored
11月 08, 2022
作者:
袁伟伟
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 页码
上级
deb06025
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
143 行增加
和
6 行删除
+143
-6
goodsApi.ts
src/api/product/goodsApi.ts
+7
-0
type.ts
src/views/product/goods-category/type.ts
+1
-1
pagination.vue
src/views/store/components/pagination.vue
+34
-0
index.vue
src/views/store/goodsList/index.vue
+88
-5
type.ts
src/views/store/goodsList/type.ts
+13
-0
没有找到文件。
src/api/product/goodsApi.ts
浏览文件 @
66779696
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
import
{
defHttp
}
from
'/@/utils/http/axios'
;
import
{
defHttp
}
from
'/@/utils/http/axios'
;
import
{
ApiResponse
}
from
'../model/baseModel'
;
import
{
ApiResponse
}
from
'../model/baseModel'
;
import
{
Goods
,
GoodsParams
,
GoodsPageResult
,
GoodsPageResponse
,
GoodsResponse
}
from
'../model/goods'
;
import
{
Goods
,
GoodsParams
,
GoodsPageResult
,
GoodsPageResponse
,
GoodsResponse
}
from
'../model/goods'
;
import
{
GoodsList
}
from
'/@/views/store/goodsList/type'
;
const
baseApi
=
'/v1/product/goods'
;
const
baseApi
=
'/v1/product/goods'
;
...
@@ -67,3 +68,9 @@ export const batchUpdate = (entityList: Array<Goods>) =>
...
@@ -67,3 +68,9 @@ export const batchUpdate = (entityList: Array<Goods>) =>
* 查询数量
* 查询数量
*/
*/
export
const
count
=
(
params
?:
GoodsParams
)
=>
defHttp
.
get
<
Number
>
({
url
:
`
${
baseApi
}
/count`
,
params
});
export
const
count
=
(
params
?:
GoodsParams
)
=>
defHttp
.
get
<
Number
>
({
url
:
`
${
baseApi
}
/count`
,
params
});
/**
* 查询商品分类下所有商品
*/
export
const
goodsList
=
(
params
?:
GoodsParams
)
=>
defHttp
.
get
<
GoodsList
>
({
url
:
`
${
baseApi
}
/line/goods/list`
,
params
});
src/views/product/goods-category/type.ts
浏览文件 @
66779696
export
interface
DataItem
{
export
interface
DataItem
{
children
?
:
DataItem
[];
children
:
DataItem
[];
name
:
string
;
name
:
string
;
id
:
number
;
id
:
number
;
disabled
?:
boolean
;
disabled
?:
boolean
;
...
...
src/views/store/components/pagination.vue
0 → 100644
浏览文件 @
66779696
<
template
>
<a-pagination
v-model:current=
"pageNum"
v-model:pageSize=
"pageSize"
:total=
"total"
showQuickJumper
:pageSizeOptions=
"[10, 50, 100]"
size=
"small"
:showTotal=
"(total) => `共 $
{total} 条数据`"
@change="handleChange"
@showSizeChange="handleSizeChange"
/>
</
template
>
<
script
lang=
"ts"
setup
>
import
{
emit
}
from
'process'
;
import
{
ref
,
defineProps
,
defineEmits
}
from
'vue'
;
const
props
=
defineProps
([
'pageNum'
,
'pageSize'
,
'total'
]);
const
emits
=
defineEmits
([
'update:pageNum'
,
'update:pageSize'
]);
const
handleChange
=
(
page
,
pageSize
)
=>
{
emits
(
'update:pageNum'
,
page
);
};
const
handleSizeChange
=
(
current
,
size
)
=>
{
emits
(
'update:pageNum'
,
1
);
emits
(
'update:pageSize'
,
size
);
};
</
script
>
<
style
lang=
"less"
scoped
>
.ant-pagination {
margin-top: 20px;
text-align: right;
}
</
style
>
src/views/store/goodsList/index.vue
浏览文件 @
66779696
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
<div
class=
"classify"
>
<div
class=
"classify"
>
<div
class=
"title"
>
全部分类
</div>
<div
class=
"title"
>
全部分类
</div>
<div
class=
"classifyWrap"
>
<div
class=
"classifyWrap"
>
<ul
class=
"classifyList"
>
<ul
class=
"classifyList
borderBottom
"
>
<li
class=
"item"
@
click=
"handleChangeLevelFour('all')"
:class=
"
{ active: levelFourActiveKey === 'all' }"
<li
class=
"item"
@
click=
"handleChangeLevelFour('all')"
:class=
"
{ active: levelFourActiveKey === 'all' }"
>全部
</li
>全部
</li
>
>
...
@@ -39,6 +39,17 @@
...
@@ -39,6 +39,17 @@
</ul>
</ul>
</div>
</div>
</div>
</div>
<div
class=
"goodsWrap"
>
<ul
class=
"goodsList"
>
<li
class=
"goods"
v-for=
"item in goodsList"
:key=
"item.id"
>
<div
class=
"img"
>
<img
:src=
"item.pic"
alt=
""
/>
</div>
<p
class=
"title"
>
{{
item
.
name
}}
</p>
</li>
</ul>
<Pagination
v-model:pageNum=
"pageNum"
v-model:pageSize=
"pageSize"
v-model:total=
"total"
@
handleChange=
""
/>
</div>
</div>
</div>
</div>
</div>
</
template
>
</
template
>
...
@@ -52,11 +63,15 @@
...
@@ -52,11 +63,15 @@
import
{
toNumber
}
from
'lodash'
;
import
{
toNumber
}
from
'lodash'
;
import
{
useUserStore
}
from
'/@/store/modules/user'
;
import
{
useUserStore
}
from
'/@/store/modules/user'
;
import
{
useNavTree
}
from
'/@/hooks/myhooks/index'
;
import
{
useNavTree
}
from
'/@/hooks/myhooks/index'
;
import
Pagination
from
'../components/pagination.vue'
;
import
{
DataItem
}
from
'/@/views/product/goods-category/type'
;
import
{
DataItem
}
from
'/@/views/product/goods-category/type'
;
import
{
Goods
}
from
'/@/views/store/goodsList/type'
;
import
*
as
GoodsApi
from
'/@/api/product/goodsApi'
;
const
go
=
useGo
();
const
go
=
useGo
();
const
route
=
useRoute
();
const
route
=
useRoute
();
const
navTree
=
useNavTree
();
const
navTree
=
useNavTree
();
const
userStore
=
useUserStore
();
const
query
=
route
.
query
;
const
query
=
route
.
query
;
const
navId
=
toNumber
(
query
.
nav
);
// 一级选择id
const
navId
=
toNumber
(
query
.
nav
);
// 一级选择id
...
@@ -70,9 +85,15 @@
...
@@ -70,9 +85,15 @@
const
levelFiveActiveKey
=
ref
<
string
|
number
>
(
'all'
);
const
levelFiveActiveKey
=
ref
<
string
|
number
>
(
'all'
);
const
title
=
ref
(
''
);
const
title
=
ref
(
''
);
const
userStore
=
useUserStore
();
navList
.
value
=
userStore
.
getNavList
;
navList
.
value
=
userStore
.
getNavList
;
const
goodsList
=
ref
<
Goods
[]
>
([]);
const
pageNum
=
ref
(
1
);
const
pageSize
=
ref
(
10
);
const
total
=
ref
(
500
);
const
formQuery
=
{
isAll
:
true
,
goodsCategoryId
:
tabItemId
};
// 获取四五级分类列表
const
getGrandsonList
=
(
arr
:
DataItem
[])
=>
{
const
getGrandsonList
=
(
arr
:
DataItem
[])
=>
{
arr
.
some
((
item
)
=>
{
arr
.
some
((
item
)
=>
{
if
(
item
.
id
===
navId
||
item
.
id
===
tabId
)
{
if
(
item
.
id
===
navId
||
item
.
id
===
tabId
)
{
...
@@ -92,20 +113,40 @@
...
@@ -92,20 +113,40 @@
const
handleChangeLevelFour
=
(
item
:
DataItem
|
string
)
=>
{
const
handleChangeLevelFour
=
(
item
:
DataItem
|
string
)
=>
{
if
(
typeof
item
===
'string'
)
{
if
(
typeof
item
===
'string'
)
{
levelFourActiveKey
.
value
=
'all'
;
levelFourActiveKey
.
value
=
'all'
;
levelFiveActiveKey
.
value
=
'all'
;
levelFiveTree
.
value
=
[];
formQuery
.
goodsCategoryId
=
tabItemId
;
getGoodsList
();
}
else
{
}
else
{
levelFiveTree
.
value
=
item
.
children
;
levelFiveTree
.
value
=
item
.
children
;
levelFourActiveKey
.
value
=
item
.
id
;
levelFourActiveKey
.
value
=
item
.
id
;
formQuery
.
goodsCategoryId
=
item
.
id
;
getGoodsList
();
}
}
};
};
const
handleChangeLevelFive
=
(
item
:
DataItem
|
string
)
=>
{
const
handleChangeLevelFive
=
(
item
:
DataItem
|
string
)
=>
{
if
(
typeof
item
===
'string'
)
{
if
(
typeof
item
===
'string'
)
{
levelFiveActiveKey
.
value
=
'all'
;
levelFiveActiveKey
.
value
=
'all'
;
if
(
typeof
levelFourActiveKey
.
value
===
'number'
)
{
formQuery
.
goodsCategoryId
=
levelFourActiveKey
.
value
;
getGoodsList
();
}
}
else
{
}
else
{
levelFiveActiveKey
.
value
=
item
.
id
;
levelFiveActiveKey
.
value
=
item
.
id
;
formQuery
.
goodsCategoryId
=
item
.
id
;
getGoodsList
();
}
}
};
};
// 获取商品分类下的商品
const
getGoodsList
=
()
=>
{
GoodsApi
.
goodsList
(
Object
.
assign
({
pageSize
:
pageSize
.
value
,
pageNum
:
pageNum
.
value
},
formQuery
)).
then
((
res
)
=>
{
total
.
value
=
res
.
total
;
goodsList
.
value
=
res
.
records
;
});
};
watch
(
watch
(
()
=>
navActiveKey
.
value
,
()
=>
navActiveKey
.
value
,
(
n
)
=>
{
(
n
)
=>
{
...
@@ -115,6 +156,7 @@
...
@@ -115,6 +156,7 @@
onMounted
(()
=>
{
onMounted
(()
=>
{
navTree
(
navList
,
getGrandsonList
,
'getGrandsonList'
);
navTree
(
navList
,
getGrandsonList
,
'getGrandsonList'
);
getGoodsList
();
});
});
</
script
>
</
script
>
...
@@ -122,12 +164,19 @@
...
@@ -122,12 +164,19 @@
.active {
.active {
color: #1890ff;
color: #1890ff;
}
}
ul {
padding: 0;
margin: 0;
}
.containe {
.containe {
padding: 30px;
padding: 30px;
.contentWrap {
.contentWrap {
padding: 30px;
padding: 30px;
background: #fff;
background: #fff;
border-radius: 10px;
border-radius: 10px;
max-width: 1400px;
margin: 0 auto;
.top {
.top {
display: flex;
display: flex;
...
@@ -168,20 +217,54 @@
...
@@ -168,20 +217,54 @@
.classifyWrap {
.classifyWrap {
flex: 1;
flex: 1;
.classifyList {
.classifyList {
border-bottom: 1px solid rgb(214, 214, 214);
height: 50px;
line-height: 50px;
padding-bottom: 10px;
padding-bottom: 10px;
display: flex;
display: flex;
justify-content: flex-start;
justify-content: flex-start;
.item {
.item {
margin-right: 10px;
font-size: 16px;
margin-right: 15px;
cursor: pointer;
cursor: pointer;
&:hover {
&:hover {
color:
rgb(129, 129, 129)
;
color:
#1890ff
;
}
}
}
}
}
}
.borderBottom {
border-bottom: 1px solid rgb(214, 214, 214);
}
}
}
.goodsWrap {
.goodsList {
display: flex;
justify-content: flex-start;
flex-wrap: wrap;
.goods {
width: 25%;
padding: 20px 20px 5px 20px;
border: 1px solid rgb(214, 214, 214);
&:hover {
background: #eee;
cursor: pointer;
}
.img {
height: 285px;
}
.title {
text-align: center;
font-size: 17px;
margin-top: 20px;
}
}
}
}
}
}
}
}
...
...
src/views/store/goodsList/type.ts
0 → 100644
浏览文件 @
66779696
export
interface
GoodsList
{
current
:
number
;
pages
:
number
;
records
:
Goods
[];
size
:
number
;
total
:
number
;
}
export
interface
Goods
{
id
:
number
;
pic
:
string
;
name
:
string
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论