Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
project-online-fi
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
project-online-fi
Commits
b3793255
提交
b3793255
authored
11月 23, 2022
作者:
matian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updates
上级
845adde8
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
42 行增加
和
63 行删除
+42
-63
CourseList.vue
src/modules/shop/components/CourseList.vue
+42
-63
没有找到文件。
src/modules/shop/components/CourseList.vue
浏览文件 @
b3793255
...
...
@@ -2,87 +2,66 @@
import
CourseListItem
from
'./CourseListItem.vue'
import
{
useDevice
}
from
'@/composables/useDevice'
const
{
mobile
}
=
useDevice
()
const
props
=
defineProps
({
courseList
:
{
type
:
Array
},
type
:
{
type
:
String
}
courseList
:
{
type
:
Array
,
default
:
()
=>
[]
},
type
:
{
type
:
String
}
})
const
page
=
reactive
({
size
:
10
,
currentPage
:
1
})
const
courseListAll
=
$computed
<
any
>
(()
=>
{
if
(
props
.
type
)
{
return
props
.
courseList
?.
filter
((
item
:
any
)
=>
item
.
category
===
props
.
type
)
}
else
{
return
props
.
courseList
}
const
page
=
reactive
({
size
:
10
,
currentPage
:
1
})
// 筛选之后的数据
const
courseFilterList
=
$computed
(()
=>
{
return
props
.
courseList
.
filter
(
(
item
:
any
)
=>
item
.
category
===
props
.
type
||
props
.
type
===
''
)
})
watch
(
()
=>
courseListAll
,
()
=>
{
return
queryByPage
}
)
const
courseListAllNew
=
ref
([])
const
queryByPage
=
$computed
<
any
>
(()
=>
{
// 当前页的数据
const
currentCourseList
=
$computed
<
any
[]
>
(()
=>
{
// 起始位置 = (当前页 - 1) x 每页的大小
const
start
=
(
page
.
currentPage
-
1
)
*
page
.
size
// 结束位置 = 当前页 x 每页的大小
const
end
=
page
.
currentPage
*
page
.
size
// 返回切割数组后的数据
return
courseListAll
.
slice
(
start
,
end
)
const
pageList
=
courseFilterList
.
slice
(
start
,
end
)
return
pageList
})
courseListAllNew
.
value
=
queryByPage
// 改变每页大小的方法
const
handleSizeChange
=
(
val
:
number
)
=>
{
page
.
size
=
val
// courseListAllNew.value = queryByPage
console
.
log
(
courseListAllNew
)
courseListAllNew
.
value
=
queryByPage
}
// 改变当前页的方法
const
handleCurrentChange
=
(
val
:
number
)
=>
{
page
.
currentPage
=
val
// courseListAllNew.value = queryByPage
console
.
log
(
courseListAllNew
)
courseListAllNew
.
value
=
queryByPage
}
const
paginationLayout
=
$computed
(()
=>
{
return
mobile
.
value
?
'prev, pager, next'
:
'prev, pager, next, jumper'
})
</
script
>
<
template
>
<div
class=
"course_list"
v-for=
"(item, index) in courseListAllNew"
:key=
"index"
>
<CourseListItem
:courseItem=
"item"
:key=
"type"
></CourseListItem>
<div
class=
"course_list"
>
<CourseListItem
:courseItem=
"item"
v-for=
"(item, index) in currentCourseList"
:key=
"index"
></CourseListItem>
</div>
<div
class=
"pagination"
v-if=
"courseFilterList.length > page.size"
>
<el-pagination
:layout=
"paginationLayout"
:page-size=
"page.size"
:total=
"courseFilterList.length"
v-model:currentPage=
"page.currentPage"
></el-pagination>
</div>
<el-pagination
class=
"pagination"
layout=
"total, sizes, prev, pager, next, jumper"
:page-sizes=
"[10, 15, 20, 30, 50]"
:page-size=
"page.size"
:total=
"courseListAll.length"
v-model:currentPage=
"page.currentPage"
@
size-change=
"handleSizeChange"
@
current-change=
"handleCurrentChange"
v-if=
"courseListAll.length > 10 && !mobile"
>
</el-pagination>
</
template
>
<
style
lang=
"scss"
scoped
>
.pagination
{
margin
:
46px
204px
40px
0
;
padding
:
40px
;
display
:
flex
;
justify-content
:
flex-end
;
align-items
:
center
;
justify-content
:
center
;
:deep
(
ul
)
{
margin
:
0
8px
;
}
:deep
(
li
)
{
margin
:
0
8px
;
}
}
.is-h5
{
.course_list
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论