Authored by yyq

fix pager

@@ -477,7 +477,7 @@ class AdminModel extends global.yoho.BaseModel { @@ -477,7 +477,7 @@ class AdminModel extends global.yoho.BaseModel {
477 return value; 477 return value;
478 }); 478 });
479 479
480 - Object.assign(resData, pager(_.get(result, '[1].total', 1), params)); 480 + Object.assign(resData, pager(_.get(result, '[1][0].total', 1), params));
481 481
482 return resData; 482 return resData;
483 }); 483 });
@@ -82,11 +82,11 @@ @@ -82,11 +82,11 @@
82 {{/if}} 82 {{/if}}
83 </li> 83 </li>
84 {{/ pages}} 84 {{/ pages}}
85 - {{# nextLimit}} 85 + {{# nextPage}}
86 <li class="page-item"> 86 <li class="page-item">
87 <a class="page-link" href="{{url}}">下一页</a> 87 <a class="page-link" href="{{url}}">下一页</a>
88 </li> 88 </li>
89 - {{/ nextLimit}} 89 + {{/ nextPage}}
90 </ul> 90 </ul>
91 </nav> 91 </nav>
92 </div> 92 </div>
@@ -6,7 +6,7 @@ const _ = require('lodash'); @@ -6,7 +6,7 @@ const _ = require('lodash');
6 * @param newParam 要拼接的 参数 6 * @param newParam 要拼接的 参数
7 * @returns {string} 7 * @returns {string}
8 */ 8 */
9 -const handleFilterUrl = (originParam, newParam, delParam) => { 9 +const handleFilterUrl = (baseUrl, originParam, newParam, delParam) => {
10 let dest = '?'; 10 let dest = '?';
11 let tempOriginParam = {}; 11 let tempOriginParam = {};
12 12
@@ -15,17 +15,17 @@ const handleFilterUrl = (originParam, newParam, delParam) => { @@ -15,17 +15,17 @@ const handleFilterUrl = (originParam, newParam, delParam) => {
15 tempOriginParam = Object.assign(tempOriginParam, originParam, newParam); 15 tempOriginParam = Object.assign(tempOriginParam, originParam, newParam);
16 delete tempOriginParam.uid; 16 delete tempOriginParam.uid;
17 17
18 - _.forEach(tempOriginParam, info => {  
19 - if (!delParam[info.key] && info.value) { 18 + _.forEach(tempOriginParam, (value, key) => {
  19 + if (!delParam[key] && value) {
20 // NOTE: 这里会对 query 进行编码,因为 query 有可以能是中文 20 // NOTE: 这里会对 query 进行编码,因为 query 有可以能是中文
21 - if (info.key === 'query') {  
22 - info.value = encodeURIComponent(info.value); 21 + if (key === 'query') {
  22 + value = encodeURIComponent(value);
23 } 23 }
24 - dest += `${info.key}=${info.value}&`; 24 + dest += `${key}=${value}&`;
25 } 25 }
26 }); 26 });
27 27
28 - return _.trim(dest, '&'); 28 + return (baseUrl || '') + _.trim(dest, '&');
29 }; 29 };
30 30
31 module.exports = (total, params = {}, baseUrl = '') => { 31 module.exports = (total, params = {}, baseUrl = '') => {
@@ -92,6 +92,7 @@ module.exports = (total, params = {}, baseUrl = '') => { @@ -92,6 +92,7 @@ module.exports = (total, params = {}, baseUrl = '') => {
92 }); 92 });
93 offsetPage++; 93 offsetPage++;
94 } 94 }
  95 +
95 if (nextLimit >= 2) { 96 if (nextLimit >= 2) {
96 pages = _.concat(pages, { 97 pages = _.concat(pages, {
97 num: '...' 98 num: '...'