From f4b985269abbb1616a32b58922df80ae812b4875 Mon Sep 17 00:00:00 2001 From: luchenqun Date: Wed, 22 Feb 2017 11:31:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=A1=E7=89=87=E5=8A=A0=E8=BD=BD=E6=9B=B4?= =?UTF-8?q?=E5=A4=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 2 +- .../controllers/bookmarks-controller.js | 27 ++++++++++--------- public/views/bookmarks.html | 18 +++++-------- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/app.js b/app.js index 463c2f2..7a1173d 100644 --- a/app.js +++ b/app.js @@ -75,7 +75,7 @@ app.use(function(err, req, res, next) { error: {} }); }); -api.checkSnapState(); +// api.checkSnapState(); api.getSnapByTimer(); module.exports = app; diff --git a/public/scripts/controllers/bookmarks-controller.js b/public/scripts/controllers/bookmarks-controller.js index 2664ed4..6470be0 100644 --- a/public/scripts/controllers/bookmarks-controller.js +++ b/public/scripts/controllers/bookmarks-controller.js @@ -14,11 +14,14 @@ app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', ' $scope.loadBusy = false; $scope.changeCurrentPage = function(currentPage) { currentPage = parseInt(currentPage) || 0; - console.log(currentPage); + console.log('currentPage = ', currentPage); if (currentPage <= $scope.totalPages && currentPage >= 1) { + $scope.loadBusy = true; $scope.currentPage = currentPage; $scope.inputPage = ''; getBookmarks(params); + } else { + $scope.currentPage = $scope.totalPages } } @@ -71,7 +74,6 @@ app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', ' toastr.warning('功能暂未实现。。。', "警告"); } - $scope.jumpToTags = function(tagId) { $state.go('tags', { tagId: tagId, @@ -95,9 +97,9 @@ app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', ' $scope.loadCardData = function() { console.log('loadCardData.........') - $scope.currentPage += 1; - $scope.changeCurrentPage($scope.currentPage); - $scope.loadBusy = true; + if (!$scope.loadBusy) { + $scope.changeCurrentPage($scope.currentPage += 1) + } } pubSubService.subscribe('EditCtr.inserBookmarsSuccess', $scope, function(event, params) { @@ -109,25 +111,26 @@ app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', ' function getBookmarks(params) { if (params.showStyle != 'navigate') { params.currentPage = $scope.currentPage; - params.perPageItems = params.showStyle == 'table' ? perPageItems : perPageItems * 3; + params.perPageItems = perPageItems; } bookmarkService.getBookmarks(params) .then((data) => { if (params.showStyle != 'navigate') { - $scope.bookmarks = data.bookmarks; $scope.totalPages = Math.ceil(data.totalItems / perPageItems); if (data.totalItems == 0) { toastr.info('您还没有书签,请点击菜单栏的添加按钮进行添加', "提示"); } - } else { if (params.showStyle == 'card') { - console.log('loadCardData end.........') - $scope.bookmarks = $scope.bookmarks.concat(data); + data.bookmarks.forEach(bookmark => { + $scope.bookmarks.push(bookmark); + }) $scope.loadBusy = false; + console.log('loadCardData end.........', $scope.loadBusy); } else { - $scope.bookmarks = data; + $scope.bookmarks = data.bookmarks; } - + } else { + $scope.bookmarks = data; if ($scope.bookmarks.length <= 2) { $(".js-msg").removeClass("hidden"); } diff --git a/public/views/bookmarks.html b/public/views/bookmarks.html index 1f11ecf..31e2612 100644 --- a/public/views/bookmarks.html +++ b/public/views/bookmarks.html @@ -19,15 +19,8 @@
-
+
@@ -92,12 +85,13 @@
-