Authored by mark

add devidepage

@@ -837,20 +837,6 @@ function fetchComment() { @@ -837,20 +837,6 @@ function fetchComment() {
837 loadingComments, 837 loadingComments,
838 loadingConsults; 838 loadingConsults;
839 839
840 - $('.comments ul').on('click', 'a', function() {  
841 -  
842 - var $this = $(this);  
843 - var href = $this.data('page');  
844 - var data = href.split('?')[1].split('&');  
845 -  
846 - var result = data.map(function(i) {  
847 - return i.split('=')[1];  
848 - });  
849 -  
850 - loadAllComments(currentType, result[2]);  
851 -  
852 - });  
853 -  
854 function loadComments(type, nowPage) { 840 function loadComments(type, nowPage) {
855 if (loadingComments) { 841 if (loadingComments) {
856 return; 842 return;
@@ -873,7 +859,7 @@ function fetchComment() { @@ -873,7 +859,7 @@ function fetchComment() {
873 // 购买评价 859 // 购买评价
874 function loadAllComments(type, nowPage) { 860 function loadAllComments(type, nowPage) {
875 loadComments(type, nowPage).then(function(data) { 861 loadComments(type, nowPage).then(function(data) {
876 - var res, filter, $ul, totalnum; 862 + var res, filter, $ul, totalnum, baseUrl;
877 863
878 if (data.code === 200) { 864 if (data.code === 200) {
879 res = data.data; 865 res = data.data;
@@ -897,7 +883,7 @@ function fetchComment() { @@ -897,7 +883,7 @@ function fetchComment() {
897 883
898 } 884 }
899 885
900 - if (fit.filterId == type) { 886 + if (fit.filterId === type) {
901 totalnum = fit.num; 887 totalnum = fit.num;
902 } 888 }
903 889
@@ -911,8 +897,10 @@ function fetchComment() { @@ -911,8 +897,10 @@ function fetchComment() {
911 comments: res 897 comments: res
912 })); 898 }));
913 899
914 - var baseUrl = '/product/detail/comment?productId=' + id + '&filterId=' + '7';  
915 - $ul.append(setPager({baseUrl: baseUrl, totalRecords: totalnum, page: nowPage, type: 'ellipsis', theme: 'msg-pager'})); 900 + baseUrl = '/product/detail/comment?productId=' + id + '&filterId=7';
  901 + $ul.append(
  902 + setPager({baseUrl: baseUrl, totalRecords: totalnum, page: nowPage, type: 'ellipsis', theme: 'msg-pager'})
  903 + );
916 904
917 } 905 }
918 }).always(function() { 906 }).always(function() {
@@ -920,6 +908,19 @@ function fetchComment() { @@ -920,6 +908,19 @@ function fetchComment() {
920 }); 908 });
921 } 909 }
922 910
  911 +
  912 + $('.comments ul').on('click', 'a', function() {
  913 + var $this = $(this);
  914 + var href = $this.data('page');
  915 + var data = href.split('?')[1].split('&');
  916 + var result = data.map(function(i) {
  917 + return i.split('=')[1];
  918 + });
  919 +
  920 + loadAllComments(currentType, result[2]);
  921 +
  922 + });
  923 +
923 // 顾客咨询 924 // 顾客咨询
924 function loadConsults() { 925 function loadConsults() {
925 if (loadingConsults) { 926 if (loadingConsults) {
@@ -48,19 +48,19 @@ module.exports = function(opts) { @@ -48,19 +48,19 @@ module.exports = function(opts) {
48 pageVar + '='; 48 pageVar + '=';
49 49
50 function getPageNums(ntype) { 50 function getPageNums(ntype) {
  51 + /** 分页展示页码个数begin 规则:展示最靠近当前页的指定个数 **/
  52 + var pageShowMax = num % 2 === 0 ? page - 1 : page;
  53 + var pageShowMin = page;
51 var pageNums = []; 54 var pageNums = [];
52 var num = showNum; 55 var num = showNum;
  56 + var i, n;
53 57
54 if (ntype === 'e') { 58 if (ntype === 'e') {
55 num = num - 2; 59 num = num - 2;
56 num = num > 2 ? num : 2; 60 num = num > 2 ? num : 2;
57 } 61 }
58 62
59 - /** 分页展示页码个数begin 规则:展示最靠近当前页的指定个数 **/  
60 - var pageShowMax = num % 2 === 0 ? page - 1 : page;  
61 - var pageShowMin = page;  
62 -  
63 - for (var i = 0; i < Math.floor(num / 2); i++) { 63 + for (i = 0; i < Math.floor(num / 2); i++) {
64 pageShowMax++; 64 pageShowMax++;
65 pageShowMin--; 65 pageShowMin--;
66 if (pageShowMax > totalPages) { 66 if (pageShowMax > totalPages) {
@@ -77,7 +77,7 @@ module.exports = function(opts) { @@ -77,7 +77,7 @@ module.exports = function(opts) {
77 } 77 }
78 } 78 }
79 79
80 - for (var n = pageShowMin; n <= pageShowMax; n++) { 80 + for (n = pageShowMin; n <= pageShowMax; n++) {
81 pageNums.push(n); 81 pageNums.push(n);
82 } 82 }
83 83
@@ -112,9 +112,9 @@ module.exports = function(opts) { @@ -112,9 +112,9 @@ module.exports = function(opts) {
112 if (val === '.') { 112 if (val === '.') {
113 ret += '<a>...</a>'; 113 ret += '<a>...</a>';
114 } else { 114 } else {
115 - ret += '<a href="javascript:void(0)" data-page="'+ base + val +'"' +  
116 - (page === val ? 'class="'+ currentClass +'"' : '') +  
117 - ' title="第'+ val +'页">'+ val + '</a>'; 115 + ret += '<a href="javascript:void(0)" data-page="' + base + val + '"' +
  116 + (page === val ? 'class="' + currentClass + '"' : '') +
  117 + ' title="第' + val + '页">' + val + '</a>';
118 } 118 }
119 }); 119 });
120 } 120 }
@@ -143,32 +143,32 @@ module.exports = function(opts) { @@ -143,32 +143,32 @@ module.exports = function(opts) {
143 items = $.isArray(items) ? items : (items || ALL_TYPES.stand).split('-'); 143 items = $.isArray(items) ? items : (items || ALL_TYPES.stand).split('-');
144 144
145 var hasPage = false; // 配置中如果配置了多次 page/pe 则将忽略,只第一次有效 145 var hasPage = false; // 配置中如果配置了多次 page/pe 则将忽略,只第一次有效
146 - var ret = '<div class="pager'+' '+theme +'">'; 146 + var ret = '<div class="pager' + ' ' + theme + '">';
147 items.forEach(function(val) { 147 items.forEach(function(val) {
148 148
149 switch (val) { 149 switch (val) {
150 case 'f' : 150 case 'f' :
151 if (page > 1) { 151 if (page > 1) {
152 152
153 - ret += '<a href="javascript:void(0)" title="首页" data-page="'+ base +'1">首页</a>'; 153 + ret += '<a href="javascript:void(0)" title="首页" data-page="' + base + '1">首页</a>';
154 } 154 }
155 break; 155 break;
156 case 'p' : 156 case 'p' :
157 if (page > 1) { 157 if (page > 1) {
158 158
159 - ret += '<a href="javascript:void(0)" data-page="'+ base + (page - 1) + 159 + ret += '<a href="javascript:void(0)" data-page="' + base + (page - 1) +
160 '" title="上一页"><span class="iconfont">&#xe60e;</span>上一页</a>'; 160 '" title="上一页"><span class="iconfont">&#xe60e;</span>上一页</a>';
161 } 161 }
162 break; 162 break;
163 case 'n' : 163 case 'n' :
164 if (page < totalPages) { 164 if (page < totalPages) {
165 - ret += '<a href="javascript:void(0)" data-page="'+ base + (page + 1) + 165 + ret += '<a href="javascript:void(0)" data-page="' + base + (page + 1) +
166 '" title="下一页">下一页<span class="iconfont">&#xe60c;</span></a>'; 166 '" title="下一页">下一页<span class="iconfont">&#xe60c;</span></a>';
167 } 167 }
168 break; 168 break;
169 case 'l' : 169 case 'l' :
170 if (page < totalPages) { 170 if (page < totalPages) {
171 - ret += '<a href="javascript:void(0)" data-page="'+ base + totalPages +'" title="尾页">尾页</a>'; 171 + ret += '<a href="javascript:void(0)" data-page="' + base + totalPages + '" title="尾页">尾页</a>';
172 } 172 }
173 break; 173 break;
174 case 'info' : 174 case 'info' :