Fix closet pagination

This commit is contained in:
Pig Fang 2019-05-03 23:17:17 +08:00
parent d8aca0b8d5
commit 04269b57e9
2 changed files with 4 additions and 2 deletions

View File

@ -48,9 +48,10 @@ class ClosetController extends Controller
$closet = $closet->where('item_name', 'like', "%$q%");
}
$total = $closet->count();
$closet->offset(($page - 1) * $perPage)->limit($perPage);
$totalPages = ceil($closet->count() / $perPage);
$totalPages = ceil($total / $perPage);
$items = $closet->get()->map(function ($t) {
$t->name = $t->pivot->item_name;

View File

@ -213,6 +213,7 @@ export default {
)
this[`${category}TotalPages`] = totalPages
this[`${category}Items`] = items
this[`${category}CurrentPages`] = page
},
removeSkinItem(index) {
this.$delete(this.skinItems, index)
@ -222,7 +223,7 @@ export default {
},
switchCategory() {
this.category = this.category === 'skin' ? 'cape' : 'skin'
this.loadCloset()
this.loadCloset(this[`${this.category}CurrentPages`])
},
pageChanged(page) {
this.loadCloset(page)