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
22ff0f92
Commit
22ff0f92
authored
Mar 31, 2018
by
Junling Bu
Browse files
update[litemall-wx, litemall-wx-api, litemall-db]: 用户收藏支分页显示。
parent
b7a2a1e6
Changes
5
Hide whitespace changes
Inline
Side-by-side
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCollectService.java
View file @
22ff0f92
...
...
@@ -21,9 +21,11 @@ public class LitemallCollectService {
return
(
int
)
collectMapper
.
countByExample
(
example
);
}
public
List
<
LitemallCollect
>
queryByType
(
Integer
userId
,
Integer
typeId
)
{
public
List
<
LitemallCollect
>
queryByType
(
Integer
userId
,
Integer
typeId
,
Integer
page
,
Integer
size
)
{
LitemallCollectExample
example
=
new
LitemallCollectExample
();
example
.
or
().
andUserIdEqualTo
(
userId
).
andTypeIdEqualTo
(
typeId
);
example
.
setOrderByClause
(
LitemallCollect
.
Column
.
addTime
.
desc
());
PageHelper
.
startPage
(
page
,
size
);
return
collectMapper
.
selectByExample
(
example
);
}
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCollectController.java
View file @
22ff0f92
...
...
@@ -10,6 +10,7 @@ import org.linlinjava.litemall.wx.annotation.LoginUser;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.time.LocalDate
;
...
...
@@ -30,7 +31,9 @@ public class WxCollectController {
* 获取用户收藏
*/
@RequestMapping
(
"list"
)
public
Object
list
(
@LoginUser
Integer
userId
,
Integer
typeId
)
{
public
Object
list
(
@LoginUser
Integer
userId
,
Integer
typeId
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
)
Integer
size
)
{
if
(
userId
==
null
){
return
ResponseUtil
.
fail401
();
}
...
...
@@ -39,8 +42,9 @@ public class WxCollectController {
}
List
<
LitemallCollect
>
collectList
=
collectService
.
queryByType
(
userId
,
typeId
);
List
<
LitemallCollect
>
collectList
=
collectService
.
queryByType
(
userId
,
typeId
,
page
,
size
);
int
count
=
collectService
.
countByType
(
userId
,
typeId
);
int
totalPages
=
(
int
)
Math
.
ceil
((
double
)
count
/
size
);
List
<
Object
>
collects
=
new
ArrayList
<>(
collectList
.
size
());
for
(
LitemallCollect
collect
:
collectList
){
...
...
@@ -59,8 +63,8 @@ public class WxCollectController {
}
Map
<
String
,
Object
>
result
=
new
HashMap
();
result
.
put
(
"co
unt"
,
count
);
result
.
put
(
"
data"
,
collect
s
);
result
.
put
(
"co
llectList"
,
collects
);
result
.
put
(
"
totalPages"
,
totalPage
s
);
return
ResponseUtil
.
ok
(
result
);
}
...
...
litemall-wx/pages/auth/login/login.js
View file @
22ff0f92
...
...
@@ -29,7 +29,7 @@ Page({
// 页面关闭
},
wxLogin
()
{
wxLogin
:
function
()
{
user
.
checkLogin
().
catch
(()
=>
{
user
.
loginByWeixin
().
then
(
res
=>
{
...
...
litemall-wx/pages/ucenter/collect/collect.js
View file @
22ff0f92
...
...
@@ -6,22 +6,44 @@ var app = getApp();
Page
({
data
:
{
typeId
:
0
,
collectList
:
[]
collectList
:
[],
page
:
1
,
size
:
10
,
totalPages
:
1
},
getCollectList
()
{
wx
.
showLoading
({
title
:
'
加载中...
'
,
});
let
that
=
this
;
util
.
request
(
api
.
CollectList
,
{
typeId
:
that
.
data
.
typeId
}).
then
(
function
(
res
)
{
util
.
request
(
api
.
CollectList
,
{
typeId
:
that
.
data
.
typeId
,
page
:
that
.
data
.
page
,
size
:
that
.
data
.
size
}).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
console
.
log
(
res
.
data
);
that
.
setData
({
collectList
:
res
.
data
.
data
collectList
:
that
.
data
.
collectList
.
concat
(
res
.
data
.
collectList
),
totalPages
:
res
.
data
.
totalPages
});
}
wx
.
hideLoading
();
});
},
onLoad
:
function
(
options
)
{
this
.
getCollectList
();
},
onReachBottom
()
{
if
(
this
.
data
.
totalPages
>
this
.
data
.
page
)
{
this
.
setData
({
page
:
this
.
data
.
page
+
1
});
this
.
getCollectList
();
}
else
{
wx
.
showToast
({
title
:
'
没有更多用户收藏了
'
,
icon
:
'
none
'
,
duration
:
2000
});
return
false
;
}
},
onReady
:
function
()
{
},
...
...
@@ -78,7 +100,6 @@ Page({
that
.
setData
({
touchStart
:
e
.
timeStamp
})
console
.
log
(
e
.
timeStamp
+
'
- touch-start
'
)
},
//按下事件结束
touchEnd
:
function
(
e
)
{
...
...
@@ -86,6 +107,5 @@ Page({
that
.
setData
({
touchEnd
:
e
.
timeStamp
})
console
.
log
(
e
.
timeStamp
+
'
- touch-end
'
)
},
})
\ No newline at end of file
litemall-wx/pages/ucenter/collect/collect.wxss
View file @
22ff0f92
...
...
@@ -6,6 +6,9 @@ page{
.container{
background: #f4f4f4;
min-height: 100%;
width: 100%;
height: auto;
overflow: hidden;
}
...
...
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