Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
2f4d305d
Unverified
Commit
2f4d305d
authored
Aug 02, 2021
by
端午安康
Committed by
GitHub
Aug 02, 2021
Browse files
小程序增加商品分页 (#487)
* 1.wx:修复首页线程池问题 * 1.wx:修复首页线程池问题 * 增加商品分页
parent
14b6d0e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
litemall-wx/pages/category/category.js
View file @
2f4d305d
...
...
@@ -11,7 +11,8 @@ Page({
scrollTop
:
0
,
scrollHeight
:
0
,
page
:
1
,
limit
:
10
limit
:
10
,
pages
:
1
,
//总页数
},
onLoad
:
function
(
options
)
{
// 页面初始化 options为页面跳转所带来的参数
...
...
@@ -89,6 +90,21 @@ Page({
onHide
:
function
()
{
// 页面隐藏
},
//触底开始下一页
onReachBottom
:
function
()
{
var
that
=
this
;
var
pagenum
=
that
.
data
.
page
+
1
;
//获取当前页数并+1
if
(
pagenum
<=
that
.
data
.
pages
){
that
.
setData
({
page
:
pagenum
,
//更新当前页数
})
that
.
getGoodsList
();
//重新调用请求获取下一页数据
}
else
{
util
.
showErrorToast
(
"
已经是最后一页了
"
);
}
},
getGoodsList
:
function
()
{
var
that
=
this
;
...
...
@@ -98,8 +114,12 @@ Page({
limit
:
that
.
data
.
limit
})
.
then
(
function
(
res
)
{
var
arr1
=
that
.
data
.
goodsList
;
//从data获取当前datalist数组
var
arr2
=
res
.
data
.
list
;
//从此次请求返回的数据中获取新数组
arr1
=
arr1
.
concat
(
arr2
);
//合并数组
that
.
setData
({
goodsList
:
res
.
data
.
list
,
goodsList
:
arr1
,
pages
:
res
.
data
.
pages
//得到总页数
});
});
},
...
...
@@ -123,9 +143,11 @@ Page({
});
}
this
.
setData
({
id
:
event
.
currentTarget
.
dataset
.
id
id
:
event
.
currentTarget
.
dataset
.
id
,
page
:
1
,
//从第一页开始查
goodsList
:[]
});
this
.
getCategoryInfo
();
}
})
\ No newline at end of file
})
Write
Preview
Supports
Markdown
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