Authored by yyq

fix pager

... ... @@ -477,7 +477,7 @@ class AdminModel extends global.yoho.BaseModel {
return value;
});
Object.assign(resData, pager(_.get(result, '[1].total', 1), params));
Object.assign(resData, pager(_.get(result, '[1][0].total', 1), params));
return resData;
});
... ...
... ... @@ -82,11 +82,11 @@
{{/if}}
</li>
{{/ pages}}
{{# nextLimit}}
{{# nextPage}}
<li class="page-item">
<a class="page-link" href="{{url}}">下一页</a>
</li>
{{/ nextLimit}}
{{/ nextPage}}
</ul>
</nav>
</div>
... ...
... ... @@ -6,7 +6,7 @@ const _ = require('lodash');
* @param newParam 要拼接的 参数
* @returns {string}
*/
const handleFilterUrl = (originParam, newParam, delParam) => {
const handleFilterUrl = (baseUrl, originParam, newParam, delParam) => {
let dest = '?';
let tempOriginParam = {};
... ... @@ -15,17 +15,17 @@ const handleFilterUrl = (originParam, newParam, delParam) => {
tempOriginParam = Object.assign(tempOriginParam, originParam, newParam);
delete tempOriginParam.uid;
_.forEach(tempOriginParam, info => {
if (!delParam[info.key] && info.value) {
_.forEach(tempOriginParam, (value, key) => {
if (!delParam[key] && value) {
// NOTE: 这里会对 query 进行编码,因为 query 有可以能是中文
if (info.key === 'query') {
info.value = encodeURIComponent(info.value);
if (key === 'query') {
value = encodeURIComponent(value);
}
dest += `${info.key}=${info.value}&`;
dest += `${key}=${value}&`;
}
});
return _.trim(dest, '&');
return (baseUrl || '') + _.trim(dest, '&');
};
module.exports = (total, params = {}, baseUrl = '') => {
... ... @@ -92,6 +92,7 @@ module.exports = (total, params = {}, baseUrl = '') => {
});
offsetPage++;
}
if (nextLimit >= 2) {
pages = _.concat(pages, {
num: '...'
... ...